Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Const-poly: Compile-time evaluation for multivariable polynomials
Hi! I was searching for some fully compile-time libraries to evaluate polynomials, and while I found some examples for simple use-cases, I did not see any support for complex multivariable equations. For example, there was no compile-time support to evaluate an equation like this:
3.0 * w * sin(x) * y² * cos(z) +
-1.2 * w³ * tan(x) * exp(y) * z +
0.7 * ln(w) * sqrt(x) * atan(y) * sinh(z) +
1.1 * cosh(w) * x * y * sin(z)
With this motivation, I built const_poly, a crate that lets you evaluate any multivariable equation or polynomial at compile time with high accuracy and zero runtime overhead.
Goals:
no_std compatible – no heap allocations, no panics.
Full compile-time evaluation of arbitrarily complex equations with high numerical accuracy (benchmarked at 1e-7).
Fully documented with code examples, user-friendly macros, benchmarking, and a comprehensive suite of tests.
Define expressions using variety of mathematical functions, all evaluable at compile time.
Who is this for?
This library is primarily meant to empower scientific computing and mathematical libraries in rust to perform all numerical approximations entirely at compile time.
Embedded and no_std environments where heapless, panic-free code is essential.
Metaprogramming and symbolic math tools that benefit from evaluating complex expressions entirely at compile time.
I love to hear your feedback. Please let me know what you think!
github: GitHub - kmolan/const_poly: Compile-time evaluation of multivariable polynomials in rust
crate: crates.io: Rust Package Registry
1 post - 1 participant
🏷️ Rust_feed