Page 319 - Applied Numerical Methods Using MATLAB
P. 319

308    ORDINARY DIFFERENTIAL EQUATIONS
                      Needless to say, you should increase the dimension of the matrix A
                    to N and move the x N term on the right-hand side of the (N − 1)th row
                    back to the left-hand side by incorporating the corresponding statement
                    into the for loop. What you have to do with “bvp2m_fdf()” for this
                    job is as follows:
                    ž Make the declaration part have the boundary coefficient vector cf =
                     [c1 c2 c3] instead of the final position (xf) as the seventh input
                     argument.

                      function [t,x] = bvp2m_fdf(a1,a0,u,t0,tf,x0,cf,N)
                    ž Replace some statement by A = zeros(N,N).
                    ž Increase the last index of the for loop to N-1.
                    ž Replace the statements corresponding to the (N − 1)th row
                     equation by

                      A(N,N-1:N) = [-cf(2) cf(1)*h + cf(2)];   b(N) = cf(3)*h;
                     which implements Eq. (P6.7.4).
                    ž Modify the last statement arranging the solution as

                      x = [x0 trid(A,b)’]’;

                     Now that you have the routine “bvp2m_fdf()” of your own making,
                     don’t hesitate to try it on the following problem:

                             2        2

                      x (t) + x (t) −  x(t) = 0   with x(1) = 5,x(2) + x (2) = 3
                              t      t 2
                                                                        (P6.7.5)
                     For this job, you only have to modify one statement of the program
                     “do_fdf.m” (Section 6.6.2) into
                      [t,x] = bvp2m_fdf(a1,a0,u,t0,tf,x0,[1 1 3],N);

                     You might need to increase the number of segments N to improve the
                     accuracy of the numerical solution. If you run it to obtain the same
                     solution as depicted in Fig. 6.9, be happy with it.
            6.8 BVP with Mixed-Boundary Conditions II

                Suppose the boundary condition for a second-order BVP is given as


                                     c 01 x(t 0 ) + c 02 x (t 0 ) = c 03  (P6.8.1a)

                                    c f 1 x(t f ) + c f 2 x (t f ) = c f 3  (P6.8.1b)
                Consider how to modify the MATLAB routines “bvp2m_shoot()”and
                “bvp2m_fdf()” so that they can accommodate this kind of problems.
   314   315   316   317   318   319   320   321   322   323   324