Chebyshev polynomial toolkit for scientific computing in Rust.
cheby provides a full interpolation pipeline suitable for numerical kernels
and ephemeris-style piecewise approximations:
- Node generation on
[-1, 1]and mapped intervals. - Coefficient fitting via DCT identities.
- Stable Clenshaw evaluation (value, derivative, or both).
- Uniform piecewise segment tables with O(1) segment lookup.
All core APIs are generic over ChebyScalar, so they work with f64 and with
typed quantities such as qtty::Quantity<Kilometer>.
[dependencies]
cheby = "0.1"use cheby::{evaluate, fit_coeffs, nodes};
const N: usize = 9;
let xi: [f64; N] = nodes();
let values: [f64; N] = std::array::from_fn(|k| xi[k].sin());
let coeffs = fit_coeffs(&values);
let tau = 0.42;
let approx = evaluate(&coeffs, tau);
println!("sin({tau}) ~= {approx}");use cheby::ChebySegmentTable;
let table: ChebySegmentTable<f64, 15> =
ChebySegmentTable::from_fn(f64::sin, 0.0, std::f64::consts::TAU, std::f64::consts::FRAC_PI_2);
let (value, derivative) = table.eval_both(1.0).unwrap();
println!("f(t)={value}, df/dt={derivative}");Runnable examples are provided in examples/:
basic_interpolationsegment_tabletyped_quantities
Use:
cargo run --example basic_interpolationSee examples/README.md for details.
cheby includes:
- Unit tests inside modules.
- Functional integration tests in
tests/functional_pipeline.rs. - Doctests for public examples.
Run locally:
cargo test --all-targets
cargo test --doc
cargo +nightly llvm-cov --workspace --all-features --doctests --summary-onlyCoverage is gated in CI at >= 90% line coverage.
GitHub Actions workflow: /.github/workflows/ci.yml
Jobs:
checkfmtclippy(-D warnings)test(unit/integration + docs)coverage(cargo +nightly llvm-cov, PR summary, 90% gate)
AGPL-3.0-only