Consider the following integral:
x * sin(x) * x
Write a Python program to evaluate this integral using Simpson's 1/3 rule. Input the lower and upper limits and the first "n" from the keyboard. Put the 1/3 rule and the integrand in separate functions. Note: you will need to include logic to account for the alternating 4's and 2's. Use two for loops or alternate the factors 4 and 2. In the main program, first check your input to see that the input value of "n" is even. If not, print a warning and leave the program.
Begin with n = 4. Compute the relative error, Ea, as the difference between the present result and the previous result. (For n = 4, the previous value is zero.) Put the call to Simpson inside a while loop and double "n" each time until you get an Ea value less than 10^(-5) in magnitude or you have made 15 attempts.
Print to the output file and from the main program. Print "n", your answer, and Ea for each value of "n" within the while loop. Compare your value to the hand solution.