AngouriMath
Taylor
Method with 2 overloads
Taylor(AngouriMath.Entity,System.Int32,System.ValueTuple{AngouriMath.Entity.Variable,AngouriMath.Entity.Variable,AngouriMath.Entity}[])
Summary
Finds the symbolic expression of terms of the Taylor expansion of the given function,
https://en.wikipedia.org/wiki/Taylor_series
Parameter "expr"
The function to find the Taylor expansion of
Parameter "degree"
The degree of the resulting taylor polynomial
Parameter "exprToPolyVars"
The variable/s to take the series over, the variable the series will be over,
and the variable values at which the Taylor polynomial will be found
(e. g. if you want to find the taylor polynomial of Sin("t") around t=1, and want
n to take that place in the series, then you may want to use ("t","n","1") for this argument)
Returns
An expression in the polynomial form over the poly variable/s given inexprToPolyVars Example
using AngouriMath; using System; using System.Linq; using static AngouriMath.MathS; using static AngouriMath.MathS.Series; var (x, y) = MathS.Var("x", "y"); Console.WriteLine(Sin(x)); Console.WriteLine(Maclaurin(Sin(x), 1, x)); Console.WriteLine(Maclaurin(Sin(x), 2, x)); Console.WriteLine(Maclaurin(Sin(x), 3, x)); Console.WriteLine(Maclaurin(Sin(x), 4, x)); Console.WriteLine(Maclaurin(Sin(x), 10, x).Simplify()); Console.WriteLine("----------------------"); var expr = Sin(x) + Cos(y); Console.WriteLine(expr); Console.WriteLine(Maclaurin(expr, 6, x, y).Simplify()); Console.WriteLine("----------------------"); Console.WriteLine(expr); Console.WriteLine(Taylor(expr, 6, (x, 1))); Console.WriteLine("----------------------"); Console.WriteLine(expr); Console.WriteLine(Taylor(expr, 6, (x, 1), (y, 5))); Console.WriteLine("----------------------"); Console.WriteLine(expr); Console.WriteLine(Taylor(expr, 6, (x, "z_1", 1), (y, "z_2", 5))); Console.WriteLine("----------------------"); var first3Terms = TaylorTerms(expr, (x, x, 0), (y, y, 1)) .Take(3); var first6Terms = TaylorTerms(expr, (x, x, 0), (y, y, 1)) .Take(6); foreach (var term in first6Terms) Console.WriteLine($"Received {term}");
Prints
sin(x) 0 0 + x 0 + x + 0 0 + x + 0 + -x ^ 3 / 3! x ^ 9 / 362880 - x ^ 7 / 5040 + x ^ 5 / 120 - x ^ 3 / 6 + x ---------------------- sin(x) + cos(y) 1 + (6 * x ^ 5 - 120 * x ^ 3) / 720 + x + (2 * y ^ 4 - 24 * y ^ 2) / 48 ---------------------- sin(x) + cos(y) sin(1) + cos(y) + cos(1) * (x - 1) + -sin(1) * (x - 1) ^ 2 / 2! + cos(1) * (-1) * (x - 1) ^ 3 / 3! + -sin(1) * (-1) * (x - 1) ^ 4 / 4! + cos(1) * (-1) * (-1) * (x - 1) ^ 5 / 5! ---------------------- sin(x) + cos(y) sin(1) + cos(5) + cos(1) * (x - 1) + -sin(5) * (y - 5) + (-sin(1) * (x - 1) ^ 2 + cos(5) * (-1) * (y - 5) ^ 2) / 2! + (cos(1) * (-1) * (x - 1) ^ 3 + -sin(5) * (-1) * (y - 5) ^ 3) / 3! + (-sin(1) * (-1) * (x - 1) ^ 4 + cos(5) * (-1) * (-1) * (y - 5) ^ 4) / 4! + (cos(1) * (-1) * (-1) * (x - 1) ^ 5 + -sin(5) * (-1) * (-1) * (y - 5) ^ 5) / 5! ---------------------- sin(x) + cos(y) sin(1) + cos(5) + cos(1) * (z_1 - 1) + -sin(5) * (z_2 - 5) + (-sin(1) * (z_1 - 1) ^ 2 + cos(5) * (-1) * (z_2 - 5) ^ 2) / 2! + (cos(1) * (-1) * (z_1 - 1) ^ 3 + -sin(5) * (-1) * (z_2 - 5) ^ 3) / 3! + (-sin(1) * (-1) * (z_1 - 1) ^ 4 + cos(5) * (-1) * (-1) * (z_2 - 5) ^ 4) / 4! + (cos(1) * (-1) * (-1) * (z_1 - 1) ^ 5 + -sin(5) * (-1) * (-1) * (z_2 - 5) ^ 5) / 5! ---------------------- Received cos(1) Received x + -sin(1) * (y - 1) Received cos(1) * (-1) * (y - 1) ^ 2 / 2! Received (-x ^ 3 + -sin(1) * (-1) * (y - 1) ^ 3) / 3! Received cos(1) * (-1) * (-1) * (y - 1) ^ 4 / 4! Received (x ^ 5 + -sin(1) * (-1) * (-1) * (y - 1) ^ 5) / 5!
Taylor(AngouriMath.Entity,System.Int32,System.ValueTuple{AngouriMath.Entity.Variable,AngouriMath.Entity}[])
Summary
Finds the symbolic expression of terms of the Taylor expansion of the given function,
WikipediaParameter "expr"
The function to find the Taylor expansion of
Parameter "degree"
The degree of the resulting taylor polynomial
Parameter "exprVariables"
The variable/s to take the series over (and the variable in the resulting series),
plus the variable values at which the Taylor polynomial will be found
(e. g. if you want to find the taylor polynomial of Sin("t") around t=1, then you may want to use ("t","1") for this argument)
Returns
An expression in the polynomial form over the expression variable/s given inexprVariables Example
using AngouriMath; using System; using System.Linq; using static AngouriMath.MathS; using static AngouriMath.MathS.Series; var (x, y) = MathS.Var("x", "y"); Console.WriteLine(Sin(x)); Console.WriteLine(Maclaurin(Sin(x), 1, x)); Console.WriteLine(Maclaurin(Sin(x), 2, x)); Console.WriteLine(Maclaurin(Sin(x), 3, x)); Console.WriteLine(Maclaurin(Sin(x), 4, x)); Console.WriteLine(Maclaurin(Sin(x), 10, x).Simplify()); Console.WriteLine("----------------------"); var expr = Sin(x) + Cos(y); Console.WriteLine(expr); Console.WriteLine(Maclaurin(expr, 6, x, y).Simplify()); Console.WriteLine("----------------------"); Console.WriteLine(expr); Console.WriteLine(Taylor(expr, 6, (x, 1))); Console.WriteLine("----------------------"); Console.WriteLine(expr); Console.WriteLine(Taylor(expr, 6, (x, 1), (y, 5))); Console.WriteLine("----------------------"); Console.WriteLine(expr); Console.WriteLine(Taylor(expr, 6, (x, "z_1", 1), (y, "z_2", 5))); Console.WriteLine("----------------------"); var first3Terms = TaylorTerms(expr, (x, x, 0), (y, y, 1)) .Take(3); var first6Terms = TaylorTerms(expr, (x, x, 0), (y, y, 1)) .Take(6); foreach (var term in first6Terms) Console.WriteLine($"Received {term}");
Prints
sin(x) 0 0 + x 0 + x + 0 0 + x + 0 + -x ^ 3 / 3! x ^ 9 / 362880 - x ^ 7 / 5040 + x ^ 5 / 120 - x ^ 3 / 6 + x ---------------------- sin(x) + cos(y) 1 + (6 * x ^ 5 - 120 * x ^ 3) / 720 + x + (2 * y ^ 4 - 24 * y ^ 2) / 48 ---------------------- sin(x) + cos(y) sin(1) + cos(y) + cos(1) * (x - 1) + -sin(1) * (x - 1) ^ 2 / 2! + cos(1) * (-1) * (x - 1) ^ 3 / 3! + -sin(1) * (-1) * (x - 1) ^ 4 / 4! + cos(1) * (-1) * (-1) * (x - 1) ^ 5 / 5! ---------------------- sin(x) + cos(y) sin(1) + cos(5) + cos(1) * (x - 1) + -sin(5) * (y - 5) + (-sin(1) * (x - 1) ^ 2 + cos(5) * (-1) * (y - 5) ^ 2) / 2! + (cos(1) * (-1) * (x - 1) ^ 3 + -sin(5) * (-1) * (y - 5) ^ 3) / 3! + (-sin(1) * (-1) * (x - 1) ^ 4 + cos(5) * (-1) * (-1) * (y - 5) ^ 4) / 4! + (cos(1) * (-1) * (-1) * (x - 1) ^ 5 + -sin(5) * (-1) * (-1) * (y - 5) ^ 5) / 5! ---------------------- sin(x) + cos(y) sin(1) + cos(5) + cos(1) * (z_1 - 1) + -sin(5) * (z_2 - 5) + (-sin(1) * (z_1 - 1) ^ 2 + cos(5) * (-1) * (z_2 - 5) ^ 2) / 2! + (cos(1) * (-1) * (z_1 - 1) ^ 3 + -sin(5) * (-1) * (z_2 - 5) ^ 3) / 3! + (-sin(1) * (-1) * (z_1 - 1) ^ 4 + cos(5) * (-1) * (-1) * (z_2 - 5) ^ 4) / 4! + (cos(1) * (-1) * (-1) * (z_1 - 1) ^ 5 + -sin(5) * (-1) * (-1) * (z_2 - 5) ^ 5) / 5! ---------------------- Received cos(1) Received x + -sin(1) * (y - 1) Received cos(1) * (-1) * (y - 1) ^ 2 / 2! Received (-x ^ 3 + -sin(1) * (-1) * (y - 1) ^ 3) / 3! Received cos(1) * (-1) * (-1) * (y - 1) ^ 4 / 4! Received (x ^ 5 + -sin(1) * (-1) * (-1) * (y - 1) ^ 5) / 5!
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online