# Any reason why this definite integral is so slow to compute and the indefinite fast?

This integral is easy and fast to compute

Integrate[Sqrt[(x^2) + k ], x]


$$\frac{1}{2} x \sqrt{k+x^2}+\frac{1}{2} k \log \left(\sqrt{k+x^2}+x\right)$$

But the same, definite, integral is very slow:

Integrate[Sqrt[x^2 + k], {x, Sqrt[u], Sqrt[u] + Sqrt[A]}]


I suspect this is related with conditions about parameter (cannot see any other reason) but I didn't managed to put proper Assumptions to make it execute faster.

I can compute the definite integral by the indefinite one with

Integrate[Sqrt[x^2 + k], x] /. {{x -> Sqrt[u] + Sqrt[A]}, {x -> Sqrt[u]}} // Apply@Subtract


but, if possible, I prefer to keep the definite form, with the proper options and assumptions.

• Well, the big difference between an indefinite integral and a definite one in Mathematica is that for the latter the machinery tries to detect discontinuities that would invalidate your method. That's a difficult and not perfectly reliable process. Mar 12, 2016 at 14:20

Yes, in the definite integral you have to make assumptions about the parameters. The natural choice for the parameters u and A is that they are positive. Letting, for simplicity, also k> 0 we find

g = Timing[
Integrate[Sqrt[x^2 + k], {x, Sqrt[u], Sqrt[u] + Sqrt[A]},
Assumptions -> {u > 0, A > 0, k > 0}]]

(* Out= {1.85641, 1/
2 (-Sqrt[u (k + u)] + Sqrt[A (A + k + u + 2 Sqrt[A u])] + Sqrt[
u (A + k + u + 2 Sqrt[A u])] +
k Log[(Sqrt[A] + Sqrt[u] + Sqrt[A + k + u + 2 Sqrt[A u]])/(
Sqrt[u] + Sqrt[k + u])])} *)


For comparison the indefinite integral is

f = Timing[Integrate[Sqrt[x^2 + k], x]]

(* Out= {0.0312002, 1/2 x Sqrt[k + x^2] + 1/2 k Log[x + Sqrt[k + x^2]]} *)