ENGRD 241: Engineering Computation
December 20, 2001
SOLUTION TO FINAL EXAM
This is an open-book, open-notes, and open-problem-set examina examination. tion. Each problem starts on a separate page. Do all work on these sheets, and confine confine your solution solution to each problem to its own page, using the back of the page if necessary necessary.. Because these sheets may be temporarily temporarily separated for grading grading purposes, purposes, be sure to print print your name name on each and every page, and to observe and sign the pledge on this cover sheet. Show all work (includi (including ng equations, formulas, formulas, and and sketches where appropriate), and include only an appropriate number of significant figures for numerical values. Read all problems problems before before beginning beginning and and follow directions directions carefully carefully.. Problems have the value indicated, and the total number of points is 150 for the 2½-hour (150-minute) examination – plan your time time accordingly. accordingly. Partial credit is availabl availablee for all problems, 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. Name (Print): (Print): _________________________ _______________________________________ ______________ Academic integrity is expected of all students of Cornell University at all a ll times, whether in the presence or absence of members of the faculty. facu lty. Understanding this, I declare that I shall not give, use, or receive unauthorized una uthorized aid in this examination. examina tion.
Signature: _____________________________ Grading Summary: Problem
Score
Value
1
15
2
15
3
20
4
15
5
15
6
20
7
20
8
15
9
15
Total
150
Letter Grade
ENGRD 241 Final Exam
Name (Print): ________________________
Fall 2001
1. Ordinary Differential Differential Equations, Initial Value Problems [15 points] Consider the first-order equation with initial condition dy y ' = y(0) = 0.5 = y e x + 1 dx (a) Use a value of Δx = h = 1.0 to find y(1) by the “classical” fourth-order Runge-Kutta (RK) method, showing all equations and work. (b) By how much would the truncation error in y(1) decrease if one used a step size of Δx = h = 0.25? [Do not solve again for Δx = h = 0.25.] (c) Briefly explain the significance (i.e., the mathematical or graphical nature) of the k’s in RK methods, using the 4th-order RK method as an example.
(a)
f ( x, y ) yi +1
y e x + 1
x0
=0
y0
= 0 .5
h=1
y1
=
y(1) = ?
1
= yi + ( k1 + 2 k2 + 2 k3 + k4 ) h 6 f ( xi , yi )
= 0.5 e0 + 1 = 1.5 1 1 k2 = f xi + h, yi + hk1 = f (0.5,1.25) = 1.25 e0.5 + 1 = 3.0609 2 2 1 1 k3 = f xi + h, yi + hk2 = f (0.5, 2.0305) = 2.0305 e0.5 + 1 = 4.3477 2 2 k4 = f ( xi + h, yi + hk3 ) = f (1.0, 4.8477) = 4.8477 e1 + 1= 14.1774 1 y1 = y(1) = 0.5 + [ 1.5 + 2(3.0609) + 2(4.3477) + 14.1774] × 1= 5.5824 6 k1
(b)
(c)
=
≡
(25.40) (25.40a) (25.40b) (25.40c) (25.40d)
The 4th-order RK method is O(h4) – from the name name and C&C C&C p. 702. Therefore, as h goes from 1.0 to 0.25, the truncation error decreases by a multiplic multiplicative ative factor factor of (0.25/1.0) (0.25/1.0 )4 = 0.0039 The k’s in the RK methods are approximations of the slope y' at different locations along the step. For the 4th-order method, k 1 is the slope at the beginning of the step, k 2 is a first estimate of the slope at the middle of the step, k 3 is an improved estimate at the middle, and k 4 is an estimate of the slope at the end of the step. These slopes are then combined in a weighted average to produce an effective sl slope ope for the solution step, Eq. (25.40).
2. Ordinary Differential Differential Equations, Boundary Value Problems [15 Points] You wish to solve the following boundary value problem for the steady-state temperature in a rod of length 10m (C&C Problems 27.1-27.3): d 2T − 0.1T = 0 T (0) = 200o T (10) = 100o 2 dx (a) For a finite difference solution, write the discrete version of this equation at a typical interior point x = xi using O(h2) finite finite divided divided difference difference operators. operato rs. Assume that Δx = h = 0.5 is uniform uniform throughout the length of the rod. rod. [Do not write out the full matrix equations for this problem, problem, just write the one equation for the one typical interior interior point, i.e., the
ENGRD 241 Final Exam
Name (Print): ________________________
Fall 2001
computational “molecule.”] (b) You now decide that it would be more convenient to solve this problem problem by the shooting method (garden hose method) because you have handy a flexible and well-designed Excel spreadsheet for the fourth-order Runge-Kutta method. (i) (i) Re-wri Re-write te the the seco second-o nd-order rder equati equation on as as two two firs first-o t-order rder diff differ erent entia iall equatio equations ns that you will use in your spreadsheet macros. (ii) Using Δx = h = 0.2, you obtain the following values from your spreadsheet corresponding to two assumed (trial) initial conditions for T'(0): When T'(0) = – 60, 60, you find T(10) = 129.481º When T'(0) = – 65, 65, you find T(10) = – 56.951º 56.951º What value of T'(0) would you use next? Is this likely likely to give you a solution that satisfies the “far” boundary bounda ry condition? Why?
(a) (b)
Ti +1 − 2Ti h (i)
+ T i 1
Let z ≡ T'=
(iii)
− 0.1Ti = 0
−
2
dT dx
dT dx
=
or
Ti +1 − 2.025 Ti
+ Ti 1 = 0 −
, then the two first-order equations are:
f ( x, T , z ) = z
and
z'=
dz dx
= g ( x, T , z) = 0.1T (1)
From Lecture Notes 7C, page 1, with T'(0) = z0: zo = zo + T '(0) = z 0
= −60 +
zo Tf
(2)
z
(1)
– o (2)
T
(1)
– f
(T
T
(1)
f – f
)
−65 + 60 (100 − 129.481) = − 60.791 56.951 51− 129. 129.48 481 1 −56.9
Because this is a linear problem, this linearly interpolated initial value will yield the correct solution from our spreadsheet using the same value value of h = 0.2 (but one should always actually try it out to verify the calculation of the interpolant).
3. Partial Differential Equations [20 points] (a) Class Classif ify y the the followi following ng PDE’s PDE’s as ellipt elliptic, ic, parabol parabolic, ic, or hyperbol hyperbolic ic and as linear or nonlinear. Show or explain your reasoning. Assume that E, F, D, ψ, and c are positive functions and that ψ < 1. (i) The gene generrali alized zed Poi Poisson equa equattion ∂ ∂u ∂ ∂u E ( x , y ) F ( x , y ) + = g( x, y) ∂ x ∂x ∂y ∂y
(ii) (ii)
(iii (iii))
The The gene genera rallized ized conve convect ctio ionn-di difffus fusion ion equa equati tion on ∂u ∂ ∂u ∂u = D( x) + u( x, t) − k u( x, t ) ∂t ∂x ∂x ∂x The equa equatio tion n governi governing ng the the behav behavio iorr of a wake wake behi behind nd a thin thin plate plate held held fixed in a uniform stream of incompressible viscous fluid so that the plate is Analysis , McGraw-Hill, McGraw-Hill, edgewise to the flow. flow. [Ref: S. H. Crandall, Engineering Analysis, 1956, Chapter 6.]
ENGRD 241 Final Exam
Name (Print): ________________________
∂ψ = ∂ x (iv) (iv)
(v)
(b)
(a) (a)
1 − ψ
Fall 2001
∂ 2ψ ∂y 2
The The gene genera rallized zed wave wave equa equati tion on 2 ∂u ∂ ∂u c ( x ) = + au = f dt 2 ∂ x ∂x The biharmonic equati ation 4 4 ∂w ∂ w ∂4 w +2 + = f ( x, y) ∂ x 4 ∂x2∂y2 ∂y4
What auxili auxiliary ary conditions – and how many of each – are needed needed to solve (analytical (analytically ly or numerically) the following second-orde second -orderr PDE’s. It is recommended that you use sketches to clarify your answers. (i) (i) Ell Ellipt iptic in 2D spac spacee (e. (e.g. g.,, Lap Lapllace ace equ equat atio ion) n) (ii) (ii) Para Parabo boli licc in 1D spac spacee (e. (e.g., g., the the hea heatt equ equat atio ion) n) (ii (iii) Hype Hyperb rbol olic ic in 1D spa space ce (e.g (e.g., ., the the wave wave equa equati tion on))
For the the seco second nd-or -order der equat equatio ions ns,, exa exam mine ine the the sig sign n of of B2 – 4AC in ∂ 2u ∂2u ∂2 u A 2 + B + C 2 + D = 0 [C&C pp. 813-814] ∂ x ∂x∂y ∂y (i) A = E, B = 0, C = F B2 – 4AC = –4EF elliptic and linear (ii) A = D, B = C = 0 B2 – 4AC = 0 parabolic and nonlinear from u u' term (iii)
A = B = 0, C =
1 −ψ
B2 – 4AC = 0 parabolic and nonlinear from
1 −ψ ψ ′ term (iv) (v) (v)
(b)
(i)
A = c, B = 0, C = –1 B2 – 4AC = 4c hyperbolic and linear This This is not sec secon ond-o d-orde rderr so we we cann cannot ot use use exa exam minat inatio ion n of of B2 – 4AC. However, because there are no time derivatives derivatives or first or second derivatives derivatives of independent independent variables variables other than x or y, we deduce that this represents represents a steady-state problem for a closed 2D domain and is thus elliptic. It is also linear. linear. Nee Need on one bou boun ndar dary condition (Dirichlet: u = f; Neumann: ∂u / ∂n = g; or mixed: a u + b ∂u / ∂n = c) on every point on the boundary. bounda ry. Typically, these problems have a closed domain, i.e., a boundary completely surrounding the spatial domain. (Because elliptic equations represent steady-state behavior, initial conditions are not relevant or needed.) (ii) Need boundary conditions conditions on both ends of the 1D spatial domain domain (Diric (Dirichlet, hlet, Neumann, or mixed), mixed), e.g., Dirichlet Dirichlet would be u ( x0 , t ) and u ( x f , t ) specified for all t. Also need initial initial conditions for the dependent dependen t variable over the entire space at the beginning of the time span, e.g., u ( x, 0) . The domain is closed in space but open in future time. (iii) Need boundary conditions conditions on both ends of the 1D spatial domain domain (Diric (Dirichlet, hlet, Neumann, or mixed) mixed) – same same as for part b(ii). Also need need two initial initial conditions conditions –
ENGRD 241 Final Exam
Name (Print): ________________________
Fall 2001
the dependent variable and its first derivative with respect to time – over the entire space at the beginning of the time span, e.g., u ( x, 0) (initial displacement) displacement) and an d u&( x, 0) (initial velocity). The domain is closed in space but open in future time.
4. Partial Differential Equations [15 points] Consider the heat conduction equation in 2 spatial dimensions:
∂T ∂ 2T ∂ 2T = k 2 + 2 ∂t ∂x ∂y
C&C C&C Eq. Eq. (30. (30.18 18))
You plan to solve this numerically using the finite difference method and, rather than using the ADI scheme, you will solve using an implicit method and the solution of the 2D spatial matrix equations equatio ns at each time step. Assume Δx = Δy = h. Write the finite finite difference difference equation for a typical interior grid point (in either equation or computational-molecule form) for the simple implicit implicit method. Use the following following indices: indices: subscript i for the x-direction grid points, subscript j l for the y-direction grid points, and superscript ℓ for the time levels, e.g., T i , j , and use appropriate additions or subtractions subtractio ns to the indices indices to indicate indicate adjacent points in space-time. Assume that all values have already been computed up to the time level ℓ.
For the simple implicit method we write the spatial operator at time ℓ+1 and the time operator as a backward difference from time time ℓ+1 to ℓ. The spatial operator opera tor is the ∇ 2 operator from C&C Eq. (29.8) written at time ℓ+1 but multiplied by k/h2:
∂ 2T ∂ 2T k 2 + 2 → ∂ x ∂y
k 2
h
(T
l +1 i +1, j
+ Ti 1,1j + Ti, j 11 + Ti, j 11 − 4Ti, j 1 ) l+
−
l+
+
l+
−
l+
The time operator is given in C&C Eq. (30.3) [identical for forward or backward finite-divided difference in time] but with subscripts that account for 2 spatial dimensions: Ti ,l j+1 − T i,l j ∂T
∂t
→
∆t
Using the usual notation of λ = k ∆t / h2 , we can combine these to obtain the equation form of the computational molecule, in which all the unknowns are collected on the left-hand side: (1 + 4λ )Ti ,l j+1 − λ Ti +l 1+,1j − λTi −l +1,1 j − λTi,l +j+11 − λTi,l +j−1 1 = Ti,l j
5. Rootfinding Rootfinding [15 [15 points] points] The locations of sampling points for Gaussian Quadrature (sometimes called "Gauss-Legendre quadrature") are the roots roo ts (zeros) of Legendre polynomial. polynomial. For example, example, for six-point six-point Gaussian Quadrature, the Legendre polynomial of sixth order is 1 P6 ( x) = 693 x6 − 945 x4 + 315 x2 − 15) ( 48 (Note: (Note : All the zeros of the Legendre polynomials are less than one in magnitude and, for Acknowledgment: C. F. Gerald & polynomials polynomials of even order, are symmetrical symmetrical about the origin.) [Acknowledgment:
ENGRD 241 Final Exam
Name (Print): ________________________
Fall 2001
P. O. Wheatley, Applied Wheatley, Applied Numerical Analysis, Analysis , Addison-Wesley, 4th Edition, 1989, prob. 1.63.] In an
attempt to find the sampling point near 0.65 for the sixth-order Legendre polynomial, the following spreadsheet calculations have been performed. Rootfinding by the Secant Method
Please do the following: 1. Define Define the function, function, ff(x), in the Visual Visual Basic Basic module for for this worksheet worksheet 2. Provi Provide de initi initial al guesses guesses (need not boun bo und d the root). root) . xi-1 =
0.5000
xi =
0.8000
3. Provi Provide de stopping tolerances: es =
(%) (%)
1.00E-05
max =
(maxim (maximum # of iterations,
5
Iter
xi-1
f(x f(x i-1 )
1
0.500000000
3.232E-01 -01
2
0.800000000 -3. -3.918E-01 -01 0.635618849
3
0.635618849
4
0.662737817 -4. -4.806E-03 -03 0.661152650
1.781E-04 -04
5
0.661152650
3.152E-07
7.741E-02 -02 1.781E- 04 04
xi
f(x f(x i )
<35)
xi+1
0.800000000 -3. -3.918E-01 -01 0.635618849 7.741E-02 -02
e a (%) (%)
7.741E-02 -02
2.59E+01
0.662737817 -4. -4.806E-03 -03 4.09E+00
0.662737817 -4. -4.806E-03 -03 0.661152650 0.661209286
f(x f(x i+1 )
1.781E-04 -04
2.40E-01 -01
0.661209286
3.152E-07 -07
8.57E-03 -03
(i)
(ii)
(iii)
For each of the indicated missing results (i) through (iii), write the equation and calculate the value. Use 9 significant significant figures figures for values of x.
xi +1
= xi −
(i)
f ( xi )( xi −1 − xi ) f ( xi −1 ) − f ( xi )
= 0.661209286 − (ii)
=
C&C C&C Eq. (6.7 (6.7))
3.152 × 10−7 (0.661152650 − 0.661209286) 1.781× 10−4 − 3.152× 10−7
f ( xi +1 ) = (((693 xi2+1 − 945) xi2+1 + 315) xi2+1 − 15) / 48 = − 1.469× 10
= 0.661209386
−9
(results may differ due to rounding and differences in pocket calculators) (iii)
ε a
=
xi +1 − xi xi +1
×100% =
0.66 0.6612 1209 0938 386 6 − 0.66 0.6612 1209 0928 286 6 0.661209386
× 100 = 1.512× 10 5 % −
6. Systems of Equations [20 points] You are to solve the following set of equations iteratively by the Gauss-Seidel method:
ENGRD 241 Final Exam
4 [ A] { x} = 1 0
0 3 1
Name (Print): ________________________
Fall 2001
1 x1
8 0 x2 = 6 = { b} x3 4 2
(a) Will Will the Gauss-Se Gauss-Seidel idel method method converge converge for this this problem problem?? Justify Justify your answe answer. r. (b) The textbook suggests using a trial starting value value for the iterative solution solution of T
{ x } = 0 0
0 0 . Suggest an alternative set set of starting values values that might be closer closer to the
final answers and explain your rationale. (c) Write the three iterative equations you will use in general symbolic form, including proper j superscripts on the xi to indicate indicate the iteration number. number. (d) Perform Perform (only) (only) two (2) full iteratio iterations ns numeri numerical cally ly,, and calculat calculatee the approximate approximate error of each iteration.
(a)
A suff suffic icie ient nt condi conditi tion on for for conver convergen gence ce of the the Gauss Gauss-Se -Seid idel el metho method d is giv given en on on page page 9 of Lecture Notes 3B and on C&C page 293, Eq. (11.10): n
aii f
∑a
ij
j =1 j ≠ i
(b)
That is, the system must be diagonally dominant. This set of equations fulfills fulfills this condition, so the method will converge. Becaus Becausee of the the diago diagonal nal domin dominanc ance, e, a good good firs firstt approx approxim imate ate solu soluti tion on is is giv given en by by xi = bi / aiii i , that is, by neglecting the off-diagonal terms. For this problem, this approximation yields: T
{ x } = 2 0
(c)
2
2
The Gauss Gauss-Se -Seide idell equatio equations ns are giv given en on page page 8 of Lectur Lecturee Notes Notes 3B or by C&C C&C Eqs. Eqs. (11.5) with appropriate superscripts added to show that the most recent values are used: x1 j +1 = (b1 − a12 x2j − a13 x3j ) / a11
= (b2 − a21 x1j 1 − a23 x3j ) / a22 x3 j 1 = (b3 − a31 x1j 1 − a32 x2j 1 ) / a33 x2 j +1 +
(d)
+
+
+
Use Use star startting valu alues from rom part part (b). b). [But full credit for correct calculations with any starting values.] 1 .5 − 2 x11 = (8 − 0 × 2 − 1× 2) 2 ) / 4 = 1 .5 × 100 = 33.3% ε a = 1.5 x12
1.5 − 0 × 2) / 3 = 1.5 = (6 − 1× 1.
x31
1 .5 − 1× 1. 1.5) / 2 = 1.25 = (4 − 0 ×1.
ε a
= ε a
1. 5 − 2 1.5
=
× 100 = 33.3%
1.25 − 2 1.25
× 100 = 60%
ENGRD 241 Final Exam
Name (Print): ________________________
x12
1 .25) / 4 = 1.6875 = (8 − 0 × 1.5 − 1× 1.
x22
= (6 − 1× 1.6875 − 0× 1.25) / 3 = 1.4375
x32
= (4 − 0 × 1.6875 − 1× 1.4375) / 2 = 1.2813
[Converged solution is { x}
T
ε a
= 1.6800
=
1.6875 − 1.5 1.6875
ε a
= ε a
× 100 = 11.1%
1.4375 − 1.5 1.4375
=
Fall 2001
× 100 =
1.2813 − 1.25 1.2813
4.3 %
× 100 =
2. 4 %
1.4400 1.2800 ]
7. Interpolation and Curve Fitting [20 points] The following following data for creep rate, ε , the time rate at which strain increases, and the corresponding stress, σ , were obtained from a creep test performed at room temperature on a wire composed of 40% tin, 60% lead, and a solid solid solder core. Use a power-law, least-squares least-squares m curve fit of the equation ε&= Bσ to find the values of B and m. [This is based on C&C Problem 20.49, page 561.]
Creep rate, min-1 Stress, MPa
0.000 4 5.775
0.001 1 8.577
0.0031 12.555
Let y = log ε and x = log σ . Then when we take logs of the full equation, equatio n, we obtain the linear linear equation log ε&= log B + m log σ or y = a0 + a1 x . We can find find the intercept and slope by linear linear regression, that is, by means of C&C Eqs. (17.4) to (17.7). We can arrange the necessary necessary calculations in tabular form as follows:
Then m = a1 = and log B = a0
n
i 1
xi = log σ 0.76155
yi = log ε -3.3979
2
0.93232
-2.9586
3
1.09882
-2.5086
Σ
2.79269
-8.8651
xi2 0.5799 6 0.8692 2 1.2074 0 2.6565 8
xiyi -2.5877
-2.7584 -2.7565 -8.1026
∑ x y − ∑ x ∑ y = 3(−8.1026) − 2.79269(− 8.8651) = 2.636 3(2.6 (2.656 5658 58)) − (2.7 (2.792 9269 69)) n∑ x − ( ∑ x ) i
i
2 i
= y − a1 x =
i
i
2
2
i
8.8651 51− 2.63 2.636( 6(2. 2.79 7926 269) 9) −8.86 3
= −5.4089 →
B = 3.900× 10−6
ENGRD 241 Final Exam
Name (Print): ________________________
Fall 2001
8. Numerical Integration [15 points] The following integral is being evaluated by Gaussian Quadrature with six sampling points. 1 1 1 + x I = ln dx x 1 x − 0
∫
[As an aside, notice that the integrand is singular at x = 1 since ln(2/0) is infinite, and that the value of the integrand is indeterminate (but not singular) at x = 0 since ln(1)/0 = 0/0; however, because Gaussian Quadrature is an open method, it never requires the evaluation of the integrand at the end points of the interval of integration. Acknowledgment: Acknowledgment: R. W. Hornbeck, Numerical Hornbeck, Numerical Methods, Methods, Quantum Publishers, 1975, prob. 8.13.] The
following partial results for this problem have been obtained with a spreadsheet program: Welcome to: Nume Numerical Integration Integration by by Gaus Gauss Quadratur Quadrature e
To use this spreadsheet: 1. Define Define the integrand, integrand, f(x), in a VB macro. acro. 2. Define Define the Lim Limits of Integration: Integration: a=
0.0000
b =
1.0000
3. Define Define the # of Gauss-Legendre Gauss- Legendre sampling sampling points: p = dx = 0.5*(b - a) =
Results: pt. #
sam sampling pt. x
0
6
( Note: 2 ? # pts. ? 6 )
0.5000
xi
f(x f(x i )*dx
wi
wi *f(x i )*dx
- 0.932469514
0.0338
1.0004
0.171324492
0.1714
1
- 0.661209386
0.1694
1.0097
0.360761573
0.3643
2
- 0.238619186
0.3807
1.0530
0.467913935
0.4927
3
0.238619186
0.6193
1.1689
0.467913935
0.5469
4
0.661209386
(i)
(ii)
0.360761573
(iii)
5
0.932469514
0.9662
2.1032
0.171324492
0.3603
d
I=
(iv)
(a) For each of the indicated indicated missing missing results (i) (i) through (iv), write the equation and calculate calculate the value. (b) If the exact answer is I = π2/4 = 2.4674011, 2.4674011 , what is the true relative relative error of the approximate numerical answer?
(a)
(i)
xi
=
(b + a) + (b − a) xd 2
=
1 + 1(0.661209386) 2
= 0.8306
C&C Eq. (22.23)
ENGRD 241 Final Exam
1
f ( xi ) dx =
(iii)
1.43 1.4328 28(0 (0.3 .360 6076 7615 1573 73)) = 0.516 0.5169 9 I = wi f ( xi ) dx = 2.4525
ε t =
xi
Fall 2001
1 + xi 1 1 + 0.8306 × 0.5 = 1.4328 dx l n = 0.8306 1 − 0.8306 1 − xi
(ii)
(iv) (b)
Name (Print): ________________________
ln
∑ i
It − I I t
× 100% =
2.46 2.4674 7401 011 1 − 2.45 2.4525 25 2.4674011
× 100 = 0.604%
9. Errors and Approximation [15 points] Discuss briefly the two principal contributions to total numerical error in computational approximations. approximations. From what do each of these arise, i.e., i.e., what is the source of each? each? Describe how the interplay of these different sources of error can sometimes be used to estimate an “optimal” step size for a numerical numerical method. method. Use a sketch and an example; for instance, the example could be numerical differentiation (in very general terms).
The two principal principal contributions contributions to numerical numerical error are truncation and roundoff. ro undoff. Truncation arises from using series approximations in place of an exact mathematical procedure (e.g., finite divided differences in in place of differentiation, summation in place of integration). Roundoff Round off arises from the discrete and finite arithmetic in digital computation, that is, from only a fixed number of significant figures in the mantissa, from critical arithmetic (e.g., subtraction of two numbers of nearly equal value), value), and from the gaps between representable representable numbers. numbers. The two errors tend to have opposite trends: truncation errors become smaller with smaller step size, and roundoff errors become more dominant dominant with with very small small step sizes. This can can be shown schematical schematically ly on a plot of log error vs. log step size size as in in C&C Figure 4.8, page 94. The fact that the total error, i.e., the sum of the truncation error and the roundoff error, may have a minimum suggests that one attempt to select a step size (h) (h) at or near the minim minimum um of the total error (T). That is, T(h) = dT = 0 estimate of “optimal” h. For example, in truncation + roundoff = C(h) + R(h), and dh numerical differentiation, a truncation error of O(hn) gives C(h) = Ahn, while roundoff error of the mth order derivative gives R(h) = B/hm. Thus T = Ahn + B/hm clearly indicate the pattern depicted in C&C Figure 4.8.