AngouriMath 1.0.20

Enables to work with formulas built in the code or from a string. Computing, derivating, latex rendering, fast functions, solving equations and systems of equations analytycally, simplification, and much more.

There is a newer version of this package available.
See the version list below for details.
Install-Package AngouriMath -Version 1.0.20
dotnet add package AngouriMath --version 1.0.20
<PackageReference Include="AngouriMath" Version="1.0.20" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AngouriMath --version 1.0.20
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Build an expression
var x = MathS.Var("x");
var y = MathS.Var("y");
var c = x * y + x / y;
Console.WriteLine(MathS.Sqr(c));
> >> (x * y + x / y) ^ 2
Use as a simple calculator
var inp = "1 + 2 * log(9, 3)";
var expr = MathS.FromString(inp);
Console.WriteLine(expr.Eval());
> >> 5
Substitute variables
var x = MathS.Var("x");
var expr = x * 2 + MathS.Sin(x) / MathS.Sin(MathS.Pow(2, x));
var subs = expr.Substitute(x, 0.3);
Console.WriteLine(subs.Eval());
> >> 0,9134260185941638
Find derivatives
var x = MathS.Var("x");
var func = MathS.Sqr(x) + MathS.Ln(MathS.Cos(x) + 3) + 4 * x;
var derivative = func.Derive(x);
Console.WriteLine(derivative.Eval());
> >> 2 * x + -1 * sin(x) / (cos(x) + 3) + 4
Build expressions faster
Entity expr = "sqr(x + y)";
Console.WriteLine(expr.Expand().Simplify());
> >> 2 * x * y + x ^ 2 + y ^ 2
Simplify
var x = MathS.Var("x");
var a = MathS.Var("a");
var b = MathS.Var("b");
var expr = MathS.Sqrt(x) / x + a * b + b * a + (b - x) * (x + b) + 
    MathS.Arcsin(x + a) + MathS.Arccos(a + x);
Console.WriteLine(expr.Simplify());
> >> 1.5707963267948966 + 2 * a * b + b ^ 2 + x ^ (-0.5) - x ^ 2
Render latex
var x = MathS.Var("x");
var y = MathS.Var("y");
var expr = x.Pow(y) + MathS.Sqrt(x + y / 4) * (6 / x);
Console.WriteLine(expr.Latexise());
> >> {x}^{y}+\sqrt{x+\frac{y}{4}}*\frac{6}{x}
Play with complex numbers
var expr = MathS.Pow(MathS.e, MathS.pi * MathS.i);
Console.WriteLine(expr);
Console.WriteLine(expr.Eval());
> >> 2,718281828459045 ^ 3,141592653589793i
> >> -1
Solve equations analytically

Under developing now and forever (always available)

Entity expr = "(sin(x)2 - sin(x) + a)(b - x)((-3) * x + 2 + 3 * x ^ 2 + (x + (-3)) * x ^ 3)";
foreach (var root in expr.Solve("x"))
    Console.WriteLine(root);
> >> arcsin((1 - sqrt(1 + (-4) * a)) / 2) - (-2) * n * pi
> >> 2 * n * pi + pi - arcsin((1 - sqrt(1 + (-4) * a)) / 2)
> >> arcsin(0.5 * (1 + sqrt(1 + (-4) * a))) - (-2) * n * pi
> >> 2 * n * pi + pi - arcsin((1 + sqrt(1 + (-4) * a)) / 2)
> >> b
> >> -i
> >> i
> >> 1
> >> 2
Solve systems of non-linear equations

Under developing now and forever (always available)

var system = MathS.Equations(
    "cos(x2 + 1)^2 + 3y",
    "y * (-1) + 4cos(x2 + 1)"
);
Console.WriteLine(system.Latexise());
var solutions = system.Solve("x", "y");
Console.WriteLine(Solutions.PrintOut());
Integrate

Only definite integral over single variable is supported yet :(

var x = MathS.Var("x");
var expr = MathS.Sin(x) + MathS.Sqrt(x) / (MathS.Sqrt(x) + MathS.Cos(x)) + MathS.Pow(x, 3);
Console.WriteLine(expr.DefiniteIntegral(x, -3, 3));
var expr2 = MathS.Sin(x);
Console.WriteLine(expr2.DefiniteIntegral(x, 0, MathS.pi));
> >> 5.56669223384056 + 0.0889406793629381i
> >> 1.98003515236381
Compile functions

Compiled functions work 15x+ faster

var x = MathS.Var("x");
var expr = MathS.Sin(x) + MathS.Sqrt(x) / (MathS.Sqrt(x) + MathS.Cos(x)) + MathS.Pow(x, 3);
var func = expr.Compile(x);
Console.WriteLine(func.Substitute(3));
Try new syntax
var expr = MathS.FromString("3x3 + 2 2 2 - x(3 0.5)");
Console.WriteLine(expr);
> >> 3 * x ^ 3 + 2 ^ 2 ^ 2 - x * sqrt(3)
Try SymPy syntax
var x = SySyn.Symbol("x");
var expr = SySyn.Exp(x) + x;
Console.WriteLine(SySyn.Diff(expr));
Console.WriteLine(SySyn.Diff(expr, x));
Console.WriteLine(SySyn.Diff(expr, x, x));
Translate number systems
string x = MathS.ToBaseN(-32.25, 4);
Console.WriteLine("-32.25(10) = " + x + "(4)");
double y = MathS.FromBaseN("AB.3", 16);
Console.WriteLine("AB.3(16) = " + y + "(1)");
> >> -32.25(10) = -200.1(4)
> >> AB.3(16) = 171,1875(1)
Build an expression
var x = MathS.Var("x");
var y = MathS.Var("y");
var c = x * y + x / y;
Console.WriteLine(MathS.Sqr(c));
> >> (x * y + x / y) ^ 2
Use as a simple calculator
var inp = "1 + 2 * log(9, 3)";
var expr = MathS.FromString(inp);
Console.WriteLine(expr.Eval());
> >> 5
Substitute variables
var x = MathS.Var("x");
var expr = x * 2 + MathS.Sin(x) / MathS.Sin(MathS.Pow(2, x));
var subs = expr.Substitute(x, 0.3);
Console.WriteLine(subs.Eval());
> >> 0,9134260185941638
Find derivatives
var x = MathS.Var("x");
var func = MathS.Sqr(x) + MathS.Ln(MathS.Cos(x) + 3) + 4 * x;
var derivative = func.Derive(x);
Console.WriteLine(derivative.Eval());
> >> 2 * x + -1 * sin(x) / (cos(x) + 3) + 4
Build expressions faster
Entity expr = "sqr(x + y)";
Console.WriteLine(expr.Expand().Simplify());
> >> 2 * x * y + x ^ 2 + y ^ 2
Simplify
var x = MathS.Var("x");
var a = MathS.Var("a");
var b = MathS.Var("b");
var expr = MathS.Sqrt(x) / x + a * b + b * a + (b - x) * (x + b) + 
    MathS.Arcsin(x + a) + MathS.Arccos(a + x);
Console.WriteLine(expr.Simplify());
> >> 1.5707963267948966 + 2 * a * b + b ^ 2 + x ^ (-0.5) - x ^ 2
Render latex
var x = MathS.Var("x");
var y = MathS.Var("y");
var expr = x.Pow(y) + MathS.Sqrt(x + y / 4) * (6 / x);
Console.WriteLine(expr.Latexise());
> >> {x}^{y}+\sqrt{x+\frac{y}{4}}*\frac{6}{x}
Play with complex numbers
var expr = MathS.Pow(MathS.e, MathS.pi * MathS.i);
Console.WriteLine(expr);
Console.WriteLine(expr.Eval());
> >> 2,718281828459045 ^ 3,141592653589793i
> >> -1
Solve equations analytically

Under developing now and forever (always available)

Entity expr = "(sin(x)2 - sin(x) + a)(b - x)((-3) * x + 2 + 3 * x ^ 2 + (x + (-3)) * x ^ 3)";
foreach (var root in expr.Solve("x"))
    Console.WriteLine(root);
> >> arcsin((1 - sqrt(1 + (-4) * a)) / 2) - (-2) * n * pi
> >> 2 * n * pi + pi - arcsin((1 - sqrt(1 + (-4) * a)) / 2)
> >> arcsin(0.5 * (1 + sqrt(1 + (-4) * a))) - (-2) * n * pi
> >> 2 * n * pi + pi - arcsin((1 + sqrt(1 + (-4) * a)) / 2)
> >> b
> >> -i
> >> i
> >> 1
> >> 2
Solve systems of non-linear equations

Under developing now and forever (always available)

var system = MathS.Equations(
    "cos(x2 + 1)^2 + 3y",
    "y * (-1) + 4cos(x2 + 1)"
);
Console.WriteLine(system.Latexise());
var solutions = system.Solve("x", "y");
Console.WriteLine(Solutions.PrintOut());
Integrate

Only definite integral over single variable is supported yet :(

var x = MathS.Var("x");
var expr = MathS.Sin(x) + MathS.Sqrt(x) / (MathS.Sqrt(x) + MathS.Cos(x)) + MathS.Pow(x, 3);
Console.WriteLine(expr.DefiniteIntegral(x, -3, 3));
var expr2 = MathS.Sin(x);
Console.WriteLine(expr2.DefiniteIntegral(x, 0, MathS.pi));
> >> 5.56669223384056 + 0.0889406793629381i
> >> 1.98003515236381
Compile functions

Compiled functions work 15x+ faster

var x = MathS.Var("x");
var expr = MathS.Sin(x) + MathS.Sqrt(x) / (MathS.Sqrt(x) + MathS.Cos(x)) + MathS.Pow(x, 3);
var func = expr.Compile(x);
Console.WriteLine(func.Substitute(3));
Try new syntax
var expr = MathS.FromString("3x3 + 2 2 2 - x(3 0.5)");
Console.WriteLine(expr);
> >> 3 * x ^ 3 + 2 ^ 2 ^ 2 - x * sqrt(3)
Try SymPy syntax
var x = SySyn.Symbol("x");
var expr = SySyn.Exp(x) + x;
Console.WriteLine(SySyn.Diff(expr));
Console.WriteLine(SySyn.Diff(expr, x));
Console.WriteLine(SySyn.Diff(expr, x, x));
Translate number systems
string x = MathS.ToBaseN(-32.25, 4);
Console.WriteLine("-32.25(10) = " + x + "(4)");
double y = MathS.FromBaseN("AB.3", 16);
Console.WriteLine("AB.3(16) = " + y + "(1)");
> >> -32.25(10) = -200.1(4)
> >> AB.3(16) = 171,1875(1)

Release Notes

Added Tensor, system of equations, polynom divisions, periodic roots for solvers, compilation boosted, simplification improved, LaTeX formatting improved, cache for compiled functions added, search boosted, tons of bugs fixed

  • .NETStandard 2.0

    • No dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.0.1 49 6/25/2020
1.1.0 49 6/5/2020
1.1.0-Beta 72 6/3/2020
1.0.20 75 4/23/2020
1.0.18-Alpha 123 2/4/2020
1.0.17.2-Beta 101 1/6/2020
1.0.17.1-Beta 92 1/5/2020
1.0.17-Beta 116 1/3/2020
1.0.16.2-Beta 194 1/2/2020
1.0.16.1-Beta 104 12/31/2019
1.0.16-Beta 163 12/31/2019
1.0.15.1 102 12/27/2019
1.0.15 94 12/25/2019
1.0.14 97 12/23/2019
1.0.13.7-Beta 113 12/23/2019
1.0.12 85 12/21/2019
1.0.11 86 12/8/2019