# Calculating volume of a sphere using cross-sectional area

I wish to derive a formula for the volume of a sphere of radius $$R$$ using its cross-sectional area $$A(r)=\pi (R-|r|)^2$$, where $$r$$ ranges from $$-R$$ to $$R$$. The below is my attempt.

\begin{align*} V&=\int_{-R}^R A(r) dr \\ &=\int_{-R}^R \pi (R-|r|)^2 dr \\ &=\pi\int_{-R}^R (R^2-2R|r|+|r|^2) dr \\ &=\pi R^2\int_{-R}^R dr-2\pi R\int_{-R}^R |r|dr+\pi\int_{-R}^R|r|^2dr \\ &=2\pi R^3-4\pi R\int_0^R r dr+2\pi\int_0^R r^2 dr \\ &=2\pi R^3-2\pi R^3+2\pi \cdot \frac{R^3}{3} \\ &=\frac23 \pi R^3 \end{align*}

Why I got the formula for the volume of a hemisphere instead?

You are using the wrong formula for the area. The radius of the cross-section at height $$h$$ will be $$r^2=R^2-h^2$$ by the Pythagoras theorem. So the area is given by $$A(h)=\pi r^2=\pi(R^2-h^2)$$. Integrating it from $$-R$$ to $$R$$ you have
$$\int_{-R}^R\pi(R^2-h^2)dh=\pi R^2h|_{-R}^R-\frac{\pi h^3}{3}|_{-R}^R=2\pi R^3-\frac{2}{3}\pi R^3=\frac{4}{3}\pi R^3$$