Page 262 - Numerical Analysis Using MATLAB and Excel
P. 262
Taylor and Maclaurin Series
′
From math tables, d tan x = sec 2 x , so f x() = sec 2 x . To find f'' x() we need to find the first
d x
d
⋅
derivative of sec 2 x , so we let z = sec 2 x . Then, using ------ sec x = sec x tan x , we get
dx
dz d 2
⋅
)
(
x
------ = 2sec ------ sec x = 2sec x sec x tan x = 2sec x tan⋅ x (6.126)
dx dx
Next, using the trigonometric identity
2 2
sec x = tan x + 1 (6.127)
and by substitution of (6.127) into (6.126), we get,
dz
)
------ = f'' x() = 2 tan( 2 x + 1 tan x (6.128)
dx
⁄
Now, at point a = π 4 we have:
π
π
π
2
⎛
⎛
⎛
)
(
---
fa()= f --- ⎞ = tan ⎛ ⎝ π ⎞ = 1 f' a()= f' --- ⎞ = 1 + 1 = 2 f'' a()= f'' --- ⎞ = 21 + 1 1 = 4 (6.129)
4 ⎠
⎝
4 ⎠
⎝
4 ⎠
⎝
4 ⎠
and by substitution into (6.125),
⎛
⎛
-
f x() = 1 + 2 x – π ⎞ -- + 2x – π ⎞ -- - ⎠ 2 + … (6.130)
⎝
⎠
⎝
n
4
4
We can also obtain a Taylor series expansion with the MATLAB taylor(f,n,a) function where f
is a symbolic expression, n produces the first terms in the series, and a defines the Taylor
n
approximation about point . A detailed description can be displayed with the help taylor com-
a
mand. For example, the following MATLAB script computes the first 8 terms of the Taylor series
expansion of y = f x() = tan x about a = π . 4 ⁄
x=sym('x'); y=tan(x); z=taylor(y,8,pi/4); pretty(z)
2 3 4
1 + 2x - 1/2 pi + 2(x - 1/4 pi) + 8/3(x - 1/4 pi) + 10/3(x - 1/4 pi)
64 5 244 6 2176 7
+ -- (x - 1/4 pi) + --- (x - 1/4 pi) + ---- (x - 1/4 pi)
15 45 315
Numerical Analysis Using MATLAB® and Excel®, Third Edition 6−45
Copyright © Orchard Publications