Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I execute the following,

Integrate[ Exp[-w^2 + I w^3], {w, -∞, ∞}]

I get

(2 E^(2/27) BesselK[1/3, 2/27])/(3 Sqrt[3])

which agrees with the result obtained from NIntegrate, which is 1.38811.
However, when I execute

Integrate[ Exp[ -a w^2 + b I w^3], {w, -∞, ∞}]

I get

ConditionalExpression[ 0, b ∈ Reals && Re[a] > 0]

which evaluates to 0 when a = 1 and b = 1. This is obviously wrong. The integral itself has no convergence issues, as the integrand is simply a Gaussian multiplied by a modulus-one third-order chirp factor, which clearly converges when integrated over the real line.
Why does Mathematica give an incorrect answer for the second integral?

share|improve this question

migrated from Jul 10 '12 at 19:46

This question came from our site for professional and enthusiast programmers.

You can always report issues to – Searke Jul 10 '12 at 20:42

4 Answers 4

Another way to get the correct result is to use a bit of insight: if one expands the imaginary exponential into $\cos$ and $\sin$ then the term with $\sin$ gives zero when integrated due the symmetry (odd function integrated over symmetric domain).

Check :

Integrate[ Exp[-a w^2] Sin[b w^3], {w, -∞, ∞}]
ConditionalExpression[0, b ∈ Reals && Re[a] >= 0]

The original integral is then :

Integrate[ Exp[- a w^2] Cos[b w^3], {w, -∞, ∞}]
  (2 a E^((2 a^3)/(27 b^2)) BesselK[1/3, (2 a^3)/(27 b^2)])/(3 Sqrt[3] Abs[b]), 
   b ∈ Reals && Re[a] > 0]
share|improve this answer

We get correct results if we act ComplexExpand on the integrand

ComplexExpand @ Exp[-a w^2 + b I w^3]
E^(-a w^2) Cos[b w^3] + I E^(-a w^2) Sin[b w^3]


Integrate[ ComplexExpand @ Exp[-a w^2 + b I w^3], {w, -Infinity, Infinity}]
    (2 a E^((2 a^3)/(27 b^2)) BesselK[1/3, (2 a^3)/(27 b^2)])/( 3 Sqrt[3] Abs[b]),
                                                           b ∈ Reals && Re[a] > 0 ]

or make assumptions directly in Integrate :


Integrate[ Exp[ -a w^2 + b I w^3], {w, -Infinity, Infinity},
           Assumptions -> a ∈ Reals]
    (2a E^((2 a^3)/(27 b^2)) BesselK[1/3, (2 a^3)/(27 b^2)])/( 3 Sqrt[3] Abs[b]),
                                                              b ∈ Reals && a > 0 ]

We could assume this condition b ∈ Reals && a > 0 (then it is automatically assumed that a is real) in Integrate to get rid of ConditionalExpression :


Integrate[ Exp[-a w^2 + b I w^3], {w, -Infinity, Infinity}, 
           Assumptions -> { b ∈ Reals, a > 0} ]
(2 a E^((2 a^3)/(27 b^2)) BesselK[1/3, (2 a^3)/(27 b^2)])/( 3 Sqrt[3] Abs[b])

There are many similar problematic issues with Integrate. This problem was also in ver. 7 but there appeared new ones quite similar in ver. 8. Perhaps the reason is that ConditionalExpression (a new function in Mathematica 8) is not perfectly integrated so far with the rest of the system. Conditional expressions are connected to assumptions imposed on a given expressions and they are ubiquitous when we deal with integrals. Above we had a correct result after imposing a proper assumption. However you can find a bit opposite issue to certain extent. Look e.g. at this example :


Integrate[ Exp[-a] Sin[2 w] (b^2 + b*Cos[w] + a Sin[w]), {w, 0, 2 Pi}]
Integrate[ Exp[-a] Sin[2 w] (b^2 + b*Cos[w] + a Sin[w]), {w, 0, 2 Pi}, 
           Assumptions -> a > 0]
8/3 Sqrt[a^2 + b^2] E^-a

As one can see, the same function integrated over the same interval gives two different results if an assumption was made (0 is the correct result). It is even more bizarre since we can add even an assumption having nothing to do with the integrand, e.g. Assumptions -> x > 0.

My supposition that there is something wrong with ConditionalExpression and Assumptions (as well as $Assumptions etc.) is more resonable since the example 4 did not casue any errors in Mathematica 7.

As it was observed by b.gatessucks the integral without assumption returns the result as the integrand would be only I Exp[-a w^2] Sin[b w^3] instead of the full exponent Exp[-a w^2 + b I w^3]. Therefore we have two quite analogical expressions (3 and 4) which are evaluated correctly or not depending on whether assumptions are imposed or not (in the former case assumptions help to get the correct result in the latter case they cause the result is wrong).

These issues are certainly bugs.

share|improve this answer

Use assumptions

In[6]:= Assuming[Element[{a,b},Reals],
         Integrate[Exp[-a w^2+b I w^3],{w,-Infinity,Infinity}]]/.{a->1,b->1}

Out[6]= (2 E^(2/27) BesselK[1/3,2/27])/(3 Sqrt[3])

which is the same as

In[8]:= Integrate[Exp[-w^2+I w^3],{w,-Infinity,Infinity}]

Out[8]= (2 E^(2/27) BesselK[1/3,2/27])/(3 Sqrt[3])
share|improve this answer
Thanks, that seems to work. However, it still doesn't change the fact that Mathematica gives an incorrect answer in the second integral, despite its claim in the ConditionalExpression[] that the answer is valid for real "a" and "b". – PJR Jul 10 '12 at 19:17

Mathematica tries the best that it can. It seems that it "does operations like numerical integration very differently from the way it does their symbolic counterparts". This link looks like it offers some settings adjustments that can help. I do not have the Mathematica software and I cannot vouch for this fixing your issue, but it is form a reputable source.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.