Calculating moment of inertia for a cylinder? I'm trying to calculate the moment of inertia for a cylinder about a longitudinal axis, but I don't know where I went wrong with my approach. 
$$I=\int r^2 dm$$
Assuming constant density:
$$\frac{M}{V} = \frac{dm}{dv} $$
Then in order to find $dv$ I found the volume by summing all the chords in the base of the cylinder from R to -R and multiplying my the length of the cylinder. (Where $R$ is the radius and $r$ is the distance from the axis of rotation, which I kept at the origin.
$$V = 2L\int \sqrt{R^2-r^2} dr$$
Thus,
$$dv = 2L\sqrt{R^2-r^2} dr$$
And I know that the volume of the cylinder is:
$$V = πR^2L$$
So then...
$$dm = \frac{2M}{πR^2}\sqrt{R^2-r^2}$$
Substituting the original definition of moment of inertia from $-R$ to $R$ gives me:
$$\frac{2M}{πR^2}\int_{-R}^{R}r^2\sqrt{R^2-r^2}dr = \frac{1}{4}MR^2$$
However, the moment of inertia I looked up in a physics textbook is exactly two times this (the factor is $1/2,$ not $1/4$). I also solved for the moment of inertia of a sphere and similarly got exactly half of the accepted answer. I have looked over this thoroughly and don't know where I went wrong, but I suspect it is something to do with my integrating bounds?
 A: Suppose that the length of the cylinder is $L$,  the radius of the cross section is $R$. We choose cylindrical coordinates to solve the question.
The momentum of inertia is that,
$$
I=\int s^2dm,
$$
and we assume the density is constant, we have,
$$
I=\int s^2 \rho dv.
$$
In cylindrical coordinates, $dv=sds\;dz\;d\theta$, so we get,
\begin{align}
I&=\rho\cdot \int\int\int s^2\cdot sds\;dz\;d\theta \\&
 =\rho\int_0^R s^3ds\int_0^Ldz\int_0^{2\pi}d\theta \\
& =\rho\cdot 2\pi \cdot L\cdot \frac{R^4}{4} \\
&  =\frac{ \rho \pi R^4L}{2}
.\end{align}
Then we substitute $\rho=\frac{M}{V}=\frac{M}{\pi R^2 L}$ into the above equation, we have
\begin{align}
I&=\frac{M}{\pi R^2 L} \cdot \frac{\pi R^4 L}{2} \\
& =\frac{1}{2}MR^2.
\end{align}
A: What is wrong with your answer?
I am going to write an answer explaining why your solution is wrong, because I don't think a comment would be enough. First, I am going to make a change of variable. You used the variable $r$ to refer to the distance from the axis of the cylinder. I feel more comfortable using the symbol $x$ for this variable, so that is what I am going to. The reason I fee more comfortable with this choice is because you don't integrate over cylindrical shells of radius $r$; you integrate over surfaces of constant $x$.
Anyway, let's look at what you did. Your equation $$dV = 2L \sqrt{R^2-x^2}dx$$ is correct. This is great so far.
The next equation I want to look at is
$$dm = \frac{2M}{\pi R^2}\sqrt{R^2-x^2}dx.$$
Notice you forgot the $dx$ in your original question, but its obvious that is what you meant. Now let's think about what this equation means. It means that the mass in the surface of constant $x$ of width $dx$ is the $dm$ given by the equation. This equation is also totally fine, but it isn't as useful as you think.
I do have a problem with your next equation. Your next equation is 
$$I = \frac{2M}{\pi R^2}\int x^2 \sqrt{R^2-x^2}dx.$$
The reason I have a problem with this equation is that it is really saying $I=\int x^2 dm /M$, but of course we know that it should be an $r$ instead of an $x$: $I=\int r^2 dm /M$. The reason this distinction is important is because your surfaces of constant $x$ are not surfaces of constant $r$. Now we can't fix this problem by just writing 
$$I = \frac{2M}{\pi R^2}\int r^2 \sqrt{R^2-x^2}dx$$
because each surface of constant $x$ is not at a well-defined $r$: the part of the surface near the surface of the cylinder has $r=R$, but the part in the middle of the surface has $r=x$. So the integral above doesn't make sense.
Correct way to get the answer
There are two ways to find the answer then. One way is just to write out the integral in rectangular coordinates and the other way is to use the parallel axis theorem to find the moment of inertia of each surface of constant $x$ and the integrate over constant $x$.
First way of getting the answer
Let's look at the first method first. We get the following expression for the moment of inertia:
$$I = \frac{M}{\pi R^2}\int^R_{-R} \int^\sqrt{R^2-x^2}_{-\sqrt{R^2-x^2}} (x^2+y^2) dy\,dx  $$
Doing the inner integral, you get 
\begin{equation}
\begin{aligned}
I &= \frac{2M}{\pi R^2}\int^R_{-R} \left(\frac{4}{3} R^2 + \frac{2}{3}x^2 \right) \sqrt{R^2-x^2}  dx \\
&=\frac{1}{3} \frac{2M}{\pi R^2}\int^R_{-R}R^2\sqrt{R^2-x^2}  dx+\frac{2}{3} \frac{2M}{\pi R^2}\int^R_{-R}x^2\sqrt{R^2-x^2}  dx
\end{aligned}
\end{equation}
Now you have already evaluated the integral in the second term in your question. The integral in the first term is easy because it is just the area of a semicircle. So we get 
\begin{equation}
\begin{aligned}
I &= \frac{1}{3} \frac{2M}{\pi R^2} R^2 \pi R^2/2 +\frac{2}{3} \frac{M R^2}{4} \\
&= MR^2/2
\end{aligned}
\end{equation}
Second way of getting the answer
Now let's look at the second way of getting the answer. This time we will just calculate the moment of inertia of each surface of constant $x$ and add them up. We could find in a table that the moment of inertia of a rectangle of width $2\sqrt{R^2-x^2}$ and mass $dm$ about its center of mass is $\frac{1}{3} dm \left(R^2-x^2\right).$ But we are more interested in the moment of inertia about the origin when this surface of constant $x$ is displaced a distance $x$ from the origin. Using the parallel axis theorem, we find that the moment of inertia is $\frac{1}{3} dm \left(R^2-x^2\right) + dm x^2$. This is the moment of inertia of each surface of constant $x$. Adding these up we get the total moment of inertia:
$$I = \int dI = \int \frac{1}{3} dm \left(R^2-x^2\right) + dm x^2 = \int \frac{1}{3} R^2 dm + \frac{2}{3} x^2 dm.$$
Now plugging in our expression for $dm$, we get that $$dI = \frac{2M}{\pi R^2} \int_{-R}^R \frac{1}{3} R^2 \sqrt{R^2-x^2} + \frac{2}{3} x^2 \sqrt{R^2-x^2} dx.$$
This is the same expression we got from the first way of computing the moment of intertia. So this will give us the correct answer. Also, we can see that the $y$ integral of the first method just gave us the moment of inertia of each surface of constant $x$.
I should add that the easiest way to get the moment of inertia is to integrate over surfaces of constant $r$ (where $r$ is the distance from the axis of the cylinder. You get that $dI = r^2 dm$ where $dm = \frac{M}{\pi R^2} 2 \pi r dr.$ So then you get $I = \int dI = \frac{M}{\pi R^2}\int_0^R r^2 2 \pi r dr = \frac{2 M}{R^2} \int_0^R r^3 dr = MR^2 /2$
