AngouriMath
Substitute
Method with 5 overloads
Substitute(AngouriMath.Entity,AngouriMath.Entity)
Summary
Replaces all withReturns
A new expressionExample
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) sqrt(3) / 2 ------------------------------- sin(x) + cos(y + x) + z! sin(1) + cos(2 + 1) + 3! ------------------------------- sin(x + y) + 1 / sin(x + y) cos(x + y) + 1 / cos(x + y)
Substitute(System.Collections.Generic.IReadOnlyDictionary{``0,``1})
Summary
Replaces allExample
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
Substitute(System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity},System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity})
Summary
Replaces x.x1 with value.v1 and
x.x2 with value.v2 and
x.x3 with value.v3 and
x.x4 with value.v4
Example
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(System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity},System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity})
Summary
Replaces x.x1 with value.v1 and
x.x2 with value.v2 and
x.x3 with value.v3
Example
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(System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity},System.ValueTuple{AngouriMath.Entity,AngouriMath.Entity})
Summary
Replaces x.x1 with value.v1 and
x.x2 with value.v2
Example
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);
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online