Simple definite integral returns useless answer

I tried to run

  Integrate[   (E^(I q x))/(q - I), {q, -\[Infinity], \[Infinity]},
Assumptions -> x \[Element] Reals]


I got something involving MeijerG function whereas the answer is really simple viz.

  E^-x (2 \[Pi] I) HeavisideTheta[x]


• FWIW: FourierTransform gives you that result basically instantly: Sqrt[2 Pi] * FourierTransform[1/(q - I), q, x] Jun 28, 2023 at 8:04
• I think F.T. is the way to go. But to get the x>0 part, you can do anti = Integrate[(E^(I q x))/(q - I), q]; hi = Limit[anti, q -> Infinity, Assumptions -> x > 0]; low = Limit[anti, q -> -Infinity, Assumptions -> x > 0]; anti = hi - low which gives 2 I Pi Exp[-x] but for x<0, it does not give zero. !Mathematica graphics F.T. does some magic internally. Maple 2023 gives !Mathematica graphics which match the result from F.T. Jun 28, 2023 at 8:17
• There are many kinds of integrals in mathematics. FourierTransform[] computes a different class than Integrate[]. I'm not sure that the classes are well-defined in Mma, but DiracDelta[] and HeavisideTheta[] (at least as a distribution) are not possible answers in classical analysis. E.g. the classical integral $\int_{\Bbb R} Exp[i q x] \, dq$ diverges. Also, FourierTransform[] uses a different lookup table, and therefore it is more likely to be successful when you wish to compute Fourier transforms. This distinction in functionality should be kept in mind. Jun 28, 2023 at 15:30

Try FourierTransform

 FourierTransform[1/(q - I), q, x]
(*2 I E^-x \[Pi] HeavisideTheta[x]*)

• This means it is well within capabilities of Mathematica. Why does the integral form give a useless answer then? Something for the makers to fix. This is an extremely critical integral in all branches of physics and engineering. It is unacceptable that the integral gives a complicated answer. Jun 28, 2023 at 8:08
• It is unacceptable that the integral gives a complicated answer Ok, this result was complicated, I agree. (but I assume it is correct, did not verify). But Mathematica still solves more integrals that any other CAS system out there. No software is perfect ! Jun 28, 2023 at 8:23
• There are many even simpler examples where F.T. gives a result:  FourierTransform[1 , q, x] (Sqrt[2 [Pi]] DiracDelta[x]) whereas Integrate[(E^(I q x)) , {q, -\[Infinity], \[Infinity]}, Assumptions -> x \[Element] Reals] doesn't evaluate Jun 28, 2023 at 8:28
• @UlrichNeumann Arguably, though, that integral is not actually well-defined and shouldn't be returned as a result from Integrate. But for something straight-forward like the Fourier transform of 1/(1 + q^2) there is no excuse. Jun 28, 2023 at 8:34
• @SjoerdSmit Here the "excuse": Mathematica 12.2 evaluates Integrate[(E^(I q x))/(1 + q^2) , {q, -\[Infinity], \[Infinity]}] (*ConditionalExpression[Pi/E^Abs[x], Element[x, Reals]]*) Jun 28, 2023 at 10:28

It also works by integrating real and imaginary parts separately:

Integrate[(q Cos[q x])/(1 + q^2) - Sin[q x]/(1 + q^2), {q, -\[Infinity], \[Infinity]},
Assumptions -> x \[Element] Reals]
(* 0 *)

Integrate[(Cos[q x]/(1 + q^2) + (q Sin[q x])/(1 + q^2)), {q, -\[Infinity], \[Infinity]},
Assumptions -> x \[Element] Reals]
(* E^-Abs[x] \[Pi] (1 + Sign[x]) *)

• Similarly, Integrate[ComplexExpand[(E^(I q x))/(q - I)], {q, -∞, ∞}, Assumptions -> x > 0] returns 2 I E^-x π, and the same input with Assumptions -> x < 0 returns 0. But Assumptions -> x \[Element] Reals returns an ugly result. Jun 28, 2023 at 15:42
• Is MeijerG result for both then? Jun 28, 2023 at 16:38