CSharpNumerics 1.1.0
dotnet add package CSharpNumerics --version 1.1.0
NuGet\Install-Package CSharpNumerics -Version 1.1.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="CSharpNumerics" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpNumerics" Version="1.1.0" />
<PackageReference Include="CSharpNumerics" />
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 CSharpNumerics --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CSharpNumerics, 1.1.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 CSharpNumerics@1.1.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=CSharpNumerics&version=1.1.0
#tool nuget:?package=CSharpNumerics&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
🧮 CSharpNumerics
A comprehensive numerical library for scientific computing, mathematical analysis, and iterative processes in C#. NuGet Package
✨ Features
- 🔢 Numerical extensions (Factorial, derivatives, integrals, root finding, etc.)
- 📈 Vectors, matrices, and complex numbers
- 🌊 Vector fields (Gradient, Divergence, Curl, Laplacian)
- 🧠 Complex and real function analysis
- 🔬 Fourier, Laplace, and Monte Carlo transforms
- 📉 Differential equation solvers (Runge–Kutta, Trapezoidal, etc.)
- 📊 Statistics and regression tools
- 🔗 Full integration with LINQ and extension methods
📘 Numeric Extensions
Factorial
int result = 5.Factorial(); // 120
Root Finding (Newton–Raphson)
Func<double, double> func = x => Math.Pow(x, 2) - 4;
double root = func.NewtonRaphson(); // 2
Derivative
Func<double, double> f = x => Math.Pow(x, 2);
Func<double, double> g = x => 4 * x - 3;
var result = f.Derivate(g, 1);
Supports Chain, Product, and Quotient rules via:
var result = f.Derivate(g, Numerics.Enums.DerivateOperator.Product);
Multiple variables:
Func<double[], double> func = vars => vars[0] * vars[1];
var dfdx = func.Derivate(new double[] { 2, 3 }, index: 0);
Or with vectors:
Func<Vector, double> func = v => v.x * v.y;
var dfdx = func.Derivate(new Vector(2, 3, 0), Cartesian.X);
Derivate series:
Func<double, double> displacement = t => 9.81 * Math.Pow(t, 2) / 2;
var velocity = displacement.GetSeries(0, 10, 1000).Derivate();
∫ Integrals
Trapezoidal rule:
Func<double, double> f = x => Math.Sin(x);
double integral = f.Integrate(0, Math.PI);
Integrate a series or timeseries:
List<TimeSerie> ts = ...;
double total = ts.Integrate();
Monte Carlo Integration
Func<(double x, double y), double> func = p => p.x * p.y;
double result = func.Integrate((0, 1), (0, 1));
🧩 Complex Numbers
var a = new ComplexNumber(3, 2);
var b = new ComplexNumber(5, 3);
var sum = a + b;
var product = a * b;
var power = a.Pow(2); // 5 + 12i
Exponential:
new ComplexNumber(0, Math.PI).Exponential(); // -1
🧭 Vector
var a = new Vector(5, 3, 0);
var b = new Vector(2, 6, 0);
var dot = a.Dot(b);
var cross = a.Cross(b);
From spherical coordinates:
var v = Vector.FromSphericalCoordinates(radius, inclination, azimuth);
🧮 Matrix
var A = new Matrix(new double[,] { { 1, 3, 7 }, { 5, 2, 9 } });
var transpose = A.Transpose();
var det = A.Determinant();
var inv = A.Inverse();
Arithmetic:
var B = new Matrix(new double[,] { { 2, 5, 1 }, { 4, 3, 7 } });
var sum = A + B;
var product = A * B;
With vector:
var x = new Vector(2, 1, 3);
var y = A * x;
🌐 Vector Field
Gradient
Func<Vector, double> f = p => Math.Pow(p.x, 2) * Math.Pow(p.y, 3);
var grad = f.Gradient((1, -2, 0));
Divergence
var field = new VectorField(p => Math.Sin(p.x * p.y),
p => Math.Cos(p.x * p.y),
p => Math.Exp(p.z));
double div = field.Divergence((1, 2, 2));
Curl
var field = new VectorField(p => p.y, p => -p.x, p => 0);
var curl = field.Curl((1, 4, 2));
⚙️ Transform
FFT
Func<double, double> f = t => Math.Exp(-t * t / 0.02);
var freq = f.FastFouriertransform(-0.5, 0.5, 100)
.ToFrequencyResolution(100);
Laplace Transform
double result = f.LaplaceTransform(2.0);
📐 Differential Equations
Runge–Kutta (RK4)
Func<(double t, double y), double> f = v => Math.Tan(v.y) + 1;
var result = f.RungeKutta(1, 1.1, 0.025, 1);
Linear Systems
var result = A.LinearSystemSolver(b);
var eigenValues = A.EigenValues();
📊 Statistics
var noise = new Random().GenerateNoise(4);
double median = ts.Median(p => p.Value);
double std = ts.StandardDeviation(p => p.Value);
Regression:
var (slope, intercept, corr) = serie.LinearRegression(p => (p.Index, p.Value));
var expFunc = serie.ExponentialRegression(p => (p.Index, p.Value));
K-nearest neighbors:
var data = new List<(double x, double y, int c)> { (7,7,0), (7,4,0), (3,4,1), (1,4,1) };
int classification = data.KnearestNeighbors(p => (p.x, p.y, p.c), (3,7), 3);
📎 Tips
- All methods are available as extension methods — just
using Numerics.Extensions. - You can export data with
.Save(path)for CSV visualization. - Works with LINQ pipelines for composable scientific workflows.
🧠 Example: Full Workflow
Func<double, double> func = x => Math.Sin(x);
var integral = func.Integrate(0, Math.PI);
var derivative = func.Derivate(Math.PI / 4);
var fft = func.FastFouriertransform(-1, 1, 100);
🧾 License
MIT License © 2025 — CSharpNumerics
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.