Magnetic field inside finite solenoid In my book they don't really derive the equation of the magnetic field inside of a finite solenoid. They just give me equation 1 and image and the end result, equation 2.
$$dB=\frac{\mu_0Ndlr^2I}{2ly^3}\tag{1}$$
Equation 1: contribution of $dl$ for $dB$ in point P

Image 1: This image is shown next to the equation
$$B=\mu_0NI/2l\int\sin( \theta) d\theta\tag{2}$$
Equation 2: Total magnetic field inside a finite solenoid. The intervals of the integral are $a=\theta_1$ and $b=\theta_2$.
So my question was, where does equation 1 come from and how do they get from equation 1 to 2?
 A: Formula 1 is the contribution to the magnetic field from the small segment of the coil of length $dl$ shown in the lower portion of Figure 1. That piece of coil has current $dI = N I\, dl/l$ flowing through it where $N$ is the number of turns in the coil, $I$ is the current per turn, and $l$ is the length of the coil.  From the hyperphysics site (or by integrating the Biot-Savart law), the axial field from this loop is:
$$B_z = \frac{\mu_0}{4\pi}(2\pi r) dI\frac{ r}{(r^2+z^2)^{3/2}} = \frac{\mu_0 r^2 dI}{2 y^3}$$
where $y=(r^2+z^2)^{1/2}$ is the distance from the measurement point to the rim of the loop and $r$ is the coil radius. Substituting the formula for $dI$ gives you the first equation.
The second equation is the integral of the above over the length $l$. The integral is first converted to an integral over angle $\theta$ via $\sin \theta = r/y$ and $\sin\theta\,dl = y\,d\theta$:
$$B = \int\frac{\mu_0 r^2 dI}{2 l y^3} = \frac{\mu_0 N I}{2 l} \int \frac{r^2 dl}{y^3} = \frac{\mu_0 N I}{2 l} \int_{\theta_1}^{\theta_2} \sin \theta \, d\theta$$ 
