2
$\begingroup$

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.

$\endgroup$
  • 4
    $\begingroup$ 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. $\endgroup$ – John Doty Mar 12 '16 at 14:20
3
$\begingroup$

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[162]= {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[163]= {0.0312002, 1/2 x Sqrt[k + x^2] + 1/2 k Log[x + Sqrt[k + x^2]]} *)
$\endgroup$
2
$\begingroup$

I believe this blog post answers your question.

http://blog.wolfram.com/2008/01/19/mathematica-and-the-fundamental-theorem-of-calculus/

It boils down to this:

The fundamental theorem of Calculus requires the antiderivative be continuous. This is something hard to guarantee and can be slow to detect and fix the discontinuities by shifting vertically.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.