microcheby

Crates.iomicrocheby
lib.rsmicrocheby
version0.1.1
sourcesrc
created_at2024-07-30 11:41:48.384937
updated_at2024-07-30 12:07:51.539819
descriptionSingle variable function approximation using Chebyshev polynomials. Embedded friendly and no_std compatible.
homepage
repositoryhttps://github.com/stuffmatic/microcheby
max_upload_size
id1319711
size337,397
Per Gantelius (stuffmatic)

documentation

README

microcheby

Crates.io Docs.rs

microcheby is a Rust library for computing and evaluating polynomial approximations of functions of one variable using 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 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.

Commit count: 0

cargo fmt