The acceleration due to gravity at an altitude y above

17.20 Temperatures are measured at various points on a heated plate Table P17.20. Estimate the temperature at a x = 4, y = 3.2, and b x = 4.3, y = 2.7. 17.21 Use the portion of the given steam table for super- heated H 2 O at 200 MPa to a find the corresponding entropy s for a specific volume v of 0.108 m 3 kg with linear interpolation, b find the same corresponding entropy using quadratic interpolation, and c find the volume correspond- ing to an entropy of 6.6 using inverse interpolation. v m 3 kg 0.10377 0.11144 0.12540 s kJkg · K 6.4147 6.5453 6.7664 TABLE P17.20 Temperatures °C at various points on a square heated plate. x = x = 2 x = 4 x = 6 x = 8 y = 100.00 90.00 80.00 70.00 60.00 y = 2 85.00 64.49 53.50 48.15 50.00 y = 4 70.00 48.90 38.43 35.03 40.00 y = 6 55.00 38.78 30.39 27.07 30.00 y = 8 40.00 35.00 30.00 25.00 20.00 429 18 Splines and Piecewise Interpolation CHAPTER OBJECTIVES The primary objective of this chapter is to introduce you to splines. Specific objectives and topics covered are • Understanding that splines minimize oscillations by fitting lower-order polynomials to data in a piecewise fashion. • Knowing how to develop code to perform a table lookup. • Recognizing why cubic polynomials are preferable to quadratic and higher-order splines. • Understanding the conditions that underlie a cubic spline fit. • Understanding the differences between natural, clamped, and not-a-knot end conditions. • Knowing how to fit a spline to data with MATLAB’s built-in functions. • Understanding how multidimensional interpolation is implemented with MATLAB.

18.1 INTRODUCTION TO SPLINES

In Chap. 17 n − 1th-order polynomials were used to interpolate between n data points. For example, for eight points, we can derive a perfect seventh-order polynomial. This curve would capture all the meanderings at least up to and including seventh derivatives suggested by the points. However, there are cases where these functions can lead to erro- neous results because of round-off error and oscillations. An alternative approach is to apply lower-order polynomials in a piecewise fashion to subsets of data points. Such con- necting polynomials are called spline functions. For example, third-order curves employed to connect each pair of data points are called cubic splines. These functions can be constructed so that the connections between adjacent cubic equations are visually smooth. On the surface, it would seem that the third- order approximation of the splines would be inferior to the seventh-order expression. You might wonder why a spline would ever be preferable. Figure 18.1 illustrates a situation where a spline performs better than a higher-order polynomial. This is the case where a function is generally smooth but undergoes an abrupt change somewhere along the region of interest. The step increase depicted in Fig. 18.1 is an extreme example of such a change and serves to illustrate the point. Figure 18.1a through c illustrates how higher-order polynomials tend to swing through wild oscillations in the vicinity of an abrupt change. In contrast, the spline also connects the points, but because it is limited to lower-order changes, the oscillations are kept to a a f x x b f x x c f x x d f x x FIGURE 18.1 A visual representation of a situation where splines are superior to higher-order interpolating polynomials. The function to be fit undergoes an abrupt increase at x = . Parts a through c indicate that the abrupt change induces oscillations in interpolating polynomials. In contrast, because it is limited to straight-line connections, a linear spline d provides a much more acceptable approximation.