16
$\begingroup$

Bug introduced in 7.0 or earlier, fixed as of 11.3


A question with the same title has been asked many times, but I can't find the solution of my problem in their answers. The integral I am trying to calculate is

Integrate[Sin[q ]^2 / Sinh[q]^2, {q, 0, ∞}]

which gives me

1/4 (-1 + 2 π Coth[π])

The correct result is

1/4 (-2 + 2 π Coth[π])

This is a tabulated integral, see for instance Gradshteyn and Ryzhik, 3.982.3

Why is Mathematica wrong here? Most issues I have seen were due to variables in the integral, which I don't have (at least not in this example, in the actual integral that I am computing I have variables).

$\endgroup$
14
  • 1
    $\begingroup$ Wolfram Alpha is wrong as well ... wolframalpha.com/input/… $\endgroup$
    – Young
    Jul 11, 2016 at 22:58
  • 1
    $\begingroup$ In the meantime: take the Laplace transform of your integrand, and let the transform variable go to zero. $\endgroup$ Jul 11, 2016 at 23:21
  • 2
    $\begingroup$ Or use GenerateConditions -> False, gives correct answer, makes you feel ucky... $\endgroup$
    – ciao
    Jul 12, 2016 at 3:37
  • 1
    $\begingroup$ Why does GenerateConditions -> False change the result (or even the algorithm behind it) if there are no parameters that possibly could cause conditions? $\endgroup$
    – Felix
    Jul 12, 2016 at 14:32
  • 1
    $\begingroup$ The bug has been confirmed by Mathematica developers. $\endgroup$
    – Felix
    Jul 12, 2016 at 20:16

1 Answer 1

2
$\begingroup$

You get the right result, if you first solve the indefinite integral and then take the upper and lower limit (using MMA version 8.0)

int[q_] = Integrate[Sin[q]^2/Sinh[q]^2, q, Assumptions -> q > 0]

(*     1/8 E^(-2 I q) (-4 E^(2 I q) Coth[q] + 2 (1 + E^(4 I q)) Coth[q] + 
       2 Hypergeometric2F1[-I, 1, 1 - I, E^(2 q)] + 
       2 E^(4 I q) Hypergeometric2F1[I, 1, 1 + I, E^(2 q)] + (1 - I) E^(
       2 q) Hypergeometric2F1[1, 1 - I, 2 - I, E^(
       2 q)] + (1 + I) E^((2 + 4 I) q)
       Hypergeometric2F1[1, 1 + I, 2 + I, E^(2 q)])     *)

lim0 = Limit[int[q], q -> 0, Direction -> -1] // FullSimplify

(*     1/2 \[Pi] Coth[\[Pi]]     *)

liminf = Limit[int[q], q -> \[Infinity]] // FullSimplify

(*     -(1/2) + \[Pi] Coth[\[Pi]]     *)

{buf = liminf - lim0, N[buf]}

(*     {-(1/2) + 1/2 \[Pi] Coth[\[Pi]], 1.07667}     *)
$\endgroup$

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.