Simple computer algebra system in C# using a DSL (domain specific language) to construct mathematical expression trees which can be manipulated, transformed, and evaluated.
The library is available as a NuGet package for any .Net implementation that supports the .Net Standard 2.0. Visit the Packages page for downloads.
var x = Symbol("x");
var y = Symbol("y");
var expression = y <= (x^2) + 6;
var x = Symbol("x");
var y = Symbol("y");
var expression = y <= (x^2) + 6;
var y6 = expression.Where(x == 6).Value;
var x = Symbol("x");
var y = Symbol("y");
var expression = y <= (x^2) + 6;
var expression_for_x = expression.SolveFor(x);
Symbol y = new Symbol("y");
Symbol x = new Symbol("x");
var expr = y <= (x^2);
var ddx = expr.Differentiate(x).Simplify();
var x = new Symbol("x");
var y = new Symbol("y");
var equation = y <= Trig.Sin(x);
Several common functions have already been created, such as the trigonometric functions which can be accessed using static methods like seen above. For adding custom functions, extend the Function
class. In order for custom functions to work with algebraic rearrangement, additionally implement the IInvertable
interface. In order for custom functions to work with the derivative calculator, additionally implement the IDifferentiable
interface.
See License for license details.