Suppose that the current through a resistor is de-

20.14 If a capacitor initially holds no charge, the voltage across it as a function of time can be computed as V t = 1 C t i t dt Use MATLAB to fit these data with a fifth-order polynomial. Then, use a numerical integration function along with a value of C = 10 −5 farad to generate a plot of voltage versus time. t , s 0.2 0.4 0.6 i , 10 − 3 A 0.2 0.3683 0.3819 0.2282 t , s 0.8 1 1.2 i , 10 − 3 A 0.0486 0.0082 0.1441 20.15 The work done on an object is equal to the force times the distance moved in the direction of the force. The veloc- ity of an object in the direction of a force is given by v = 4t 0 ≤ t ≤ 5 v = 20 + 5 − t 2 5 ≤ t ≤ 15 where v is in ms. Determine the work if a constant force of 200 N is applied for all t. 20.16 A rod subject to an axial load Fig. P20.16a will be deformed, as shown in the stress-strain curve in Fig. P20.16b. PROBLEMS 519 The area under the curve from zero stress out to the point of rupture is called the modulus of toughness of the material. It provides a measure of the energy per unit volume required to cause the material to rupture. As such, it is representative of the material’s ability to withstand an impact load. Use nu- merical integration to compute the modulus of toughness for the stress-strain curve seen in Fig. P20.16b. 20.17 If the velocity distribution of a fluid flowing through a pipe is known Fig. P20.17, the flow rate Q i.e., the vol- ume of water passing through the pipe per unit time can be computed by Q = v d A, where v is the velocity, and A is the pipe’s cross-sectional area. To grasp the meaning of this relationship physically, recall the close connection between summation and integration. For a circular pipe, A = πr 2 and d A = 2πr dr . Therefore, Q = r v 2πr dr 20 40 60 0.1 s, ksi b a e 0.02 0.05 0.10 0.15 0.20 0.25 s 40.0 37.5 43.0 52.0 60.0 55.0 Rupture 0.2 e Modulus of toughness FIGURE P20.16 a A rod under axial loading and b the resulting stress-strain curve, where stress is in kips per square inch 10 3 lbin 2 , and strain is dimensionless. r A FIGURE P20.17 where r is the radial distance measured outward from the center of the pipe. If the velocity distribution is given by v = 2 1 − r r 16 where r is the total radius in this case, 3 cm, compute Q using the composite trapezoidal rule. Discuss the results. 20.18 Using the following data, calculate the work done by stretching a spring that has a spring constant of k = 300 Nm to x = 0.35 m. To do this, first fit the data with a polynomial and then integrate the polynomial numerically to compute the work: F , 10 3 · N 0.01 0.028 0.046 x , m 0.05 0.10 0.15 F , 10 3 · N 0.063 0.082 0.11 0.13 x , m 0.20 0.25 0.30 0.35 20.19 Evaluate the vertical distance traveled by a rocket if the vertical velocity is given by v = 11t 2 − 5t 0 ≤ t ≤ 10 v = 1100 − 5t 10 ≤ t ≤ 20 v = 50t + 2t − 20 2 20 ≤ t ≤ 30 20.20 The upward velocity of a rocket can be computed by the following formula: v = u ln m m − qt − gt where v = upward velocity, u = velocity at which fuel is ex- pelled relative to the rocket, m = initial mass of the rocket at time t = 0, q = fuel consumption rate, and g = downward acceleration of gravity assumed constant = 9.81 ms 2 . If u = 1850 ms, m = 160,000 kg, and q = 2500 kgs, determine how high the rocket will fly in 30 s. 20.21 The normal distribution is defined as f x = 1 √ 2π e −x 2 2 a Use MATLAB to integrate this function from x = −1 to 1 and from −2 to 2. b Use MATLAB to determine the inflection points of this function. 20.22 Use Romberg integration to evaluate 2 e x sin x 1 + x 2 d x to an accuracy of ε s = 0.5. Your results should be pre- sented in the form of Fig. 20.1. 20.23 Recall that the velocity of the free-falling bungee jumper can be computed analytically as [Eq. 1.9]: v t = gm c d tanh gc d m t where vt = velocity ms, t = time s, g = 9.81 ms 2 , m = mass kg, c d = drag coefficient kgm. a Use Romberg integration to compute how far the jumper travels during the first 8 seconds of free fall given m = 80 kg and c d = 0.2 kgm. Compute the answer to ε s = 1. b Perform the same computation with quad. 20.24 Prove that Eq. 20.30 is equivalent to Boole’s rule. 20.25 As specified in the following table, the earth’s density varies as a function of the distance from its center r ⫽ 0:

r, km 1100 1500 2450 3400 3630 4500

␳ , gcm 3 13 12.4 12 11.2 9.7 5.7 5.2

r, km 5380 6060 6280 6380

␳ , gcm 3 4.7 3.6 3.4 3 Develop a script to fit these data with interp1 using the pchip option. Generate a plot showing the resulting fit along with the data points. Then use one of MATLAB’s in- tegration functions to estimate the earth’s mass in metric tonnes by integrating the output of the interp1 function. 20.26 Develop an M-file function to implement Romberg in- tegration based on Fig. 20.2. Test the function by using it to determine the integral of the polynomial from Example 20.1. Then use it to solve Prob. 20.1. 20.27 Develop an M-file function to implement adaptive quadrature based on Fig. 20.6. Test the function by using it to determine the integral of the polynomial from Example 20.1. Then use it to solve Prob. 20.20. 521 Numerical Differentiation 21 CHAPTER OBJECTIVES The primary objective of this chapter is to introduce you to numerical differentiation. Specific objectives and topics covered are • Understanding the application of high-accuracy numerical differentiation formulas for equispaced data. • Knowing how to evaluate derivatives for unequally spaced data. • Understanding how Richardson extrapolation is applied for numerical differentiation. • Recognizing the sensitivity of numerical differentiation to data error. • Knowing how to evaluate derivatives in MATLAB with the diff and gradient functions. • Knowing how to generate contour plots and vector fields with MATLAB. YOU’VE GOT A PROBLEM R ecall that the velocity of a free-falling bungee jumper as a function of time can be computed as v t = gm c d tanh gc d m t 21.1 At the beginning of Chap. 19, we used calculus to integrate this equation to determine the vertical distance z the jumper has fallen after a time t. zt = m c d ln cosh gc d m t 21.2