%% Problem 11

%% (a) Find solutions of nonlinear system using solve
% Matlab finds two solutions for (x,y): 
% The point (1,0) and the point (5/3,-4/3).
syms x y real               % declare x, y as real symbolic variables
f1 = x^2 - y^2 - 1
f2 = 2*x + y - 2
[xs,ys] = solve(f1,f2,x,y)  % find all x,y such that f1=0 and f2=0
                            % 1st solution is xs(1), ys(1)
                            % 2nd solution is xs(2), ys(2)

%% (b) Plot two curves and solution points
%  We plot the points in the rectangle -3<x<3, -3<y<3 where f1=0 and f2=0:
ezplot(f1,[-3 3 -3 3]); hold on  % f1=0 gives hyperbola
ezplot(f2,[-3 3 -3 3]);          % f2=0 gives straight line
plot(double(xs),double(ys),'ro'); hold off 
                           % mark two intersection points with read circles


