241 Prelim II Solution Fa02

advertisement
ENGRD 241: Engineering Computation
November 12, 2002
SOLUTION TO SECOND PRELIMINARY EXAM
This is an open-book, open-notes examination (but not open problem sets, computer
assignments, in-class exercises, and sample exams). Each problem is on a separate page. Do all
work on these sheets, and confine your solution to each problem to its own page, using the back
of the page if necessary. Because these sheets may be temporarily separated for grading
purposes, be sure to print your name on each and every page, and to observe and sign the pledge
on this cover sheet. Show all work (including formulas and sketches where appropriate), and
include only an appropriate number of significant figures for numerical values. Read all
problems before beginning and follow directions carefully. Problems have the value indicated,
and the total number of points is 90 for the 1½-hour (90-minute) examination – plan your time
accordingly. Partial credit is available for all problems, so you are advised to work on all of
them.
You must submit all of these pages upon completion of the exam, whether or not you have
attempted all problems. Because a makeup exam will be offered for a few members of the class
with conflicts on Tuesday evening, please do not discuss this exam with those class members
who are taking the makeup.
Name (Print): _______________________________________
Academic integrity is expected of all students of Cornell University at all times, whether in the
presence or absence of members of the faculty. Understanding this, I declare that I shall not
give, use, or receive unauthorized aid in this examination.
Signature: _____________________________
Grading Summary:
Problem
Score
Value
1
20
2
10
3
10
4
10
5
10
6
10
7
10
8
10
Total
90
Letter Grade
Page i
ENGRD 241 Prelim II Solution
Name (Print): ________________________
Fall 2002
1. EXCEL and Iterative Equation Solving [20 points]
Following is a spreadsheet for the solution of 4 equations by the Gauss-Seidel method with
relaxation. The matrix elements and the right-hand side are inserted by the use in the shaded cells;
you should assume that (i) satisfactory data in all shaded cells are provided and (ii) the input matrix
is diagonally dominant. (Although one could provide a check of these assumptions before solving,
you are NOT asked to do so here). Cell C7 is named lambda and cell F7 is named es, but the other
shaded cells are not named. In the following, you are asked to write the appropriate Excel code to
begin the calculations, but you are NOT required here to write the various IF-statement parts of the
commands that would control whether calculations should be displayed in the various cells. Write
your commands in the spaces provided below the sheet (don’t try to write in the too-short blank
cells!). [Extra info not needed to solve this problem: To use this spreadsheet for less than four equations, the matrix
[A] could be filled out with extra uncoupled equations with zero rows and columns except for unity on the diagonal and
with the right-hand side {b} having unity in the corresponding row.]
A
B
C
D
E
F
G
1 Solution of 4 Equations by Gauss-Seidel With Relaxation
2
3
[A] =
{b} =
4
5
6
(0 < < 2)
es (%) =
7
lambda =
8
x1
x2
x3
x4
ea (%)
9 Iteration
10
0
11
1
12
2
(a) Write Excel instructions below to compute the initial values of the four roots in the
following cells of row 10. Choose optimal values for diagonally dominant systems.
B10: =G2/B2
Optimal choice is xi0 = bi/Aii (full credit = 6)
C10: =G3/C3 [-B3*B10/C3]
Can add optional updates [terms in brackets]
D10: =G4/D4 [-(B4*B10-C4*C10)/D4]
Alternative: All 0’s (half credit = 3)
E10: =G5/E5 [-(B5*B10-C5*C10-D5*D10)/E5]
(b) Write Excel instructions below to compute an iteration of Gauss-Seidel method with
relaxation in the following cells of row 11. These instructions should be general enough to
be “filled down” into successive rows without modifications. Note that the approximate error
ea should be the maximum absolute error for the four roots.
B11: =lambda*($G$2-$C$2*C10-$D$2*D10-$E$2*E10)/$B$2+(1-lambda)*B10
C11: =lambda*($G$3-$B$3*B11-$D$3*D10-$E$3*E10)/$C$3+(1-lambda)*C10
D11: =lambda*($G$4-$B$4*B11-$C$4*C11-$E$4*E10)/$D$4+(1-lambda)*D10
E11: =lambda*($G$5-$B$5*B11-$C$5*C11-$D$5*D11)/$E$5+(1-lambda)*E10
F11: =100*MAX(ABS(1-B10/B11),ABS(1-C10/C11),ABS(1-D10/D11),ABS(1-E10/E11))
Page 1
ENGRD 241 Prelim II Solution
Name (Print): ________________________
Fall 2002
2. MATLAB [10 Points]
The row vector v = [2 3 –4]. What numerical values will MATLAB yield in response to the
following commands? (Note: no semicolons. Just give the numerical answer, not the MATLAB
format or arrangement of the command window display.)
>> a = zeros(size(v)) =
0
>> b = zeros(length(v)) =
>> c = diag(v) =
2
0
0
0
0
0
0
0
3
0
0
0
0
0
0
0
0
0
0
–4
>> d = sum(v) = 1
>> e = norm(v,inf) = 4
>> f = norm(v,2) = 5.3852
>> g = v*v' = 29
>> h = v.*v = 4
9
16
>> i = v./v = 1
1
1
>> j = v.^v = 4
27 0.00390625
[Note: 0.00390625 = 1/256]
Two-point bonus, solve only if you have time: >> k = v'*v =
4
6
–8
6
9
–12
–8
–12
16
3. Probability [10 points]
This problem deals with the experiment of rolling of a fair, six-sided die with each face bearing a
unique number of dots from 1 to 6.
(a) If we roll the die twice, what is the probability of obtaining two 3’s? What is the probability
of obtaining at least one 3? What is the probability of obtaining no 3’s?
(b) The outcome of rolling the die represents a discrete random variable. The discrete analogy of
the probability distribution function (pdf) is a probability mass function (pmf) or a probability
histogram. Sketch the probability histogram for rolling a single die and the corresponding
cumulative distribution function (cdf), being careful to label the values on the horizontal
outcome axes and the vertical probability axes.
Page 2
ENGRD 241 Prelim II Solution
Name (Print): ________________________
Fall 2002
Solution:
 1  1  1
 0.0278
(a) Probability of two 3’s:    
 6  6  36
 1   1  1 11

 0.3056
Probability of at least one 3:      
 6   6  36 36
 5  5  25
 0.6944
or from previous:
Probability of no 3’s:    
 6  6  36
1
11 25

36 36
(b)
pmf for casting a single die
probabiity
0.167
0.083
0.000
1
2
3
4
5
6
outcome
cdf for casting a single die
cum. probability
1.000
0.667
0.333
0.000
1
2
3
4
outcome
5
6
4. Statistics [10 points]
The following tabulated data represents a sample of eleven values of the propagation lives (xi =
flight hours/104) to reach a certain crack length in fastener holes intended for use in military aircraft.
Determine (a) the mean, (b) the variance [Hint: Remember that there is a shortcut equation in C&C
PT5.2.1], (c) the standard deviation, and (d) the 95% confidence interval for the mean. For part (d)
you may need to use the table at the bottom of page X-11 of the Lecture Notes. [Acknowledgement: J.
L. Devore, Probability and Statistics for Engineering & the Sciences, 4th Ed., 1995, Prob. 1.31, p. 27.]
Page 3
ENGRD 241 Prelim II Solution
i
1
2
3
4
5
6
7
8
9
10
11
SUM
xi
0.863
0.865
0.913
0.915
0.937
0.983
1.007
1.011
1.064
1.109
1.132
10.7990
xi2
0.7448
0.7482
0.8336
0.8372
0.8780
0.9663
1.0140
1.0221
1.1321
1.2299
1.2814
10.6876
Name (Print): ________________________
Fall 2002
Solution:
(a) x  10.799/11  0.9817
(b) Use “shortcut” equation at the bottom of C&C page 428:
2
xi2    xi   / n 10.6876  10.7990 2 /11


 
s2 
 0.008594
n 1
10
(c) s  0.008594  0.09271
(d)
s
n  0.09271 11  0.02795
t0.025,10  2.228
(from table on p. X-11)
s
t0.025,10  0.9817   0.02795  2.228  0.9195
n
s
U x
t0.025,10  0.9817   0.02795  2.228  1.0440
n
Lx
5. Least Squares Regression [10 points]
For each of the following five sets of data, please recommend and sketch one or more types of least
squares regression fit you would recommend trying and explain briefly your rationale. Types to
consider are linear, quadratic (parabolic), logarithmic, power, exponential, and saturation-growth.
Solution:
In the following, the preferred sketched fit is solid, the second choice (if any) is dotted, and the
third choice (if any) is dashed. [For information, R2 value is given for each fit.]
(a) Parabola (solid curve 0.718) is first choice due to Ushaped pattern. Linear (dotted 0.211) is next because of
wide scatter of data and no other discernable pattern.
Part (a)
(b) Saturation growth (solid 0.967) is first choice due to
asymptotic behavior apparently starting from the origin.
But additional choices that seem to fit are parabolic (dotted
0.959) and logarithmic (dashed 0.946).
Part (b)
Page 4
ENGRD 241 Prelim II Solution
Name (Print): ________________________
Fall 2002
(c) Power (solid 0.952) is first choice, although saturation
decay (dotted 0.941) and parabolic (dashed 0.897) also
appear to work well. Other choices such as logarithmic
(0.871) and exponential (0.782) are acceptable but not as
good in quality of fit. [Saturation decay will not be good
for small values of x (equation goes through origin).]
Part (c)
(d) There are several logical possibilities here with the
exponential (solid 0.998) and parabolic (dotted 0.994)
giving almost perfect fits. Other possibilities are linear
(0.932), power (0.922), and logarithmic (0.776).
Part (d)
(e) This data is so widely scattered that only a linear fit (solid
0.688) seems to make sense. However, despite discernable
patterns, power, parabolic, exponential, and logarithmic
fits all give an R2 of about 0.7 as well.
Part (e)
6. Splines [10 points]
Consider the piecewise polynomial function f (x) that passes through three points at the values of
x = 1, 2, and 3:
For 1  x  2 :
f1 ( x)  1.25x3  3.75x 2  0.5x  3
For 2  x  3:
f 2 ( x)  1.25 x3  11.25 x 2  30.5 x  23
Is this a natural cubic spline? Justify your answer by showing whether or not this function
satisfies the defining characteristics of natural cubic splines.
Solution:
To be a cubic spline, the piecewise function must satisfy the following conditions:
Continuity of position at the interior point:
f1 (2)  f2 (2)
Continuity of slope at the interior point:
f1 (2)  f 2 (2)
Continuity of curvature at the interior point:
f1 (2)  f 2 (2)
To be a natural spline, the curvatures at the two end points should vanish: f1 (1)  0 & f 2 (3)  0
Page 5
ENGRD 241 Prelim II Solution
Name (Print): ________________________
f1 ( x)  1.25 x 3  3.75 x 2  0.5 x  3
f1 (2)  20  30  4  3  3
f1 ( x)  3.75 x 2  7.5 x  0.5
f1 (2)  15  15  0.5  0.5
f1 ( x)  7.5 x 2  7.5
f1 (2)  15  7.5  7.5
Fall 2002
f1 (1)  7.5  7.5  0 OK
f 2 ( x)  1.25 x 3  11.25 x 2  30.5 x  23
f 2 (2)  10  45  61  23  3 OK
f 2 ( x)  3.75 x 2  22.5 x  30.5
f 2 (2)  15  45  30.5  0.5 OK
f 2 ( x)  7.5 x  22.5
f 2 (2)  15  22.5  7.5 OK
f 2 (3)  22.5  22.5  0 OK
All conditions are satisfied, so the given function is indeed a natural cubic spline.
7. Numerical Integration [10 points]
A method of numerical integration that you obtain from a table has a truncation error of the form:
ET  C hn f ( m) ( )
(a) What is the order of accuracy of this method? Explain what “order of accuracy” means in
this case. What is the order of accuracy of Boole’s 5-point Rule? Of 5-point Gauss-Legendre
Quadrature?
(b) What is the rate of convergence of this method? Explain what “rate of convergence” means
in this case. What is the rate of convergence of Boole’s 5-point Rule?
Solution
[Items in brackets are extra information not required in the solution.]
(a) The order of accuracy is m–1. This means that the method can integrate exactly a
polynomial of order (m–1) because it is a function for which the mth derivative, and thus
the truncation error, vanishes identically everywhere in the interval. For Boole’s 5-point
Rule, C&C Table 21.2, page 604, indicates that m = 6, so the order of accuracy is 6 – 1 =
5, i.e., the method can integrate a 5th order polynomial exactly. For 5-point Gauss
Quadrature, in C&C Equation (22.26), page 627, using the n-notation of that equation, we
find that the number of points minus one is n = 5 – 1 = 4, and thus m = 2n + 2 = 10 (this
agrees with C&C Table 22.1, page 626, as well). Therefore, the order of accuracy is
m – 1 = 10 – 1 = 9. [Alternatively, we know directly (Lecture Notes page 6-10) that ppoint Gauss Quadrature can integrate exactly a polynomial of order 2p – 1 = 9.]
(b) The rate of convergence is of nth order. This means that if the segment size is halved, the
truncation error will be reduced by a factor of 1/2n. [Alternatively, we can say that the
truncation error goes to zero as fast as, or at about the same rate as, hn.] From C&C Table
21.2, page 604, the rate of convergence of Boole's rule is of 7th order; this means that if
Page 6
ENGRD 241 Prelim II Solution
Name (Print): ________________________
Fall 2002
the segment size is halved, the truncation error will be reduced by a factor of 1/27 = 1/128.
[Note: We cannot make a comparable statement about 5-point Gauss-Legendre
Quadrature because the convergence of the method is not based on h-refinement but
rather on increasing the number of unequally spaced sampling points.]
8. Numerical Integration of Functions [10 points]
The standard normal probability density function is [exp(–x2/2)]/(2π)1/2. The probability that
the random variable X lies between 0 and 1 is:
1
1
 x2 / 2
P  Pr(0  X  1) 
e
 dx
2 0
Application of the trapezoidal rule with different numbers of segments over this interval
gives the results tabulated below. Using these results, calculate the estimate of P with the
highest possible order, carrying 7 decimal places. Arrange your work in tabular form, and
show all formulas you use. What is the order of error of your result?
h
# segments
P
0.5
2
0.3362609
0.25
4
0.3400818
0.125
8
0.3410295
Solution:
Use Romberg Integration starting with the O(h2) trapezoidal results given above and tabulate
in the appropriate column of the typical Romberg integration table as in C&C Figure 22.3:
# Trap.
segments
2
4
8
Trapezoidal
O(h2)
0.3362609
0.3400818
0.3410295
Simpson’s 1/3
O(h4)
0.3413554
0.3413454
Boole 5-point
O(h6)
0.3413447
O(h8)
To find O(h4) from O(h2), we use:
4  Pbetter  1 Ppoorer
P
P
 Pbetter  better poorer
3
3
6
4
To find O(h ) from O(h ), we use:
16  Pbetter  1 Ppoorer
P
P
 Pbetter  better poorer
15
15
To find O(h8) from O(h6), we would use (not needed here):
64  Pbetter  1 Ppoorer
P
P
 Pbetter  better poorer
63
63
The best order results that we can obtain here is that P = 0.3413447. From its position in the
above table, we see that this is an O(h6) estimate.
Page 7
Download