AngouriMath

Navigation

← Back to list of members

Maclaurin​(AngouriMath.​Entity,​System.​Int32,​AngouriMath.​Entity.​Variable[])

 Method (no overloads)

Summary

Finds the symbolic expression of terms of the Maclaurin expansion of the given function,
Wikipedia

Parameter "expr"

The function to find the Maclaurin expansion of

Parameter "degree"

The degree of the resulting Maclaurin polynomial (and the variable in the resulting series)

Parameter "exprVariables"

The variable/s to take the series over (and the variable the series will be over)
(e. g. if you have expr = Sin("t"), then you may want to use "t" for this argument)

Returns

An expression in the polynomial form over the expression variables given in exprVariables

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