AngouriMath

Navigation

← Back to list of members

Apply​(AngouriMath.​Entity,​AngouriMath.​Entity[])

 Method (no overloads)

Summary

Applies the list of arguments to the given expression

Returns

Application

Example

Entity expr = "sin";
Console.WriteLine(expr);
var applied = expr.Apply(pi / 3);
Console.WriteLine(applied);
Console.WriteLine(applied.Simplify());
Console.WriteLine(applied.Evaled);
Console.WriteLine("------------------------------");
var lambda = Lambda("x", "x ^ 3 + x");
Console.WriteLine(lambda);
Console.WriteLine(lambda.Apply("3"));
Console.WriteLine(lambda.Apply("3").Evaled);
Console.WriteLine("------------------------------");
var lambda2 = Lambda("y", "y".ToEntity().Apply(pi / 3));
Console.WriteLine(lambda2);
Console.WriteLine(lambda2.Apply("sin").Simplify());
Console.WriteLine(lambda2.Apply("cos").Simplify());
Console.WriteLine(lambda2.Apply("tan").Simplify());
Console.WriteLine("------------------------------");
var lambda3 = Lambda("x", Lambda("y", Lambda("z", "x + y / z")));
Console.WriteLine(lambda3);
Console.WriteLine(lambda3.Apply(5));
Console.WriteLine(lambda3.Apply(5).Simplify());
Console.WriteLine(lambda3.Apply(5).Apply(10));
Console.WriteLine(lambda3.Apply(5).Apply(10).Simplify());
Console.WriteLine(lambda3.Apply(5, 10));
Console.WriteLine(lambda3.Apply(5, 10).Simplify());
Console.WriteLine(lambda3.Apply(5, 10, 7));
Console.WriteLine(lambda3.Apply(5, 10, 7).Simplify());

Prints
sin
sin (pi / 3)
sqrt(3) / 2
1/2 * sqrt(3)
------------------------------
x -> x ^ 3 + x
(x -> x ^ 3 + x) 3
30
------------------------------
y -> y (pi / 3)
sqrt(3) / 2
1/2
sqrt(3)
------------------------------
x -> y -> z -> x + y / z
(x -> y -> z -> x + y / z) 5
y -> z -> 5 + y / z
(x -> y -> z -> x + y / z) 5 10
z -> 5 + 10 / z
(x -> y -> z -> x + y / z) 5 10
z -> 5 + 10 / z
(x -> y -> z -> x + y / z) 5 10 7
45/7

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online