





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Numerical Computing S’09 MATH/CSCI 4800- Computational portion of Test II Due Thursday April 16, in class
NOTES
(a) Matlab scripts, printed outputs and figures must be attached. Scripts should include appropriate comments, and printouts and figures should be suitably labelled. (b) Provide adequate explanation and justification.
Problems
(a) Write down an expression for the least squares error. (b) Write down the system of equations that results when the error is minimized with respect to the coefficients. (Note that the equations will be linear in the coefficients ln c 1 and c 2 for the linearized approach and nonlinear in c 1 and c 2 for the direct approach.) (c) Write a Matlab program and find the coefficients. (For the linearized approach you may use any of the several procedures discussed in class, including the backslash command in Matlab. For the direct approach use Newton’s method for nonlinear systems.) Hints. i. Do the linearized problem first. Use the answer to this problem (i.e., the values of c 1 , c 2 you found) as as the starting guess for the direct problem. ii. If V is a vector, then the Matlab command sum(V) gives you the sum of the components of the vector.
(d) Plot the data and the two fitting functions on the same graph. Comment on the goodness of the fits. Which one captures better the trend of the data?
(a) Denote the data points as (ti, pi). The fitting function is p = c 1 ec^2 t. The least-squares errors for the two cases are:
Direct case: E =
i=
c 1 ec^2 ti^ − pi
Linearized case: E =
i=
d 1 + c 2 ti − ln pi
where d 1 = ln c 1 in the second expression above.
(b) Error is minimized by setting the first partial derivatives of E with respect to each of the two coefficients to zero, leading to the following results. Linearized case:
∂E ∂d 1
i=
d 1 + c 2 ti − ln pi
∂c 2
i=
d 1 + c 2 ti − ln pi
ti = 0.
Simplification yields the normal equations
12 d 1 +
i=
ti
c 2 =
i=
ln pi,
d 1
i=
ti
i=
t^2 i
c 2 =
i=
ti ln pi.
Direct case:
∂E ∂c 1
i=
c 1 ec^2 ti^ − pi
ec^2 ti^ = 0,
∂c 2
i=
c 1 ec^2 ti^ − pi
c 1 tiec^2 ti^ = 0.
These simplify to the normal equations
∑^12
i=
c 1 e^2 c^2 ti^ −
i=
piec^2 ti^ = 0 ,
i=
c^21 t 1 e^2 c^2 ti^ −
i=
pic 1 tiec^2 ti^ = 0
(c) See Matlab Log. The fitting coefficients are found to be c 1 = 0. 5165 , c 2 = 0. 2028 for the linearized case and c 1 = 0. 4057 , c 2 = 0.2319 for the direct case.
(d) See attached figure. The two fits seem to capture the data trend equally well.
Figure 2: Plot of K(x) in problem 2.