Mass of a spherical cap with height-proportional density (source code)

= Mass of a spherical cap with height-proportional density
{title2=$M=\frac{\pi k}{4}(R^2-c^2)^2$}

For a solid <spherical cap> $r^2+z^2\leq R^2$, $z\geq c$, where $0\leq c\leq R$ and the <mass density> is $\rho=kz$ with $k\geq0$, a <volume integral> in <cylindrical coordinates> gives
$$
M=\pi k\int_c^Rz(R^2-z^2)\,dz=\frac{\pi k}{4}(R^2-c^2)^2.
$$
Here the height is measured from the centre of the <sphere>, rather than from the bottom of the cap. Specifying that origin matters for a nonuniform <mass density>.