Discussion 15

Subhalaxmi Rout

2020-11-27

Gives the nth term of the Taylor series of common functions. 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.

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

Solution

Formula for a Taylor Series Expansion:

\[f(x) = \sum_{n=0} ^ {\infty} \frac {f^{(n)}(a)}{n!} (x - a) ^ {n}\]

\[f(x)= f(a) + f'(a)(x-a) + \frac {f''(a)}{2!}(x-a)^2 + \frac {f'''(a)}{3!}(x-a)^3 + \frac {f''''(a)}{4!}(x-a)^4 + ........\]

Given function:

\[f(x) = sin x, f(0) = sin 0 = 0\] \[f'(x) = cos x, f'(0) = cos 0 = 1\] \[f''(x) = -sin x, f''(0) = -sin 0 = 0\] \[f'''(x) = -cos x, f'''(0) = -cos 0 = -1\] \[f''''(x) = sin x, f''''(0) = sin 0 = 0\] \[........\]

Substitute expressions into Taylor Series expansion:

\[f(x) = f(0) + f'(0)(x - 0) + \frac {f''(0)}{2!}(x - 0)^2 + \frac {f'''(0)}{3!}(x-0)^3 + \frac {f''''(0)}{4!}(x-0)^4 + ........\] \[f(x) = 0 + 1x + \frac {0}{2!} x^2 + \frac {-1}{3!}x^3 + \frac {0}{4!}x^4 + ......\] \[f(x) = x - \frac {x^3}{3!} + \frac {x^5} {5!} -.......\] \[f(x) = \sum_{n = 0} ^ {\infty} (-1) ^ n \frac {x ^ {(2n+1)}}{(2n+1)!}\] Using R:

library(pracma)
myfun <- function(x)
  {
  sin(x)
}
taylor(myfun, 0)
## [1] -0.1666666  0.0000000  1.0000000  0.0000000