$\int \sqrt{a^2+x^2} \,dx$ when $\int \sqrt{1+x^2} \, dx$ is known I messed up calculating $\int\sqrt{a^2+x^2} \, dx$ when $\int \sqrt{1+x^2} \, dx$ is known.
What I did
$$\int \sqrt{a^2+x^2} \,dx = \int \sqrt{a^2(1+(x/a)^2)} \, dx = a \int \sqrt{1+(x/a)^2} \,dx$$
now set $u=(x/a)$ and $a\,du=dx$ and use the known formula for $\int \sqrt{1+u^2} \, du$
$$\int \sqrt{a^2+x^2} \,dx= a^2 · (1/2) \left( u \sqrt{1+u^2} + \log(u+\sqrt{1+u^2})\right)$$
now switch back $u=(x/a)$
$$
\begin{align}
& a^2 \cdot (1/2) \left( u \sqrt{1+u^2} + \log(u+\sqrt{1+u^2})\right) \\[8pt]
& = a^2 \cdot (1/2) \left( (x/a) \sqrt{1+(x/a)^2} + \log((x/a)+\sqrt{1+(x/a)^2})\right) \\[8pt]
& = (ax/2) \sqrt{(1/a^2)(a^2+x^2)} + (a^2/2)\cdot\log((x/a)+\sqrt{(1/a^2)(a^2+x^2)} \\
& = (x/2) \sqrt{a^2+x^2} + (a^2/2)\cdot\log\left(1/a(x+\sqrt{a^2+x^2})
\right)\end{align}
$$
$$= (x/2) \sqrt{a^2+x^2}+a^2/2·\log(x+\sqrt{a^2+x^2}) -a$$
Can someone help where's the mistake? I can't find it..

Remember when you change variables you must change $dx$ to $du$. If $u=\frac{x}{a}$, $\frac{du}{dx}=\frac{1}{a} \implies a\cdot du= dx$
Here is a correct derivation. Let $I(x)=\int \sqrt{1+x^{2}}dx$. Then, your new integral is
$$\int \sqrt{a^{2}+x^{2}}dx=\int a \sqrt{1+ \left( \frac{x}{a} \right)^2}dx=a\int a\sqrt{1+u^2}du=a^{2}I(u)=a^{2}I\left(\frac{x}{a}\right)$$
Since $I(x)=\frac{1}{2}(x\sqrt{x^2+1}+\ln(x+\sqrt{1+x^{2}})),$ $$a^{2}I\left(\frac{x}{a}\right)=\frac{1}{2}a^{2}\left(\frac{x}{a}\sqrt{\left(\frac{x}{a}\right)^{2}+1}+\ln\left(\frac{x}{a}+\sqrt{1+\left(\frac{x}{a}\right)^{2}}\right)\right)$$
$$=\frac{1}{2}x\sqrt{x^{2}+a^{2}}+\frac{1}{2}a^{2}\ln\left(x+\sqrt{a^{2}+x^{2}}\right)-\frac{1}{2}a^{3}$$
With an arbitrary constant of integration, since this is an indefinite integral. Notice that since this constant is arbitrary, we may as well 'absorb' the $-\frac{1}{2}a^{3}$ into it. Hence, your integral is
$$=\frac{1}{2}x\sqrt{x^{2}+a^{2}}+\frac{1}{2}a^{2}\ln\left(x+\sqrt{a^{2}+x^{2}}\right)+C$$
