Multi-dimensional Chebyshev tensor interpolation with analytical derivatives for .NET.
ChebyshevSharp builds reusable polynomial surrogates for smooth multi-dimensional functions. It evaluates values, derivatives, integrals, roots, and optimizers from precomputed Chebyshev data, with dense, piecewise, sliding, and Tensor Train approximations for different dimensional regimes. Benchmarks, validation details, and reference-implementation comparisons are documented in Performance and Testing & Validation.
- Documentation
- API Reference
- NuGet Package
- Changelog
- Contributing
- Support & Reporting
- Security Policy
| Feature | Description |
|---|---|
| Chebyshev interpolation | Multi-dimensional tensor interpolation with spectral convergence |
| Analytical derivatives | Spectral differentiation matrices — no finite differences |
| BLAS acceleration | N-D tensor contractions routed through OpenBLAS via BlasSharp.OpenBlas |
| Piecewise splines | ChebyshevSpline — place knots at singularities for spectral convergence on each piece |
| Sliding technique | ChebyshevSlider — partition dimensions into groups for high-dimensional approximation |
| Tensor Train interpolation | ChebyshevTT — approximate high-dimensional coupled functions without materializing the dense grid |
| Algebra | Combine interpolants via +, -, *, / |
| Extrusion & slicing | Add or fix dimensions for portfolio aggregation |
| Spectral calculus | Integration (Fejer-1), root-finding (colleague matrix), minimization, maximization |
| Serialization | Save/load interpolants as JSON, plus portable .pcb for dense approximations and compatible splines |
dotnet add package ChebyshevSharpNo system BLAS installation required — cross-platform OpenBLAS binaries are included.
using ChebyshevSharp;
// 1. Define a function
double MyFunc(double[] x, object? data)
=> Math.Sin(x[0]) * Math.Cos(x[1]);
// 2. Build the interpolant
var cheb = new ChebyshevApproximation(
function: MyFunc,
numDimensions: 2,
domain: new[] { new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 } },
nNodes: new[] { 11, 11 }
);
cheb.Build();
// 3. Evaluate — function value and derivatives
double value = cheb.VectorizedEval(new[] { 0.5, 0.3 }, new[] { 0, 0 });
double dfdx = cheb.VectorizedEval(new[] { 0.5, 0.3 }, new[] { 1, 0 });
double d2fdy = cheb.VectorizedEval(new[] { 0.5, 0.3 }, new[] { 0, 2 });
// Query points must be inside the declared domain; out-of-domain points throw.
// 4. Check accuracy
double error = cheb.ErrorEstimate(); // ~1e-15 for this function
// 5. Save for deployment
cheb.Save("interpolant.json");Runnable example projects are available in examples/:
dotnet run --project examples/QuickStart/QuickStart.csproj
dotnet run --project examples/TensorTrainHighDim/TensorTrainHighDim.csprojThe examples print accuracy checks against the original function so you can verify the local build and see how dense and TT-Cross workflows differ.
| Class | Use case | Build cost |
|---|---|---|
ChebyshevApproximation |
Smooth functions on a single domain | |
ChebyshevSpline |
Functions with discontinuities or singularities | pieces |
ChebyshevSlider |
High-dimensional, additively separable functions | |
ChebyshevTT |
High-dimensional functions with general coupling |
|
Replace a slow Black-Scholes pricer with a fast Chebyshev interpolant that returns price in ~500 ns, or price plus delta and gamma in ~2 us:
var cheb = new ChebyshevApproximation(
function: BsPrice,
numDimensions: 3,
domain: new[] {
new[] { 80.0, 120.0 }, // spot
new[] { 0.1, 0.5 }, // volatility
new[] { 0.25, 2.0 } // maturity
},
nNodes: new[] { 15, 12, 10 }
);
cheb.Build(); // 1,800 function evaluations (one-time cost)
// Price, delta, and gamma in one call
double[] results = cheb.VectorizedEvalMulti(
new[] { 100.0, 0.2, 1.0 },
new[] {
new[] { 0, 0, 0 }, // price
new[] { 1, 0, 0 }, // delta
new[] { 2, 0, 0 }, // gamma
}
);| Area | Status |
|---|---|
ChebyshevApproximation |
Dense Chebyshev interpolation with analytical derivatives, algebra, calculus, serialization, and Sobol indices |
ChebyshevSpline |
Piecewise interpolation with knots, algebra, calculus, serialization, and automatic knot helpers |
ChebyshevSlider |
Partitioned high-dimensional approximation with parallel build, progress reporting, and sensitivity diagnostics |
ChebyshevTT |
Tensor Train build/eval, finite-difference derivatives, integration, roots, optimization, algebra, slicing/extrusion, reordering, and guarded dense materialization |
| Validation | xUnit regression suite, deterministic FsCheck properties, Codecov patch gate, package validation, DocFX build, and scheduled/manual mutation testing |
See the changelog for release-by-release changes, fixes, and validation notes.
Full documentation is available at 0xc000005.github.io/ChebyshevSharp.
- Getting Started
- Which Class Should I Use?
- Mathematical Concepts
- Piecewise Chebyshev (Splines)
- Sliding Technique
- Tensor Train
- Computing Greeks
- Chebyshev Algebra
- Advanced Usage
- Calculus
- Error Estimation
- Serialization
- Performance
- Testing & Validation
- Support & Reporting
- Citations
- API Reference
- Questions and usage problems: start a GitHub Discussion with a small runnable example.
- Bugs: use the bug report template and include OS, .NET SDK version, ChebyshevSharp version, expected behavior, and actual behavior.
- Numerical accuracy concerns: use the numerical accuracy template and include the function, domain, node counts, construction method, tolerance, and a reference value or independent check.
- Security issues: do not open a public issue; follow the security policy.
See CONTRIBUTING.md for the development workflow, required checks, Codecov policy, Stryker.NET mutation-testing expectations, and PR checklist. For a shorter site version, see Contributing.
This project follows CODE_OF_CONDUCT.md. Keep issue and PR discussions focused, reproducible, and respectful.
MIT