1. Overview

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) \\ f(x)=x^{1/2} \] 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 an R- Markdown document.

2. Solution

2. 1 f(x) = 1/(1−x)

Let f(x) have derivatives of all orders at x = c. The Taylor Series of f(x), centered at c is \[\sum_{n=0}^\infty \frac{f^{(n)}(c)}{n!}(x − c)^n\] We will start with finding the derivatives: \[f(c)=\frac{1}{(1−c)} \\ f'(c)=\frac{1}{(1−c)^2} \\ f''(c)=\frac{2}{(1−c)^3} \\ f'''(c)=\frac{6}{(1−c)^4} \\ f''''(c)=\frac{24}{(1−c)^5} \\\] Taylor Series of f(x): \[ \frac{1}{(1−x)}= \frac{1}{(1−c)0!}(x − c)^0 + \frac{1}{(1−c)^21!}(x − c)^1 + \frac{2}{(1−c)^32!}(x − c)^2 + \frac{6}{(1−c)^43!}(x − c)^3 + \frac{24}{(1−c)^4!}(x − c)^4 + ... = \\ =\sum_{n=0}^\infty \frac{1}{(1-c)^{n+1}}(x − c)^n\] Taylor Series Expansion (Maclaurin Series) is defined by setting the c=0: \[f(x)=1 + x + x^2 + x^3 +x^4 + ... = \sum_{n=0}^\infty x^n\] Ratio test: \[\lim_{n->\infty}\frac{a^{n+1}}{a^n} = \lim_{n->\infty} \frac{|x^{n+1}|}{|x^n|}=|x|\] To make it converge, limit of |x| should be less than 1, so x should be less than 1 and greater than -1. As a result, the series will converges in the range of (−1,1).
Using R, we can define numeric coefficients which are all 1:

func <- function(x) {1/(1-x)}
taylor(func, x0 = 0, n = 4)
## [1] 1.000029 1.000003 1.000000 1.000000 1.000000

2.2 f(x) = e^x

Derivatives: \[f(c)=e^c \\ f'(c)=e^c \\ f''(c)=e^c\\ f'''(c)=e^c\] Taylor Series of f(x): \[f(x)= \frac{e^c}{0!}(x − c)^0 + \frac{e^c}{1!}(x − c)^1 + \frac{e^c}{2!}(x − c)^2 + \frac{e^c}{3!}(x − c)^3 + ... = e^c\sum_{n=0}^\infty \frac{1}{n!}(x − c)^n\] Taylor Series Expansion (Maclaurin Series) is defined by setting the c=0: \[e^x= 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + ... = \sum_{n=0}^\infty \frac{x^n}{n!}\] Ratio test: \[\lim_{n->\infty}\frac{a^{n+1}}{a^n} = \lim_{n->\infty} \frac{|x^{n+1}|n!}{|x^n|(n+1)!}=\lim_{n->\infty}\frac{|x|}{n+1}=0\] The limit is always less than 0, the radius of convergence of the set of all real numbers.
Using R, we can define numeric coefficients which are 1,1,0.5 and 1/6. The same as above:

func <- function(x) {exp(x)}
taylor(func, x0 = 0, n = 3)
## [1] 0.1666667 0.5000000 1.0000000 1.0000000

2.3 f (x) = ln(1 + x)

Derivatives: \[f(c)=ln(1 + c) \\ f'(c)=\frac{1}{1+c} \\ f''(c)=-\frac{1}{(1+c)^2} \\ f'''(c)=\frac{2}{(1+c)^3} \\ f''''(c)=-\frac{6}{(1+c)^4} \]

Taylor Series of f(x): \[ ln(1 + x) = \frac{ln(1 + c)}{0!}(x − c)^0 + \frac{1}{(1+c)\cdot1!}(x − c)^1 - \frac{1}{(1+c)^2 2!}(x − c)^2 + \frac{2}{(1+c)^3 3!}(x − c)^3- \frac{6}{(1+c)^4 4!}(x − c)^4 + ... =\\ = ln(1 + c) + \sum_{n=1}^\infty (-1)^{n+1}\frac{1}{n(1+c)^{n}}(x − c)^n\]

Taylor Series Expansion (Maclaurin Series) is defined by setting the c=0: \[ln(1 + x) = 0 + x - \frac{x^2}{2} + \frac{x^3}{3} - \frac{x^4}{4} + ... = \sum_{n=1}^\infty (-1)^{n+1}\frac{x^n}{n}\] Ratio test: \[\lim_{n->\infty}\frac{a^{n+1}}{a^n} = \lim_{n->\infty} \frac{(-1)^{n+2}|x^{n+1}|n}{|(-1)^{n+1}x^n|(n+1)}=\lim_{n->\infty}-\frac{|x|n}{n+1}=|x|\] To make it converge, limit of |x| should be less than 1, so x should be less than 1 and greater than -1. As a result, the series will converges in the range of (−1,1).
Using R, we can define numeric coefficients which are 0, 1, -0.5 1/3, -1/4. The same as above:

func <- function(x) {log(1+x)}
taylor(func, x0 = 0, n = 4)
## [1] -0.2500044  0.3333339 -0.5000000  1.0000000  0.0000000

2.4 f(x)=x^{1/2}

Derivatives: \[f(c)=c^{1/2} \\ f'(c)=\frac{1}{2c^{1/2}} \\ f''(c)=-\frac{1}{4c^{3/2}} \\ f'''(c)=\frac{3}{8c^{5/2}} \\ f''''(c)=-\frac{15}{16c^{7/2}} \]

The derivatives are not defined at c=0. The Taylor series doesn’t exist at c=0.