ChebyshevSharp 0.4.0

dotnet add package ChebyshevSharp --version 0.4.0
                    
NuGet\Install-Package ChebyshevSharp -Version 0.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ChebyshevSharp" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ChebyshevSharp" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="ChebyshevSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ChebyshevSharp --version 0.4.0
                    
#r "nuget: ChebyshevSharp, 0.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ChebyshevSharp@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ChebyshevSharp&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=ChebyshevSharp&version=0.4.0
                    
Install as a Cake Tool

ChebyshevSharp

Tests codecov NuGet NuGet Downloads License: MIT .NET 8 .NET 10

Multi-dimensional Chebyshev tensor interpolation with analytical derivatives for .NET.

ChebyshevSharp is a C# port of PyChebyshev, providing fast polynomial evaluation of smooth multi-dimensional functions via barycentric interpolation with pre-computed weights. On low-dimensional problems (1-3D), C# is 17-42x faster than the Python reference; see Performance.

Features

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
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 for deployment without the original function

Installation

dotnet add package ChebyshevSharp

No system BLAS installation required — cross-platform OpenBLAS binaries are included.

Quick Start

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 });

// 4. Check accuracy
double error = cheb.ErrorEstimate();  // ~1e-15 for this function

// 5. Save for deployment
cheb.Save("interpolant.json");

Classes

Class Use case Build cost
ChebyshevApproximation Smooth functions on a single domain $\prod_i n_i$
ChebyshevSpline Functions with discontinuities or singularities pieces $\times \prod_i n_i$
ChebyshevSlider High-dimensional, additively separable functions $\sum_g \prod_{i \in g} n_i$
ChebyshevTT High-dimensional, general coupling Planned

Example: Option Pricing

Replace a slow Black-Scholes pricer with a fast Chebyshev interpolant that returns price and all Greeks in ~500 ns:

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 and all Greeks 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
        new[] { 0, 1, 0 },  // vega
    }
);

Status

Phase Class Tests Status
1 ChebyshevApproximation 233 Done
2 ChebyshevSpline 128 Done
3 ChebyshevSlider 122 Done
4 ChebyshevTT Planned
Total 483

See skip_csharp.txt for detailed feature parity with PyChebyshev.

Documentation

Full documentation is available at 0xc000005.github.io/ChebyshevSharp.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0 22 2/27/2026
0.3.0 32 2/27/2026
0.2.0 25 2/27/2026
0.1.0 36 2/27/2026