I want to work out the moment of inertia of a solid cylinder of radius $r$, length $l$ and mass $M$ about an axis through the centre of the cylinder.
My approach was to line the central axis of the cylinder with the $x$-axis and consider a small cylindrical element of thickness $dx$. Then my mass element would be $dm = \rho \pi r^2 dx$, where $\rho$ is the mass per unit volume (density).
Using the formula for moment of inertia and integrating from $0$ to $l$, I then find the answer to be $Mr^2$. Now that is wrong, there should be a factor of $\frac{1}{2}$ in there. But I don't understand why. Some solutions I've seen online consider concentric disks, but I don't understand why this method isn't working.