AngouriMath Documentation

repository·master·Indexed 21 days ago

https://github.com/asc-community/angourimath

A 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.

Tokens
1.4K
Snippets
9
Records
12
Agent score
74%

What's inside AngouriMath

  1. Build AngouriMath.CPP.Exporting exports manually

    master

    If pre-built archives or setups are unavailable, you can manually build the exports in two steps:

    1. Generate Code: Run generate_exports.bat (Windows) or generate_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.
    2. 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
  2. Use interactive commands for parsing, differentiation, and solving

    master

    Once 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"
  3. Install and set up AngouriMath.Interactive

    master

    To use the interactive features of AngouriMath in an F# environment (such as an .ipynb notebook), install the AngouriMath.Interactive NuGet package and call Interactive.magic() to register the interactive commands and magic functions.

    Before using the interactive commands, ensure you have opened the necessary namespaces:

    • Functions
    • Core
    • Operators
    #r "nuget:AngouriMath.Interactive, *-*"
    Interactive.magic()
    
    open Functions
    open Core
    open Operators
  4. Parse mathematical strings into Entities

    master

    Use the .ToEntity() extension method on a string to parse it into a mathematical Entity. This allows you to work with symbolic expressions directly from string literals. Ensure you have using AngouriMath; and using 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();