Question Ex8.8 Q11

find a formula for the \(n^{th}\) term of the Taylor series of \(f(x)\), centered at c, by finding the coefficients of the first few powers of x and looking for a pattern.

Solution

\[ \begin{aligned} f(x) &= \frac{x}{x+1}; \: \text{centered at } c = 1 \end{aligned} \]

Taylor Series Formula: \[ \begin{aligned} f(x) &= \sum_{n = 0}^{\infty}\frac{f^{(n)}(a)}{n!}(x-a)^n \end{aligned} \]

The Taylor Series around a = 1; \[ \begin{aligned} f(x) = \frac{x}{x+1} &= x(x+1)^{-1}, \:\text{evaluated at } x = 1 \rightarrow \frac{1}{2} \\ \text{First derivative},\: f'(x) &= (x+1)^{-1} - x(x+1)^{-2}, \:\text{evaluated at } x = 1 \rightarrow \frac{1}{4} \\ \text{Second derivative},\: f''(x) &= -1(x+1)^{-2} - (x+1)^{-2} + 2x(x+1)^{-3}, \:\text{evaluated at } x = 1 \rightarrow \frac{-1}{4} \\ \text{Third derivative},\: f'''(x) &= 2(x+1)^{-3} + 2(x+1)^{-3} + 2(x+1)^{-3} - 6x(x+1)^{-4}, \:\text{evaluated at } x = 1 \rightarrow \frac{3}{8} \\ \text{Fourth derivative},\: f^{4}(x) &= -6(x+1)^{-4} - 6(x+1)^{-4} - 6(x+1)^{-4} - 6(x+1)^{-4} + 24x(x+1)^{-5}, \:\text{evaluated at } x = 1 \rightarrow \frac{-3}{4} \\ \end{aligned} \]

Therefore, the full expansion of \(\frac{x}{1+x}\) as a Taylor series around a = 1; \[ \begin{aligned} f(x) &= f(1) + f'(1)(x-1) + \frac{f''(1)}{2!}(x-1)^{2} + \frac{f'''(1)}{3!}(x-1)^{3} + \frac{f^{4}(1)}{4!}(x-1)^{4} + ... \\ &= \frac{1}{2} + \frac{1}{4}(x-1) - \frac{1}{4}\frac{(x-1)^2}{2} + \frac{3}{8}\frac{(x-1)^3}{6} - \frac{3}{4}\frac{(x-1)^4}{24} + ... \\ &= \frac{1}{2} + \frac{1}{4}(x-1) - \frac{1}{8}(x-1)^2 + \frac{1}{16}(x-1)^3 - \frac{1}{32}(x-1)^4 + ... \\ &= \frac{1}{2} + \sum_{n=1}^{\infty}(-1)^{n-1}\frac{1}{2^{n+1}}(x-1)^n \end{aligned} \]

Using R

library(pracma)
library(Deriv)

Define function

f <- function(x)
  x/(x+1)

Taylor expansion

f_taylor_expansion_1 <- taylor(f, x0 = 1, n = 1) #first derivative evaluated at 1, divided by 1!
f_taylor_expansion_2 <- taylor(f, x0 = 1, n = 2) #Second derivative evaluated at 1, divided by 2!
f_taylor_expansion_3 <- taylor(f, x0 = 1, n = 3) #Third derivative evaluated at 1, divided by 3!
f_taylor_expansion_4 <- taylor(f, x0 = 1, n = 4) #Fourth derivative evaluated at 1, divided by 4!
print(f_taylor_expansion_1[2])
## [1] 0.25
print(f_taylor_expansion_2[3])
## [1] 0.125
print(f_taylor_expansion_3[4])
## [1] 0.06249997
print(f_taylor_expansion_4[5])
## [1] 0.03124947

Derivative

df1 <- Deriv(f,'x') ## first derivative
print(df1(1))
## [1] 0.25
df2 <- Deriv(df1, 'x') # second derivative
print(df2(1))
## [1] -0.25
df3 <- Deriv(df2, 'x') # third derivative
print(df3(1))
## [1] 0.375
df4 <- Deriv(df3, 'x') # fourth derivative
print(df4(1))
## [1] -0.75