In: Statistics and Probability
A mathematician requires the calculation of the integral
y[n] = \int_0^1 x^n exp(-x) dx
where \int_0^1 means the integral with limits 0 and 1.
A) Using integration by parts, show that y[n] satisfies the
recursion y[n+1] = -1/e + (n+1) y[n]
B) Write a function that uses this recursion to calculate y[1:n] using R
@param n A postive integer
@return A vector of values y = c(y[1], ... , y[n])
Use this function to produce a vector y = c(y[1], ... , y[20]) in the object YInt
C) Recompute Yint using the pgamma and gamma functions in
R.
Note that gamma(n+1)=factorial(n).
A)
B)
C)
Interestingly for n>16, the recursive approach is giving the wrong results.