CUNY MSDS DATA 605 HW14
library(pracma)
This week, we’ll work out some Taylor Series expansions of popular functions.
1.\[f(x) = 1/(1-x)\]
\(f'(x) = 1/(1-x)^2\)
\(f''(x) = f'(f'(x)) = f'(1/(1-x)^2) = 2/(1-x)^3\)
\(f'''(x) = f'(f''(x)) = 6/(1-x)^4\)
\(f''''(x) = f'(f'''(x)) = 6*4/(1-x)^5\)
The series is bounded by \(x[-1,1]\)
q1 <- function(x){
1/(1-x)
}
taylor(q1, 0, 6)
## [1] 1.001710 1.000293 1.000029 1.000003 1.000000 1.000000 1.000000
2.\[f(x) = e^x\]
Regardless of how many derivates of \(e^x\) it’ll always be \(e^x\)
\(f(x) = e^x\)
\(f(c) = e^c\)
\(f'(c) = e^c\)
\(f''(c) = e^c\)
q2<- function(x){
exp(x)
}
taylor(q2, 0, 4)
## [1] 0.04166657 0.16666673 0.50000000 1.00000000 1.00000000
3.\[f(x) = ln(1 + x)\]
q3 <- function(x){
log(1+x)
}
taylor(q3, 0, 4)
## [1] -0.2500044 0.3333339 -0.5000000 1.0000000 0.0000000