Page 174 - Applied Numerical Methods Using MATLAB
P. 174

PROBLEMS   163
                    where the left-hand and right-hand sides of this equation are


                           x k+1

                    LHS:      f (x)s (x) dx

                          x k
                                         x k+1

                                  x k+1
                      = f (x)s (x)|  −      f (x)s (x) dx
                                  x k
                                        x k




                      = f (x k+1 )s (x k+1 ) − f (x k )s (x k ) − C(f (x k+1 ) − f(x k )) (P3.7.3a)

                           x k+1


                    RHS:      s (x)s (x) dx
                          x k




                      = s (x k+1 )s (x k+1 ) − s (x k )s (x k ) − C(s(x k+1 ) − s(x k ))  (P3.7.3b)
                (b) Check the validity of the following inequality:
                           x k+1           2



                     0 ≤      (f (x) − s (x)) dx
                          x k
                           x k+1              x k+1              x k+1

                                    2
                                                                          2




                       =      (f (x)) dx − 2     f (x)s (x) dx +    (s (x)) dx
                          x k                x k                x k

                              x k+1            x k+1
                      (P3.7.2)         2                2
                        =        (f (x)) dx −     (s (x)) dx
                             x k              x k

                           x k+1            x k+1
                                    2                2
                             (f (x)) dx ≤      (s (x)) dx               (P3.7.4)
                          x k              x k
             3.8 MATLAB Built-in Routine for Cubic Spline
                There are two MATLAB built-in routines:
                 >>yi = spline(x,y,xi);
                 >>yi = interp1(x,y,xi,’spline’);
                Both receive a set of data points (x,y) and return the values of the cubic
                spline interpolating function s(x) for the (intermediate) points xi given as
                the third input argument. Write a program that uses these MATLAB routines
                to get the interpolation for the set of data points
                               {(0, 0), (0.5, 2), (2, −2), (3.5, 2), (4, 0)}
                and plots the results for [0, 4]. In this program, append the statements that
                do the same job by using the routine “cspline(x,y,KC)” (Section 3.5) with
                KC = 1, 2, and 3. Which one yields the same result as the MATLAB built-
                in routine? What kind of boundary condition does the MATLAB built-in
                routine assume?
   169   170   171   172   173   174   175   176   177   178   179