Skip to Main Content Skip to Search
Product Documentation

taylor - Taylor series expansion

Syntax

taylor(f)
taylor(f,n)
taylor(f,a)
taylor(f,n,a)
taylor(f,n,v)
taylor(f,n,v,a)

Description

taylor(f) computes the Taylor series expansion of f up to the fifth order. The expansion point is 0.

taylor(f,n) computes the Taylor series expansion of f up to the (n-1)-order. The expansion point is 0.

taylor(f,a) computes the Taylor series expansion of f up to the fifth order around the expansion point a.

taylor(f,n,a) computes the Taylor series expansion of f up to the (n-1)-order around the expansion point a.

taylor(f,n,v) computes the Taylor series expansion of f up to the (n-1)-order with respect to variable v. The expansion point is 0.

taylor(f,n,v,a) computes the Taylor series expansion of f with respect to v around the expansion point a.

Tips

Input Arguments

f

A symbolic expression

n

A positive integer specifying the truncation order

Default: 6

v

A string or symbolic variable with respect to which you want to compute the Taylor series expansion

Default: A symbolic variable of f determined by symvar.

a

A real number (including infinities, symbolic numbers, and numbers defined as strings) specifying the expansion point.

Default: 0

Definitions

Taylor Series Expansion

Taylor series expansion represents an analytic function f(x) as an infinite sum of terms around the expansion point x=a:

Taylor series expansion requires a function to have derivatives up to infinite order around the expansion point.

Maclaurin Series Expansion

Taylor series expansion around x=0 is called Maclaurin series expansion:

Examples

Compute the Maclaurin series expansion for this function:

syms x;
f = sin(x)/x;
t = taylor(f)

The default truncation order is 6. Taylor series approximation of this function does not have a fifth-degree term, so taylor approximates this function with the forth-degree polynomial:

t =
x^4/120 - x^2/6 + 1

Plot the original function f and its approximation t:

ezplot(f, [-3, 3]);
hold on;
plotT = ezplot(t, [-3, 3]);
set(plotT,'Color','red');
legend('sin(x)/x','approximation of sin(x)/x',...
'Location', 'South');
title('Taylor Series Expansion')
hold off

 

Compute the Maclaurin series expansions of these functions up to the order 7. The truncation order is 8:

syms x;
taylor(exp(x), 8)
taylor(sin(x), 8)
taylor(cos(x), 8)
ans =
x^7/5040 + x^6/720 + x^5/120 +...
x^4/24 + x^3/6 + x^2/2 + x + 1
 
ans =
- x^7/5040 + x^5/120 - x^3/6 + x
 
ans =
- x^6/720 + x^4/24 - x^2/2 + 1
 

Compute the Taylor series expansions around x = 1 for these functions. Since the expansion point is an integer, also specify the truncation order, even if it is the default order 6:

syms x;
taylor(log(x), 6, 1)
taylor(acot(x), 6, 1)
ans =
x - (x - 1)^2/2 + (x - 1)^3/3 - (x - 1)^4/4 + (x - 1)^5/5 - 1
 
ans =
pi/4 - x/2 + (x - 1)^2/4 - (x - 1)^3/12 + (x - 1)^5/40 + 1/2

See Also

symvar | taylortool

How To

  


Free Symbolic Math Interactive Kit

See how symbolic computations can help you find analytical solutions to math and engineering problems.

Get free kit

Trials Available

Try the latest version of symbolic math products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS