{"id":31345834,"url":"https://github.com/Nonanti/mathcore","last_synced_at":"2025-09-26T08:08:04.408Z","repository":{"id":312400433,"uuid":"1047399758","full_name":"Nonanti/mathcore","owner":"Nonanti","description":"Symbolic math library and computer algebra system for Rust","archived":false,"fork":false,"pushed_at":"2025-09-20T20:42:41.000Z","size":63,"stargazers_count":56,"open_issues_count":4,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-20T22:20:39.085Z","etag":null,"topics":["calculus","computer-algebra-system","differential-equations","equation-solver","mathematics","rust","scientific-computing","symbolic-math"],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/Nonanti.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-30T10:34:24.000Z","updated_at":"2025-09-20T20:42:44.000Z","dependencies_parsed_at":"2025-09-04T04:45:33.588Z","dependency_job_id":null,"html_url":"https://github.com/Nonanti/mathcore","commit_stats":null,"previous_names":["nonanti/mathcore"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Nonanti/mathcore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonanti%2Fmathcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonanti%2Fmathcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonanti%2Fmathcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonanti%2Fmathcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nonanti","download_url":"https://codeload.github.com/Nonanti/mathcore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nonanti%2Fmathcore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276348291,"owners_count":25626605,"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","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["calculus","computer-algebra-system","differential-equations","equation-solver","mathematics","rust","scientific-computing","symbolic-math"],"created_at":"2025-09-26T08:02:51.719Z","updated_at":"2025-09-26T08:08:04.400Z","avatar_url":"https://github.com/Nonanti.png","language":"Rust","readme":"# MathCore\n\n[![Crates.io](https://img.shields.io/crates/v/mathcore.svg)](https://crates.io/crates/mathcore)\n[![Documentation](https://docs.rs/mathcore/badge.svg)](https://docs.rs/mathcore)\n[![Build Status](https://github.com/Nonanti/mathcore/workflows/CI/badge.svg)](https://github.com/Nonanti/mathcore/actions)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA symbolic math library for Rust. Think of it as a computer algebra system (CAS) that can do symbolic differentiation, integration, equation solving, and more.\n\n## What it does\n\n### Basic stuff\n- Parse math expressions from strings (with proper precedence)\n- Work with symbols, not just numbers\n- Differentiate and integrate symbolically\n- Solve equations (linear, quadratic, and some higher degree)\n- Complex number support\n- ASCII plots (for quick visualization)\n- Expression simplification\n- Variables and substitution\n\n### Fancier features\n- Limits (including one-sided and at infinity)\n- Matrix operations and linear algebra\n- Arbitrary precision arithmetic (BigInt/BigRational)\n- Optimization (gradients, Hessian, autodiff)\n- Taylor series expansion\n- Numerical methods (Newton's method, gradient descent)\n- ODEs and PDEs solvers\n- FFT and signal processing\n\n## Installation\n\n**Option 1:** Run `cargo add mathcore` in your project's root directory.\n\n**Option 2:** Add to your `Cargo.toml`:\n\n```toml\n[dependencies]\nmathcore = \"0.3.1\"\n```\n\n## Quick example\n\n```rust\nuse mathcore::MathCore;\n\nfn main() {\n    let math = MathCore::new();\n    \n    // basic arithmetic\n    let result = math.calculate(\"2 + 3 * 4\").unwrap();\n    println!(\"2 + 3 * 4 = {}\", result);  // 14\n    \n    // take derivatives\n    let derivative = MathCore::differentiate(\"x^2 + 2*x + 1\", \"x\").unwrap();\n    println!(\"d/dx(x^2 + 2*x + 1) = {}\", derivative);  // 2*x + 2\n    \n    // solve equations\n    let roots = MathCore::solve(\"x^2 - 4\", \"x\").unwrap();\n    println!(\"roots: {:?}\", roots);  // [2, -2]\n}\n```\n\n## Advanced Usage\n\n### Limits\n\n```rust\nuse mathcore::calculus::limits::{Limits, LimitDirection};\n\nlet expr = MathCore::parse(\"sin(x)/x\").unwrap();\nlet limit = Limits::limit(\u0026expr, \"x\", 0.0, LimitDirection::Both).unwrap();\nprintln!(\"lim(x→0) sin(x)/x = {}\", limit); // Should be 1\n\n// Check continuity\nlet continuous = Limits::is_continuous_at(\u0026expr, \"x\", 1.0).unwrap();\nprintln!(\"Function is continuous: {}\", continuous);\n```\n\n### Matrix Operations\n\n```rust\nuse mathcore::matrix::{SymbolicMatrix, LinearAlgebra};\nuse nalgebra::{DMatrix, DVector};\n\n// Symbolic matrices\nlet matrix = SymbolicMatrix::from_vec(vec![\n    vec![1.0, 2.0],\n    vec![3.0, 4.0],\n]).unwrap();\n\nlet det = matrix.determinant().unwrap();\nprintln!(\"Determinant: {}\", det);\n\n// Solve linear system Ax = b\nlet a = DMatrix::from_row_slice(2, 2, \u0026[1.0, 2.0, 3.0, 4.0]);\nlet b = DVector::from_row_slice(\u0026[5.0, 11.0]);\nlet solution = LinearAlgebra::solve_system(\u0026a, \u0026b).unwrap();\nprintln!(\"Solution: {:?}\", solution);\n```\n\n### Arbitrary Precision\n\n```rust\nuse mathcore::precision::{PrecisionNumber, ArbitraryPrecision};\n\n// Exact rational arithmetic\nlet a = PrecisionNumber::from_str_with_precision(\"1/3\").unwrap();\nlet b = PrecisionNumber::from_str_with_precision(\"1/6\").unwrap();\nlet sum = a.add(\u0026b);\nprintln!(\"1/3 + 1/6 = {}\", sum); // Outputs: 1/2\n\n// Compute π with arbitrary precision\nlet pi = ArbitraryPrecision::compute_pi(100);\nprintln!(\"π ≈ {}\", pi);\n```\n\n### Optimization and Calculus\n\n```rust\nuse mathcore::ml::{Optimization, SymbolicIntegration};\nuse std::collections::HashMap;\n\n// Compute gradient\nlet loss = MathCore::parse(\"x^2 + y^2\").unwrap();\nlet vars = vec![\"x\".to_string(), \"y\".to_string()];\nlet gradient = Optimization::gradient(\u0026loss, \u0026vars).unwrap();\nprintln!(\"∇f = [{}, {}]\", gradient[0], gradient[1]);\n\n// Taylor series expansion\nlet func = MathCore::parse(\"exp(x)\").unwrap();\nlet taylor = Optimization::taylor_series(\u0026func, \"x\", 0.0, 5).unwrap();\nprintln!(\"Taylor series: {}\", taylor);\n\n// Gradient descent optimization\nlet mut params = HashMap::new();\nparams.insert(\"x\".to_string(), 10.0);\nparams.insert(\"y\".to_string(), 10.0);\nlet optimized = Optimization::gradient_descent(\n    \u0026loss, params, 0.1, 100\n).unwrap();\nprintln!(\"Optimized parameters: {:?}\", optimized);\n```\n\n### Working with Variables\n\n```rust\nlet math = MathCore::new();\nlet mut vars = HashMap::new();\nvars.insert(\"a\".to_string(), 3.0);\nvars.insert(\"b\".to_string(), 4.0);\n\nlet result = math.evaluate_with_vars(\"sqrt(a^2 + b^2)\", \u0026vars).unwrap();\nprintln!(\"Distance: {}\", result);\n```\n\n### Symbolic Integration\n\n```rust\nlet integral = MathCore::integrate(\"x^2\", \"x\").unwrap();\nprintln!(\"∫x² dx = {}\", integral);\n\n// Numerical integration\nlet area = MathCore::numerical_integrate(\"x^2\", \"x\", 0.0, 1.0).unwrap();\nprintln!(\"∫₀¹ x² dx = {}\", area);\n```\n\n### Function Plotting\n\n```rust\nlet plot = MathCore::plot_ascii(\"sin(x)\", \"x\", -3.14, 3.14, 60, 20).unwrap();\nprintln!(\"{}\", plot);\n```\n\n### Complex Numbers\n\n```rust\nlet math = MathCore::new();\nlet result = math.evaluate(\"(3+4i) * (2-i)\").unwrap();\nprintln!(\"(3+4i) * (2-i) = {}\", result);\n```\n\n## Supported Functions\n\n### Arithmetic Operations\n- Addition: `+`\n- Subtraction: `-`\n- Multiplication: `*`\n- Division: `/`\n- Power: `^`\n- Modulo: `%`\n- Factorial: `!`\n- Absolute value: `|x|`\n\n### Trigonometric Functions\n- `sin(x)`, `cos(x)`, `tan(x)`\n- `sec(x)` (through derivatives)\n\n### Exponential \u0026 Logarithmic\n- `exp(x)` - e^x\n- `ln(x)` - Natural logarithm\n- `log(x, base)` - Logarithm with custom base\n- `sqrt(x)` - Square root\n\n### Utility Functions\n- `min(a, b, ...)` - Minimum value\n- `max(a, b, ...)` - Maximum value\n- `abs(x)` - Absolute value\n\n## Mathematical Constants\n\nThe following constants are predefined:\n- `pi` - π (3.14159...)\n- `e` - Euler's number (2.71828...)\n- `tau` - τ = 2π (6.28318...)\n\n## Expression Syntax\n\n### Basic Examples\n```\n2 + 3 * 4           # Arithmetic\nx^2 - 5*x + 6       # Polynomial\nsin(x) + cos(x)     # Trigonometric\ne^x                 # Exponential (using constant e)\n3! + 4!            # Factorials\n|x - 5|            # Absolute value\n3 + 4i             # Complex numbers\n```\n\n### Differentiation\n```rust\nMathCore::differentiate(\"sin(x) * x^2\", \"x\")\n// Returns: (cos(x) * x^2 + sin(x) * 2*x)\n```\n\n### Integration\n```rust\nMathCore::integrate(\"2*x\", \"x\")\n// Returns: x^2\n```\n\n### Equation Solving\n```rust\nMathCore::solve(\"x^2 + x - 6\", \"x\")\n// Returns: [2, -3]\n```\n\n## Performance\n\nPretty fast. Uses LTO in release builds. Some rough numbers:\n- Expression parsing: ~1μs \n- Differentiation: ~10μs for polynomials\n- Matrix ops use nalgebra (which uses BLAS when available)\n- Exact arithmetic with rationals (no precision loss)\n\n## When to use this\n\n- Scientific computing (physics simulations, engineering calcs)\n- ML/optimization (automatic differentiation)\n- Education (demonstrating calculus concepts)\n- Financial calculations (need exact arithmetic)\n- Any time you need symbolic math in Rust\n\n## Contributing\n\nPRs welcome! \n\n```bash\n# run tests\ncargo test\n\n# benchmarks\ncargo bench\n\n# docs\ncargo doc --open\n```\n\n## License\n\nMIT\n\n© 2025 Nonanti\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","funding_links":[],"categories":["Libraries"],"sub_categories":["Computation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNonanti%2Fmathcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNonanti%2Fmathcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNonanti%2Fmathcore/lists"}