Integrating $\int \sqrt{a^2+x^2} \ \mathrm{d} x$ with trig. substitution I am trying to come up with all the formulas I have myself and I stumbled upon a roadblock again.
Integrating $\int \sqrt{a^2+x^2} \ \mathrm{d} x$ with Trig Substitution.
So I imagined a triangle where the hypotenuse is $1$, $\sin(y) = x$ opposite over hypotenuse and $\cos(y) = a$ adjacent over hypotenuse.
Then $dx = \cos(y)dy$ and factoring out the a out of the square root,
I get $ \int a $ $\sqrt{1+\frac{x^2}{a^2}} \ \mathrm{d} x$ or $ \int  \sqrt{1+\tan y^2}\cos y^2 \ \mathrm{d} y$
which I could simplify to $\int \cos y \ \mathrm{d} y$. This gives me the wrong answer.
Can you pinpoint or hint at where I am going wrong with my substitution once more?
Apologies, I appreciate it.

Let $x=a\tan\theta\implies dx=a\sec^2\theta\ d\theta$
$$\int \sqrt{a^2+x^2}dx=\int \sqrt{a^2+a^2\tan^2\theta}\ a\sec^2\theta \ d\theta$$
$$=\int a\sec\theta\ a \sec^2\theta \ d\theta$$
$$=a^2\int \sec^3\theta \ d\theta$$
Using integration by parts
$$=a^2\left(\frac{1}{2}\sec\theta \tan\theta+\frac12\ln|\sec\theta+\tan\theta|\right)+C$$
substituting back to $x$,
$$=\frac{1}{2}\left(x\sqrt{a^2+x^2}+a^2\ln|x+\sqrt{a^2+x^2}|\right)+C$$
