Code and test an adaptive two-point Gaussian integration procedure to approximate the integral
Write three procedures using double precision:
a. Two-point Gauss
procedure Gauss ( f, a, b)
b. Nonrecursive two-point Gauss that initializes variables sum and depth to zero and calls the procedure in c
procedure Adaptive Initial ( f, a, b)
c. Recursive two-point Gauss
recursive procedure Adaptive ( f , sum , a , b , depth )
that checks to see whether the maximum depth is exceeded; if so, it prints an error message and stops; if not, it continues by dividing the interval [a, b] in half and calling procedure Gauss on the left subinterval, the right subinterval, and the whole interval, then checking to see whether the tolerance test is accepted; if it is, it adds the approximate value over the whole interval to the variable sum; otherwise it calls recursive procedure Adaptive on the left and right subintervals in addition to increasing the value of the depth variable. The tolerance test checks to see if the difference in absolute value between the approximate value over the whole interval and the sum of the approximate values over the left subinterval and right subinterval is less than the variable tolerance.
Print out the contribution of each subinterval and the depth at which the approximate value over the subinterval is accepted. Use a maximum depth of 100 subintervals, and stop subdividing subintervals when the tolerance is less than 10−7.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.