Starting from:

$25

CS-SE4X03 - Assignment 3 - Solved

Consider the integral f 0 1sin(πx2/3)dx. Suppose that we wish to 
integrate it numerically with an error of magnitude less than 10-8 and using equally spaced 
points and the trapezoidal rule. Derive how many points are needed to achieve this accuracy.
Problem 2 [3 points] Approximate f 1 -1(x − 0.5)2 dx using the Simpson’s rule with 5 equally spaced points and calculate the error in this approximation.
Problem 3 [3 points] A common problem in surveying is to determine the altitudes of a series of points with respect to some reference point. The measurements are subject to error, so more observations are taken than are necessary to determine the altitudes, and the resulting overdetermined system is solved in the least square sense to smooth out the error. Suppose that there are four points whose altitudes x1, x2, x3, x4 are to be determined. In addition to direct measurements of each xi, with respect to a reference point, measurements are taken of each point with respect to all of the others. The resulting measurements are:
    x1 = 2.95    x2 = 1.74
x3 = −1.45    x4 = 1.32
    x1 − x2 = 1.23    x1 − x3 = 4.45
    x1 − x4 = 1.61    x2 − x3 = 3.21
    x2 − x4 = 0.45    x3 − x4 = −2.75
From these data, find the best values for the altitudes. How do your computed values compare with the direct measurements?
Problem 4 [10 points] Implement the composite Simpson’s rule and adaptive Simpson. Construct an example of a function f(x), interval [a, b] and tolerance tol such that, to achieve about the same accuracy, the composite Simpson’s rule on a uniform mesh requires at least 100 times more function evaluations than your adaptive Simpson.
For this purpose consider the following steps.
•    Use Matlab’s quad function to compute an accurate approximation. For example, you can use tolerance 1e-2*tol in quad.
To measure the error produced by your implementations, you can subtract from the quad’s result and take absolute values.
•    Select an m in your composite Simpson such that the error is about tol. Count the number of function evaluation for this m; denote them by C1.
•    In the adaptive Simpson, use tol and compare with the result from quad, to ensure that your computed result is within the tolerance.
Count the the number of function evaluations; denote them by C2.
Then C1 ≥ 100C2 should hold.
 
Name the program implementing the above main_simpson.m. It should output the errors of the composite and adaptive Simpson, C1 and C2, and should also plot f(x) versus x.

•    Avenue: main_simpson.m and all the files it uses (if there are such) Problem 5 [10 points] The error function is defined as

~
2
erf(x) = /π
0    x    e_t2dt

In MATLAB, it can be evaluated as erf(x).
(a)    Use the midpoint, trapezoid, and Simpson composite quadrature rules to compute an approximate value for erf(1).
Using loglog, plot on the same figure the error in each of these methods versus h = 1/2i, where i = 1, 2, ..., 10.
(b)    The errors in these rules behave like chk for constants c and k, where k is the order of a method. Using least squares, estimate these constants for each of the methods using the error data. Output the computed constants for each method as e.g.
fprintf(’trapezoid %.2e*h^%.2f\n’, c, k);
You must use this format specification.
Name the main program main_integration_error.m implementing the above. It should produce the plot and output the constants.

More products