Maximizing the Distance Traveled by a Projectile by Applying Chain Rule to the Fundamental Theorem of Calculus I'm having some difficulty reconciling my understanding of the fundamental theorem of calculus with a particular problem from Stewart Calculus. The question asks what value of the angle of elevation $\alpha$ maximizes the total distance traveled by the projectile with a position at time $t$ given by the parametric equations $x=(v\cos{\alpha})t$, $y=(v\sin{\alpha})t-\frac{1}{2}gt^2$, where $v$ is the initial speed of the projectile and $g$ is the gravitational constant. The projectile is launched at $t=0$ and necessarily returns to Earth at $t=\frac{2v\sin{\alpha}}{g}$ (as can be shown by setting $y=0$ and solving for $t$). It follows that the arc length of the parabola traced out by the projectile (as a function of the chosen angle of elevation) is $$L(\alpha)=\int_0^\frac{2v\sin{\alpha}}{g}{\sqrt{\left(\frac{dx}{dt}\right)^2+\left(\frac{dy}{dt}\right)^2}\,dt}=\int_0^\frac{2v\sin{\alpha}}{g}{\sqrt{(v\cos{\alpha})^2+\left(v\sin{\alpha}-gt\right)^2}\,dt}=\int_0^\frac{2v\sin{\alpha}}{g}{\sqrt{v^2\cos^2{\alpha}+v^2\sin^2{\alpha}-2vg(\sin{\alpha})t+g^2t^2}\,dt}=\int_0^\frac{2v\sin{\alpha}}{g}{\sqrt{v^2-2vg(\sin{\alpha})t+g^2t^2}\,dt}$$ From here, I see two possible ways to determine the $\alpha$ value that maximizes this function. The first solves the integral directly by factoring out $g$ from the square root to produce $$L(\alpha)=\int_0^\frac{2v\sin{\alpha}}{g}{\sqrt{(v\cos{\alpha})^2+\left(v\sin{\alpha}-gt\right)^2}\,dt}=\int_0^\frac{2v\sin{\alpha}}{g}{{g}\sqrt{\left(t-\frac{v}{g}\sin{\alpha}\right)^2+\frac{v^2}{g^2}\cos^2{\alpha}}\,dt}$$ and then uses the identity$$\int{\sqrt{a^2+u^2}\,du}=\frac{u}{2}\sqrt{a^2+u^2}+\frac{a^2}{2}\ln{\left(u+\sqrt{a^2+u^2}\right)}+C$$ to eventually express $L$ as $$L(\alpha)=\frac{v^2}{g}\sin{\alpha}+\frac{v^2}{2g}\cos^2{\alpha}\ln{\left(\frac{1+\sin{\alpha}}{1-\sin{\alpha}}\right)}$$  At this point, $\frac{dL}{d\alpha}=\frac{v^2}{g}\cos{\alpha}\left[2-\sin{\alpha}\ln{\left(\frac{1+\sin{\alpha}}{1-\sin{\alpha}}\right)}\right]$ can be set equal to $0$ to determine the critical points of $L(\alpha)$ on the interval $0<\alpha<\frac{\pi}{2}$, the only one being at $\alpha\approx56°$. According to the textbook solutions manual, this is the correct answer.
However, I also feel that it should be possible to take advantage of the fundamental theorem of calculus and the chain rule to avoid having to find that nasty integral altogether. Since $$\frac{d}{dx}\int_a^{g(x)}{f(t)\,dt}=\frac{d}{dx}\left(F(g(x))-F(a)\right)=f(g(x))\frac{d}{dx}g(x)$$ shouldn't it be that $$\frac{dL}{d\alpha}=\frac{d}{d\alpha}\int_0^\frac{2v\sin{\alpha}}{g}{\sqrt{v^2-2vg(\sin{\alpha})t+g^2t^2}\,dt}=\sqrt{v^2-2vg(\sin{\alpha})\left(\frac{2v\sin{\alpha}}{g}\right)+g^2\left(\frac{2v\sin{\alpha}}{g}\right)^2}\,\frac{d}{d\alpha}\left(\frac{2v\sin{\alpha}}{g}\right)=\sqrt{v^2-4v^2\sin^2{\alpha}+g^2\left(\frac{4v^2\sin^2{\alpha}}{g^2}\right)}\,\left(\frac{2v\cos{\alpha}}{g}\right)=\sqrt{v^2}\,\frac{2v\cos{\alpha}}{g}=\frac{2v^2\cos{\alpha}}{g}$$ for which there is no critical value on the interval $0<\alpha<\frac{\pi}{2}$. Where am I going wrong?
 A: There is a missing term in your application of the chain derivatives, The following expression should be used instead,
$$\frac{d}{dx}\int_a^{g(x)}{f(x,t)dt}=f(x,g(x))\frac{d}{dx}g(x) + \int_a^{g(x)} \frac{d}{dx}f(x,t) dt $$

Added the explanation below answering the question in comments:
Let the antiderivative of $f(\alpha,t)$ be $F(\alpha,t)$, that is
$$\frac{dF(\alpha,t)}{dt}=f(\alpha,t)
$$
$$I(\alpha)=\int_0^{g(\alpha)}{f(\alpha,t)\,dt}=F(\alpha,g(\alpha))-F(\alpha,0)
$$
Take the derivative with respect to $\alpha$,
$$\frac{dI(\alpha)}{d\alpha}= \frac{dF(\alpha,g(\alpha))}{dg(\alpha)} \frac{dg(\alpha)}{d\alpha} + \frac{d}{d\alpha}[F(\alpha,g(\alpha)) - F(\alpha,0)]\tag{1}
$$
Recognize
$$\frac{dF(\alpha,g(\alpha))}{dg(\alpha)}=f(\alpha,g(\alpha))\tag{2}$$
$$\frac{d}{d\alpha}[F(\alpha,g(\alpha)) - F(\alpha,0)]=\frac{d}{d\alpha}\int_0^{g(\alpha)}{f(\alpha,t)\,dt}=\int_0^{g(\alpha)}\frac{d}{d\alpha}{f(\alpha,t)\,dt}\tag{3}
$$
and substitute (2) and (3) into (1) to arrive at
$$\frac{dI(\alpha)}{d\alpha}= f(\alpha,g(\alpha)) \frac{dg(\alpha)}{d\alpha} + \int_0^{g(\alpha)}\frac{d}{d\alpha}{f(\alpha,t)\,dt}
$$
A: Please add the following term and it'll be correct:
$\displaystyle \int_0^\frac{2v\sin{\alpha}}{g} [\frac{\partial}{\partial \alpha}{\sqrt{v^2-2vg(\sin{\alpha})t+g^2t^2}]~dt}$
