Discussion 14

Question: Key Idea 32 gives the nth term of the Taylor series of common func ons. In Exercises 3 – 6, verify the formula given in the Key Idea by finding the first few terms of the Taylor series of the given function and identifying a pattern.

3. f(x) = ex; c = 0

library(pracma)
x = function(x) {exp(x)}
c = 0
n = 8
taylor(x, c, n)
## [1] 2.505533e-05 1.961045e-04 1.386346e-03 8.334245e-03 4.166657e-02
## [6] 1.666667e-01 5.000000e-01 1.000000e+00 1.000000e+00

4) f(x) = sin x; c = 0

x = function(x) {sin(x)}
c = 0
n = 8
taylor(x, c, n)
## [1] -0.0001983869  0.0000000000  0.0083332754  0.0000000000 -0.1666666439
## [6]  0.0000000000  1.0000000000  0.0000000000

5) f(x) = 1/(1 - x); c = 0

x = function(x) {1/(1-x)}
c = 0
n = 8
taylor(x, c, n)
## [1] 1.022551 1.007014 1.001710 1.000293 1.000029 1.000003 1.000000 1.000000
## [9] 1.000000

6) f(x) = tan-1 x; c = 0

x = function(x) {atan(x)}
c = 0
n = 8
taylor(x, c, n)
## [1] -0.1420852  0.0000000  0.1999579  0.0000000 -0.3333328  0.0000000
## [7]  1.0000000  0.0000000