% This is a matlab m-file that
% computes approximations for the first order 
% hyperbolic equation using finite differences
%
%   a(x,y,u) u_x + b(x,y,u) u_y = c(x,y,u)
%   
%   u = given on some boundary
%
% (DMA, 6-2-07)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
%
% given initial data
%
xR=1;yR=0;uR=xR;xP=1.1;   %E.B.Y. problem on p. 70
xR=1;yR=0;uR=1;xP=1.1;    %E.B.Y. homework 3.1 (p. 71)
%
%
%
N=10;
abc=fun_hyper1st(xR,yR,uR);
aR=abc(1,1);
bR=abc(2,1);
cR=abc(3,1);
sumA=aR;
sumB=bR;
sumC=cR;
for i=1:N
    yPi(i)=yR+(sumB/sumA)*(xP-xR);
    uPi(i)=uR+(sumC/sumA)*(xP-xR);
    abc=fun_hyper1st(xP,yPi(i),uPi(i)); 
    aPi=abc(1,1);
    bPi=abc(2,1);
    cPi=abc(3,1);
    sumA=aR+aPi;
    sumB=bR+bPi;
    sumC=cR+cPi;
end
[yPi' uPi']