{"id":13995212,"url":"https://github.com/programmerjake/algebraics","last_synced_at":"2025-04-29T18:30:49.282Z","repository":{"id":42672625,"uuid":"197165064","full_name":"programmerjake/algebraics","owner":"programmerjake","description":"algebraic numbers implemented in rust; mirror of https://salsa.debian.org/Kazan-team/algebraics","archived":false,"fork":false,"pushed_at":"2023-11-28T23:33:26.000Z","size":715,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T18:52:02.541Z","etag":null,"topics":["algebraic-numbers","quadratic-equations","quadratic-numbers","real-number","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/programmerjake.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-07-16T09:39:30.000Z","updated_at":"2024-04-12T11:34:37.000Z","dependencies_parsed_at":"2024-01-20T18:01:58.904Z","dependency_job_id":"2fb1cfcc-2f5d-409b-a420-9e91a60e941f","html_url":"https://github.com/programmerjake/algebraics","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmerjake%2Falgebraics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmerjake%2Falgebraics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmerjake%2Falgebraics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmerjake%2Falgebraics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/programmerjake","download_url":"https://codeload.github.com/programmerjake/algebraics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251559740,"owners_count":21609065,"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":["algebraic-numbers","quadratic-equations","quadratic-numbers","real-number","rust"],"created_at":"2024-08-09T14:03:18.443Z","updated_at":"2025-04-29T18:30:48.798Z","avatar_url":"https://github.com/programmerjake.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"## [Algebraic Numbers](https://en.wikipedia.org/wiki/Algebraic_number) Library\n\nUse when you need exact arithmetic, speed is not critical, and rational numbers aren't good enough.\n\n## Example:\n\n```rust\nuse algebraics::prelude::*;\nuse algebraics::RealAlgebraicNumber as Number;\n\nlet two = Number::from(2);\n\n// 2 is a rational number\nassert!(two.is_rational());\n\n// 1/2 is the reciprocal of 2\nlet one_half = two.recip();\n\n// 1/2 is also a rational number\nassert!(one_half.is_rational());\n\n// 2^(1/4)\nlet root = (\u0026two).pow((1, 4));\n\n// we can use all the standard comparison operators\nassert!(root != Number::from(3));\nassert!(root \u003c Number::from(2));\nassert!(root \u003e Number::from(1));\n\n// we can use all of add, subtract, multiply, divide, and remainder\nlet sum = \u0026root + \u0026root;\nlet difference = \u0026root - Number::from(47);\nlet product = \u0026root * \u0026one_half;\nlet quotient = \u0026one_half / \u0026root;\nlet remainder = \u0026root % \u0026one_half;\n\n// root is not a rational number\nassert!(!root.is_rational());\n\n// the calculations are always exact\nassert_eq!((\u0026root).pow(4), two);\n\n// lets compute 30 decimal places of root\nlet scale = Number::from(10).pow(30);\nlet scaled = \u0026root * scale;\nlet digits = scaled.into_integer_trunc();\nassert_eq!(\n    digits.to_string(),\n    1_18920_71150_02721_06671_74999_70560u128.to_string()\n);\n\n// get the minimal polynomial\nlet other_number = root + two.pow((1, 2));\nassert_eq!(\n    \u0026other_number.minimal_polynomial().to_string(),\n    \"2 + -8*X + -4*X^2 + 0*X^3 + 1*X^4\"\n);\n\n// works with really big numbers\nlet really_big = Number::from(1_00000_00000i64).pow(20) + Number::from(23);\nassert_eq!(\n    \u0026really_big.to_integer_floor().to_string(),\n    \"100000000000000000000000000000000000000000000\\\n     000000000000000000000000000000000000000000000\\\n     000000000000000000000000000000000000000000000\\\n     000000000000000000000000000000000000000000000\\\n     000000000000000000023\"\n)\n```\n\n## Python support\n\nUsing algebraics from Python:\n\n```bash\npython3 -m pip install algebraics\n```\n\n```python\nfrom algebraics import RealAlgebraicNumber\nsqrt_2 = 2 ** (RealAlgebraicNumber(1) / 2)\nassert sqrt_2 * sqrt_2 == 2\n```\n\nUsing algebraics in your own Rust project:\n\n```toml\n[dependencies.algebraics]\nversion = \"0.3\"\n```\n\nDeveloping algebraics:\n\n```bash\ncargo install maturin\nmaturin develop --cargo-extra-args=\"--features python-extension\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrammerjake%2Falgebraics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrammerjake%2Falgebraics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrammerjake%2Falgebraics/lists"}