AngouriMath
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
AngouriMath Namespace Reference

Namespaces

Classes

class  AngouriMathException
 
class  Entity
 
class  EntityEvaluationExtension
 
struct  ErrorCode
 
struct  HandleDeleter
 
class  InnerEvalZeroedSinCosConditions
 
class  InternalAMExtensions
 This is a set of extensions for internal use.
 
class  MathS
 Use functions from this class More...
 

Typedefs

using NumericsComplex = System.Numerics.Complex
 
using GenTensor = GenericTensor.Core.GenTensor< Entity, Entity.Matrix.EntityTensorWrapperOperations >
 
using SortLevel = Functions.TreeAnalyzer.SortLevel
 

Enumerations

enum  ApproachFrom : std::int32_t { BothSides = 0, Left = 1, Right = 2 }
 

Functions

abstract Entity Replace (Func< Entity, Entity > func)
 Applies the given function to every node starting from the leaves More...
 
virtual Entity Substitute (Entity x, Entity value)
 Replaces all

Parameters
xwith
Parameters
value
More...
 
Entity Substitute ((Entity x1, Entity x2) x,(Entity v1, Entity v2) value)
 Replaces x.x1 with value.v1 and x.x2 with value.v2 More...
 
Entity Substitute ((Entity x1, Entity x2, Entity x3) x,(Entity v1, Entity v2, Entity v3) value)
 Replaces x.x1 with value.v1 and x.x2 with value.v2 and x.x3 with value.v3 More...
 
Entity Substitute ((Entity x1, Entity x2, Entity x3, Entity x4) x,(Entity v1, Entity v2, Entity v3, Entity v4) value)
 Replaces x.x1 with value.v1 and x.x2 with value.v2 and x.x3 with value.v3 and x.x4 with value.v4 More...
 
Entity Substitute< TFrom, TTo > (IReadOnlyDictionary< TFrom, TTo > replacements)
 Replaces all

Parameters
replacements
More...
 
bool ContainsNode (Entity x)
 Checks if x is a subnode inside this Entity tree. More...
 
abstract IEnumerable< EntityInvertNode (Entity value, Entity x)
 Use Invert(Entity, Entity) instead which auto-simplifies value More...
 
Entity Sinh (const Entity &arg0)
 
Entity Sinh (const Entity &arg0, ErrorCode &e)
 
Entity Cosh (const Entity &arg0)
 
Entity Cosh (const Entity &arg0, ErrorCode &e)
 
Entity Tanh (const Entity &arg0)
 
Entity Tanh (const Entity &arg0, ErrorCode &e)
 
Entity Cotanh (const Entity &arg0)
 
Entity Cotanh (const Entity &arg0, ErrorCode &e)
 
Entity Sech (const Entity &arg0)
 
Entity Sech (const Entity &arg0, ErrorCode &e)
 
Entity Cosech (const Entity &arg0)
 
Entity Cosech (const Entity &arg0, ErrorCode &e)
 
Entity Arsinh (const Entity &arg0)
 
Entity Arsinh (const Entity &arg0, ErrorCode &e)
 
Entity Arcosh (const Entity &arg0)
 
Entity Arcosh (const Entity &arg0, ErrorCode &e)
 
Entity Artanh (const Entity &arg0)
 
Entity Artanh (const Entity &arg0, ErrorCode &e)
 
Entity Arcotanh (const Entity &arg0)
 
Entity Arcotanh (const Entity &arg0, ErrorCode &e)
 
Entity Arsech (const Entity &arg0)
 
Entity Arsech (const Entity &arg0, ErrorCode &e)
 
Entity Arcosech (const Entity &arg0)
 
Entity Arcosech (const Entity &arg0, ErrorCode &e)
 
Entity Sin (const Entity &arg0)
 
Entity Sin (const Entity &arg0, ErrorCode &e)
 
Entity Cos (const Entity &arg0)
 
Entity Cos (const Entity &arg0, ErrorCode &e)
 
Entity Sec (const Entity &arg0)
 
Entity Sec (const Entity &arg0, ErrorCode &e)
 
Entity Cosec (const Entity &arg0)
 
Entity Cosec (const Entity &arg0, ErrorCode &e)
 
Entity Log (const Entity &arg0, const Entity &arg1)
 
Entity Log (const Entity &arg0, const Entity &arg1, ErrorCode &e)
 
Entity Pow (const Entity &arg0, const Entity &arg1)
 
Entity Pow (const Entity &arg0, const Entity &arg1, ErrorCode &e)
 
Entity Sqrt (const Entity &arg0)
 
Entity Sqrt (const Entity &arg0, ErrorCode &e)
 
Entity Cbrt (const Entity &arg0)
 
Entity Cbrt (const Entity &arg0, ErrorCode &e)
 
Entity Sqr (const Entity &arg0)
 
Entity Sqr (const Entity &arg0, ErrorCode &e)
 
Entity Tan (const Entity &arg0)
 
Entity Tan (const Entity &arg0, ErrorCode &e)
 
Entity Cotan (const Entity &arg0)
 
Entity Cotan (const Entity &arg0, ErrorCode &e)
 
Entity Arcsin (const Entity &arg0)
 
Entity Arcsin (const Entity &arg0, ErrorCode &e)
 
Entity Arccos (const Entity &arg0)
 
Entity Arccos (const Entity &arg0, ErrorCode &e)
 
Entity Arctan (const Entity &arg0)
 
Entity Arctan (const Entity &arg0, ErrorCode &e)
 
Entity Arccotan (const Entity &arg0)
 
Entity Arccotan (const Entity &arg0, ErrorCode &e)
 
Entity Arcsec (const Entity &arg0)
 
Entity Arcsec (const Entity &arg0, ErrorCode &e)
 
Entity Arccosec (const Entity &arg0)
 
Entity Arccosec (const Entity &arg0, ErrorCode &e)
 
Entity Ln (const Entity &arg0)
 
Entity Ln (const Entity &arg0, ErrorCode &e)
 
Entity Factorial (const Entity &arg0)
 
Entity Factorial (const Entity &arg0, ErrorCode &e)
 
Entity Gamma (const Entity &arg0)
 
Entity Gamma (const Entity &arg0, ErrorCode &e)
 
Entity Signum (const Entity &arg0)
 
Entity Signum (const Entity &arg0, ErrorCode &e)
 
Entity Abs (const Entity &arg0)
 
Entity Abs (const Entity &arg0, ErrorCode &e)
 
Entity Negation (const Entity &arg0)
 
Entity Negation (const Entity &arg0, ErrorCode &e)
 
Entity Provided (const Entity &arg0, const Entity &arg1)
 
Entity Provided (const Entity &arg0, const Entity &arg1, ErrorCode &e)
 
Entity CreateByHandle (Internal::EntityRef handle)
 
Internal::EntityRef ParseString (const char *expr)
 
Internal::EntityRef GetHandle (const Entity &e)
 
std::ostream & operator<< (std::ostream &out, const AngouriMath::Entity &e)
 

Variables

IReadOnlyList< EntityDirectChildren => directChildren.GetValue(static @this => @this.InitDirectChildren(), this)
 Represents all direct children of a node More...
 
IEnumerable< EntityNodes => nodes.GetValue(static @this => @this.DirectChildren.SelectMany(c => c.Nodes).Prepend(@this), this)
 The list of all subnodes of the given expression, including its own. More...
 
bool IsFinite => isFinite.GetValue(static @this => @this.ThisIsFinite && @this.DirectChildren.All(x => x.IsFinite), this)
 Whether both parts of the complex number are finite meaning that it could be safely used for calculations. More...
 
virtual bool ThisIsFinite => true
 Not NaN and not infinity More...
 
int Complexity => complexity.GetValue(static @this => 1 + @this.DirectChildren.Sum(x => x.Complexity), this)
 Number of nodes in tree More...
 
IReadOnlyList< Variable > Vars
 Set of unique variables, for example it extracts x, goose from (x + 2 * goose) - pi * x More...
 
IReadOnlyCollection< Variable > VarsAndConsts
 Set of unique variables, for example it extracts x, goose, pi from (x + 2 * goose) - pi * x More...
 
IReadOnlyCollection< Variable > FreeVariables
 Returns a set of free variables. More...
 
double SimplifiedRate => simplifiedRate.GetValue(MathS.Settings.ComplexityCriteria.Value, this)
 Shows how simple the given expression is. More...
 
bool IsSymbolic => Vars.Any()
 Checks whether the given expression contains variable More...
 
bool IsConstantLeaf => this is Boolean or Number or Set.SpecialSet
 Checks whether the given expression is a finite constant leaf More...
 
bool IsNaN => this == Real.NaN
 Checks whether this entity represents the undefined value (MathS.NaN). More...
 
partial record x => throw new AngouriBugException("This function must contain " + nameof(x))
 
partial record v
 
partial record MathS.Settings. NewtonSolver
 

Function Documentation

◆ ContainsNode()

bool AngouriMath.ContainsNode ( Entity  x)

Checks if x is a subnode inside this Entity tree.

Optimized for Variable.

using System;
using static AngouriMath.MathS;
var (x, y) = Var("x", "y");
var expr1 = Sin(x + y) - Sqr(x);
Console.WriteLine(expr1);
Console.WriteLine(expr1.ContainsNode(y + x));
Console.WriteLine(expr1.ContainsNode(x + y));

Prints

sin(x + y) - x ^ 2
False
True

◆ InvertNode()

abstract IEnumerable<Entity> AngouriMath.InvertNode ( Entity  value,
Entity  x 
)
protectedpure virtual

Use Invert(Entity, Entity) instead which auto-simplifies value

◆ Replace()

abstract Entity AngouriMath.Replace ( Func< Entity, Entity func)
pure virtual

Applies the given function to every node starting from the leaves

Parameters
funcThe delegate that takes the current node as an argument and replaces the current node with the result of the delegate
Returns
Processed expression
using System;
using AngouriMath;
using static AngouriMath.MathS;
using static AngouriMath.Entity;
using static AngouriMath.Entity.Number;
static Entity MySimplify(Entity expr) => expr switch
{
Sumf(Powf(Sinf(var e1), Integer(2)), Powf(Cosf(var e2), Integer(2))) when e1 == e2 => 1,
Sinf(Integer(0)) => 0,
var other => other
};
var x = Var("x");
Entity expr = (Sqr(Sin(x / 3)) + Sqr(Cos(x / 3))) + Sin(0);
Console.WriteLine(expr);
Console.WriteLine(expr.Replace(MySimplify));

Prints

sin(x / 3) ^ 2 + cos(x / 3) ^ 2 + 0
1 + 0

◆ Substitute() [1/4]

virtual Entity AngouriMath.Substitute ( Entity  x,
Entity  value 
)
virtual

Replaces all

Parameters
xwith
Parameters
value

Returns
A new expression
using System;
using AngouriMath;
using static AngouriMath.MathS;
var (x, y, z) = Var("x", "y", "z");
Entity expr = Sin(x);
var substituted = expr.Substitute(x, pi / 3);
Console.WriteLine(expr);
Console.WriteLine(substituted);
Console.WriteLine(substituted.Simplify());
Console.WriteLine("-------------------------------");
var expr2 = Sin(x) + Cos(y + x) + Factorial(z);
var substituted2 =
expr2
.Substitute(x, 1)
.Substitute(y, 2)
.Substitute(z, 3);
Console.WriteLine(expr2);
Console.WriteLine(substituted2);
Console.WriteLine("-------------------------------");
var expr3 = Sin(x + y) + 1 / Sin(x + y);
var substituted3 = expr3.Substitute(Sin(x + y), Cos(x + y));
Console.WriteLine(expr3);
Console.WriteLine(substituted3);

Prints

sin(x)
sin(pi / 3)
<h2>sqrt(3) / 2
</h2>
sin(x) + cos(y + x) + z!
<h2>sin(1) + cos(2 + 1) + 3!
</h2>
sin(x + y) + 1 / sin(x + y)
cos(x + y) + 1 / cos(x + y)

◆ Substitute() [2/4]

Entity AngouriMath.Substitute ( (Entity x1, Entity x2)  x,
(Entity v1, Entity v2)  value 
)

Replaces x.x1 with value.v1 and x.x2 with value.v2

See how Substitute(AngouriMath.Entity,AngouriMath.Entity) works.

using System;
using static AngouriMath.MathS;
var (x, y) = Var("x", "y");
var expr = Sin(x + y) + 1 / Sin(x + y);
var sub = expr
.Substitute((x, y), (5, 11));
Console.WriteLine(sub);

◆ Substitute() [3/4]

Entity AngouriMath.Substitute ( (Entity x1, Entity x2, Entity x3)  x,
(Entity v1, Entity v2, Entity v3)  value 
)

Replaces x.x1 with value.v1 and x.x2 with value.v2 and x.x3 with value.v3

See how Substitute(AngouriMath.Entity,AngouriMath.Entity) works.

using System;
using static AngouriMath.MathS;
var (x, y, z) = Var("x", "y", "z");
var expr = Sin(x + y) + 1 / Sin(x + y) + z;
var sub = expr
.Substitute((x, y, z), (5, 11, 115));
Console.WriteLine(sub);

Prints

sin(5 + 11) + 1 / sin(5 + 11) + 115

◆ Substitute() [4/4]

Entity AngouriMath.Substitute ( (Entity x1, Entity x2, Entity x3, Entity x4)  x,
(Entity v1, Entity v2, Entity v3, Entity v4)  value 
)

Replaces x.x1 with value.v1 and x.x2 with value.v2 and x.x3 with value.v3 and x.x4 with value.v4

See how Substitute(AngouriMath.Entity,AngouriMath.Entity) works.

using System;
using static AngouriMath.MathS;
var (x, y, z, w) = Var("x", "y", "z", "w");
var expr = Sin(x + y) + 1 / Sin(x + y) + z / w;
var sub = expr
.Substitute((x, y, z, w), (5, 11, 115, Sqr(w)));
Console.WriteLine(sub);

Prints

using System;
using static AngouriMath.MathS;
var (x, y, z, w) = Var("x", "y", "z", "w");
var expr = Sin(x + y) + 1 / Sin(x + y) + z / w;
var sub = expr
.Substitute((x, y, z, w), (5, 11, 115, Sqr(w)));
Console.WriteLine(sub);

◆ Substitute< TFrom, TTo >()

Entity AngouriMath.Substitute< TFrom, TTo > ( IReadOnlyDictionary< TFrom, TTo >  replacements)

Replaces all

Parameters
replacements

See how Substitute(AngouriMath.Entity,AngouriMath.Entity) works.

using System;
using System.Collections.Generic;
using AngouriMath;
using static AngouriMath.MathS;
var (x, y, z, w) = Var("x", "y", "z", "w");
var expr = Sin(x + y) + 1 / Sin(x + y) + z / w;
var subs = new Dictionary<Entity, Entity>()
{
{ x, 1 },
{ y, 2 },
{ z, z + Sin(y) }
};
Console.WriteLine(expr);
Console.WriteLine(expr.Substitute(subs));

Prints

sin(x + y) + 1 / sin(x + y) + z / w
sin(1 + 2) + 1 / sin(1 + 2) + (z + sin(y)) / w
Type Constraints
TFrom :Entity 
TTo :Entity 

Variable Documentation

◆ Complexity

int AngouriMath.Complexity => complexity.GetValue(static @this => 1 + @this.DirectChildren.Sum(x => x.Complexity), this)

Number of nodes in tree

using System; using static AngouriMath.MathS;

var (x, y) = Var("x", "y"); var expr1 = x; Console.WriteLine($"{expr1}: {expr1.Complexity}"); var expr2 = x * 2; Console.WriteLine($"{expr2}: {expr2.Complexity}"); var expr3 = Sin(x); Console.WriteLine($"{expr3}: {expr3.Complexity}"); var expr4 = Sin(x) + Cos(x + 2); Console.WriteLine($"{expr4}: {expr4.Complexity}"); Prints x: 1 x * 2: 3 sin(x): 2 sin(x) + cos(x + 2): 7

◆ DirectChildren

IReadOnlyList<Entity> AngouriMath.DirectChildren => directChildren.GetValue(static @this => @this.InitDirectChildren(), this)

Represents all direct children of a node

using System;
using AngouriMath;
Entity frac = "log(sqrt(x), a + b)";
Console.WriteLine(frac);
foreach (var child in frac.DirectChildren)
Console.WriteLine(child);

Prints

log(sqrt(x), a + b)
sqrt(x)
a + b

◆ FreeVariables

IReadOnlyCollection<Variable> AngouriMath.FreeVariables
Initial value:
=>
freeVariables.GetValue(
static @this =>
@this switch
{
Lambda(var par, var body)
=> body.FreeVariables.Where(v => v != par).ToList(),
Variable v => new []{ v },
_ => new HashSet<Variable>(@this.DirectChildren.SelectMany(c => c.FreeVariables))
}
,
this
)
IReadOnlyList< Entity > DirectChildren
Represents all direct children of a node
Definition: Entity.Definition.cs:132

Returns a set of free variables.

We call a bound variable a variable which is a parameter of some outer lambda. Then, all other variables are free.

using System;
using static AngouriMath.MathS;
var (x, y) = Var("x", "y");
var expr1 = Lambda(x, x * 2 + Sin(y * pi));
Console.WriteLine(expr1);
Console.WriteLine("Variables:");
foreach (var var in expr1.Vars)
Console.WriteLine($" {var}");
Console.WriteLine("Variables and constants:");
foreach (var var in expr1.VarsAndConsts)
Console.WriteLine($" {var}");
Console.WriteLine("Only free variables:");
foreach (var var in expr1.FreeVariables)
Console.WriteLine($" {var}");

Prints

x -> x * 2 + sin(y * pi)
Variables:
x
y
Variables and constants:
x
y
pi
Only free variables:
y
pi

◆ IsConstantLeaf

bool AngouriMath.IsConstantLeaf => this is Boolean or Number or Set.SpecialSet

Checks whether the given expression is a finite constant leaf

using System;
using AngouriMath;
using static AngouriMath.MathS;
Entity expr1 = 5;
Console.WriteLine($"{expr1}, IsConstantLeaf: {expr1.IsConstantLeaf}");
Entity expr2 = Sin(5);
Console.WriteLine($"{expr2}, IsConstantLeaf: {expr2.IsConstantLeaf}");
Entity expr3 = pi;
Console.WriteLine($"{expr3}, IsConstantLeaf: {expr3.IsConstantLeaf}");
Entity expr4 = 3 + 4 * i;
Console.WriteLine($"{expr4}, IsConstantLeaf: {expr4.IsConstantLeaf}");
Entity expr5 = (Entity)3 + 4 * i;
Console.WriteLine($"{expr5}, IsConstantLeaf: {expr5.IsConstantLeaf}");
var expr6 = expr5.InnerSimplified;
Console.WriteLine($"{expr6}, IsConstantLeaf: {expr6.IsConstantLeaf}");
var expr7 = GreaterThan(pi, e);
Console.WriteLine($"{expr7}, IsConstantLeaf: {expr7.IsConstantLeaf}");
var expr8 = expr7.Evaled;
Console.WriteLine($"{expr8}, IsConstantLeaf: {expr8.IsConstantLeaf}");

Prints

5, IsConstantLeaf: True
sin(5), IsConstantLeaf: False
pi, IsConstantLeaf: False
3 + 4i, IsConstantLeaf: True
3 + 4i, IsConstantLeaf: False
3 + 4i, IsConstantLeaf: True
pi > e, IsConstantLeaf: False
True, IsConstantLeaf: True

◆ IsFinite

bool AngouriMath.IsFinite => isFinite.GetValue(static @this => @this.ThisIsFinite && @this.DirectChildren.All(x => x.IsFinite), this)

Whether both parts of the complex number are finite meaning that it could be safely used for calculations.

By finite we mean that it is not a MathS.NaN and it is not positive or negative infinity.

using System;
using static AngouriMath.MathS;
var x = Var("x");
var expr1 = Sin(x);
Console.WriteLine($"{expr1}, IsFinite: {expr1.IsFinite}");
var expr2 = Sin(x + 5) + 5;
Console.WriteLine($"{expr2}, IsFinite: {expr2.IsFinite}");
var expr3 = Sin(x + 3) / 0;
Console.WriteLine($"{expr3}, IsFinite: {expr3.IsFinite}");
var expr4 = expr3.Evaled;
Console.WriteLine($"{expr4}, IsFinite: {expr4.IsFinite}");
var expr5 = Sin(x / 0);
Console.WriteLine($"{expr5}, IsFinite: {expr5.IsFinite}");
var expr6 = x + +oo;
Console.WriteLine($"{expr6}, IsFinite: {expr6.IsFinite}");
var expr7 = x + +oo * i;
Console.WriteLine($"{expr7}, IsFinite: {expr7.IsFinite}");
var expr8 = -oo + 6 * i;
Console.WriteLine($"{expr8}, IsFinite: {expr8.IsFinite}");
var expr9 = Sin(+oo) - Cos(pi / 3);
Console.WriteLine($"{expr9}, IsFinite: {expr9.IsFinite}");
var expr10 = Hyperbolic.Tanh(NaN + 3);
Console.WriteLine($"{expr10}, IsFinite: {expr10.IsFinite}");

Prints

sin(x), IsFinite: True
sin(x + 5) + 5, IsFinite: True
sin(x + 3) / 0, IsFinite: True
NaN, IsFinite: False
sin(x / 0), IsFinite: True
x + +oo, IsFinite: False
x + +ooi, IsFinite: False
-oo + 6i, IsFinite: False
sin(+oo) - cos(pi / 3), IsFinite: False
(e ^ (2 * (NaN + 3)) - 1) / (e ^ (2 * (NaN + 3)) + 1), IsFinite: False

◆ IsNaN

bool AngouriMath.IsNaN => this == Real.NaN

Checks whether this entity represents the undefined value (MathS.NaN).

◆ IsSymbolic

bool AngouriMath.IsSymbolic => Vars.Any()

Checks whether the given expression contains variable

using System;
using static AngouriMath.MathS;
var (x, y) = Var("x", "y");
var expr1 = Sin(x + y) - Sqr(x);
Console.WriteLine(expr1.IsSymbolic);
var expr2 = Sin(5) - 22;
Console.WriteLine(expr2.IsSymbolic);
var expr3 = Sin(5) - 22 / x;
Console.WriteLine(expr3.IsSymbolic);

Prints

True
False
True

◆ Nodes

IEnumerable<Entity> AngouriMath.Nodes => nodes.GetValue(static @this => @this.DirectChildren.SelectMany(c => c.Nodes).Prepend(@this), this)

The list of all subnodes of the given expression, including its own.

A depth-first enumeration is required by AngouriMath.Functions.TreeAnalyzer.GetMinimumSubtree

Traverses the tree the following order:

  1. The node itself
  2. All nodes from all children
Entity expr = "a + b / 2 ^ 3";
for (var node in expr.Nodes)
Console.WriteLine(node);

Output:

a + b / 2 ^ 3
a
b / 2 ^ 3
b
2 ^ 3
2
3

◆ SimplifiedRate

double AngouriMath.SimplifiedRate => simplifiedRate.GetValue(MathS.Settings.ComplexityCriteria.Value, this)

Shows how simple the given expression is.

The lower - the simpler the expression is. You might need it to pick the best expression to represent something. Unlike Complexity, which shows the number of nodes, SimplifiedRate shows how convenient it is to view the expression. This depends on MathS.Settings.ComplexityCriteria which can be changed by user. See MathS.Settings.ComplexityCriteria for more details.

◆ ThisIsFinite

virtual bool AngouriMath.ThisIsFinite => true
protected

Not NaN and not infinity

◆ Vars

IReadOnlyList<Variable> AngouriMath.Vars
Initial value:
=> vars.GetValue(static @this
=> @this.VarsAndConsts.Where(x => !x.IsConstant).ToList() , this)
IReadOnlyCollection< Variable > VarsAndConsts
Set of unique variables, for example it extracts x, goose, pi from (x + 2 * goose) - pi * x ...
Definition: Entity.Definition.cs:549

Set of unique variables, for example it extracts x, goose from (x + 2 * goose) - pi * x

Returns
Set of unique variables excluding mathematical constants such as MathS.pi and MathS.e
using System;
using static AngouriMath.MathS;
var (x, y) = Var("x", "y");
var expr1 = Lambda(x, x * 2 + Sin(y * pi));
Console.WriteLine(expr1);
Console.WriteLine("Variables:");
foreach (var var in expr1.Vars)
Console.WriteLine($" {var}");
Console.WriteLine("Variables and constants:");
foreach (var var in expr1.VarsAndConsts)
Console.WriteLine($" {var}");
Console.WriteLine("Only free variables:");
foreach (var var in expr1.FreeVariables)
Console.WriteLine($" {var}");

Prints

x -> x * 2 + sin(y * pi)
Variables:
x
y
Variables and constants:
x
y
pi
Only free variables:
y
pi

◆ VarsAndConsts

IReadOnlyCollection<Variable> AngouriMath.VarsAndConsts
Initial value:
=> varsAndConsts.GetValue(
static @this => new HashSet<Variable>(@this is Variable v ? new[] { v } : @this.DirectChildren.SelectMany(x => x.VarsAndConsts)), this)
IReadOnlyList< Entity > DirectChildren
Represents all direct children of a node
Definition: Entity.Definition.cs:132

Set of unique variables, for example it extracts x, goose, pi from (x + 2 * goose) - pi * x

Returns
Set of unique variables and mathematical constants such as MathS.pi and MathS.e
using System;
using static AngouriMath.MathS;
var (x, y) = Var("x", "y");
var expr1 = Lambda(x, x * 2 + Sin(y * pi));
Console.WriteLine(expr1);
Console.WriteLine("Variables:");
foreach (var var in expr1.Vars)
Console.WriteLine($" {var}");
Console.WriteLine("Variables and constants:");
foreach (var var in expr1.VarsAndConsts)
Console.WriteLine($" {var}");
Console.WriteLine("Only free variables:");
foreach (var var in expr1.FreeVariables)
Console.WriteLine($" {var}");

Prints

x -> x * 2 + sin(y * pi)
Variables:
x
y
Variables and constants:
x
y
pi
Only free variables:
y
pi