AngouriMath 1.0.11

Enables to work with formulas built in the code or from string. Computing, derivating, latex rendering.

There is a newer version of this package available.
See the version list below for details.
Install-Package AngouriMath -Version 1.0.11
dotnet add package AngouriMath --version 1.0.11
<PackageReference Include="AngouriMath" Version="1.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AngouriMath --version 1.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

AngouriMath

Open-source Math engine for ASC

Use as a simple calculator
var inp = "1 + 2 * log(9, 3)";
var expr = MathS.FromString(inp);
Console.WriteLine(expr.Eval());
> >> 5
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
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.Simplify());
> >> 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.Simplify());
> >> 2 * x + -1 * sin(x) / (cos(x) + 3) + 4
Build formulas
var x = MathS.Var("x");
var expr = (x + 3).Pow(x + 4);
Func<NumberEntity, Entity> wow = v => expr.Substitute(x, v).Simplify();
Console.WriteLine(wow(4));
Console.WriteLine(wow(5));
Console.WriteLine(wow(6));
> >> 5764801
> >> 134217728
> >> 3486784401
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 eqations
var x = MathS.Var("x");
var equation = (x - 1) * (x - 2) * (MathS.Sqr(x) + 1);
foreach (var re in equation.SolveNt(x))
    Console.Write(re.ToString() + "  ");
> >> 1  2  1i

Full documentation

Function list

<br>MathS.Sin(x)
<br>MathS.Cos(x)
<br>MathS.Log(num, base),
<br>MathS.Pow(base, power)
<br>MathS.Sqrt(x) = MathS.Pow(x, 0.5)
<br>MathS.Sqr(x) = MathS.Pow(x, 2)
<br>MathS.Tan(x) = MathS.Sin(x) / MathS.Cos(x)
<br>MathS.Cotan(x) = 1 / MathS.Tan(x)
<br>MathS.Sec(x) = 1 / MathS.Cos(x)
<br>MathS.Cosec(x) = 1 / MathS.Sin(x)
<br>MathS.B(x) = x * MathS.Sin(x)
<br>MathS.TB(x) = x * MathS.Cos(x)

<br>MathS.FromString(str) - returns Entity

Entity methods

<br>expr.Derive(x) - derivation for variable x
<br>expr.Eval() - evaluation & simplification
<br>expr.Latexise() - render to latex
<br>expr.SolveNt(expr, from, to, stepCount, precision) - find roots assuming we are solving equation expr=0.
<br>The algorithm iterates on [from.Re; to.Re] for real part and on [from.Im; to.Im] for imaginary part.
<br>The higher stepCount is, the more roots the function can find
<br>Precision - if you get similar roots that you think are equal, you can increase this argument.
<br>You can also decrease MathS.EQUALITY_THRESHOLD which is responsible for comparing Numbers.

AngouriMath

Open-source Math engine for ASC

Use as a simple calculator
var inp = "1 + 2 * log(9, 3)";
var expr = MathS.FromString(inp);
Console.WriteLine(expr.Eval());
> >> 5
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
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.Simplify());
> >> 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.Simplify());
> >> 2 * x + -1 * sin(x) / (cos(x) + 3) + 4
Build formulas
var x = MathS.Var("x");
var expr = (x + 3).Pow(x + 4);
Func<NumberEntity, Entity> wow = v => expr.Substitute(x, v).Simplify();
Console.WriteLine(wow(4));
Console.WriteLine(wow(5));
Console.WriteLine(wow(6));
> >> 5764801
> >> 134217728
> >> 3486784401
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 eqations
var x = MathS.Var("x");
var equation = (x - 1) * (x - 2) * (MathS.Sqr(x) + 1);
foreach (var re in equation.SolveNt(x))
    Console.Write(re.ToString() + "  ");
> >> 1  2  1i

Full documentation

Function list

<br>MathS.Sin(x)
<br>MathS.Cos(x)
<br>MathS.Log(num, base),
<br>MathS.Pow(base, power)
<br>MathS.Sqrt(x) = MathS.Pow(x, 0.5)
<br>MathS.Sqr(x) = MathS.Pow(x, 2)
<br>MathS.Tan(x) = MathS.Sin(x) / MathS.Cos(x)
<br>MathS.Cotan(x) = 1 / MathS.Tan(x)
<br>MathS.Sec(x) = 1 / MathS.Cos(x)
<br>MathS.Cosec(x) = 1 / MathS.Sin(x)
<br>MathS.B(x) = x * MathS.Sin(x)
<br>MathS.TB(x) = x * MathS.Cos(x)

<br>MathS.FromString(str) - returns Entity

Entity methods

<br>expr.Derive(x) - derivation for variable x
<br>expr.Eval() - evaluation & simplification
<br>expr.Latexise() - render to latex
<br>expr.SolveNt(expr, from, to, stepCount, precision) - find roots assuming we are solving equation expr=0.
<br>The algorithm iterates on [from.Re; to.Re] for real part and on [from.Im; to.Im] for imaginary part.
<br>The higher stepCount is, the more roots the function can find
<br>Precision - if you get similar roots that you think are equal, you can increase this argument.
<br>You can also decrease MathS.EQUALITY_THRESHOLD which is responsible for comparing Numbers.

Release Notes

Bug related to recurrent calls of synonimical functions (for example, sqrt(sqrt(x))) fixed

  • .NETCoreApp 3.0

    • No dependencies.

GitHub repositories (0)

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.0.1 46 6/25/2020
1.1.0 46 6/5/2020
1.1.0-Beta 72 6/3/2020
1.0.20 75 4/23/2020
1.0.18-Alpha 120 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 113 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
Show less