This week, we’ll work out some Taylor Series expansions of popular functions.

f(x) =\(\frac{1}{(1−x)}\) f(x) = \(e^x\) f(x) = ln(1 + x)

For each function, only consider its valid ranges as indicated in the notes when you are computing the Taylor Series expansion. Please submit your assignment as a R-Markdown document.

1 \(f(x) =\frac{1}{(1−x)}\)

\(f(x) = f(k) + f'(k)(x-k) + \frac{f''(k)}{2!} + \frac{f'''(k)}{3!}+...\frac{f^n(k)}{n!}\) \(= \sum_{n=0}^{\infty}\frac{f^{(n)}(k)}{n!}x^n\)

When centered at 0 this becomes a McLaurin series of \(1+x^2+x^3....x^n\) With convergence happening at x \(\in\){-1,1}

library(pracma)

f <- function(x) (1/(1-x))
p <- taylor(f, 0, 3)

x <- seq(-1.0, 1.0, .01)
y <- f(x)
pp <- polyval(p, x)
plot(x, y, type = "l", main =' Taylor Series Approximation of 1/(1-x)',col = "blue", lwd = 2)
lines(x, pp, col = "red")

2 \(f(x) = e^x\)

All derivatives of \(e^x\) is \(e^x\). So, \(f^n(x)=e^x\), centered at 0, \(f^n(0)=e^0=1\)

\(f(x) = 1+ \frac{1}{1!}x^1 + \frac{1}{2!}x^2 + \frac{1}{3!}x^3 +...\frac{1}{n!}x^n\) \(= \sum_{n=0}^{\infty}\frac{x^n}{n!}\) \(x \in (-1, 1]\)

f <- function(x) (exp(1)^x)
p <- taylor(f, 0, 3)

x <- seq(-1.0, 1.0, .01)
y <- f(x)
pp <- polyval(p, x)
plot(x, y, type = "l", main =' Taylor Series Approximation of e^x',col = "blue", lwd = 2)
lines(x, pp, col = "red")

## 3 \(f(x) = ln(1 + x)\) \(f'(x) =\frac{1}{(1+x)}\) \(f''(x) =-\frac{1}{(1+x)^2}\) \(f'''(x) =\frac{2}{(1+x)^3}\) \(f'''(x) =-\frac{6}{(1+x)^4}\) \(= \sum_{n=0}^{\infty} \frac {(-1)^{n}} {n+1} {x^{n+1}}\) \(= \frac {x} {1} - \frac {x^2} {2} +\frac {x^3} {3} - \frac {x^4} {4}.+.-.+.-. \frac {x^n} {n}\)

f <- function(x) log(1+x)
p <- taylor(f, 0, 3)

x <- seq(-1.0, 1.0, .01)
y <- f(x)
pp <- polyval(p, x)
plot(x, y, type = "l", main =' Taylor Series Approximation of log(1+x)',col = "blue", lwd = 2)
lines(x, pp, col = "red")