AngouriMath
Navigation
AngouriMath.MathS
Classes within the AngouriMath.MathS namespace
Boolean
Summary
Some operations on booleans are stored here
Compute
Summary
Implements necessary functions for symbolic computation of limits, derivatives and integrals
DecimalConst
Summary
Some non-symbolic constantsDiagnostic
Summary
This class is used for diagnostic and debug of the library itself.
Usually, you do not want to use it in production code.
Dimensions
Summary
Dimensional analysis: whether a formula is physically meaningful, what kind of
quantity it produces, and which combinations of its variables are pure numbers.
Remarks
A variable is a symbol, and nothing in an Entity says that v is a speed. The caller says so, with a map from each variable to its
Dimension, and the check reads the formula against it. The map is
passed rather than attached to the variables, so the same expression can be read
under different assignments, and nothing about how an expression prints, parses or
simplifies changes.
This complements a units library rather than replacing one. UnitsNet and its kind
check a value: a length divided by a time is a speed. Neither can look at
sqrt(2 g h) and say whether it is one, and that is what this does.
Undetermined is not a verdict. An undeclared variable, or a node the check does
not read, gives Undetermined, never a guess.
The page Docs/Usage/Dimensions.md lists the rule for each kind of node and
works the water-wave example through.
ExperimentalFeatures
Summary
Features that might become stable
in the future, but are not guaranteed
to do anything useful or correctly
at the current moment.
Hyperbolic
Summary
Represents a few hyperbolic functions
Matrices
Summary
Classes and functions related to matrices are defined hereMultithreading
Summary
A few functions convenient to use in industrial projects
to keep the system more reliable and distribute computations
to other threads
Numbers
Summary
All operations for Number and its derived classes are available from here.
These methods represent the only possible way to explicitly create numeric instances.
It will automatically downcast the result for you,
so
is an Integer.Number.Create(1.0);
To avoid it, you may temporarily disable it
using var _ = MathS.Settings.DowncastingEnabled.Set(false); var yourNum = Number.Create(1.0);
and the result will be a Real.
Example
using System; using System.Numerics; using AngouriMath; using PeterO.Numbers; using static AngouriMath.MathS.Numbers; using static AngouriMath.MathS; Entity a1 = 5; Entity a2 = "5"; Entity a3 = new Complex(5.5, 6.5); Entity a4 = 6.5m; Entity a5 = 6.5; Entity a6 = 6.5f; Entity a7 = 5.6 + 3 * i; Entity a8 = EInteger.One; Entity a9 = ERational.One; Entity a10 = pi; Console.WriteLine("---------------"); var n0 = Create(0); var n1 = Create(0L); var n2 = Create(new Complex(5.5, 4.75)); var n3 = Create(EInteger.One); var n4 = CreateRational(4, 5); var n5 = Create(ERational.One); var n6 = Create(5.5m); var n7 = Create(5.5); var n8 = Create(5.5m, 6.5m); Console.WriteLine("---------------"); float i0 = (float)FromString("1 + 5").EvalNumerical(); double i1 = (double)FromString("1 + 5").EvalNumerical(); int i2 = (int)FromString("1 + 5").EvalNumerical(); long i3 = (long)FromString("1 + 5").EvalNumerical(); short i4 = (short)FromString("1 + 5").EvalNumerical(); BigInteger i5 = (BigInteger)FromString("1 + 5").EvalNumerical(); Complex i6 = (Complex)FromString("1 + 5").EvalNumerical(); EInteger i7 = ((Entity.Number.Integer)FromString("1 + 5").EvalNumerical()).EInteger; ERational i8 = ((Entity.Number.Rational)FromString("1 + 5").EvalNumerical()).ERational; EDecimal i9 = ((Entity.Number.Real)FromString("1 + 5").EvalNumerical()).EDecimal;NumberTheory
Summary
Use it in order to explore further number theoryPolynomials
Summary
The polynomial layer: factorisation over the rationals, multivariate greatest
common divisors, resultants and discriminants.
Remarks
These are the operations Simplify(System.Int32),
Solve(AngouriMath.Entity.Variable) and Integrate(AngouriMath.Entity.Variable) already run internally, offered here directly. A caller who wants the factors, the
common divisor or the eliminant — rather than whatever a simplification decides to
do with them — had no way to ask for one, and no way to find out that the request
was outside what the layer can do.
Every one of these answers null rather than guessing.null means "I could not settle this" — the input is not a
polynomial of the shape the operation needs, or it is one but past a bound the
implementation carries. It never means "the answer is the input": a polynomial
that does not factor comes back as itself from Factor(AngouriMath.Entity,AngouriMath.Entity.Variable), which is a
statement that it is irreducible over the rationals, and is a different thing from
a refusal. The bounds are stated on each member.
Part of the polynomial layer of
#746, item 43.
Quantum
Summary
Symbolic quantum states: superpositions of basis kets with Entity amplitudes.
Remarks
A state is an ordinary expression rather than a new kind of node.Ket builds
apply(ket, 0, 1) for |01>, so a superposition is a sum of products and
everything that reads expressions reads it -- which is why adding two states,
scaling one, and collectinga|x> + b|x> into(a+b)|x> need no
method here.Simplify already does them.
What is here is what the ordinary machinery has no reason to know: factoring a
definite qubit out of a superposition, and the two questions that are about states
as states rather than as expressions.
There are deliberately no gates. A gate acts *on* a state rather than being one,
and operators, circuits and measurement belong to a quantum computing library
rather than to a computer algebra system.
Series
Summary
That is a collection of some series, expressed in a symbolic form
Sets
Summary
Settings
Summary
A couple of settings allowing you to set some preferences for AM's algorithms
To use these settings the syntax is
using var _ = MathS.Settings.SomeSetting.Set(5 /* Here you set a value to the setting */); // here you write your code normallyRemarks
While any setting is scoped, FromString(System.String,System.Boolean) does not use its cache,
and parsing the same string repeatedly inside the scope costs a parse each time.
Shaders
Summary
Expressions printed as shader source: straight-line HLSL or GLSL that computes each
output once, sharing every repeated subexpression.
Remarks
The use is to derive on the CPU what is expensive or error-prone to derive by hand —
an exact gradient, a Hessian, a closed form of a physical law — and run the result
on the GPU. Differentiate(AngouriMath.Entity.Variable) followed by one of these
is an analytic normal for a signed distance field.
The code computes the real-valued reading, the one Compile<double, …> computes; where that has no value the shader's isNaN , an infinity or
unspecified, as the language's own/ ,pow andsqrt leave it.
Three of those are worth naming, because a GPU does give them a value: a division by
zero,a / b atb = 0 , isNaN compiled and ±infinity in the
shader; so is zero to a negative power,x^(-2) orx^(-1/2) atx = 0 ,
printed1.0 / (x * x) andrsqrt(x) ; and an unsimplifiedx^0 is
printed1.0 , which is 1 atx = 0 where compiled it isNaN . A
branch on every quotient would cost more than the difference is worth, so the
difference is documented rather than paid for. Nor ispow of a negative base
defined in a shader, even where the exponent is a variable that happens to be whole.
A node with no faithful form — a complex constant, a set, a piecewise with inputs it
gives no value to, a function with no intrinsic and no straight-line form — is declined
with the node named, never printed approximately; and whatCompile refuses, a
binder or a statement where a number is expected, is declined withCompile 's
message.
Nothing is simplified. Call Simplify(System.Int32) first if a smaller
form is wanted: what is printed is the expression that was given. The only rewrites
are the onesCompile makes as well: an operation on matrices written out is
the number it gives, a membership in an interval or a finite set is the comparisons
it stands for, and(b^v + c1) / (b^v + c2) , astanh is spelled, is taken
as1 + (c1 - c2) / (b^v + c2) so that it does not overflow.
The page Docs/Usage/Shaders.md works an example through.
UnsafeAndInternal
Summary
You may need it to manually manage some issues.
Although those functions might be used inside the library
only, the user may want to use them for some reason
Utils
Summary
Some additional functions that would be barely
ever used by the user, but kept for "just in case" as public
Angouri © 2019-2026 · Project's repo · Site's repo · Octicons · Transparency · 6003 pages online