MathSharp 1.0.11

Suggested Alternatives

AngouriMath

Additional Details

Because of a naming conflict, we are renaming our project from MathSharp to AngouriMath. Sorry for this mistake.

There is a newer prerelease version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package MathSharp --version 1.0.11                
NuGet\Install-Package MathSharp -Version 1.0.11                
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="MathSharp" Version="1.0.11" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MathSharp --version 1.0.11                
#r "nuget: MathSharp, 1.0.11"                
#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.
// Install MathSharp as a Cake Addin
#addin nuget:?package=MathSharp&version=1.0.11

// Install MathSharp as a Cake Tool
#tool nuget:?package=MathSharp&version=1.0.11                
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

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

MathS.FromString(str) - returns Entity

Entity methods

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

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0-pre 1,089 12/13/2019

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