### Run QuickStart example project Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/getting-started.md Runs the QuickStart console project, which demonstrates the same workflow as a runnable example. ```bash dotnet run --project examples/QuickStart/QuickStart.csproj ``` -------------------------------- ### Run example projects with dotnet run Source: https://github.com/0xc000005/chebyshevsharp/blob/main/examples/README.md Run the three example console projects from the repository root after installing the .NET 10 SDK. ```bash dotnet run --project examples/QuickStart/QuickStart.csproj ``` ```bash dotnet run --project examples/SliderPartitionValidation/SliderPartitionValidation.csproj ``` ```bash dotnet run --project examples/TensorTrainHighDim/TensorTrainHighDim.csproj ``` -------------------------------- ### Run the example project Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/continuous-state-dynamic-programming.md Command to run the continuous-state dynamic programming example project. ```bash dotnet run --project examples/ContinuousStateDynamicProgramming/ContinuousStateDynamicProgramming.csproj ``` -------------------------------- ### Run example projects Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/testing-and-validation.md Run the example projects when changing public workflows. Each project validates a specific aspect; the Examples page explains how to interpret the output. ```bash dotnet run --project examples/QuickStart/QuickStart.csproj dotnet run --project examples/SliderPartitionValidation/SliderPartitionValidation.csproj dotnet run --project examples/TensorTrainHighDim/TensorTrainHighDim.csproj dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj dotnet run --project examples/ContinuousStateDynamicProgramming/ContinuousStateDynamicProgramming.csproj ``` -------------------------------- ### Run example projects Source: https://github.com/0xc000005/chebyshevsharp/blob/main/README.md Commands to run the example projects in the examples/ directory. They print accuracy checks against the original function so you can verify the local build and see how dense and TT-Cross workflows differ. ```bash dotnet run --project examples/QuickStart/QuickStart.csproj ``` ```bash dotnet run --project examples/TensorTrainHighDim/TensorTrainHighDim.csproj ``` ```bash dotnet run --project examples/ContinuousStateDynamicProgramming/ContinuousStateDynamicProgramming.csproj ``` -------------------------------- ### Example Output from FixedRateBondSurrogate Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-2-public-data-fixtures.md Observed example output from running the FixedRateBondSurrogate example after refreshing the curve fixture. Shows the curve fixture name, date, source, dirty price, and number of cashflows. ```text Curve fixture : fed-nominal-yield-curve-2026-05-15 Curve date : 2026-05-15 Curve source : Board of Governors of the Federal Reserve System Dirty price : 98.53533001 Cashflows : 21 ``` -------------------------------- ### Run FixedRateBondSurrogate example with CLI flags Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/fixed-rate-bond-surrogate.md Run the example project with each CLI flag in order to reproduce the evidence for the fixed-rate bond surrogate. Each flag triggers a different analysis mode, from naive surrogate discovery to accuracy recipe search. ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --naive-surrogate-discovery dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --structured-alternatives dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --analytic-coupon-decomposition dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --maturity-special-points dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --schedule-aware-router dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --accuracy-recipe-search ``` -------------------------------- ### Run Phase 9 tests and example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-9-maturity-special-points.md Run the focused Phase 9 tests and the Phase 9 example. The test command filters to FixedRateBondMaturitySpecialPointTests and the example runs with the --maturity-special-points flag. ```bash dotnet test tests/ChebyshevSharp.Tests/ChebyshevSharp.Tests.csproj --framework net10.0 --configuration Release --filter "FullyQualifiedName~FixedRateBondMaturitySpecialPointTests" --verbosity minimal ``` ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --maturity-special-points ``` -------------------------------- ### Run baseline example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/callable-bond-surrogate.md Command to run the baseline callable bond surrogate example. The default scenario is a 30Y, 6% coupon callable bond with first call at 5Y, call price 100, Hull-White mean reversion 3%, volatility 1%, and 80 tree steps. ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj ``` -------------------------------- ### Run public modes of CallableBondSurrogate example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/callable-bond-surrogate.md Runs the public modes of the CallableBondSurrogate example. The first command runs the default mode; the remaining commands pass flags to select specific modes: --naive-surrogate-discovery, --structured-alternatives, --risk-acceptance, and --risk-acceptance-heavy. ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj ``` ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --naive-surrogate-discovery ``` ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --structured-alternatives ``` ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --risk-acceptance ``` ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --risk-acceptance-heavy ``` -------------------------------- ### Install DocFX 2.78.5 Source: https://github.com/0xc000005/chebyshevsharp/blob/main/CONTRIBUTING.md Install DocFX globally at version 2.78.5, required for building documentation. ```bash dotnet tool install --global docfx --version 2.78.5 ``` -------------------------------- ### Verification commands for Phase 7 structured alternatives Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-7-structured-alternatives.md Run the structured-alternatives example, verify formatting, run focused tests, build, generate docs, check whitespace, and run the full release test suite. Results: example succeeded, formatting clean, 3 Phase 7 tests passed, 59 fixed-rate bond tests passed, Release build with 0 warnings/errors, DocFX built with 0 warnings/errors, no whitespace errors, 1708 release tests passed. ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --structured-alternatives dotnet format --verify-no-changes --verbosity minimal dotnet test --filter "FullyQualifiedName~FixedRateBondStructuredAlternativesTests" dotnet test --filter "FullyQualifiedName~FixedRateBond" dotnet build --configuration Release --no-restore docfx docs/docfx.json git diff --check dotnet test --configuration Release --no-build --verbosity minimal ``` -------------------------------- ### Run American option example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/continuous-state-dynamic-programming.md Command to run the American option dynamic Chebyshev example project using the dotnet CLI. This executes the example that demonstrates the optimal stopping problem with Chebyshev interpolation. ```bash dotnet run --project examples/AmericanOptionDynamicChebyshev/AmericanOptionDynamicChebyshev.csproj ``` -------------------------------- ### Example output for asset allocation Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/continuous-state-dynamic-programming.md Representative output from the example, showing wealth, value, selected action, and derivative for several wealth levels, plus the total number of build evaluations. ```text Continuous-state DP: dynamic asset allocation Wealth | value | action | dV/dWealth 50.0 | 7.60083 | risky | 0.075610 100.0 | 10.74943 | risky | 0.053848 150.0 | 13.16166 | risky | 0.043399 200.0 | 15.08648 | risky | 0.031351 Build evaluations: 279 ``` -------------------------------- ### Stochastic growth example output Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/continuous-state-dynamic-programming.md Shows the console output from running the stochastic growth example. It prints the capital, value, action, and derivative of value with respect to capital for several capital levels, followed by the number of build evaluations. ```text Continuous-state DP: stochastic growth Capital | value | action | dV/dCapital 1.0 | -1.36661 | save-20 | 0.350000 2.0 | -1.12401 | save-20 | 0.175000 4.0 | -0.88141 | save-20 | 0.087500 6.0 | -0.73949 | save-20 | 0.058333 Build evaluations: 396 ``` -------------------------------- ### Run ChebyshevSharp console examples Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/examples.md Execute the provided console projects from the repository root using the dotnet CLI. Various flags are available for specific surrogate and bond analysis tasks. ```bash dotnet run --project examples/QuickStart/QuickStart.csproj dotnet run --project examples/SliderPartitionValidation/SliderPartitionValidation.csproj dotnet run --project examples/TensorTrainHighDim/TensorTrainHighDim.csproj dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --diagnostics dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --surrogate-reproduction dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --naive-surrogate-discovery dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --structured-alternatives dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --analytic-coupon-decomposition dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --maturity-special-points dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --schedule-aware-router dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --accuracy-recipe-search dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --naive-maturity-scan-csv dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --naive-surrogate-discovery dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --structured-alternatives dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --risk-acceptance dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --risk-acceptance-heavy dotnet run --project examples/ContinuousStateDynamicProgramming/ContinuousStateDynamicProgramming.csproj dotnet run --project examples/AmericanOptionDynamicChebyshev/AmericanOptionDynamicChebyshev.csproj ``` -------------------------------- ### Run Phase 10 tests and example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-10-schedule-aware-router.md Run the focused Phase 10 tests and the example application. The test command filters to the FixedRateBondScheduleAwareRouterTests and the run command passes the --schedule-aware-router flag. Both commands are part of the verification workflow for Phase 10. ```bash dotnet test tests/ChebyshevSharp.Tests/ChebyshevSharp.Tests.csproj --framework net10.0 --configuration Release --filter "FullyQualifiedName~FixedRateBondScheduleAwareRouterTests" --verbosity minimal ``` ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --schedule-aware-router ``` -------------------------------- ### Quick Start: Build and evaluate a Chebyshev interpolant Source: https://github.com/0xc000005/chebyshevsharp/blob/main/README.md Shows how to define a function, construct a ChebyshevApproximation, build it, evaluate values and derivatives, check accuracy, and save the interpolant. Query points must be inside the declared domain; out-of-domain points throw. ```csharp 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"); ``` -------------------------------- ### Install ChebyshevSharp via dotnet CLI Source: https://github.com/0xc000005/chebyshevsharp/blob/main/README.md Adds the ChebyshevSharp NuGet package to the project. No system BLAS installation is required because cross-platform OpenBLAS binaries are included. ```bash dotnet add package ChebyshevSharp ``` -------------------------------- ### Run boundary diagnostics for American option Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/american-option-dynamic-chebyshev.md Run the AmericanOptionDynamicChebyshev example with the --boundary-diagnostics flag to output representative payoff and continuation values and the estimated first-step exercise boundary. ```bash dotnet run --project examples/AmericanOptionDynamicChebyshev/AmericanOptionDynamicChebyshev.csproj -- --boundary-diagnostics ``` -------------------------------- ### Run CallableBondSurrogate with --structured-alternatives Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/callable-bond-surrogate.md Runs the CallableBondSurrogate example with the --structured-alternatives flag to execute the internal curve compression trial. The trial uses a 65D public wrapper with an internal 8D factor-risk surrogate. ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --structured-alternatives ``` -------------------------------- ### Run CallableBondSurrogate risk-acceptance probes Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/callable-bond-surrogate.md Run the CallableBondSurrogate example in standard risk-acceptance mode, then in the heavier full-pillar TT probe mode. The heavy mode is intentionally separate and is used to test stronger risk acceptance. ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --risk-acceptance ``` ```bash dotnet run --project examples/CallableBondSurrogate/CallableBondSurrogate.csproj -- --risk-acceptance-heavy ``` -------------------------------- ### Stryker.NET mutation testing commands Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/contributing.md Install and run Stryker.NET mutation testing with the specified configuration file. ```bash dotnet tool install --global dotnet-stryker --version 4.14.1 dotnet stryker --config-file stryker-config.json ``` -------------------------------- ### ChebyshevSharp minimal approximation example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/index.md Defines a two-dimensional function, creates a ChebyshevApproximation with a specified domain and number of nodes, builds the approximation, and evaluates it at a point, including a partial derivative with respect to the first variable. ```csharp using ChebyshevSharp; double Function(double[] x, object? data) => Math.Sin(x[0]) + Math.Cos(x[1]); var cheb = new ChebyshevApproximation( function: Function, numDimensions: 2, domain: new[] { new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 } }, nNodes: new[] { 11, 11 }); cheb.Build(); double value = cheb.VectorizedEval(new[] { 0.5, 0.3 }, new[] { 0, 0 }); double dx0 = cheb.VectorizedEval(new[] { 0.5, 0.3 }, new[] { 1, 0 }); ``` -------------------------------- ### Run refresh script and fixed-rate bond tests Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-5-realistic-baseline.md Commands used to verify the refresh script and run the fixed-rate bond tests and example. The script is invoked with --help, then with --curve-date 2026-05-15, --download-date 2026-05-20, and either --density semiannual-svensson or --density selected-annual, writing to /tmp/fed-dense-check.json and /tmp/fed-annual-check.json respectively. The dotnet test filter runs all tests whose fully qualified name contains 'FixedRateBond', and dotnet run executes the example project. ```bash uv run tools/RefreshFixedRateBondMarketData/refresh_fed_nominal_yield_curve.py --help uv run tools/RefreshFixedRateBondMarketData/refresh_fed_nominal_yield_curve.py --curve-date 2026-05-15 --download-date 2026-05-20 --density semiannual-svensson --input-csv /tmp/feds200628.csv --output /tmp/fed-dense-check.json uv run tools/RefreshFixedRateBondMarketData/refresh_fed_nominal_yield_curve.py --curve-date 2026-05-15 --download-date 2026-05-20 --density selected-annual --input-csv /tmp/feds200628.csv --output /tmp/fed-annual-check.json dotnet test --filter "FullyQualifiedName~FixedRateBond" dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj ``` -------------------------------- ### Refresh Fed Nominal Yield Curve Fixture and Run Example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-2-public-data-fixtures.md Commands to refresh the Fed nominal yield curve fixture for a specific date and then run the FixedRateBondSurrogate example project. The refresh tool sends an explicit user-agent header to avoid HTTP 403 errors from Python's default urllib user agent. ```bash uv run tools/RefreshFixedRateBondMarketData/refresh_fed_nominal_yield_curve.py --help uv run tools/RefreshFixedRateBondMarketData/refresh_fed_nominal_yield_curve.py --curve-date 2026-05-15 dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj ``` -------------------------------- ### Run thesis Table 2.1-style LSM comparison Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/american-option-dynamic-chebyshev.md Runs the thesis Table 2.1-style LSM comparison for the American option Dynamic Chebyshev example. ```bash dotnet run --project examples/AmericanOptionDynamicChebyshev/AmericanOptionDynamicChebyshev.csproj -- --thesis-benchmark ``` -------------------------------- ### C# example of domain mismatch throwing ArgumentException Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/algebra.md Creates two ChebyshevApproximation objects with different domains, builds them, and attempts addition, which throws ArgumentException due to domain mismatch. The example illustrates the compatibility requirement that both operands must have identical Domain bounds in every dimension. ```csharp var a = new ChebyshevApproximation(F, 2, new[] { new[] { 0.0, 1.0 }, new[] { 0.0, 1.0 } }, new[] { 10, 10 }); var b = new ChebyshevApproximation(G, 2, new[] { new[] { 0.0, 1.0 }, new[] { 0.0, 2.0 } }, // different domain new[] { 10, 10 }); a.Build(verbose: false); b.Build(verbose: false); var c = a + b; // throws ArgumentException: domain mismatch ``` -------------------------------- ### Run closeout verification commands Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-5-realistic-baseline.md Closeout verification commands: format check, Release build, Release test with code coverage, Release example run, DocFX documentation build, and whitespace check. The test command collects XPlat Code Coverage and disables parallelization. The example run uses the Release configuration without rebuilding. ```bash dotnet format --verify-no-changes --verbosity minimal dotnet build --configuration Release --no-restore dotnet test --configuration Release --no-build --verbosity minimal --collect:"XPlat Code Coverage" -- RunConfiguration.DisableParallelization=true dotnet run --configuration Release --no-build --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj docfx docs/docfx.json git diff --check ``` -------------------------------- ### Phase 8 Verification Commands Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-8-analytic-coupon-decomposition.md Runs formatting, focused tests, coverage, example, build, documentation, and diff checks to verify Phase 8 implementation. All checks passed with zero failures, warnings, or errors. ```bash dotnet format --verify-no-changes --verbosity minimal dotnet test --configuration Release --filter "FullyQualifiedName~FixedRateBondAnalyticCouponDecompositionTests" --collect:"XPlat Code Coverage" --results-directory TestResults/phase8-coverage-final dotnet test --filter "FullyQualifiedName~FixedRateBond" dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --analytic-coupon-decomposition dotnet build --configuration Release --no-restore docfx docs/docfx.json dotnet test --configuration Release --verbosity minimal git diff --check ``` -------------------------------- ### Combine Chebyshev proxies with weighted addition Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/from-values.md Combines two Chebyshev proxies (built externally) into a weighted portfolio proxy using scalar multiplication and addition. The example assumes valsA, valsB, domain, and nNodes are already defined. ```csharp // Two proxies built externally var chebA = ChebyshevApproximation.FromValues( valsA, 2, domain, nNodes); var chebB = ChebyshevApproximation.FromValues( valsB, 2, domain, nNodes); // Portfolio-level proxy var portfolio = 0.6 * chebA + 0.4 * chebB; ``` -------------------------------- ### Worked example — spline_1d_kink.pcb (100 bytes) Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/binary-format.md Byte-level breakdown of the committed fixture tests/fixtures/spline_1d_kink.pcb encoding |x| on [-1,1] with one knot at 0. Shows offsets, sizes, and values for each field. Total size is 100 bytes. ```text Offset Size Value Field ------ ---- ---------- ----- 0 12 (header) magic + version + class_tag=2 12 4 01 00 00 00 d = 1 16 8 lo[0] = -1.0 24 8 hi[0] = 1.0 32 4 03 00 00 00 n_nodes[0] = 3 36 4 01 00 00 00 num_knots[0] = 1 40 8 0.0 knots[0][0] = 0.0 48 4 02 00 00 00 num_pieces = 2 52 24 2 × 3 × f64 piece tensors ``` -------------------------------- ### ChebyshevSpline ErrorEstimate Example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/error-estimation.md Shows how to build a 1-D ChebyshevSpline with a knot at a kink and obtain the maximum error estimate across all pieces. The output is written to the console with format 'E2'. ```csharp using ChebyshevSharp; double absFunc(double[] x, object? data) => Math.Abs(x[0]); var spline = new ChebyshevSpline( function: absFunc, numDimensions: 1, domain: new[] { new[] { -1.0, 1.0 } }, nNodes: new[] { 15 }, knots: new[] { new[] { 0.0 } } // knot at the kink ); spline.Build(verbose: false); Console.WriteLine($"Spline error estimate: {spline.ErrorEstimate():E2}"); ``` -------------------------------- ### Define action grid for asset allocation Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/continuous-state-dynamic-programming.md Defines a simple action grid for the dynamic asset allocation example, with three discrete allocations: cash, balanced, and risky. ```csharp BellmanAction[] allocations = [ new(0, "cash", 0.0), new(1, "balanced", 0.5), new(2, "risky", 1.0), ]; ``` -------------------------------- ### Batch evaluation with EvalBatch Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/spline.md Evaluates a spline at many points at once. Points are grouped by piece to minimize per-point overhead. The example creates 1000 random points in the domain [80,120]x[0.25,1.0] and evaluates them with EvalBatch. ```csharp double[][] points = new double[1000][]; for (int i = 0; i < 1000; i++) { points[i] = new[] { 80.0 + 40.0 * Random.Shared.NextDouble(), // S in [80, 120] 0.25 + 0.75 * Random.Shared.NextDouble(), // T in [0.25, 1.0] }; } double[] values = spline.EvalBatch(points, new[] { 0, 0 }); ``` -------------------------------- ### Multi-Extrude 1D to 3D with two tuples Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/extrude-slice.md Demonstrates multi-extrude: starting from a 1D ChebyshevApproximation, adds two dimensions in a single Extrude call with an array of tuples. The resulting cheb3d is a 3D interpolant of the same type, already built, with Function = null. ```csharp double F(double[] x, object? _) => Math.Sin(x[0]); var cheb1d = new ChebyshevApproximation(F, 1, new[] { new[] { -1.0, 1.0 } }, new[] { 15 }); cheb1d.Build(); // Add two dimensions at once var cheb3d = cheb1d.Extrude( (1, new[] { 0.0, 5.0 }, 11), (2, new[] { -2.0, 2.0 }, 9) ); ``` -------------------------------- ### Worked example — approx_2d_simple.pcb (128 bytes) Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/binary-format.md Byte-level breakdown of the committed fixture tests/fixtures/approx_2d_simple.pcb encoding f(x,y)=x+y on [-1,1]² with n=[3,3]. Shows exact offsets, sizes, and values for each field. Total size is 128 bytes. ```text Offset Size Value Field ------ ---- ---------- ----- 0 4 50 43 42 00 magic "PCB\0" 4 1 01 major = 1 5 1 00 minor = 0 6 2 01 00 class_tag = 1 (Approximation) 8 4 00 00 00 00 reserved = 0 12 4 02 00 00 00 d = 2 16 8 0000 0000 0000 F0BF lo[0] = -1.0 24 8 0000 0000 0000 F0BF lo[1] = -1.0 32 8 0000 0000 0000 F03F hi[0] = 1.0 40 8 0000 0000 0000 F03F hi[1] = 1.0 48 4 03 00 00 00 n_nodes[0] = 3 52 4 03 00 00 00 n_nodes[1] = 3 56 72 9 × f64 tensor values (row-major) ``` -------------------------------- ### ChebyshevSpline.AutoKnots example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/adaptive-refinement.md Builds a ChebyshevSpline by scanning for second-difference spikes. The heuristic places a knot near x=0 and produces a 2-piece spline. Tuning parameters are thresholdFactor (default 5.0), maxKnotsPerDim (default 5), and nScanPoints (default 200); set maxKnotsPerDim: 0 to disable auto-knot insertion. ```csharp double F(double[] p, object? _) => Math.Abs(p[0]); var sp = ChebyshevSpline.AutoKnots(F, 1, new[] { new[] { -1.0, 1.0 } }, new[] { 16 }); // Discovers a knot near x=0; the resulting Spline has 2 pieces. ``` -------------------------------- ### Slice a 2D spline to 1D Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/spline.md Fixes a dimension at a specific value, reducing dimensionality. The example fixes dimension 1 (T) at 0.5 to get h(S) = spline(S, 0.5). Slicing selects the piece containing the slice value and performs barycentric interpolation; a slice exactly at an interior knot uses the right piece. ```csharp // Fix dimension 1 (T) at 0.5: h(S) = spline(S, 0.5) var spline1d = spline2d.Slice((1, 0.5)); ``` -------------------------------- ### Auto-N ChebyshevApproximation with errorThreshold Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/error-driven-construction.md Constructs a ChebyshevApproximation with auto-sized dimensions by passing null for nNodes and an errorThreshold. The first example auto-sizes all dimensions; the second fixes dimension 1 at 15 nodes while auto-sizing dimension 0. Build starts auto-sized dimensions at 3 nodes and doubles the worst-contributing growable dimension until the coefficient-tail estimate and off-grid validation pass are at or below the threshold. ```csharp using ChebyshevSharp; // Auto-N: every dim resolves automatically. var cheb = new ChebyshevApproximation( function: (x, _) => Math.Sin(x[0]) + Math.Cos(x[1]), numDimensions: 2, domain: new[] { new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 } }, nNodes: null, errorThreshold: 1e-8); cheb.Build(verbose: true); // [auto-N] nNodes=[3, 3], error=... // [auto-N] validation error=... // [auto-N] nNodes=[6, 3], error=... // ... // Mixed: fix dim 1 at 15, auto-size dim 0 against the threshold. var mixed = new ChebyshevApproximation( function: (x, _) => Math.Sin(8 * x[0]) + Math.Cos(x[1]), numDimensions: 2, domain: new[] { new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 } }, nNodes: new int?[] { null, 15 }, errorThreshold: 1e-6); ``` -------------------------------- ### Run all benchmarks Source: https://github.com/0xc000005/chebyshevsharp/blob/main/benchmark-results/README.md Executes the full suite of benchmarks in Release configuration. ```bash dotnet run --configuration Release --project benchmarks/ChebyshevSharp.Benchmarks/ChebyshevSharp.Benchmarks.csproj ``` -------------------------------- ### Run DocFX documentation build Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/superpowers/plans/2026-05-21-phase9-maturity-special-points.md Builds the documentation using DocFX with the configuration file docs/docfx.json. ```bash docfx docs/docfx.json ``` -------------------------------- ### Combine Chebyshev approximations into a portfolio proxy Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/algebra.md Creates two ChebyshevApproximation objects on the same grid, builds them, combines them into a portfolio proxy, and evaluates price, delta, and gamma at a point. The resulting portfolio is a regular ChebyshevApproximation, so all existing evaluation methods work unchanged. ```csharp using ChebyshevSharp; // Two functions on the same grid double F(double[] x, object? data) => Math.Sin(x[0]) + Math.Sin(x[1]); double G(double[] x, object? data) => Math.Cos(x[0]) * Math.Cos(x[1]); var a = new ChebyshevApproximation(F, 2, new[] { new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 } }, new[] { 11, 11 }); var b = new ChebyshevApproximation(G, 2, new[] { new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 } }, new[] { 11, 11 }); a.Build(verbose: false); b.Build(verbose: false); // Combine into a portfolio proxy var portfolio = 0.6 * a + 0.4 * b; // Evaluate price and Greeks at any point double[] point = { 0.5, 0.3 }; double price = portfolio.VectorizedEval(point, new[] { 0, 0 }); double delta = portfolio.VectorizedEval(point, new[] { 1, 0 }); double gamma = portfolio.VectorizedEval(point, new[] { 2, 0 }); ``` -------------------------------- ### Run FixedRateBondSurrogate benchmarks Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-13-accuracy-speed-pilot.md Runs the BenchmarkDotNet suite for the FixedRateBondSurrogate benchmarks in Release mode with a short job, one warmup, and three iterations. Use this command to reproduce the reported performance numbers. ```bash dotnet run --project benchmarks/ChebyshevSharp.Benchmarks/ChebyshevSharp.Benchmarks.csproj \ -c Release -- --filter '*FixedRateBondSurrogateBenchmarks*' \ --job Short --warmupCount 1 --iterationCount 3 ``` -------------------------------- ### Spectral convergence with ChebyshevApproximation.ErrorEstimate() Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/error-estimation.md Shows how to create a ChebyshevApproximation for a 1-D sine function and print the error estimate for increasing node counts. Expect the estimate to drop by several orders of magnitude as n grows. ```csharp using ChebyshevSharp; double f(double[] x, object? data) => Math.Sin(x[0]); for (int n = 5; n <= 30; n += 5) { var cheb = new ChebyshevApproximation(f, 1, new[] { new[] { -1.0, 1.0 } }, new[] { n }); cheb.Build(verbose: false); Console.WriteLine($"n={n,2}: ErrorEstimate = {cheb.ErrorEstimate():E2}"); } ``` -------------------------------- ### Set and get descriptor on ChebyshevApproximation Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/ergonomics.md Attach a free-form text label to any interpolant using SetDescriptor and retrieve it with GetDescriptor. The descriptor survives save/load. ```csharp var approx = new ChebyshevApproximation( (p, _) => p[0] + p[1], numDimensions: 2, domain: new[] { new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 } }, nNodes: new[] { 5, 5 }); approx.Build(); approx.SetDescriptor("Black-Scholes 2D, vol=20%"); string? label = approx.GetDescriptor(); ``` -------------------------------- ### Save and load ChebyshevApproximation in binary and JSON formats Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/binary-format.md Shows how to save a ChebyshevApproximation as .pcb (binary) or .json (default or explicit) and load it back. The loader sniffs the first four bytes: 'PCB\0' routes to binary, otherwise JSON. Loading a valid .pcb with the wrong class fails with a 'class_tag' error. ```csharp cheb.Save("model.pcb", format: "binary"); // .pcb cheb.Save("model.json"); // JSON (default) cheb.Save("model.json", format: "json"); // explicit var dense = ChebyshevApproximation.Load("model.pcb"); ``` -------------------------------- ### Run structured alternatives mode Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/examples.md Compares various modelling choices including global TensorTrain, TT auto-ordering, Slider grouping, and factor models. ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --structured-alternatives ``` -------------------------------- ### Run naive discovery mode Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/examples.md Estimates the feasibility of the full dense tensor and compares 62D TensorTrain and Slider probes. ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --naive-surrogate-discovery ``` -------------------------------- ### Compute first, second, and multiple derivatives with Eval and EvalMulti Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/spline.md Shows how to compute first and second derivatives with respect to dimension 0 using Eval, and how to compute multiple derivative orders at once with EvalMulti, which reuses barycentric weights and exact-node detection for better performance. ```csharp // First derivative w.r.t. dimension 0 double dfdx0 = spline.Eval(new[] { 110.0, 0.5 }, new[] { 1, 0 }); // Second derivative w.r.t. dimension 0 double d2fdx0 = spline.Eval(new[] { 110.0, 0.5 }, new[] { 2, 0 }); // Multiple derivatives at once (shared barycentric weights) double[] results = spline.EvalMulti( new[] { 110.0, 0.5 }, new[] { new[] { 0, 0 }, // function value new[] { 1, 0 }, // dV/dS new[] { 2, 0 }, // d2V/dS2 new[] { 0, 1 }, // dV/dT } ); ``` -------------------------------- ### No Knots in a Dimension Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/spline.md Uses an empty array for dimensions where the function is smooth. This example places a knot at S=100 in the price dimension but none in time or vol dimensions, creating a 3D spline with 2 pieces. ```csharp // Knot at S = 100 in price dimension, none in time or vol var spline = new ChebyshevSpline( function: BsPrice, numDimensions: 3, domain: new[] { new[] { 80.0, 120.0 }, new[] { 0.25, 1.0 }, new[] { 0.15, 0.35 } }, nNodes: new[] { 15, 15, 15 }, knots: new[] { new[] { 100.0 }, Array.Empty(), Array.Empty() } ); ``` -------------------------------- ### Full verification commands Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-1-baseline-pricer.md Runs the complete set of verification commands including build, test, format, pack, and documentation generation. Expected results include zero warnings/errors, all tests passing, and successful package creation. ```bash git diff --check dotnet restore dotnet format --verify-no-changes --verbosity minimal dotnet build --configuration Release --no-restore dotnet test --configuration Release --no-build --verbosity minimal -- RunConfiguration.DisableParallelization=true dotnet pack src/ChebyshevSharp --configuration Release --no-build --output artifacts/packages dotnet build --no-restore dotnet test dotnet run --project examples/QuickStart/QuickStart.csproj dotnet run --project examples/SliderPartitionValidation/SliderPartitionValidation.csproj dotnet run --project examples/TensorTrainHighDim/TensorTrainHighDim.csproj dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj dotnet run --configuration Release --no-build --project examples/QuickStart/QuickStart.csproj dotnet run --configuration Release --no-build --project examples/SliderPartitionValidation/SliderPartitionValidation.csproj dotnet run --configuration Release --no-build --project examples/TensorTrainHighDim/TensorTrainHighDim.csproj dotnet run --configuration Release --no-build --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj docfx docs/docfx.json ``` -------------------------------- ### American option actions description Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/continuous-state-dynamic-programming.md Describes the two actions available in the American option optimal stopping example: exercise to receive the payoff h(S), or continue to receive the discounted expected future value. ```text exercise -> receive payoff h(S) continue -> receive discounted expected future value ``` -------------------------------- ### Compute portfolio delta and gamma with ChebyshevApproximation Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/algebra.md Builds two Chebyshev interpolants, combines them with a weighted sum, and evaluates the portfolio's delta and gamma using VectorizedEval with derivative orders. The derivative propagates automatically through algebraic operations. ```csharp // Build two interpolants for call and put call.Build(verbose: false); put.Build(verbose: false); // Combine var portfolio = 0.6 * call + 0.4 * put; // Delta of the portfolio = 0.6 * delta_call + 0.4 * delta_put double delta = portfolio.VectorizedEval(point, new[] { 1, 0, 0 }); // Gamma works too double gamma = portfolio.VectorizedEval(point, new[] { 2, 0, 0 }); ``` -------------------------------- ### Run accuracy recipe search mode Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/examples.md Compares candidate recipes and the schedule-resolved cashflow-kernel proof of concept to identify near-roundoff PV error configurations. ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --accuracy-recipe-search ``` -------------------------------- ### Run 10-case assessment Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/american-option-dynamic-chebyshev.md Runs the 10-case price and sensitivity assessment for the Dynamic Chebyshev American option model, comparing against QLNet finite difference ground truth at 10 spot levels. ```bash dotnet run --project examples/AmericanOptionDynamicChebyshev/AmericanOptionDynamicChebyshev.csproj -- --case-assessment ``` -------------------------------- ### ChebyshevSlider ErrorEstimate Example Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/error-estimation.md Shows how to build a 3-D ChebyshevSlider with a partition and pivot point, and obtain the sum error estimate from all slides. The estimate only captures per-slide interpolation error; cross-group coupling error is not included. ```csharp using ChebyshevSharp; double f(double[] x, object? data) { return Math.Sin(x[0]) + Math.Sin(x[1]) + Math.Sin(x[2]); } var slider = new ChebyshevSlider( function: f, numDimensions: 3, domain: new[] { new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 }, new[] { -1.0, 1.0 } }, nNodes: new[] { 11, 11, 11 }, partition: new[] { new[] { 0 }, new[] { 1 }, new[] { 2 } }, pivotPoint: new[] { 0.0, 0.0, 0.0 } ); slider.Build(); Console.WriteLine($"Slider error estimate: {slider.ErrorEstimate():E2}"); ``` -------------------------------- ### Run diagnostics mode Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/examples.md Inspects baseline coupon linearity, zero-pillar DV01, and maturity-date spike candidates before fitting a Chebyshev surrogate. ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --diagnostics ``` -------------------------------- ### Extrude a 1D spline to 2D Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/spline.md Adds a new dimension where the function is constant. The example extrudes a 1D spline to 2D with a new axis over [0,1] with 10 nodes. Each piece is extruded independently and the new dimension has no knots. ```csharp // Start with a 1D spline f(x) with a knot // Extrude to 2D: g(x, y) = f(x), constant in y var spline2d = spline1d.Extrude((1, new[] { 0.0, 1.0 }, 10)); ``` -------------------------------- ### Get derivative IDs and evaluate derivatives Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/docs/ergonomics.md Obtain stable session-local integer IDs for derivative orders using GetDerivativeId, then evaluate those derivatives with Eval. The registry is per-instance and persists across Save/Load on all supported interpolant classes. ```csharp int delta = approx.GetDerivativeId(new[] { 1, 0 }); int gamma = approx.GetDerivativeId(new[] { 2, 0 }); double d = approx.Eval(point, delta); double g = approx.Eval(point, gamma); ``` -------------------------------- ### Run analytic coupon decomposition Source: https://github.com/0xc000005/chebyshevsharp/blob/main/docs/research/fixed-rate-bond-surrogate/reports/phase-8-analytic-coupon-decomposition.md Command to run the analytic coupon decomposition analysis for the fixed-rate bond surrogate project. ```bash dotnet run --project examples/FixedRateBondSurrogate/FixedRateBondSurrogate.csproj -- --analytic-coupon-decomposition ```