%%% Convergence Team Lab Solution %% Problem 1. %% Area of Sphere ............................................. function area = areaSphere( x) % This function computes the area of a half a cross section of a sphere. rad = sqrt( 9 - x.^2) ; area = 0.5*pi*rad.^2 ; ............................................. %% Volume of a Sphere function vol = volumeSphere( X ) % This function computes the volume of the sphere from -3 to X. vol = quad( 'areaSphere', -3, X ) ; ............................................. % When is volume = 20? In preparation for later sections. function z = tobezeroSphere( X) % This is the function passed to fzero. z = volumeSphere(X) - 20 ; ............................................. % To find the value of x where the volume is 20, use x = fzero( 'tobezeroSphere', -2, 2 ) ......................................................................... %% Problem 2 %% Area of Torus function area = areaTorus2(x) % This function computes the area of a shell of the torus. y = sqrt( 1 - (x-2).^2 ) ; height = 2.*y ; area = 2*pi*height.*x ; ............................................. function vol = volumeTorus2( x) % This function computes the volume of the torus from 1 to X. vol = quad( 'areaTorus2', 1, x) ; ............................................. % When is volume = 20? function z = tobezeroTorus2( x ) % This is the function passed to fzero for Problem 2. z = volumeTorus2(x) - 20 ; ............................................. % To find the value of x where the volume is 20, use x = fzero( 'tobezeroTorus2', 1.8, 2.3 ) ......................................................................... % Problem 3 function area = areaTorus3(y ) % This function computes the area of the disk for part 3. rad1 = 2 - sqrt( 1 - y.^2 ) ; rad2 = 2 + sqrt( 1 - y.^2 ) ; area = pi*( rad2.^2 - rad1.^2 ) ; ............................................. function vol = volumeTorus3( s ) % This function computes the volume of the torus from -s to s. vol = 2*quad( 'areaTorus3', 0, s ) ; ............................................. function z = tobezeroTorus3(s) % This is the function passed to fzero for Problem 3. z = volumeTorus3(s ) - 20 ; ............................................. % To find the value of x where the volume is 20, use x = fzero( 'tobezeroTorus3', 0, .8 )