Physics 503: Scientific Computing Homework #5 Topic:Numeric Integration Due:Thurs. Mar. 4 by the beginning of class (please email your code to [email protected]) Assignment 1.Evaluate the definite integral xsin(x)dx=π0π∫using both the trapezoid and Simpson’s 1/3 methods for a range of panels (say between 10 and 100). Plot the |error| for each method as a function of the number of panels (might want a log-log plot for this). 2.Use the polyfit() function in pylab to fit the errors for each of the above methods to a power law function. Discuss the different powers of number of panels each method seems to follow. HINT: remember you can linearize a power law by taking the log of both sides of the equation, then fit the log of the data to a line -> the slope will then be the exponent. 3.Apply the Richardson extrapolation method to the trapezoid function to improve the accuracy. Compare errors for with and without Richardson for an integral of your choice for a few different values for the number of panels. Use h
This is the end of the preview.
access the rest of the document.