Epsilon.LinearAlgebra
1.0.0
See the version list below for details.
dotnet add package Epsilon.LinearAlgebra --version 1.0.0
NuGet\Install-Package Epsilon.LinearAlgebra -Version 1.0.0
<PackageReference Include="Epsilon.LinearAlgebra" Version="1.0.0" />
<PackageVersion Include="Epsilon.LinearAlgebra" Version="1.0.0" />
<PackageReference Include="Epsilon.LinearAlgebra" />
paket add Epsilon.LinearAlgebra --version 1.0.0
#r "nuget: Epsilon.LinearAlgebra, 1.0.0"
#:package Epsilon.LinearAlgebra@1.0.0
#addin nuget:?package=Epsilon.LinearAlgebra&version=1.0.0
#tool nuget:?package=Epsilon.LinearAlgebra&version=1.0.0
![]()
Epsilon.LinearAlgebra
Linear algebra for Epsilon. Matrices and vectors of symbolic expressions or of doubles: exact determinants, inverses and solutions of symbolic systems, and LU decomposition for numeric ones.
var m = Matrix<Expr>.Parse("[[a, b], [c, d]]");
m.Determinant().Print(); // a * d - b * c
m.Adjugate().Print(); // [[d, -b], [-c, a]]
Installation
dotnet add package Epsilon.LinearAlgebra
Requires .NET 10. The core package Epsilon comes with it; the namespaces are
Epsilon.LinearAlgebra and Epsilon.Core.
Quick start
using Epsilon.Core;
using Epsilon.LinearAlgebra;
// Symbols
var m = Matrix<Expr>.Parse("[[a, b], [c, d]]");
m.Determinant().Print(); // a * d - b * c
m.Trace().Print(); // a + d
// Exact numbers: the entries are rationals, never rounded
var r = Matrix<Expr>.Parse("[[1, 2], [3, 4]]");
r.Inverse().Print(); // [[-2, 1], [3/2, -1/2]]
r.CharacteristicPolynomial("t").Print(); // t^2 - 5t - 2
// Doubles
var n = Matrix<double>.FromRows([2, 1], [4, 4]);
n.Determinant(); // 4
n.Solve([4, 12]); // [1, 2]
Features
Matrices and vectors
Matrix<T> is an immutable matrix of any entry type; Vector<T> is a column vector, a
matrix with one column, and converts to one implicitly. Build them from rows, from a
function of the indices, from text, or with a collection expression:
Matrix<double>.FromRows([1, 2, 3], [4, 5, 6]).Transpose(); // [[1, 4], [2, 5], [3, 6]]
Matrix<double>.Create(2, 3, (i, j) => 10 * i + j); // [[0, 1, 2], [10, 11, 12]]
Vector<double> v = [1, 2, 3];
v.Dot([4, 5, 6]); // 32
The arithmetic is defined for double and Expr entries: +, -, the matrix product,
scalars, Identity, Zero, Trace. With expressions every entry of a result is simplified:
(2 * m).Print(); // [[2a, 2b], [2c, 2d]]
(m * Vector<Expr>.Parse("[x, y]")).Print(); // [a * x + b * y, c * x + d * y]
Symbolic results that hold wherever they are defined
The determinant and the characteristic polynomial come from Berkowitz's algorithm, which never divides, so no entry has to be assumed nonzero. The inverse is the adjugate divided by the determinant: it is undefined exactly where the matrix is singular, and nowhere else.
var inverse = Matrix<Expr>.Parse("[[x, 1], [1, x]]").Inverse();
inverse.Print(); // [[x / (x^2 - 1), -1 / (x^2 - 1)], [-1 / (x^2 - 1), x / (x^2 - 1)]]
inverse.Substitute("x", 0).Simplify().Print(); // [[0, 1], [1, 0]]
Elimination with x as the first pivot would have divided by x and lost the point x = 0.
Terms cancel exactly, functions included:
Matrix<Expr>.Parse("[[x + 1, x - 1], [x - 1, x - 3]]").Determinant().Print(); // -4
Matrix<Expr>.Parse("[[cos(x), -sin(x)], [sin(x), cos(x)]]").Inverse().Print();
// [[cos(x), sin(x)], [-sin(x), cos(x)]]
Numeric results that know when they can't be trusted
For doubles, LU decomposition with partial pivoting gives the determinant, the inverse, solutions and the rank. A pivot that is no larger than the rounding error of the terms it was computed from counts as zero, so a matrix that is singular stays singular:
var s = Matrix<double>.FromRows([1, 2, 3], [4, 5, 6], [7, 8, 9]);
s.Determinant(); // 0, not the 6.7e-16 that plain elimination gives
s.Rank(); // 2
s.Inverse(); // InvalidOperationException: The matrix is singular: its rank is 2, not 3, to working precision.
A badly scaled matrix such as [[1e-20, 0], [0, 1]] is still regular: nothing cancels there.
Entry-wise operations, text and LaTeX
Simplify, Expand, Substitute, Differentiate, Evaluate and EvaluateComplex work on
every entry. Print() writes text that Parse reads back; ToLatex() writes a bmatrix:
var rotation = Matrix<Expr>.Parse("[[cos(x), -sin(x)], [sin(x), cos(x)]]");
rotation.Differentiate("x").Print(); // [[-sin(x), -cos(x)], [cos(x), -sin(x)]]
m.Evaluate(("a", 1), ("b", 2), ("c", 3), ("d", 4)); // [[1, 2], [3, 4]]
Vector<Expr>.Parse("[x^2, 1/2]").Simplify().ToLatex();
// \begin{bmatrix} x^{2} \\ \frac{1}{2} \end{bmatrix}
Good to know
System.Numericshas aVector<T>of its own, soVector<double>is ambiguous in a file that uses both namespaces. Name the type you need with an alias,using RealVector = Epsilon.LinearAlgebra.Vector<double>;, or writeSystem.Numerics.BigIntegerin full instead of importing the namespace.- Like
ExprParser.Parse,Parsedoesn't simplify:[[1/2, x + x]]keeps1 / 2andx + xuntilSimplify(). - The operators on
Exprmatrices simplify in the defaultGenericmode, so an entryx/xbecomes1.
Documentation
The guide explains every feature in detail, the API reference lists every public type and member, and the changelog lists the changes. The expressions themselves are documented with the core.
License
MIT, copyright (c) 2026 Max Zakharov - see LICENSE.
| 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. |
-
net10.0
- Epsilon (>= 1.1.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Epsilon.LinearAlgebra:
| Package | Downloads |
|---|---|
|
Epsilon.Calculus
Calculus for the Epsilon symbolic math library. Gradients, directional derivatives, divergence, curl and potentials, Hessians, Laplacians and the second-derivative test for functions of several variables, as vectors and matrices of expressions that compile to fast delegates. Taylor, Laurent and Puiseux series with exact coefficients, and exact limits at a point, from either side and at infinity, by Gruntz's algorithm. Exact antiderivatives from a table of integrals, by substitution, by parts, by partial fractions with Hermite's reduction (over the roots of cubic and quartic factors in radicals too), by Bioche's rules and t = tan(x/2) for rational functions of sin and cos, by t = exp(x) and by trigonometric, hyperbolic and Euler substitutions for square roots of quadratics. Exact definite integrals, improper ones included, from the antiderivative with its singular points and jumps checked, and from a table of classic integrals such as the Gaussian, Dirichlet and Fresnel integrals. Line integrals by arc length and along vector fields. Numeric definite integrals by the tanh-sinh and exp-sinh rules over finite and infinite intervals, oscillating ones included, split at the singularities, kinks and peaks found in the expression, accurate at singular ends, and with divergent integrals reported instead of returned as numbers. |
GitHub repositories
This package is not used by any popular GitHub repositories.