Question: In Python: Consider the gamma function(a), which is defined by the integral 0 There is no closed form expression for this integral, so we have

In Python:In Python: Consider the gamma function(a), which is defined by the integral

Consider the gamma function(a), which is defined by the integral 0 There is no closed form expression for this integral, so we have to evluate it numerically Before we calculate the integral, we have to make two transformations to the integrand. First, to map the infinite range onto a finite one, in a way that places the peak of the function at the middle of the interval, we can use the transformation or equivalently dz x=(a-1) 2 Second, to avoid multiplying very large numbers by very small numbers in the integrand, it is also convenient to write it as a single exponential a) Using these two transformations, rewrite the integrand as a well-behaved function of z on the interval 0 to 1 Then write Python code to evaluate I(a) by integrating this function, using any method you have seen (i.e. a Riemann sum, the trapzoid rule, or Simpson's rule but not another method or prepackaged function). Use enough subintervals to get a relative accuracy of10 b) Evaluate rai) forai = 0.01, 0.11, 021 , 1.01 , and save the results in an array Use these values to implement a lookup table, a Python function that for a given value anew on the interval [0.1, 1.1], estimates the value of anew by linear interpolation on the aj To do this, you will have to find two values ai, ai+1 that bracket anew Then you can use the linear interpolation formula from slides 6-7 of module 13 (aHi - anew (a-i -a) (anew - ai) (ati -ai) (anew)~ T(a)+ (4m ) c) Estimate the accuracy of your lookup table, relative to the full integration, by comparing0.15) estimated from the lookup table to your code from part a) 5 calculated by Consider the gamma function(a), which is defined by the integral 0 There is no closed form expression for this integral, so we have to evluate it numerically Before we calculate the integral, we have to make two transformations to the integrand. First, to map the infinite range onto a finite one, in a way that places the peak of the function at the middle of the interval, we can use the transformation or equivalently dz x=(a-1) 2 Second, to avoid multiplying very large numbers by very small numbers in the integrand, it is also convenient to write it as a single exponential a) Using these two transformations, rewrite the integrand as a well-behaved function of z on the interval 0 to 1 Then write Python code to evaluate I(a) by integrating this function, using any method you have seen (i.e. a Riemann sum, the trapzoid rule, or Simpson's rule but not another method or prepackaged function). Use enough subintervals to get a relative accuracy of10 b) Evaluate rai) forai = 0.01, 0.11, 021 , 1.01 , and save the results in an array Use these values to implement a lookup table, a Python function that for a given value anew on the interval [0.1, 1.1], estimates the value of anew by linear interpolation on the aj To do this, you will have to find two values ai, ai+1 that bracket anew Then you can use the linear interpolation formula from slides 6-7 of module 13 (aHi - anew (a-i -a) (anew - ai) (ati -ai) (anew)~ T(a)+ (4m ) c) Estimate the accuracy of your lookup table, relative to the full integration, by comparing0.15) estimated from the lookup table to your code from part a) 5 calculated by

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!