Similarly, for the sphere, set up spherical coordinates so that the sphere, of radius R, has center at (0,0,0) and the axis of rotation is the z-axis. Then the distance from each point to the axis is just the projection to the xy-plane, [tex]\rho sin\phi[/tex] and differential of volume is [tex]\rho^2sin\phi d\rho d\phi d\theta[/tex] so the moment of inertia, with density [tex]\lambda[/tex] is given by
[tex]\int_0^\pi\int_0^{2\pi}\int_0^R(\lambda\rho^4sin^3\phi)d\rho d\theta d\phi[/tex]
= [tex]\lambda (\int_0^{2\pi} d\theta )(\int_0^R\rho^4d\rho)(\int_0^\pi sin^3\phi d\phi)[/tex]
The first two of those can be integrated directly and give
[tex](2\pi)(\frac{1}{5}R^5)[/tex].
To integrate the third, let [tex]u= cos\phi[/tex] and we get
[tex]\frac{4}{3}[/tex]. The moment of inertia is given by
[tex]\frac{8}{15}\pi\lambda R^5[/tex].
Since the mass is M= [tex]\lambda\frac{4}{3}R^3[/tex], the moment of inertia is [tex]\frac{2}{5}\pi R^2[/tex].