{"id":21453432,"url":"https://github.com/lapets/polynomium","last_synced_at":"2025-03-17T03:13:06.914Z","repository":{"id":57327176,"uuid":"115872480","full_name":"lapets/polynomium","owner":"lapets","description":"Library for symbolically representing and working with polynomials.","archived":false,"fork":false,"pushed_at":"2018-04-26T02:47:38.000Z","size":23,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T02:51:50.644Z","etag":null,"topics":["javascript-library","library","math","mathematics","polynomial","polynomials","symbolic-math"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/polynomium","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/lapets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-31T16:01:32.000Z","updated_at":"2020-08-09T00:27:58.000Z","dependencies_parsed_at":"2022-09-13T19:22:02.775Z","dependency_job_id":null,"html_url":"https://github.com/lapets/polynomium","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpolynomium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpolynomium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpolynomium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpolynomium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lapets","download_url":"https://codeload.github.com/lapets/polynomium/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243965783,"owners_count":20375918,"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":["javascript-library","library","math","mathematics","polynomial","polynomials","symbolic-math"],"created_at":"2024-11-23T04:39:36.818Z","updated_at":"2025-03-17T03:13:06.886Z","avatar_url":"https://github.com/lapets.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# polynomium\nLibrary for symbolically representing and working with polynomials.\n\n[![npm version](https://badge.fury.io/js/polynomium.svg)](https://badge.fury.io/js/polynomium)\n\n## Package Installation and Usage\n\nThe package is available on npm:\n```shell\nnpm install polynomium\n```\nThe library can be imported in the usual ways:\n```javascript\nvar polynomium = require('polynomium');\n```\nThe library also supports standalone usage in browsers:\n```html\n\u003cscript src=\"https://lapets.github.io/polynomium/lib/polynomium.js\"\u003e\u003c/script\u003e\n```\n\n## Examples\n\nThe library supports the creation of objects that represent polynomials of zero or more variables:\n```javascript\nvar x = polynomium.v('x');\nvar y = polynomium.v('y');\nvar a = polynomium.c(2);\nvar b = polynomium.c(3);\nvar c = polynomium.c(5);\nvar p = (y.mul(x.add(b)));\nvar q = (y.mul(x.add(b))).mul(a);\nvar r = (y.mul(x.add(b))).mul((y.mul(x.add(b))));\n```\nGiven the polynomials above, it is possible to display them in a human-readable way:\n```javascript\n\u003e x.toString()\n'x'\n\u003e b.toString()\n'3'\n\u003e (y.add(x.add(b))).toString()\n'y + x + 3'\n\u003e p.toString()\n'x*y + 3y'\n\u003e q.toString()\n'2x*y + 6y'\n\u003e q.maxCoefficients(p).toString()\n'2x*y + 6y'\n\u003e r.toString()\n'x^2*y^2 + 6x*y^2 + 9y^2'\n```\nWhen possible, the operator functions will convert arguments that are numeric constants and valid variable names into polynomium objects:\n```javascript\n\u003e (y.add(x.add(5))).toString()\n'y + x + 5'\n\u003e (y.add('x')).toString()\n'y + x'\n```\nBy default, the terms in the outer sum are in order of descending significance (where a term's significance is the sum of its exponents across its factors). The individual variables within factors are in ascending alphabetical order.\n\nIt is also possible to evaluate a polynomial by supplying an object that binds explicit values to each variable:\n```javascript\n\u003e r.evaluate({\"x\":2, \"y\":5})\n625\n\u003e r({\"x\":2, \"y\":5})\n625\n```\nIn some cases, function objects cannot be used within data structures (such as when converting to JSON). A method is included for such scenarios:\n```javascript\n\u003e var o = r.toObject()\n\u003e o\n{ polynomium: true,\n  terms: \n   { 'y': { '2': 9 }, \n     'x,y': { '1,2': 6, '2,2': 1 } } }\n\u003e polynomium.add(o, o).toObject()\n{ polynomium: true,\n  terms: \n   { 'y': { '2': 18 }, \n     'x,y': { '1,2': 12, '2,2': 2 } } }\n```\n\n## Testing\n\nUnit tests are included in `test/test.js`. They can be run using [Mocha](https://mochajs.org/):\n```javascript\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flapets%2Fpolynomium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flapets%2Fpolynomium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flapets%2Fpolynomium/lists"}