%
% SHOOTM1.M Example of Shooting Method for Solving 2-Point BVPs
% (Manual Iterative Procedure)
%
% This demo solves a particular 2nd order ODE using an iterative form of
% the shooting method. The variable ALF is chosen interactively. This is
% discussed as Example 5.1 Case 1 Manual Interactive Iteration in the course
% notes for Math Methods (10/24.539).
%
% The goal is to find the value of the free parameter, ALF = y'(0) which,
% upon solution of the IVP, satisfies the desired boundary condition at x = pi.
%
% also see SHOOTF.M - contains description of given differential equation
% y'' + 3xy' + 7y = cos(2x) with y(0) = 1 and y(pi) = 0
%
% also see related files:
% SHOOTM2.M - shows multiple curves of y(x) for different ALF
% SHOOTA.M - solves same problem using an automated iterative scheme
% BVP2SH.M - implements Shooting Method for 2nd order BVP with linear BCs
%
% Files prepared by J. R. White, UMass-Lowell (Aug. 2003)
%
%
% getting started
clear all, close all
%
% set domain limits and tolerance for ODE23
xo = 0; xf = pi; tol = 1e-6;
%
% specify desired BCs
yxo = 1.0; yxf = 0;
%
% set format for edit to long words (more significant digits)
format long
%
% guess at initial conditions (note that ALF is defined manually)
ALF = input('Input initial guess for free parameter (ALF) = ')
%
% start looping (for various values of ALF)
options = odeset('RelTol',tol);
while ALF ~= 0
zo = [yxo ALF]';
%
% call ODE23
[x,z] = ode23('shootf',[xo xf],zo,options);
%
% plot results for visual inspection of solution at each iteration
plot(x,z(:,1),'LineWidth',2),title('ShootM1: Shooting Method for ODEs')
xlabel('x values'),ylabel('y values'),grid
%
% edit error in BC at second boundary point (x = xf)
[nr,nc] = size(z);
eps = z(nr,1)-yxf;
disp(' ')
disp(' Error in 2nd BC'), eps
ALF = input('Enter another guess for ALF (zero to quit)? ')
end
disp('Manual iterative procedure terminated by user...')
%
% end demo