Quiz #5, Exercise #1

Start with

z^2 - x^2 -4y^2 = 4,

substitute

x = r cos(theta) and y = r sin(theta), then solve for r to produce

r = sqrt((z^2 - 4)/(cos^2(theta) + 4sin^2(theta)).

The domain is {(theta,z): 0 <= theta <= 2pi, abs(z) >= 2}.

% close all open figure window
close all

% graph the lower half
% Set up the grid on the domain
theta=linspace(0,2*pi,40);
z=linspace(-3,-2,20);
[theta,z]=meshgrid(theta,z);

% compute r
r=sqrt((z.^2-4)./(cos(theta).^2+4*sin(theta).^2));

% compute x and y
x=r.*cos(theta);
y=r.*sin(theta);

% mesh the surface
mesh(x,y,z)

% hold the graph
hold on

% graph the upper half
% Set up the grid on the domain
theta=linspace(0,2*pi,40);
z=linspace(2,3,20);
[theta,z]=meshgrid(theta,z);

% compute r
r=sqrt((z.^2-4)./(cos(theta).^2+4*sin(theta).^2));

% compute x and y
x=r.*cos(theta);
y=r.*sin(theta);

% mesh the surface
mesh(x,y,z)

% annotate
xlabel('x-axis')
ylabel('y-axis')
title('z^2 - x^2 -4y^2 = 4')

% rotate the view
view(130,35)

% equalize the axes
axis equal