taylor
Taylor series expansion of a symbolic expression about a point.
Category: Mathematics > Calculus
Syntax
T = taylor(f, x)
Expands f in powers of x about 0, keeping terms below degree 6.
T = taylor(f, x, a)
Expands about the point a.
T = taylor(___, Name, Value)
Sets 'Order' or 'ExpansionPoint' by name.
Description
taylor builds the truncated series f(a) + f'(a)(x-a) + f''(a)(x-a)^2/2! + ... by differentiating f symbolically and evaluating the derivatives at the expansion point. The remainder term is not returned.
The Order option counts terms, not the degree of the last term, so 'Order', 4 stops at the cubic term.
Input arguments
f- Symbolic expression or symbolic function.
x- Symbolic variable to expand in.
'Order'- Number of terms: the result has degree at most
Order - 1. Default 6. 'ExpansionPoint'- Point
athe series is centered on. Default 0.
Output arguments
T- Symbolic polynomial in
x(or inx - a).
Example
Maclaurin and shifted series
syms x
taylor(exp(x), x, 'Order', 4)
taylor(cos(x), x, 'ExpansionPoint', 1, 'Order', 3)
Output
ans = x^3/6 + x^2/2 + x + 1
ans = cos(1) - (x - 1)*sin(1) - ((x - 1)^2*cos(1))/2