<s>[INST] Calculate $\int\sqrt{(x^2+1)}dx$ Calculate $I$ =$\int\sqrt{(x^2+1)}dx$
I have tried calculating it using integration by parts:
$$f'(x) = 1, f(x) = x$$
$$g(x) = \sqrt{x^2+1}, g'(x) = \frac{x}{\sqrt{x^2+1}}$$
$$\int\sqrt{x^2+1}dx = x\sqrt{x^2+1} - \int\frac{x}{\sqrt{x^2+1}}$$
Then I make the substitution:
$$x^2+1 = u$$
$$2xdx = du$$
$$ I = \frac{1}{2}\int{\frac{1}{\sqrt{u}}}du = \sqrt u$$
Substituting back $x$ I get:
$$\int\sqrt{(x^2+1)}dx = x\sqrt{x^2+1} - (x^2+1)^{\frac{1}{4}}  $$
What am I doing wrong? Because I plugged this into an integral calculator and the answer is $\ln(|\sqrt{x^2+1}+x|) +x\sqrt{x^2+1}$.
 [/INST] Your IBP should have given $$\int\sqrt{x^2+1}dx=x\sqrt{x^2+1}-\int\frac{x^2dx}{\sqrt{x^2+1}}=x\sqrt{x^2+1}-\int\sqrt{x^2+1}dx+\int\frac{dx}{\sqrt{x^2+1}}.$$Rearranging,$$\int\sqrt{x^2+1}dx=\frac{x\sqrt{x^2+1}+\int\frac{dx}{\sqrt{x^2+1}}}{2}.$$For the last integral, use $x=\tan t$.
</s>