clc
clear all
close all

%% 1
[x,y]=meshgrid(linspace(-15,15),linspace(-15,15));
z=4*(x-1).^2+25*(y-2).^2;
contour(x,y,z,100)
hold on
y=-5:0.0001:5;
x=-(y-1).^2-5;
plot(x,y,'r')
axis([-10 10 -10 10])
grid on
plot([0-5.1144,-48.9152-5.1144],[0+1.3382,-33.09+1.3382],'k')
plot([0-5.1144,1-5.1144],[0+1.3382,0.6764+1.3382],'m')

%% 2
[x,y]=meshgrid(linspace(-12,12),linspace(-12,12));
z=4*(x-1).^2+25*(y-2).^2;
figure
contour(x,y,z,100)
hold on
y=-5:0.0001:6;
x=-(y-1).^2+8;
plot(x,y,'r')
axis([-10 10 -10 10])
grid on
plot([0+2.7599,14.0788+2.7599],[0+3.2891,64.455+3.2891],'k')
plot([0+2.7599,1+2.7599],[0+3.2891,4.5782+3.2891],'m')

%% 3
[x,y]=meshgrid(linspace(-15,15),linspace(-15,15));
z=9*(x-2).^2+25*(y-1).^2;
figure
contour(x,y,z,100)
hold on
y=-5:0.0001:5;
x=y.^2+5;
plot(x,y,'r')
axis([-15 15 -15 15])
grid on
plot([0+5.096,55.728+5.096],[0+0.3097,-34.515+0.3097],'k')
plot([0+5.096,-1+5.096],[0+0.3097,0.6194+0.3097],'m')

%% 4
[x,y]=meshgrid(linspace(-12,12),linspace(-12,12));
z=9*(x-2).^2+25*(y-1).^2;
figure
contour(x,y,z,100)
hold on
y=-5:0.0001:5;
x=y.^2-5;
plot(x,y,'r')
axis([-10 10 -10 10])
grid on
plot([0+1.1703,-14.9346+1.1703],[0+2.484,74.2+2.484],'k')
plot([0+1.1703,-1+1.1703],[0+2.484,4.968+2.484],'m')

%% 5
[x,y]=meshgrid(linspace(-12,12),linspace(-12,12));
z=16*(x-1).^2+9*(y+1).^2;
figure
contour(x,y,z,100)
hold on
x=-5:0.0001:5;
y=x.^2+5;
plot(x,y,'r')
axis([-10 10 -10 10])
grid on
plot([0+0.1287,-27.8816+0.1287],[0+5.017,108.3060+5.017],'k')
plot([0+0.1287,0.2574+0.1287],[0+5.017,-1+5.017],'m')

%% 6
[x,y]=meshgrid(linspace(-9,9),linspace(-9,9));
z=25*(x+1).^2+9*y.^2;
figure
contour(x,y,z,100)
hold on
x=-5:0.0001:5;
y=x.^2-5;
plot(x,y,'r')
axis([-9 9 -9 9])
grid on
plot([0-2.0694,-54.47-2.0694],[0-0.7177,-12.919-0.7177],'k')
plot([0-2.0694,-4.1388-2.0694],[0-0.7177,-1-0.7177],'m')

%% 7
[x,y]=meshgrid(linspace(-10,10),linspace(-10,10));
z=9*(x+1).^2+4*(y-1).^2;
figure
contour(x,y,z,100)
hold on
x=-5:0.0001:5;
y=-x.^2-5;
plot(x,y,'r')
axis([-10 10 -10 10])
grid on
plot([-0.1573,15.1686-0.1573],[0-5.025,-48.2-5.025],'k')
plot([0-0.1573,-0.3146-0.1573],[0-5.025,1-5.025],'m')

%% 8
[x,y]=meshgrid(linspace(-10,10),linspace(-10,10));
z=25*(x-1).^2+4*(y+1).^2;
figure
contour(x,y,z,100)
hold on
x=-5:0.0001:5;
y=-x.^2+5;
plot(x,y,'r')
axis([-10 10 -10 10])
grid on
plot([0+2.0904,54.52+2.0904],[0+0.6301,13.0408+0.6301],'k')
plot([0+2.0904,4.1808+2.0904],[0+0.6301,1+0.6301],'m')