{"id":22480048,"url":"https://github.com/zeta611/polycalc","last_synced_at":"2026-02-27T12:35:04.163Z","repository":{"id":43104713,"uuid":"348328440","full_name":"Zeta611/polycalc","owner":"Zeta611","description":"🧮 Polynomial Calculator","archived":false,"fork":false,"pushed_at":"2023-01-03T07:09:53.000Z","size":159,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-30T17:44:17.062Z","etag":null,"topics":["math","mathematics","polynomial","polynomial-arithmetic","polynomial-equations","polynomial-multiplication","polynomial-systems","polynomials","symbolic","symbolic-computation","symbolic-math"],"latest_commit_sha":null,"homepage":"","language":"C","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/Zeta611.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":"2021-03-16T11:52:22.000Z","updated_at":"2023-07-30T23:22:52.000Z","dependencies_parsed_at":"2023-02-01T05:15:22.518Z","dependency_job_id":null,"html_url":"https://github.com/Zeta611/polycalc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Zeta611/polycalc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fpolycalc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fpolycalc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fpolycalc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fpolycalc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zeta611","download_url":"https://codeload.github.com/Zeta611/polycalc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeta611%2Fpolycalc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29894999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T12:09:13.686Z","status":"ssl_error","status_checked_at":"2026-02-27T12:09:13.282Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["math","mathematics","polynomial","polynomial-arithmetic","polynomial-equations","polynomial-multiplication","polynomial-systems","polynomials","symbolic","symbolic-computation","symbolic-math"],"created_at":"2024-12-06T15:19:11.641Z","updated_at":"2026-02-27T12:35:04.140Z","avatar_url":"https://github.com/Zeta611.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PolyCalc\nPolyCalc is a polynomial calculator.\nIt calculates and expands polynomials, equations, and relations.\nIt supports simple variable assignments for the ease of handling expressions.\n\n## Usage\nPolyCalc can be used as a simple calculator:\n```\n2^10 - 1\nAST: (- (^ 2 10) 1)\nVAL: 1023\n\n2 * 3.14159265 * 7\nAST: (* (* 2 3.141593) 7)\nVAL: 43.982297\n```\nBoth `AST` and `VAL` are generated by PolyCalc--you can check `AST` to ensure\nthat PolyCalc indeed parsed the given input as you have intended.\n`VAL` is the result of the expression.\n\nIf `AST` is not necessary, you can hide the parsed result and remove both\n`AST:` and `VAL:` labels altogether by invoking PolyCalc with the `-q` flag.\nThe `-v` flag does nothing--PolyCalc is by default verbose--but it is there for\ncompleteness.\nThe `-q` flag is useful if you want to redirect the output to a file via shell\noutput redirection.\n\nPolyCalc can also calculate and expand polynomials:\n```\n(x + y)^3\nAST: (^ (+ x y) 3)\nVAL: x^3 + 3 x^2 y + 3 x y^2 + y^3\n\n(a^2 + 2ab + b^2)(a^2 - 2ab + b^2)\nAST: (* (+ (+ (^ a 2) (* (* 2 a) b)) (^ b 2)) (+ (- (^ a 2) (* (* 2 a) b)) (^ b 2)))\nVAL: a^4 + -2 a^2 b^2 + b^4\n\n(x + y)(x - y) + y^2\nAST: (+ (* (+ x y) (- x y)) (^ y 2))\nVAL: x^2\n```\n\nUse assignments to improve readability and avoid repetitions:\n```\n'sum := a + b\nAST: (:= sum (+ a b))\nASN: sum := a + b\n\n'sub := a - b\nAST: (:= sub (- a b))\nASN: sub := a + -1 b\n\n'sum * 'sub\nAST: (* sum sub)\nVAL: a^2 + -1 b^2\n```\nNote that the assignment operator is `:=`, not `=` which represents a relation\npresented below.\n\nIt can simplify (a system of) equations/inequalities as well:\n```\na + b + c = 2a - b\nAST: (= (+ (+ a b) c) (- (* 2 a) b))\nREL: a + -2 b + -1 c = 0\n\nx \u003e= y \u0026 x = y \u0026 x - y \u003c= 0\nAST: (\u003e= x y) \u0026 (= x y) \u0026 (\u003c= (- x y) 0)\nREL: x + -1 y = 0\n\na \u003e 2a\nAST: (\u003e a (* 2 a))\nREL: a \u003c 0 \n\ny \u003c y\nAST: (\u003c y y)\nREL: INCONSISTENT SYSTEM\n```\nThe result will start with `VAL` if you have typed an expression without a\nrelation--`REL` will be shown otherwise.\nPolyCalc will prompt you `INCONSISTENT SYSTEM` if it can figure out that the\ngiven system has no solution.\n\nIf you need a variable with a name longer than a letter, put a quote(`'`)\nbefore the name:\n```\n'long = 1\nAST: (= long 1)\nREL: long + -1 = 0\n```\n\nSince PolyCalc sorts the input variables composing a product, you can use it\ncreatively:\n```\nsorttheseletters\nAST: (* (* (* (* (* (* (* (* (* (* (* (* (* (* (* s o) r) t) t) h) e) s) e) l) e) t) t) e) r) s)\nVAL: e^4 h l o r^2 s^3 t^4\n```\n\nPolyCalc also accepts a file as an input.\nFor example, consider a file named `input.poly` with the below content:\n```\nx := 3\ny := 2\nx + y\n```\nInvoking PolyCalc via `./build/poly input.poly` outputs:\n```\nAST: (:= x 3)\nASN: x := 3 \n\nAST: (:= y 3)\nASN: y := 3 \n\nAST: (+ x y)\nVAL: 6 \n```\nYou can combine shell redirection and the `-q` flag to save the output:\n```\n./build/poly -q input.poly \u003eout.txt\n```\nNote that the flag must precede the filename.\n\n## Building Source\n```sh\nmake\n```\n\nRequires GNU Bison and flex.\nTested on Ubuntu 20.04.2 LTS using GNU Bison 3.5.1 and flex 2.6.4.\n\n## Running\nAfter `make`, the executable is placed under `build` directory:\n```sh\n./build/poly\n```\n\nYou can use [`rlwrap`](https://github.com/hanslub42/rlwrap), e.g., to use arrow\nkeys:\n```sh\nrlwrap ./build/poly\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeta611%2Fpolycalc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeta611%2Fpolycalc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeta611%2Fpolycalc/lists"}