SkillAgentSearch skills...

Microcheby

A Rust library for computing and evaluating polynomial approximations of functions of one variable using Chebyshev expansions.

Install / Use

/learn @stuffmatic/Microcheby

README

microcheby

Crates.io Docs.rs

microcheby is a Rust library for computing and evaluating polynomial approximations of functions of one variable using Chebyshev polynomials. The code is no_std compatible, does not depend on alloc and is optimized for resource constrained environments where every clock cycle counts. Optimizations include:

  • Clenshaw recursion for evaluating approximations.
  • Efficient loop free functions for evaluating low order approximations.
  • Even more efficient loop free evaluation if the range happens to be [-1, 1].
  • Approximation evaluation without divisions.

Installing

Add the following line to your Cargo.toml file:

microcheby = "0.1"

To use microcheby in a no_std environment:

microcheby = { version = "0.1", default-features = false }

Usage

See the crate documentation.

Chebyshev approximation

Sufficiently well behaved functions of one variable can be expressed as an infinite weighted sum of so called Chebyshev polynomials of increasing order. Such a sum is known as a Chebyshev expansion. If the target function is smooth enough, the coefficients (weights) of the expansion will typically converge to zero quickly and only the first few terms are needed to get a good approximation. For a truncated expansion with n terms, an estimate of the approximation error is given by the magnitude of coefficient n+1.

Below are some graphs showing how the approximation converges to the target function as the number of terms in the expansion increases. For smoother target functions, convergence is typically faster.

View on GitHub
GitHub Stars12
CategoryDevelopment
Updated2mo ago
Forks0

Languages

Rust

Security Score

95/100

Audited on Jan 17, 2026

No findings