SI
Siderust/cheby
A Rust crate for Chebyshev-polynomial interpolation and evaluation. Provides node generation, coefficient fitting, and stable polynomial evaluation for efficient numeric approximation and piecewise interpolation.
cheby
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>.
Installation
[dependencies]
cheby = "0.1"Quick start
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}");Segment-table workflow
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}");Examples
Runnable examples are provided in examples/:
basic_interpolationsegment_tabletyped_quantities
Use:
cargo run --example basic_interpolationSee examples/README.md for details.
Tests and coverage
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.
CI
GitHub Actions workflow: /.github/workflows/ci.yml
Jobs:
checkfmtclippy(-D warnings)test(unit/integration + docs)coverage(cargo +nightly llvm-cov, PR summary, 90% gate)
License
AGPL-3.0-only
On this page
Languages
Rust100.0%
Contributors
GNU Affero General Public License v3.0
Created February 11, 2026
Updated February 26, 2026