============================================================================== areaSlice.m ============================================================================== % % 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); ============================================================================== volumeDisk.m ============================================================================== % % 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); ============================================================================== volDiskLess20.m ============================================================================== % % 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 vol = volDiskLess20(t) vol = volumeDisk(t) - 20;