Epsilon 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Epsilon --version 1.0.0
                    
NuGet\Install-Package Epsilon -Version 1.0.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="Epsilon" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Epsilon" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Epsilon" />
                    
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 Epsilon --version 1.0.0
                    
#r "nuget: Epsilon, 1.0.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 Epsilon@1.0.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=Epsilon&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Epsilon&version=1.0.0
                    
Install as a Cake Tool

Epsilon

NuGet CI .NET License: MIT

Symbolic math for .NET. Parse formulas, simplify them exactly, differentiate, factor polynomials and find roots — with no dependencies beyond the .NET base library.

Expr f = ExprParser.Parse("x^3 - 2x^2 + x", "x");

f.Differentiate("x").Print();            // 3x^2 - 4x + 1
f.TryFactorReal("x").Factored.Print();   // (x - 1)^2 * x

Installation

dotnet add package Epsilon

Requires .NET 10. The package contains the core library; its namespace is Epsilon.Core.

Quick start

using Epsilon.Core;

Expr f = ExprParser.Parse("x^3 - 2x^2 + x", "x");

f.Evaluate(3);                           // 12
f.Differentiate("x").Print();            // 3x^2 - 4x + 1
f.Differentiate("x").ToLatex();          // 3x^{2} - 4x + 1
f.FindRealRoots(-10, 10);                // [0, 1]
f.TryFactorReal("x").Factored.Print();   // (x - 1)^2 * x

Expressions can also be built with ordinary C# operators:

var x = new Variable("x");

(x * x + 3 * x - x).Simplify().Print();  // x^2 + 2x
(x.Pow(2) + 2 * x + 1).Print();          // x^2 + 2x + 1

Features

Exact arithmetic

Numbers are arbitrary-precision rationals, never floating point, so nothing is lost along the way:

ExprParser.Parse("0.1 + 0.2").Simplify().Print();       // 3/10
ExprParser.Parse("x^2 - 2").TryFactorReal("x").Factored.Print();
                                                         // (x + sqrt(2)) * (x - sqrt(2))

Factoring is exact as well: roots are rational or written with square roots, and a polynomial that can't be factored that way is left alone rather than approximated.

Simplification that respects the domain

Simplify folds constants, combines like terms and factors, cancels common factors and applies identities such as sin(x)^2 + cos(x)^2 = 1. It never changes the value of an expression where that expression is defined. Two modes decide what happens where it isn't:

Expr e = ExprParser.Parse("x/x");

e.Simplify().Print();                     // 1      Generic (default): may become defined at x = 0
e.Simplify(SimplifyMode.Strict).Print();  // x / x  Strict: keeps exactly the same domain

Assumptions

Tell the simplifier what you know about your variables to unlock rules that are only valid under conditions:

Expr s = ExprParser.Parse("sqrt(x^2)");

s.Simplify().Print();                                        // abs(x)
s.Simplify(Assumptions.None.AssumePositive("x")).Print();    // x

Contradictory assumptions (x > 0 and x < 0) are rejected with an error naming the variable.

Differentiation

Symbolic derivatives, partial derivatives included, returned already simplified:

ExprParser.Parse("x^2 * y + y^3").Differentiate("y").Print();   // 3y^2 + x^2

Root finding

All real roots in a range — including infinite ranges, double roots and roots on the edge of the domain — and complex roots via Newton's method:

ExprParser.Parse("sqrt(1 - x^2)").FindRealRoots();              // [-1, 1]
ExprParser.Parse("sin(x)").FindRealRoots(ExprParser.Parse("1/2"), -4, 4);
                                                                 // ≈ [-3.665, 0.524, 2.618]
ExprParser.Parse("x^2 + 1").FindComplexRoots(-2, 2, -2, 2);      // ≈ [-i, i]

Points where the expression is undefined are never reported as roots.

Real and complex evaluation, text and LaTeX output

ExprParser.Parse("x*y + 1").Evaluate(("x", 2), ("y", 3));      // 7
ExprParser.Parse("sqrt(x)").EvaluateComplex(-4);                // ≈ 2i

Print() writes compact text that Parse reads back; ToLatex() writes LaTeX.

Parser syntax

Kind Syntax
Operators + - * / ^, parentheses, \|x\| for absolute value
Implicit multiplication 2x, 2(x + 1), x y
Numbers 12, 1.5, .5, 1e-5, 2.5E3 — always a decimal point, never a comma
Constants pi (or π), e, i
Trigonometric sin cos tan cot sec csc, asin acos atan
Hyperbolic sinh cosh tanh coth sech csch, asinh acosh atanh
Other functions exp ln sqrt abs sign floor ceiling round
Two arguments min(a, b), max(a, b), log(x, base), nthroot(x, n)

Without a list of variables, every single letter is a variable and xy means x*y. Pass the names to allow longer ones and to catch typos:

ExprParser.Parse("theta^2 + 2t", "theta", "t").Print();   // theta^2 + 2t
ExprParser.Parse("sen(x)", "x");
// FormatException: Unknown identifier 'sen' at position 0. Declared variables: x.

Design principles

  • Exact first. Rationals instead of doubles; exact factoring or none at all.
  • Never wrong, sometimes unsimplified. A rule that is only valid under a condition is applied only when the condition is known to hold — a missed simplification is always safer than an incorrect one.
  • No dependencies. Only the .NET base library.
  • Documented. Every public member has XML documentation for IntelliSense.

Roadmap

This package is the core. The next areas are built on it as separate packages, in this order:

  1. Calculus — symbolic and numeric integration (improper integrals included), gradients, Hessians, Laplacians. Already in this repository as an experimental project. Planned next, as far as time and energy allow: limits (including multivariable limits in 2D and 3D), double and triple integrals, surface and contour integrals, Lebesgue integration and more.
  2. Linear algebra — symbolic and numeric matrices and the operations on them.
  3. Transforms — Fourier, wavelets and more.
  4. Probability theory — under consideration.
  5. Further areas as the library grows.

Alongside them the core keeps improving:

  • Equation solver — symbolic solutions of f(x) = g(x) with every branch: sin(x) = 1/2 → π/6 + 2πk, 5π/6 + 2πk, verified by substitution, with a clearly marked numeric fallback.
  • Polynomial expansion, piecewise expressions (derivatives of floor, min, max) and faster evaluation for hot loops.

Building from source

git clone https://github.com/XBambinoX/Epsilon.git
cd Epsilon
dotnet build
dotnet test

License

MIT © Max Zakharov — see LICENSE.

Product 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 (3)

Showing the top 3 NuGet packages that depend on Epsilon:

Package Downloads
Epsilon.LinearAlgebra

Linear algebra for the Epsilon symbolic math library: immutable matrices and vectors of expressions, exact rationals or doubles, and fixed-size vector and matrix value types (Vector2 to Vector4, Matrix2x2 to Matrix4x4) of float, double or any number type for games and graphics. Exact symbolic determinant, characteristic polynomial, inverse and solve without division; exact rational elimination; LU decomposition for doubles with singularity detection to working precision; QR, Cholesky, symmetric eigenvalue and singular value decompositions by accurate Jacobi methods, least squares for any shape (exact for rationals and expressions), the pseudo-inverse and the condition number. Vector geometry, transforms, quaternions with slerp, Euler angles in any axis order, translation-rotation-scale decomposition, camera view and projection matrices (right- and left-handed, any depth range, reverse-Z), a closed-form inverse that detects singular matrices, conversions to System.Numerics, blocks, ranges, powers and approximate equality. Symbolic formulas become fast code: matrices and vectors of expressions compile to delegates with exactly the values of Evaluate or to standalone C# source, with Jacobians and symbolic rotations and translations for kinematic chains and inverse kinematics.

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.

Epsilon.Solving

Equation solving for the Epsilon symbolic math library. Exact solutions of equations in one unknown: polynomial and rational equations, with cubics and quartics in radicals; equations with roots of the unknown, raised to powers with the solutions that adds kept out; exponentials, logarithms, powers, absolute values, inverse trigonometric and hyperbolic functions undone by their inverses with every branch; trigonometric equations as families of solutions, with their values one by one and in a range; and polynomials in one function of the unknown, by substitution. The other variables are parameters, with the conditions on them each solution needs, and no step enlarges the domain. Numeric solutions where there is no formula: every real and complex root of a polynomial, the solutions in a range of the real line, infinite ones included, by a scan that is finer where the equation oscillates, in a rectangle of the complex plane, and near a guess by Newton's method.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0 0 11/23/2026
1.3.0 101 11/19/2026
1.2.0 390 10/12/2026
1.1.1 390 10/4/2026
1.1.0 352 10/2/2026
1.0.1 361 10/1/2026
1.0.0 399 9/28/2026