Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this problem we will use recurrence relations to compute an integral and determine the relative and absolute error associated with each of them. As
In this problem we will use recurrence relations to compute an integral and determine the relative and absolute error associated with each of them. As an aside (not required) you should be able to verify both the recurrence relation on your own. Now, consider the integral 1 Is = mke dx xk er dx where Io = 1-1/e Evaluate the integrals In and store them in an array, 11, using the 'Forward Recurrence Relation' defined as follows: Ik = 1 kIk-1 V ke 1, 2, 3, ....., nmax We would now use a 'Backward Recurrence Relation' to determine the integrals. Assume that Ik = 0 for k = nmax. Using this and the recurrence relation provided below, evaluate the integrals and store them in an array named 12: Ix-1= (17) v k nmax,........., 1 Now let us evaluate the error associated with both the schemes. Calculate the exact integral using the provided function func_int which takes the input k and returns the integral Ik. Calculate the integral for all the k values in the array [1, 2, 3,..., nmax]. Calculate the absolute and relative errors associated with the forward recurrence relation and store them in arrays abserri and relerri respectively. Similarly calculate the absolute and relative errors associated with the backward recurrence relation and store them in arrays abserr2 and relerr2 respectively. Also provide one plot showing the relationship between k and the relative error arrays you get from both schema. Note: In both the calculations above, use the values generated by the function func_int to be the true values. Inputs: nmax: The upper bound of k value func_int: A function that takes an input k, and returns the exact integral Ik Outputs: 11: [11, 12, 13,..., Inmax] calculated using the forward recurrence relation 12: [11, 12, 13,..., Inmax] calculated using the backward recurrence relation abserri and relerri: Absolute and Relative error associated with the forward recurrence relation abserre and relerr2: Absolute and Relative error associated with the backward recurrence relation Plot: As described above with relevant title, labels etc. Note: please exclude Io in both 11 and 12 The setup code gives the following variables: Name nmax Type int function Description The upper bound of k value A function that takes an input k, and returns the exact integral Ik func_int In this problem we will use recurrence relations to compute an integral and determine the relative and absolute error associated with each of them. As an aside (not required) you should be able to verify both the recurrence relation on your own. Now, consider the integral 1 Is = mke dx xk er dx where Io = 1-1/e Evaluate the integrals In and store them in an array, 11, using the 'Forward Recurrence Relation' defined as follows: Ik = 1 kIk-1 V ke 1, 2, 3, ....., nmax We would now use a 'Backward Recurrence Relation' to determine the integrals. Assume that Ik = 0 for k = nmax. Using this and the recurrence relation provided below, evaluate the integrals and store them in an array named 12: Ix-1= (17) v k nmax,........., 1 Now let us evaluate the error associated with both the schemes. Calculate the exact integral using the provided function func_int which takes the input k and returns the integral Ik. Calculate the integral for all the k values in the array [1, 2, 3,..., nmax]. Calculate the absolute and relative errors associated with the forward recurrence relation and store them in arrays abserri and relerri respectively. Similarly calculate the absolute and relative errors associated with the backward recurrence relation and store them in arrays abserr2 and relerr2 respectively. Also provide one plot showing the relationship between k and the relative error arrays you get from both schema. Note: In both the calculations above, use the values generated by the function func_int to be the true values. Inputs: nmax: The upper bound of k value func_int: A function that takes an input k, and returns the exact integral Ik Outputs: 11: [11, 12, 13,..., Inmax] calculated using the forward recurrence relation 12: [11, 12, 13,..., Inmax] calculated using the backward recurrence relation abserri and relerri: Absolute and Relative error associated with the forward recurrence relation abserre and relerr2: Absolute and Relative error associated with the backward recurrence relation Plot: As described above with relevant title, labels etc. Note: please exclude Io in both 11 and 12 The setup code gives the following variables: Name nmax Type int function Description The upper bound of k value A function that takes an input k, and returns the exact integral Ik func_int
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started