% This is a matlab m-file that
% computes approximations for the second order 
% hyperbolic equation using finite differences
% (actually just takes one step along two crossing
% characteristics).
%
%   a(x,y,u,p,q) u_xx + b(x,y,u,p,q) u_xy +  c(x,y,u,p,q) u_yy + e(x,y,u,p,q) =0
%
%   where p=du/dx and q=du/dy
%
%   u,p,q = given on some boundary
%
% (DMA, 6-5-07)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
%
% given initial data
%
xA=0.1;yA=0;                    %E.B.Y. problem on p. 83
xB=0.2;yB=0;
upq=upq_hyper2nd(xA,yA);
uA=upq(1,1);
pA=upq(2,1);
qA=upq(3,1);
upq=upq_hyper2nd(xB,yB);
uB=upq(1,1);
pB=upq(2,1);
qB=upq(3,1);
abc=abc_hyper2nd(xA,yA,uA,pA,qA);
aA=abc(1,1);
bA=abc(2,1);
cA=abc(3,1);
eA=abc(4,1);
abc=abc_hyper2nd(xB,yB,uB,pB,qB);
aB=abc(1,1);
bB=abc(2,1);
cB=abc(3,1);
eB=abc(4,1);
fg=fg_hyper2nd(xA,yA,uA,pA,qA);
fA=fg(1,1);
gA=fg(2,1);
fg=fg_hyper2nd(xB,yB,uB,pB,qB);
fB=fg(1,1);
gB=fg(2,1);
%
%
%
Axy=[fA -1;gB -1];
bxy=[xA*fA-yA;xB*gB-yB];
xy=Axy\bxy;
xP=xy(1,1);
yP=xy(2,1);
%
%
%
Apq=[aA*fA cA;aB*gB cB];
bpq=[aA*fA*pA+cA*qA-eA*(yP-yA);aB*gB*pB+cB*qB-eB*(yP-yB)];
pq=Apq\bpq;
pP=pq(1,1);
qP=pq(2,1);
%
%
%
uP=uA+0.5*((pA+pP)*(xP-xA)+(qA+qP)*(yP-yA));
%uP=uB+0.5*((pB+pP)*(xP-xB)+(qB+qP)*(yP-yB));

[xP yP pP qP uP]
