Page 317 - Applied Numerical Methods Using MATLAB
P. 317
306 ORDINARY DIFFERENTIAL EQUATIONS
Noting that the initial derivative of the true solution for Eq. (6.6.3) is
zero, apply this routine to solve the BVP by inserting the following
statement into the program “do_shoot.m”.
[t,x1] = bvp2_shootp(’df661’,t0,tf,0,xf,N,tol,kmax);
and plot the result to check if it conforms with that (Fig. 6.8) obtained
by “bvp2_shoot()”.
(b) As for “bvp2_fdfp()” implementing the finite difference method, you
have to approximate the boundary condition as
x 1 − x −1
x (t 0 ) = x 20 → = x 20 , x −1 = x 1 − 2hx 20 , (P6.6.2)
2h
substitute this into the finite difference equation corresponding to the
initial time as
x 1 − 2x 0 + x −1 x 1 − x −1
+ a 10 + a 00 x 0 = u 0 (P6.6.3)
2
h 2h
x 1 − 2x 0 + x 1 − 2hx 20
+ a 10 x 20 + a 00 x 0 = u 0
2
h
2 2
(a 00 h − 2)x 0 + 2x 1 = h u 0 + h(2 − ha 10 )x 20 (P6.6.4)
and augment the matrix–vector equation with this equation. Also, make
its declaration part have the initial derivative (dx0) instead of the initial
position (x0) as the sixth input argument as follows:
function [t,x] = bvp2_fdfp(a1,a0,u,t0,tf,dx0,xf,N)
Noting that the initial derivative of the true solution for Eq. (6.6.10)
is −7, apply this routine to solve the BVP by inserting the following
statement into the program “do_fdf.m”.
[t,x1] = bvp2_fdfp(a1,a0,u,t0,tf,-7,xf,N);
and plot the result to check if it conforms with that obtained by using
“bvp2_fdf()” and depicted in Fig. 6.9.
6.7 BVP with Mixed-Boundary Conditions I
Suppose the boundary condition for a second-order BVP is given as
x(t 0 ) = x 10 , c 1 x(t f ) + c 2 x (t f ) = c 3 (P6.7.1)
Consider how to modify the MATLAB routines “bvp2_shoot()”and
“bvp2_fdf()” so that they can accommodate this kind of problem.