# # Numerical Mathematics and Computing, Fifth Edition # Ward Cheney & David Kincaid # Brooks/Cole Publ. Co. # (c) 2003 # # file: cubic_spline2 # # Generate and plot the cubic spline function # for the following data: # (x,y) = {(.0,-.8),(.6,-.34),(1.5,.59),(1.7,.59),(1.9,.23), # (2.1,.1),(2.3,.28),(2.6,1.03),(2.8,1.5),(3,1.44), # (3.6,.74),(4.7,-.82),(5.2,-1.27),(5.7,-.92),(5.8,-.92) # (6,-1.04),(6.4,-.79),(6.9,-.06),(7.6,1),(8,0)} readlib(spline): S := spline([0,.6,1.5,1.7,1.9,2.1,2.3,2.6,2.8,3, 3.6,4.7,5.2,5.7,5.8,6,6.4,6.9,7.6,8], [-.8,-.34,.59,.59,.23,.1,.28,1.03,1.5, 1.44,.74,-.82,-1.27,-.92,-.92,-1.04, -.79,-.06,1,0], x, cubic); plot(S(x), x=0..8);