| Contents | Index |
taylor(f)
taylor(f,n)
taylor(f,a)
taylor(f,n,a)
taylor(f,n,v)
taylor(f,n,v,a)
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.
taylor determines the purpose of the arguments from their position and type. If a is not an integer, not a symbolic number, and not a number defined as a string, you can provide the arguments n, v, and a in any order. In this case, you also can omit any of these arguments. If you do not specify v, taylor uses symvar to determine the independent variable of f. The default values are n=6 and a=0.
If a is a positive integer, use taylor(f,n,a) instead of taylor(f,a) even if you use the default truncation order.
If a is a symbolic number or a number defined as a string, do not omit v.
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 |
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.
Taylor series expansion around x=0 is called Maclaurin series expansion:
![]()
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 how symbolic computations can help you find analytical solutions to math and engineering problems.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |