{"id":15355793,"url":"https://github.com/fibo/cayley-dickson","last_synced_at":"2025-04-15T06:38:13.649Z","repository":{"id":57195126,"uuid":"42432516","full_name":"fibo/cayley-dickson","owner":"fibo","description":"implements Cayley-Dickson construction to produce a sequence of algebras over a field","archived":false,"fork":false,"pushed_at":"2020-01-24T01:09:30.000Z","size":57,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T07:35:53.538Z","etag":null,"topics":["algebra","cayley-dickson","complex","octonion","quaternion"],"latest_commit_sha":null,"homepage":"http://g14n.info/cayley-dickson","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fibo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["fibo"],"patreon":"fibo"}},"created_at":"2015-09-14T06:59:53.000Z","updated_at":"2023-04-08T16:30:04.000Z","dependencies_parsed_at":"2022-09-16T05:22:25.557Z","dependency_job_id":null,"html_url":"https://github.com/fibo/cayley-dickson","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Fcayley-dickson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Fcayley-dickson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Fcayley-dickson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Fcayley-dickson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibo","download_url":"https://codeload.github.com/fibo/cayley-dickson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657867,"owners_count":21140844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algebra","cayley-dickson","complex","octonion","quaternion"],"created_at":"2024-10-01T12:25:39.603Z","updated_at":"2025-04-15T06:38:13.623Z","avatar_url":"https://github.com/fibo.png","language":"JavaScript","funding_links":["https://github.com/sponsors/fibo","https://patreon.com/fibo"],"categories":[],"sub_categories":[],"readme":"# cayley-dickson\n\n\u003e implements [Cayley-Dickson construction][Cayley-Dickson] to produce a sequence of algebras over a field\n\n[Installation](#installation) |\n[Usage](#usage) :\n[Real](#real) \u003e\n[Complex](#complex) \u003e\n[Quaternion](#quaternion) \u003e\n[Octonion](#octonion) \u003e\n[Sedenion](#sedenion) |\n[License](#license)\n\n[![NPM version](https://badge.fury.io/js/cayley-dickson.svg)](http://badge.fury.io/js/cayley-dickson)\n[![Build Status](https://travis-ci.org/fibo/cayley-dickson.svg?branch=master)](https://travis-ci.org/fibo/cayley-dickson?branch=master)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Installation\n\nWith [npm](https://www.npmjs.com) do\n\n```bash\nnpm install cayley-dickson\n```\n\n## Usage\n\nEvery code snippet below it is intended to be contained in a [single file](https://github.com/fibo/cayley-dickson/blob/master/test.js).\n\nDefine real operators, see also [algebra-ring]. Note that you could use any operators definition, for example using a *big numbers* lib.\n\n```javascript\nconst real = {\n  zero: 0,\n  one: 1,\n  equality: (a, b) =\u003e (a === b),\n  contains: (a) =\u003e (typeof a === 'number' \u0026\u0026 isFinite(a)),\n  addition: (a, b) =\u003e (a + b),\n  negation: (a) =\u003e -a,\n  multiplication: (a, b) =\u003e (a * b),\n  inversion: (a) =\u003e (1 / a)\n}\n```\n\nImport cayley-dickson.\n\n```javascript\nconst iterateCayleyDickson = require('cayley-dickson')\n```\n\nNow you can use [Cayley-Dickson] constructions to build algebras.\nEvery iteration doubles the dimension.\nLet's take a trip through Cayley-Dickson algebras.\n\n### Real\n\n\u003e start from here\n\nWell, iteration 0 gives the common Real numbers. The result is just the return value of the [algebra-ring] function, nothing really exciting.\n\n```javascript\n// Real numbers.\nconst R = iterateCayleyDickson(real, 0)\n\nR.equality(2, 2) // true\nR.disequality(1, 2) // true\nR.contains(Math.PI) // true\nR.notContains(Infinity) // true\nR.addition(1, 2) // 3\nR.subtraction(1, 2) // -1\nR.negation(2) // -2\nR.multiplication(-3, 2) // -6\nR.division(10, 2) // 5\nR.inversion(2) // 0.5\n```\n\n### Complex\n\n\u003e a beautiful plane\n\nFirst iteration gives Complex numbers, they are a field like the Real numbers.\n\n```javascript\n// Complex numbers.\nconst C = iterateCayleyDickson(real, 1)\n\nC.equality([1, 2], [1, 2]) // true\nC.disequality([1, 2], [0, 1]) // true\nC.contains([Math.PI, 2]) // true\nC.notContains(1) // true\nC.addition([1, 2], [-1, 2], [2, 2]) // [2, 6]\nC.subtraction([1, 1], [2, 3]) // [-1, -2]\nC.negation([1, 2]) // [-1, -2]\nC.multiplication([1, 2], [1, -2]) // [5, 0]\nC.division([5, 0], [1, 2]) // [1, -2]\nC.inversion([0, 2]) // [0, -0.5]\nC.conjugation([1, 2]) // [1, -2]\n```\n\n### Quaternion\n\n\u003e here you loose commutativity\n\nSecond iteration gives [Quaternion numbers](https://en.wikipedia.org/wiki/Quaternion),\nusually denoted as ℍ in honour of sir Hamilton.\nThey are used in computer graphics cause rotations are far easier to manipulate in this land.\n\nLet's check the famous formula for Quaternion multiplication `ijk = i² = j² = k² = -1`\n\n![ijk-1]\n\n```javascript\n// Quaternion numbers.\nconst H = iterateCayleyDickson(real, 2)\n\nconst minusOne = new H([-1, 0, 0, 0])\nj\nconst i = new H([0, 1, 0, 0])\nconst j = new H([0, 0, 1, 0])\nconst k = new H([0, 0, 0, 1])\n\nH.equality(H.multiplication(i, i), minusOne) // true\nH.equality(H.multiplication(j, j), minusOne) // true\nH.equality(H.multiplication(k, k), minusOne) // true\n\n// ijk - 1 = 0\nH.subtraction(H.multiplication(i, j, k), minusOne) // [0, 0, 0, 0]\n```\n\n### Octonion\n\n\u003e here you loose associativity\n\nThird iteration gives [Octonion numbers](https://en.wikipedia.org/wiki/Octonion).\nA byte could be seen as an octonion of bits, which should define a new kind of bit operator.\n\n```javascript\n// Octonion numbers.\nconst O = iterateCayleyDickson(real, 3)\n\nconst minusOne = [-1, 0, 0, 0, 0, 0, 0, 0]\n\nconst i1 = [0, 1, 0, 0, 0, 0, 0, 0]\n\nO.equality(O.multiplication(i1, i1), minusOne) // true\n\nO.conjugation([1, 2, 3, 4, 5, 6, 7, 8]) // [1, -2, -3, -4, -5, -6, -7, -8]\n```\n\n### Sedenion\n\n\u003e hic sunt leones\n\nFourth iteration gives [Sedenion numbers](https://en.wikipedia.org/wiki/Sedenion),\nthat are out of my scope sincerely. They are not a division ring, there are elements that divide zero 😱.\n\n```javascript\n// Sedenion numbers.\nconst S = iterateCayleyDickson(real, 4)\n```\n\n## License\n\n[MIT](http://g14n.info/mit-license)\n\n[Cayley-Dickson]: https://en.wikipedia.org/wiki/Cayley%E2%80%93Dickson_construction \"Cayley-Dickson construction\"\n[algebra-ring]: http://npm.im/algebra-ring \"algebra-ring\"\n[ijk-1]: http://i.stack.imgur.com/eYs5r.jpg \"ijk-1\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibo%2Fcayley-dickson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibo%2Fcayley-dickson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibo%2Fcayley-dickson/lists"}