Crates.io | microcheby |
lib.rs | microcheby |
version | 0.1.1 |
source | src |
created_at | 2024-07-30 11:41:48.384937 |
updated_at | 2024-07-30 12:07:51.539819 |
description | Single variable function approximation using Chebyshev polynomials. Embedded friendly and no_std compatible. |
homepage | |
repository | https://github.com/stuffmatic/microcheby |
max_upload_size | |
id | 1319711 |
size | 337,397 |
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:
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 }
See the crate documentation.
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.