<s>[INST] Applying Euler's substitution to evaluate the integral? $$\int \frac{dx}{\sqrt{x^2+a^2}} $$
let $$\sqrt{x^2+a^2}=x+t $$
$$a^2=2xt+t^2 $$
$$x=\frac{1}{2}\Big( \frac{a^2}{t}-t\Big) $$
$$dx=-\frac{1}{2}\Big(\frac{a^2}{t^2}+1\Big)dt$$
hence $$x+t=\frac{a^2+t^2}{2t} $$
this gives $$\int \frac{dx}{\sqrt{x^2+a^2}}=-\ln({\sqrt{x^2+a^2}-x}) $$
Which is wrong. What mistake I have made?
 [/INST] Hint
You are not wrong and you did a good job but, may be, you just forgot the integration constant at the end of the calculation. 
Just rewriting your last expression
$$A=-\log\left({\sqrt{x^2+a^2}-x}\right)=\log\left(\frac 1 {\sqrt{x^2+a^2}-x}\right)$$ $$A=\log\left(\frac 1 {\sqrt{x^2+a^2}-x}\times\frac{\sqrt{x^2+a^2}+x}{\sqrt{x^2+a^2}+x}\right)$$  $$A=\log\left(\frac{\sqrt{x^2+a^2}+x}{x^2+a^2-x^2}\right)=\log\left(\sqrt{x^2+a^2}+x\right)-2\log(a)$$ The last term will be absorbed in the integration constant. So $$\int \frac{dx}{\sqrt{x^2+a^2}}=-\log\left({\sqrt{x^2+a^2}-x}\right)+K_1=\log\left(\sqrt{x^2+a^2}+x\right)+K_2$$ The two expressions are the same.
</s>