AngouriMath Documentation
repository·master·Indexed 21 days ago
https://github.com/asc-community/angourimathA mathematical library featuring a lightweight CLI (AngouriMath Terminal) for calculations using F#-based syntax. It provides capabilities for symbolic expressions, parsing mathematical strings into Entities, creating systems of equations and symbolic matrices, and performing differentiation and solving. The library includes AngouriMath.Interactive for C# and F# interactive environments, as well as AngouriMath.CPP.Exporting for C++ integration.
What's inside AngouriMath
- AngouriMath Terminal is a lightweight, desktop-targeted CLI designed for performing basic mathematical calculations. The interface language is F#, allowing users to input expressions directly into the terminal for evaluation. For users preferring a graphical interactive experience, an AngouriMathLab Jupyter notebook is available as an alternative.
Catch all AngouriMath exceptions using AngouriMathBaseException
masterIf you want to catch only exceptions that originate from the AngouriMath library and avoid catching general system or runtime exceptions, catchAngouriMathBaseException. This class serves as the root of the entire AngouriMath exception hierarchy.Build AngouriMath.CPP.Exporting exports manually
masterIf pre-built archives or setups are unavailable, you can manually build the exports in two steps:
- Generate Code: Run
generate_exports.bat(Windows) orgenerate_exports.sh(Unix-like) to generate the C# and C++ code required for exporting and importing functions. You only need to do this if you require changes to the generated code. - Build the Library: Run the appropriate build script for your operating system to generate the binary files (
dll,so, etc.), debug symbols (pdb), and linking files. The output will be placed in../AngouriMath.CPP.Importing/[your-os]-x64/.
# 1. Generate code ./generate_exports.sh # 2. Build the library (example for Linux) ./build-linux-x64.sh- Generate Code: Run
Install AngouriMath Terminal as a .NET tool
masterYou can install AngouriMath Terminal globally as a .NET tool using the
dotnetCLI. Replaceversionyoulikewith your desired version number.dotnet tool install --global AngouriMath.Terminal --version versionyoulikeUninstall AngouriMath Terminal .NET tool
masterTo remove the AngouriMath Terminal global tool from your system, use the
dotnet tool uninstallcommand.dotnet tool uninstall --global AngouriMath.TerminalInstall AngouriMath Terminal for desktop
masterFor non-dotnet-tool installation methods (e.g., direct desktop binaries), refer to the official quickstart guide at https://am.angouri.org/quickstart/#terminal.Use interactive commands for parsing, differentiation, and solving
masterOnce
Interactive.magic()is executed, you can use high-level string-based commands to perform mathematical operations directly:parse: Converts a mathematical string into an expression.differentiate: Computes the derivative of an expression with respect to a variable.solve: Finds solutions for a given expression or constraint.
Note: These commands take string arguments representing the mathematical expressions and variables.
// Parse an expression parse "x2 + sin(sqrt(x + 1/2)) + integral(sqrt(x + derivative(sin(y), y)), x)" // Differentiate an expression with respect to a variable differentiate "x" "sqrt(sin(x) + 1 / (x + epsilon)) + e^(3x2)" // Solve an equation with constraints solve "x" "x > 0 and x ^ 2 = 9"Install and set up AngouriMath.Interactive
masterTo use the interactive features of AngouriMath in an F# environment (such as an .ipynb notebook), install the
AngouriMath.InteractiveNuGet package and callInteractive.magic()to register the interactive commands and magic functions.Before using the interactive commands, ensure you have opened the necessary namespaces:
FunctionsCoreOperators
#r "nuget:AngouriMath.Interactive, *-*" Interactive.magic() open Functions open Core open OperatorsInstall AngouriMath.Interactive for C# Interactive environments
masterTo use AngouriMath in a C# Interactive environment (like Polyglot Notebooks or .NET Interactive), install the
AngouriMath.InteractiveNuGet package and callInteractive.magic()to register the interactive features and magic commands.#r "nuget:AngouriMath.Interactive, *-*" Interactive.magic()Create a symbolic matrix
masterUse
MathS.Matrices.Matrix()to create a matrix containing symbolic expressions. You can pass a 2D array of strings or entities to define the matrix elements.MathS.Matrices.Matrix(new Entity[,]{ { "x / 2", "beta - 2^3", "e / sqrt(pi)" }, { "epsilon", "integral(sin(k), k)", "e - pi" }, })Parse mathematical strings into Entities
masterUse the
.ToEntity()extension method on a string to parse it into a mathematicalEntity. This allows you to work with symbolic expressions directly from string literals. Ensure you haveusing AngouriMath;andusing AngouriMath.Extensions;in your scope.using AngouriMath.Extensions; using AngouriMath; "x2 + sin(sqrt(x + 1/2)) + integral(sqrt(x + derivative(sin(y), y)), x)".ToEntity();Create a system of equations
masterYou can define a system of equations using
MathS.Equations(), passing one or more string expressions representing the equations in the system.var sys = MathS.Equations( "x + 2 - y - y2", "x / y - sin(z) + 3", "x - sin(z)" ); sys