Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When numerically calculating a double integral using NIntegrate over an infinite domain (with all options at their default), Mathematica 7 calculates my integral with some comments about slow convergence, but Mathematica 9 aborts calculating with a long message which starts with

SystemException["MemoryAllocationFailure" ...

What do I have to do to make the calculation in Mathematica 9 (Linux)?

share|improve this question
My experience with this site tells me that people will ask you to show them what integral you're trying to do, and what output (if any) you get before crashing.. in both versions. –  QuantumDot May 14 '13 at 5:38
@nail, that doesn't parse if I copy and paste into Mathematica. Can you edit the original question so that the calculation you are trying to do is included? –  Jonathan Shock May 14 '13 at 5:52
Sorry, I forget about this point. The file with calculations is rather long and it may be found here yadi.sk/d/OQzPSZQg4oZly . –  nail May 14 '13 at 5:58
In which case can you find the minimum amount of code which will reproduce the error? Looking through the code it seems that you should be able to simplify the problem and it is still likely to run into memory problems as you have it set up. –  Jonathan Shock May 14 '13 at 6:26
Ok, I'll try to minimize the code with problem. –  nail May 14 '13 at 7:05

1 Answer 1

I get this error fairly often and my usual course of action is to switch over to Mathematica 8 which does not get this error. A relatively minimal way to get this error in Mathematica 9 is to run the following three commands:

lambda[t_] := ModularLambda[t]
theta[t_] := EllipticTheta[3, 0, Exp[I Pi t]]
N[-Pi Integrate[
   lambda[I x]^4 theta[I x]^4 lambda[I x] (1 - lambda[I x]), {x, 0, 
    Infinity}], 30]

In Mathematica 8 this integral calculates without any problems. The two definitions are needed to replicate this error for some reason. My suspicion is that it has something to do with the complexity of the integrand.

I have been trying a different workaround which has helped in some instances. If I compile the integrand, the MemoryAllocationFailure goes away and is replaced with another error that I can sometimes fix:

Block[{integrandCompiled, integrandDeferred},
 integrandCompiled = 
   N[lambda[I x]^4 theta[I x]^4 lambda[I x] (1 - lambda[I x])]];
 integrandDeferred[x_ /; NumberQ[x]] := integrandCompiled[x];
 -Pi NIntegrate[integrandDeferred[x], {x, .1, 10},
   PrecisionGoal -> 30]

This code gets the right answer but generates error messages. With integration, I usually throw away the result if I get any error because I have seen integration results that are completely wrong when errors occur during the integration.

share|improve this answer
In your first example you don't need := (SetDelayed). Then you can use NIntegrate[ lambda[I x]^4 theta[I x]^4 lambda[I x] (1 - lambda[I x]), {x, 0, Infinity}] and it works... –  s0rce Oct 14 '13 at 16:20

Your Answer


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

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