%
% Computes the area of a slice of the hemisphere perpendicular to the
% base at distance x from the center.
%
function a = areaHemisphere(x)

% The cross-section is a half-circle whose diameter is parallel to
% the y-axis and lies inside the circle x^2 + y^2 = 9

radius = sqrt(9 - x.^2);  % note use of .^ (element-wise operations)
a = 0.5*pi*radius.^2;