ASSIGNMENT 14 - TAYLOR SERIES
This week, we’ll work out some Taylor Series expansions of popular functions.
• 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.
Soluiton: we will set c=0 and use the following equation.
knitr::include_graphics("881.png")
f(x) = 1 / (1−x)
We will find the value of the 5 derivatives of this function at 0.
#First Derivative
x<-0
f=expression(1/(1-x))
eval(f)
## [1] 1
f<-D(f,'x')
eval(f)
## [1] 1
#Second Derivative
f<-D(f,'x')
eval(f)
## [1] 2
#Third Derivative
f<-D(f,'x')
eval(f)
## [1] 6
#Forth Derivative
f<-D(f,'x')
eval(f)
## [1] 24
#Fifth Derivative
f<-D(f,'x')
eval(f)
## [1] 120
Simplifying this expression gives us:
1 + x + x^2 + x^3 + x^4 + x^5 + …
library(pracma)
## Warning: package 'pracma' was built under R version 3.5.2
x = function(x) {1 / (1-x) }
c = 0
taylor(x, c, 5)
## [1] 1.000293 1.000029 1.000003 1.000000 1.000000 1.000000
f(x) = e^x
We will find the value of the 5 derivatives of this function at 0.
#First Derivative
x<-0
f=expression(exp(x))
eval(f)
## [1] 1
f<-D(f,'x')
eval(f)
## [1] 1
#Second Derivative
f<-D(f,'x')
eval(f)
## [1] 1
#Third Derivative
f<-D(f,'x')
eval(f)
## [1] 1
#Forth Derivative
f<-D(f,'x')
eval(f)
## [1] 1
#Fifth Derivative
f<-D(f,'x')
eval(f)
## [1] 1
Simplifying this expression gives us:
1 + x + (x^2) / 2 + (x^3) / 6 + (x^4) / 24 + (x^5) / 120 + …
library(pracma)
x = function(x) {exp(x)}
c = 0
taylor(x, c, 5)
## [1] 0.008334245 0.041666573 0.166666726 0.499999996 1.000000000 1.000000000
f(x) = ln(1+x)
We will find the value of the 5 derivatives of this function at 0.
#First Derivative
x<-0
f=expression(log(1+x))
eval(f)
## [1] 0
f<-D(f,'x')
eval(f)
## [1] 1
#Second Derivative
f<-D(f,'x')
eval(f)
## [1] -1
#Third Derivative
f<-D(f,'x')
eval(f)
## [1] 2
#Forth Derivative
f<-D(f,'x')
eval(f)
## [1] -6
#Fifth Derivative
f<-D(f,'x')
eval(f)
## [1] 24
Simplifying this expression gives us:
x - (x^2) / 2 + (x^3) / 3 - (x^4) / 4 + (x^5) / 5 + …
library(pracma)
x = function(x) {log(1+x)}
c = 0
taylor(x, c, 5)
## [1] 0.2000413 -0.2500044 0.3333339 -0.5000000 1.0000000 0.0000000