2
$\begingroup$

I am solving the following integral in Mathematica

Integrate[1 - Cos[8 ArcTan[(Exp[x - a + z] + Exp[-x + z])/(1 - Exp[2 z - 
a])]], {x, -z, Infinity},  Assumptions -> {a \[Element] Reals, z > 0}]

Notice that I have assumed the variable $a$ to be Real in the assumptions. Mathematica doesn't return an output for this command. (it returns the input statement). But if I change the sign in front of $a$ in the integrand still assuming $a$ to be any real value

Integrate[1 - Cos[8 ArcTan[(Exp[x + a + z] + Exp[-x + z])/(1 - Exp[2 z + 
a])]], {x, -z, Infinity},  Assumptions -> {a \[Element] Reals, z > 0}]

I get an output result for any general $a$ i.e. with no constraints on $a$ in the output. Why does changing the sign in front of $a$ help Mathematica solve the integral even though it does it for any arbitrary $a$, as indicated by no constraints in the output?

$\endgroup$
4
  • 1
    $\begingroup$ May be when sign is changed mathematica having hard time showing it converges or not? $\endgroup$
    – Nasser
    Commented Jul 6, 2017 at 3:52
  • $\begingroup$ Yeah, maybe, but I also imagine that this might be a 'bug' that could be corrected. $\endgroup$
    – cleanplay
    Commented Jul 6, 2017 at 3:54
  • 1
    $\begingroup$ With version 11.1.1 for Mac OS X x86 (64-bit), if you add the option GenerateConditions -> True, both expressions indicate that the integral does not coverage on {-z, Infinity} $\endgroup$
    – Bob Hanlon
    Commented Jul 6, 2017 at 4:01
  • $\begingroup$ @BobHanlon Looks to me like the integral converges just fine. The second result in the question is correct, and I can reproduce it in 11.0.1. So it appears that 11.1.1 is failing to simplify the limit at infinity correctly. As to the answer to the question, it happens from time to time that Mathematica needs to be prodded in the right direction. That can take trial and error... $\endgroup$
    – Jens
    Commented Jul 6, 2017 at 4:46

1 Answer 1

3
$\begingroup$

When Integrate calculates the definite integral, it has to take a limit for $x\to \infty$. I'm guessing that's where the difference between the two signs in front of a causes trouble. It's not that the limit doesn't exist. It's that the input to Limit may be in a form that is too hard for Mathematica to simplify in the first formulation of the question, before it times out.

We can try to decide if the integral converges or not, by doing the definite integral and investigating the limits of the definite integral separately:

integral = 
  Integrate[
   1 - Cos[8 ArcTan[(Exp[x - a + z] + Exp[-x + z])/(1 - Exp[2 z - a])]], x];

result = Limit[integral /. x -> Log[y], y -> ∞] - integral /. x -> -z

The output is a long and unilluminating expression, but it's obtained without making any assumptions at all, as you can see.

Above, I helped Mathematica do the $x\to\infty$ limit (after the integration) by switching to a new variable $y=e^x$. Because this is a monotonic transformation, the limit is equivalent to $y\to\infty$, and that limit can be done by Mathematica without difficulty.

By default, Integrate doesn't generate conditions, so it wasn't initially obvious that the result you obtained in the second attempt was generally valid. But the approach I chose here seems to confirm that the integral can indeed be done without any assumptions.

This leaves the question why the first attempt in the question failed. The limit of $x\to\infty$, which I avoid by the above substitution, can in fact be done by Mathematica, but it takes quite long. If I ask for

Assuming[{a ∈ Reals, z > 0}, Limit[integral, x -> ∞]]

Assuming[{a ∈ Reals, z > 0}, 
 Limit[integral /. a -> -a, x -> ∞]]

both eventually return a result. So the sign in front of a in itself is irrelevant to the ability to get a result, if I split up the calculation as shown. It just seems that the calculation in one case times out if we ask Mathematica to do it in a single command.

$\endgroup$
2
  • $\begingroup$ Jens, thanks for the nice answer. Any ideas on how does Mathematica time out? Sometimes it runs for an hour before giving an output while here, it just times out in a few minutes. Does it calculate the time beforehand or on in parallel and time out when it knows it will take too long? $\endgroup$
    – cleanplay
    Commented Jul 7, 2017 at 16:26
  • 1
    $\begingroup$ @cleanplay Actually maybe it's not strictly correct to say it "times out", because there's no fixed time constraint unless you specify one. It just stops trying, but the criteria for this inside Integrate aren't revealed anywhere that I know of. Instead of just time, the number of transformations that have been tried could also be a criterion. Weird decisions happen behind the scenes, as seen e.g. in Why does Simplify ignore an assumption $\endgroup$
    – Jens
    Commented Jul 7, 2017 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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