• f(x) = 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.
\(f(X) = 1 / (1-x)\)
\(sum_{n = 0}^{\infty} (f^(n)*(a)/n!)* (x - a)^n\)
f(X) = 1 / (1-x)
f’(x) = 1/(1-x)^2;
f“(x) = 2/(1-x)^3;
f’’’(x) = 6/(1-x)^4;
for x = 0,
f(0) = 1
f’(0) = 1
f“(0) = 2
f“’(0) = 6
Taylor Series expansion:
\(f(a)+f'(a) * (x−a)+(f''\div2!)* (x−a)+(f'''\div3!) * (x−a)+(f""(4)\div/4!) * (x−a)+...\)
\(= 1+x+(2\div2!)x^2+(6\div3!)x^3+(24\div4!)x^4+...\)
\(= 1 + x + x^2 + x^3 +x^4 +.......\)
library(pracma)
funct <- function(x) {1/(1-x)}
t <- taylor(funct,x0 = 0,n = 7)
t
## [1] 1.007014 1.001710 1.000293 1.000029 1.000003 1.000000 1.000000 1.000000
\(f(x) = e^x\)
f’(x) = e^x
f“(x) = e^x
f“’(x) = e^x
for x = 0
f(0) = 1
f’(0) = 1
f“(0) = 1
f“’(0) = 1
Substituting values in Taylor series :
\(f(a)+f′(a)* (x−a)+(f′′\div2!)* (x−a)+(f′′′\div3!) * (x−a)+(f""(4)\div/4!) * (x−a)+...\)
= \(f(0)+f′(0)* (x−0)+(f′′(0) \div2!)* (x−0)+(f′′′(0) \div3!) * (x−0)+(f""(0)\div/4!) * (x−0)+...\)
= $ 1 + x + (x^2)/2 + (x^3)/3 + (x^4)/ 4+…..$
funct1 <- function(x) {exp(x)}
t1 <- taylor(funct1,x0 = 0,n = 7)
t1
## [1] 0.0001961045 0.0013863458 0.0083342450 0.0416665728 0.1666667256
## [6] 0.4999999963 1.0000000000 1.0000000000
f(x) = log( 1 + x)
f’(x) = 1/(1 + x)
f“(x) = -1/(1 + x)^2
f“’(x) = 2/(1 + x)^3
f“”(x) = -6/(1 + x)^4
for x = 0
f(0) = 0
f’(0) = 1
f“(0) = -1
f“’(0) = 2
f“”(0) = -6
Substituting in Taylor series :The expression becomes
= $ f(0)+f′(0)* (x−0)+(f′′(0) 2!)* (x−0)+(f′′′(0) 3!) * (x−0)+(f“”(0)/4!) * (x−0)+…$
= $ x - ((x^2)2) + ((x^3)3) - ((x)^44) + …$
funct2 <- function(x) {log(1+x)}
t2 <- taylor(funct2,x0 = 0,n = 7)
t2
## [1] 0.1436357 -0.1668792 0.2000413 -0.2500044 0.3333339 -0.5000000
## [7] 1.0000000 0.0000000