%
%   SF_DEMO3.M  Plot slope field for function f(x,y) = x^2 - y^2 
%
%   This problem comes from Prob. 30 pg. 27 of the 2nd Ed. of Edwards and Penny 
%   (Prentice Hall, 2000).  It generates the slope field and solution curves 
%   for y' = x^2 - y^2.
%
%   Calls SF_DEMO3_EQN.M to evaluate desired function
%         SFIELD.M to plot slope field
%
%   File prepared by J. R. White, UMass-Lowell (Feb. 2005)
%
      
%
%   getting started
      clear all;   close all;   nfig = 0;
%
%   use SFIELD to plot slope field
      v = [0 5 -4 4];    % [minx maxx miny maxy]
      sfield('sf_demo3_eqn',v,25);  axis(v);
      title('SF\_Demo3: Slope Field and Solution Curves for y'' = x^2 - y^2')
      xlabel('x values'),ylabel('y values')
      hold on
%
%   let's find the solution curve for several different initial conditions (use ODE23)
      xo = 0;   xf = 5;   yo = [-3 -1 0 1 3];   Ni = length(yo);
      for n = 1:Ni
        [x,y] = ode23('sf_demo3_eqn',[xo xf],yo(n));
        plot(x,y,'r-',xo,yo(n),'g*','LineWidth',2)
      end
      hold off
%
%   end of problem
