% Convergence Team Lab % Part 1 %% Find the volume of two portions of a hemisphere. %% The function crossSection(x) computes the cross sectional area. disp([' ' ]) % Get a blank line X = 0; volPartSphere = quad('crossSection', -3, X); disp([' For x = ', num2str(X),' the volume of the piece of the hemisphere is ',... num2str(volPartSphere) ]) check = (4/3)*pi*3^3 / 4; disp([' If everything is correct, then ', num2str(volPartSphere), ... ' must equal ', num2str(check)]) X = 1.5; volPartSphere = quad('crossSection', -3, X); disp([' For x = ', num2str(X),' the volume of the piece of the hemisphere is ',... num2str(volPartSphere) ]) % Part 2 %% Compute the volume of the torus. % Find the volume at t = 2 t = 2; vol = quad('areaShell', 1, t); disp([' For x = ', num2str(t),' the volume of the torus is ', num2str(vol) ]) % Find the volume at t = 3 t = 3; vol = quad('areaShell', 1, t); disp([' For x = ', num2str(t),' the volume of the torus is ', num2str(vol) ]) %% Put the volume in a function and do it again. t = 2; vol = volumeTorus(t) ; disp([' For x = ', num2str(t),' the volume of the torus is ', num2str(vol) ]) t = 3; vol = volumeTorus(t); disp([' For x = ', num2str(t),' the volume of the torus is ', num2str(vol) ]) %% Find the value of t so that the volume of that piece of %% the torus is 20. tShell = fzero('volLess20', 2); disp([' For problem 2.b the volume is 20 when x = ', num2str(tShell) ]) % Part 3 %% Find the value of t so that the volume of that piece of %% the torus is 20. tSlice = fzero('volDiskLess20', 0.5); disp([' For problem 3 the volume is 20 when y = ', num2str(tShell) ])function area = crossSection(x) % This function gives the area of the half circle that % intersects the hemisphere at x. radius = sqrt( 9 - x.^2 ); area = 0.5*pi*radius.^2 ;% % Computes the area of the shell taken by cutting the torus given by % (x - 2)^2 + y^2 = 1 % parallel to the y-axis at x. % function a = areaShell(x) % Area of the shell at x is 2*pi*x*ht(x) % where ht(x) is the height of the shell at x height = 2*sqrt(1 - (x - 2).^2); a = 2*pi*x.*height;% % Computes the volume of the solid obtained by cutting the torus along % the x-axis at t. % function vol = volumeTorus(t) vol = quad('areaShell', 1, t);% % Computes (the volume of the solid obtained by cutting the torus along % the x-axis at t ) - 20 % % It's necessary to do this to use the function with Matlab's fzero % function (which assumes equations are set up in standard form: % f(x) = 0). % function getToZero = volLess20(t) getToZero = volumeTorus(t) - 20;% % Computes the area of a slice of the torus parallel to the x-axis % taken at height y. % function a = areaSlice(y) radiusOuter = 2 + sqrt(1 - y.^2); % radius of outer disk radiusInner = 2 - sqrt(1 - y.^2); % radius of inner disk % area = area of outer disk - area of inner disk a = pi*(radiusOuter.^2 - radiusInner.^2);% % Computes the volume of the solid obtained by slicing the torus % (x - 2)^2 + y^2 =1 % parallel to the x-axis at t and -t. % function vol = volumeDisk(t) % take the volume from 0 to t and double it to get the volume from % -t to t vol = 2 * quad('areaSlice', 0, t);% % Computes (the volume of the solid obtained by slicing the torus % parallel to the x-axis at t and -t) - 20. % % It's necessary to do this to use the function with Matlab's fzero % function (which assumes equations are set up in standard form: % f(x) = 0). % function getToZero = volDiskLess20(t) getToZero = volumeDisk(t) - 20;