Data 605 Discussion #14

Calculus section 8.8, question 26

Heather Geiger

Question

In these exercises, use the Taylor series given in Key Idea 32 to create the Taylor series of the given functions.

f(x) = e^-x

Answer

We find in key idea 32 the following.

When f(x) = e^x, the Taylor series is the sum from 0 to infinity of x^n/n!.

Building on this, we also find that when f(x) = e^-x, the Taylor series is the sum from 0 to infinity of (-x)^n/n!.

Let’s prove this by looking at n going up to 100, which should be enough to see convergence. Along with a number of x values both integer and fractional, positive and negative.

factorial <- function(n){
result = 1
for(i in 1:n){result = result *i}
return(result)
}

myfunc <- function(x,n){
denom = factorial(n)
numer = (-x)^n
return(numer/denom)
}

x_values_to_test = c(-5:-1,-0.99,-0.5,0,0.5,0.99,1:5)

value_converged_to_per_x = c()

par(mfrow=c(3,2))

for(x in x_values_to_test[1:6])
{
myresults = rep(NA,times=100)
for(i in 1:100){myresults[i] = myfunc(x,i)}
plot(0:100,cumsum(c(1,myresults)),xlab="n",ylab="Cumsum",main=paste0("x=",x))
value_converged_to_per_x = c(value_converged_to_per_x,cumsum(c(1,myresults))[101])
}

par(mfrow=c(1,3))

for(x in x_values_to_test[7:9])
{
myresults = rep(NA,times=100)
for(i in 1:100){myresults[i] = myfunc(x,i)}
plot(0:100,cumsum(c(1,myresults)),xlab="n",ylab="Cumsum",main=paste0("x=",x))
value_converged_to_per_x = c(value_converged_to_per_x,cumsum(c(1,myresults))[101])
}

par(mfrow=c(3,2))

for(x in x_values_to_test[10:15])
{
myresults = rep(NA,times=100)
for(i in 1:100){myresults[i] = myfunc(x,i)}
plot(0:100,cumsum(c(1,myresults)),xlab="n",ylab="Cumsum",main=paste0("x=",x))
value_converged_to_per_x = c(value_converged_to_per_x,cumsum(c(1,myresults))[101])
}

value_converged_to_per_x
##  [1] 1.484132e+02 5.459815e+01 2.008554e+01 7.389056e+00 2.718282e+00
##  [6] 2.691234e+00 1.648721e+00 1.000000e+00 6.065307e-01 3.715767e-01
## [11] 3.678794e-01 1.353353e-01 4.978707e-02 1.831564e-02 6.737947e-03
exp(-1*x_values_to_test)
##  [1] 1.484132e+02 5.459815e+01 2.008554e+01 7.389056e+00 2.718282e+00
##  [6] 2.691234e+00 1.648721e+00 1.000000e+00 6.065307e-01 3.715767e-01
## [11] 3.678794e-01 1.353353e-01 4.978707e-02 1.831564e-02 6.737947e-03

First of all, we find that the sum of n = 0 to infinity for (-x)^n/n! appears to converge to a finite value for a number of x values both fractional and integer, both positive and negative. This suggests that similar to for x^n/n!, the sum of n = 0 to infinity converges to a finite value for an unlimited range of x values (-infinity to +infinity).

Second of all, we find that the sum of n = 0 to infinity for (-x)^n/n! converges to e^-x for a number of x values within the range (-infinity to +infinity).