%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Team Lab Solution
% Convergence: Volumes of Revolution
% Fall 2003
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Problem 1')

% Display volume of entire hemisphere
vol = 0.5 * (4/3*pi*3^3);
disp(['Volume of entire hemisphere is ', num2str(vol)])

% Find volume when X = 0
X = 0;
vol = quad('areaHemisphere', -3, X);
disp(['When X = ', num2str(X), ' the volume is ', num2str(vol)])

% Find volume when X = 1.5
X = 1.5;
vol = quad('areaHemisphere', -3, X);
disp(['When X = ', num2str(X), ' the volume is ', num2str(vol)])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Problem 2')

% Part 2.a
% Volume for t = 2
vol2 = volumeTorus(2);
disp(['The volume for t = 2 is ', num2str(vol2)])

% Volume for t = 3
vol3 = volumeTorus(3);
disp(['The volume for t = 3 is ', num2str(vol3)])

% Part 2.b: find the value of t so that the volume is 20
t = fzero('volLess20', 2);
disp(['The value of t where volume = 20 is ', num2str(t)])


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Problem 3')
t = fzero('volDiskLess20', 0.5);
disp(['The value of t where volume = 20 is ', num2str(t)])
