%Math 316 - Spring 2017
%Written by M. Motamed @ UNM 
%========================================================
%EXAMPLE 7 of Chapter 2. 
%IVP: (2 - sin(y)*cos(x))*y'=cos(y)*sin(x)+1 & y(0)=0
%========================================================

[x,y]=meshgrid((0:.02:5),(-5:.02:5));
psi=@(x,y) cos(x).*cos(y)-x+2*y;

%(a) the 3-dimensional illustration of the function psi of two variables
figure
surf(x,y,psi(x,y)); 
shading interp
xlabel('x')
ylabel('y')
zlabel('\Psi')
set(gca,'fontsize', 20);

%pause
%(b) the countour level illustration of the function psi of two variables
figure
[C,h]=contour(x,y,psi(x,y),[-5 -2 -1 0 1 2 5],'Linewidth',1.5); 
clabel(C,h)
xlabel('x')
ylabel('y')
set(gca,'fontsize', 20);

%pause
%(c) plotting the solution using its implicit form 
x0=0; y0=0;
figure
contour(x,y,psi(x,y),[1 1],'b','Linewidth',1)
hold on
plot(x0,y0,'*r','Linewidth',3)
xlabel('x')
ylabel('y')
set(gca,'fontsize', 20);
