km 1100 1500 2450 3400 3630 4500 km 5380 6060 6280 6380 Applied Numerical Methods with MATLAB fo

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 Now suppose that you were given the reverse problem. That is, you were asked to de- termine velocity based on the jumper’s position as a function of time. Because it is the in- verse of integration, differentiation could be used to make the determination: v t = d zt dt 21.3 Substituting Eq. 21.2 into Eq. 21.3 and differentiating would bring us back to Eq. 21.1. Beyond velocity, you might also be asked to compute the jumper’s acceleration. To do this, we could either take the first derivative of velocity, or the second derivative of displacement: at = dvt dt = d 2 zt dt 2 21.4 In either case, the result would be at = g sech 2 gc d m t 21.5 Although a closed-form solution can be developed for this case, there are other func- tions that may be difficult or impossible to differentiate analytically. Further, suppose that there was some way to measure the jumper’s position at various times during the fall. These distances along with their associated times could be assembled as a table of discrete values. In this situation, it would be useful to differentiate the discrete data to determine the velocity and the acceleration. In both these instances, numerical differentiation methods are available to obtain solutions. This chapter will introduce you to some of these methods.

21.1 INTRODUCTION AND BACKGROUND

21.1.1 What Is Differentiation? Calculus is the mathematics of change. Because engineers and scientists must continuously deal with systems and processes that change, calculus is an essential tool of our profession. Standing at the heart of calculus is the mathematical concept of differentiation. According to the dictionary definition, to differentiate means “to mark off by differ- ences; distinguish; . . . to perceive the difference in or between.” Mathematically, the deriva- tive, which serves as the fundamental vehicle for differentiation, represents the rate of change of a dependent variable with respect to an independent variable. As depicted in Fig. 21.1, the mathematical definition of the derivative begins with a difference approximation: y x = f x i + x − f x i x 21.6 where y and f x are alternative representatives for the dependent variable and x is the independent variable. If x is allowed to approach zero, as occurs in moving from Fig. 21.1a to c, the difference becomes a derivative: d y d x = lim x→ f x i + x − f x i x 21.7 21.1 INTRODUCTION AND BACKGROUND 523