The following data define the sea-level concentra- a

Although the relationship of drag to the Reynolds number is sometimes available in equation form, it is frequently tabu- lated. For example, the following table provides values for a smooth spherical ball: Re ×10 − 4 2 5.8 16.8 27.2 29.9 33.9 C D 0.52 0.52 0.52 0.5 0.49 0.44 Re ×10 − 4 36.3 40 46 60 100 200 400 C D 0.18 0.074 0.067 0.08 0.12 0.16 0.19 a Develop a MATLAB function that employs the spline function to return a value of C D as a function of the Reynolds number. The first line of the function should be function CDout = DragReCD,ReIn where ReCD = a 2-row matrix containing the table, ReIn = the Reynolds number at which you want to estimate the drag, and CDout = the corresponding drag coefficient. b Write a script that uses the function developed in part a to generate a labeled plot of the drag force versus velocity recall Sec. 1.4. Use the following parameter val- ues for the script: D = 22 cm, ρ = 1.3 kgm 3 , and μ = 1.78 × 10 −5 Pa · s. Employ a range of velocities from 4 to 40 ms for your plot. 18.14 The following function describes the temperature dis- tribution on a rectangular plate for the range −2 ≤ x ≤ 0 and 0 ≤ y ≤ 3 T = 2 + x − y + 2x 2 + 2x y + y 2 Develop a script to: a Generate a meshplot of this function using the MATLAB function surfc . Employ the linspace function with default spacing i.e., 100 interior points to generate the x and y values. b Use the MATLAB function interp2 with the default interpolation option linear to compute the temperature at x = –1.63 and y = 1.627. Determine the percent relative error of your result. c Re- peat b, but with spline . Note: for parts b and c, em- ploy the linspace function with 9 interior points. 459 P ART F IVE Integration and Differentiation

5.1 OVERVIEW

In high school or during your first year of college, you were introduced to differential and integral calculus. There you learned techniques to obtain analytical or exact derivatives and integrals. Mathematically, the derivative represents the rate of change of a dependent variable with respect to an independent variable. For example, if we are given a function yt that specifies an object’s position as a function of time, differentiation provides a means to de- termine its velocity, as in: v t = d dt yt As in Fig. PT5.1a, the derivative can be visualized as the slope of a function. Integration is the inverse of differentiation. Just as differentiation uses differences to quantify an instanta- neous process, integration involves summing instanta- neous information to give a total result over an interval. Thus, if we are provided with velocity as a function of time, integration can be used to determine the distance traveled: yt = t v t dt As in Fig. PT5.1b, for functions lying above the abscissa, the integral can be visualized as the area under the curve of vt from 0 to t. Consequently, just as a derivative can be thought of as a slope, an integral can be envisaged as a summation. Because of the close relationship between differentia- tion and integration, we have opted to devote this part of the book to both processes. Among other things, this will provide the opportunity to highlight their similarities and differences from a numerical perspective. In addition, the material will have relevance to the next part of the book where we will cover differential equations. Although differentiation is taught before integration in calculus, we reverse their order in the following chapters. We do this for several reasons. First, we have already introduced you to the basics of numerical differentiation in Chap. 4. Second, in part because it is much less sensitive to roundoff errors, integration represents a more highly developed area of numerical methods. Finally, although numerical differentiation is not as widely employed, it does have great significance for the solution of differential equations. Hence, it makes sense to cover it as the last topic prior to describing differential equations in Part Six.

5.2 PART ORGANIZATION

Chapter 19 is devoted to the most common approaches for numerical integration—the Newton-Cotes formulas . These relationships are based on replacing a complicated function or tabulated data with a simple polynomial that is easy to integrate. Three of the most widely used Newton-Cotes formulas are discussed in detail: the trapezoidal rule, Simpson’s 13 rule, and Simpson’s 38 rule. All these formulas are designed for cases where the data to be integrated are evenly spaced. In addition, we also include a discussion of numerical integration of unequally spaced data. This is a very important topic because many real- world applications deal with data that are in this form. y 200 400 8 12 4 t v 2 4 8 12 4 t v 2 4 8 12 4 a t y 200 400 8 12 4 b t FIGURE PT5.1 The contrast between a differentiation and b integration.