The following is the built-in

conditions. In addition, develop a plot using c piecewise cubic Hermite interpolation. x 100 200 400 f x 0.82436 1.00000 0.73576 x 600 800 1000 f x 0.40601 0.19915 0.09158 In each case, compare your plot with the following equation which was used to generate the data: f x = x 200 e −x200+1

18.5 The following data are sampled from the step function

depicted in Fig. 18.1: x −1 −0.6 −0.2 0.2 0.6 1 f x 1 1 1 Fit these data with a a cubic spline with not-a-knot end con- ditions, b cubic spline with zero-slope clamped end condi- tions, and c piecewise cubic Hermite interpolation. In each case, create a plot comparing the fit with the step function.

18.6 Develop an M-file to compute a cubic spline fit with

natural end conditions. Test your code by using it to dupli- cate Example 18.3.

18.7 The following data were generated with the fifth-

order polynomia l: f x = 0.0185x 5 − 0.444x 4 + 3.9125x 3 − 15.456x 2 + 27.069x − 14.1: x 1 3 5 6 7 9 f x 1.000 2.172 4.220 5.430 4.912 9.120 a Fit these data with a cubic spline with not-a-knot end conditions. Create a plot comparing the fit with the function. b Repeat a but use clamped end conditions where the end slopes are set at the exact values as determined by differen- tiating the function. 18.8 Bessel functions often arise in advanced engineering and scientific analyses such as the study of electric fields. These functions are usually not amenable to straightforward evaluation and, therefore, are often compiled in standard mathematical tables. For example, x 1.8 2 2.2 2.4 2.6 J 1 x 0.5815 0.5767 0.556 0.5202 0.4708 Estimate J 1

2.1, a using an interpolating polynomial and b

using cubic splines. Note that the true value is 0.5683.

18.9 The following data define the sea-level concentra-

tion of dissolved oxygen for fresh water as a function of temperature: T , ⴗC 8 16 24 32 40 o , mgL 14.621 11.843 9.870 8.418 7.305 6.413 Use MATLAB to fit the data with a piecewise linear inter- polation, b a fifth-order polynomial, and c a spline. Dis- play the results graphically and use each approach to estimate o 27. Note that the exact result is 7.986 mgL.

18.10 a

Use MATLAB to fit a cubic spline to the follow- ing data to determine y at x = 1.5: x 2 4 7 10 12 y 20 20 12 7 6 6 b Repeat a, but with zero first derivatives at the end knots. 18.11 Runge’s function is written as f x = 1 1 + 25x 2 Generate five equidistantly spaced values of this function over the interval: [⫺1, 1]. Fit these data with a a fourth- order polynomial, b a linear spline, and c a cubic spline. Present your results graphically. 18.12 Use MATLAB to generate eight points from the function f t = sin 2 t from t = 0 to 2π. Fit these data using a cubic spline with not-a-knot end conditions, b cubic spline with derivative end conditions equal to the exact values calculated with dif- ferentiation, and c piecewise cubic hermite interpolation. Develop plots of each fit as well as plots of the absolute error E t = approximation − true for each. 18.13 The drag coefficient for spheres such as sporting balls is known to vary as a function of the Reynolds number Re, a dimensionless number that gives a measure of the ratio of inertial forces to viscous forces: Re = ρ VD μ where ρ = the fluid’s density kgm 3 , V = its velocity ms, D = diameter m, and μ = dynamic viscosity N · sm 2 . PROBLEMS 457