



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solutions for various numerical computing problems. It includes finding the normal equations for a quadratic function using different methods, solving a system of nonlinear equations using newton's method, finding the polynomial interpolant through given data points, approximating a function by a polynomial interpolant, and obtaining a numerical approximation to an integral using the composite trapezoidal rule and the 4-point newton-cotes quadrature rule. The document also covers additional topics such as chebyshev nodes, piecewise polynomial interpolation, and cubic splines.
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




TEST II Solutions(theory portion) April 13, 2009
(a) (12 points) Consider the problem of fitting the quadratic function c 0 + c 1 x + c 2 x^2 to the discrete data (− 2 , 1), (− 1 , 0), (0, 1), (1, 0). i. In class we learned three different ways of solving this problem. Describe any two of these methods briefly, devoting only a few sentences to each. ii. By using any method of your choice, write down the normal equations for the system, i.e., the equations whose solution will yield the coefficients ci. Do not solve the equations. (b) (12 points) Consider the problem of solving the system of nonlinear equations
x^2 + xy^3 = 9 , 3 x^2 y − y^3 = 4.
Starting with the initial guess x 0 = y 0 = 1, use Newton’s method for systems to find the next iterate x 1 , y 1.
(a) i. We have considered three different methods of finding the normal equations (full credit for describing any two). The first method uses calculus to minimize the mean squared error
i=
[c 0 + c 1 xi + c 2 x^2 i − yi]^2
with respect to the ci, thereby obtaining the three normal equations. The others use linear algebra and begin with the inconsistent 4×3 system Ac = b, obtained by forcing the fitting function to pass through all the data points. One of these uses the fact that the solution vector c corresponding to the best fit forces the residual b − Ac to be orthogonal to the column space of A, leading to normal equations in the form ATAc = ATb. The other computes the QR factorization of A and selects the upper three equations of the system Rc = QTb as the normal equations. ii. We shall use the second method. The inconsistent system is Ac = b, or
c 1 c 2 c 3
The normal equations are ATAc = ATb, or
c 1 c 2 c 3
reducing to (^)
c 1 c 2 c 3
(b) The standard form of the equations is
f 1 (x, y) = x^2 + xy^3 − 9 , f 2 (x, y) = 3 x^2 y − y^3 − 4.
The Jacobian is J(x, y) =
[ (^) ∂f 1 ∂x
∂f 1 ∂y ∂f 2 ∂x
∂f 2 ∂y
2 x + y^3 3 xy^2 6 xy 3 x^2 − 3 y^2
The equation to be solved for the increments ∆x 1 and ∆y 1 is
J(x 0 , y 0 )
∆x 1 ∆y 1
f 1 (x 0 , y 0 ) f 2 (x 0 , y 0 )
With x 0 = y 0 = 1 the above equation reduces to [ 3 3 6 0
∆x 1 ∆y 1
which yields ∆x 1 = 1/ 3 , ∆y 1 = 2. Hence
x 1 = x 0 + ∆x 1 = 4/ 3 , y 1 = y 0 + ∆y 1 = 3.
Consider the problem of obtaining a numerical approximation to the integral I(f ) =
∫ (^3) h 0 f^ (x)^ dx^ by using four equally spaced nodes 0, h, 2 h and 3h.
(a) (12 points) One option is to use the composite trapezoidal rule, which can be written as
I(f ) =
∫ (^3) h
0
f (x) dx = QCT (f ) + ECT (f ). (1)
Here QCT (f ) is the quadrature formula and ECT (f ) the associated error. Find formulas for both of these quantities. You may use the fact that the trapezoidal rule is given by ∫ (^) b
a
f (x) dx =
b − a 2 [f (a) + f (b)] −
(b − a)^3 12 f ′′(c).
(b) (12 points) Another option is to use the 4-point Newton-Cotes quadrature rule, which can be written as I(f ) =
∫ (^3) h
0
f (x) dx = Q 4 (f ) + E 4 (f ), (2)
where Q 4 (f ) =
3 h 8
[f (0) + 3f (h) + 3f (2h) + f (3h)].
i. What is the smallest value of the positive integer n for which this rule fails to be exact when applied to f (x) = xn? Justify your answer. ii. Assume that the error term associated with Q 4 is proportional to f (n)(c), i.e., E 4 (f ) = khp^ f (n)(c), where n has the value found in part (i) above. Apply the quadrature rule (2) to f (x) = xn^ to find the values of k and p.
(a)
I(f ) = h 2
[f (0) + f (h) + f (h) + f (2h) + f (2h) + f (3h)] − h^3 12
[f ′′(c 1 ) + f ′′(c 2 ) + f ′′(c 3 )]
where c 1 ∈ [0, h], c 2 ∈ [h, 2 h], c 3 ∈ [2h, 3 h]. Consolidation of the error terms leads to
I(f ) =
h 2
[f (0) + 2f (h) + 2f (2h) + f (3h)] −
h^3 4
f ′′(c) = QCT (f ) + ECT (f ).
Here, c ∈ [0, 3 h]. (b) i. The degree of precision for a 4-point method is 3, so that n = 4. ii. We can write I(f ) =
3 h 8
[f (0) + 3f (h) + 3f (2h) + f (3h)] + khpf iv^ (c).
Applying the above equation to f (x) = x^4 , we get ∫ (^3) h
0
x^4 dx =
35 h^5 5
3 h 8
[0 + 3h^4 + 3 × 16 h^4 + 81h^4 ] + khp4!
Simplification leads to 243 h^5 5
h^5 + 24khp.
The above expression is an equality only if p = 5, k = − 803.
(a) Why are Chebyshev nodes preferred over equally-spaced nodes in polynomial interpolation of a function? (b) Can two different polynomials interpolate the same set of discrete data? If so, then under what conditions? (c) In interpolating a smooth function over a large number of nodes, what is the advantage of piecewise polynomial interpolation over interpolation by a single polynomial? (d) How many parameters are required to define a cubic spline that interpolates 5 data points? Justify your answer. (e) What is an advantage of n -point Gaussian quadrature over n -point Newton-Cotes quadrature? What is a disadvantage? (f) Explain why numerical differentiation is an unstable procedure. (g) Why is it important for all of the weights of a quadrature rule to be nonnegative?
(a) Chebyshev nodes equidistribute the error, which is skewed towards the end for equispaced nodes. (b) Yes. For n distinct nodes there is a unique polynomial interpolant of degree n− 1 , but an infinity of polynomial interpolants of degree greater than n − 1. (c) High-degree polynomials tend to be wiggly as compared to low-degree polynomials used in piece- wise polynomial interpolation. Also, the error for piecewise interpolation involves a lower deriva- tive which can be an advantage. (d) Four cubics are needed for the four subintervals, each involving four unknowns; hence sixteen unknowns in all. (e) The Gaussian quadrature has double the degree of precision, but there is the added expense of computing the nodes. (f) The numerical approximation of a derivative involves subtraction of nearly equal quantities divided by a small quantity. Thus catastrophic cancellation, worsened by the small divisor, results in instability. (g) If the wi are the weights, then it is known that
κ =
i
|wi| and b − a =
i
wi,
where κ is the condition number and b − a the width of the interval of integration. For non- negative weights, κ = b − a but κ > b − a and hence less well-conditioned when some of the weights are negative.