Re: Another Out of Memory Problem

• To: mathgroup at smc.vnet.net
• Subject: [mg91311] Re: Another Out of Memory Problem
• From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
• Date: Fri, 15 Aug 2008 06:52:33 -0400 (EDT)
• References: <g8137j\$19\$1@smc.vnet.net> <48A42D4D.7060504@gmail.com>

```On Thu, Aug 14, 2008 at 3:08 PM, Kevin J. McCann wrote:

> Thanks, Jean-Marc. I still find it strange that it runs out of memory and so
> fast. The error message comes up within less than 1 second.

[... Cross-posted on MathGroup ...]

Kevin,

I have just tried to do the integration with approximate coefficient
on my system (64-bit Intel Core 2 Duo 4 GB RAM Mac OS X Leopard 1.5.4
Mathematica 6.0.3).

. On this 64-bit platform, the kernel does not crash: the expression
two minutes cpu-time)

. However, the computation takes up to about 2.2 GB of memory, which
is fine on a 64-bit system but is too much on a standard 32-bit
platform

. Also, I have observed thanks to the command Top (UNIX/Mac OS X shell
command) that the memory consumption varies/oscillates quickly from
nearly nothing (few dozens of MB) to one or two GB in a fraction of
second

. OTOH, with exact coeffiecients, the integration consumes about 200
MB of memory (steady increase from the beginning to the end, no wild
variations, as far as I can tell), though the process is seven time
slower

So it seems that the algorithm goes wild when used with approximate
numbers, for reasons I am clueless about.

(* Timing and memory consumption with *floating-point* coefficients *)

In[1]:= Integrate[Cos[2.5*x]*Exp[I*z*Cos[x]], {x, -Pi, Pi}] // Timing

Out[1]=
I z Cos[x]
{112.795, Integrate[E           Cos[2.5 x], {x, -Pi, Pi}]}

In[2]:= MaxMemoryUsed[]/2.^30 GB

Out[2]= 2.19748 GB

In[3]:= \$Version

Out[3]= "6.0 for Mac OS X x86 (64-bit) (May 21, 2008)"

(* Timing and memory consumption with *exact* coefficients *)

In[1]:= Integrate[Cos[5/2*x]*Exp[I*z*Cos[x]], {x, -Pi, Pi}] // Timing

Out[1]=
I z Cos[x]     5 x
{705.092, Integrate[E           Cos[---], {x, -Pi, Pi}]}
2

In[2]:= MaxMemoryUsed[]/2.^30 GB

Out[2]= 0.191426 GB

In[3]:= \$Version

Out[3]= "6.0 for Mac OS X x86 (64-bit) (May 21, 2008)"

Best regards,
-- Jean-Marc

> Kevin
>
> Jean-Marc Gulliet wrote:
>>
>> Kevin J. McCann wrote:
>>
>>> I can do the following:
>>>
>>> Integrate[Cos[2*x]*
>>>      Exp[I*z*Cos[x]],
>>>    {x, -Pi, Pi}]
>>>
>>>
>>> which produces a Bessel function answer; however if I change the
>>> argument in the cosine to 2.5 as in:
>>>
>>> Integrate[Cos[2.5*x]*
>>>      Exp[I*z*Cos[x]],
>>>    {x, -Pi, Pi}]
>>>
>>> I almost immediately get this:
>>>
>>> No more memory available.
>>> Mathematica kernel has shut down.
>>> Try quitting other applications and then retry.
>>>
>>> Any ideas why? I am running XP with 2Gb of memory.
>>
>> When using symbolic function (i.e. Integrate rather than NIntegrate, Solve
>> rather than NSolve, etc.) it is always a good idea to feed the function with
>> *exact* (infinite precision) numbers, thus 5/2 rather 2.5 in your case.
>> (Mathematica does not find any closed form for your integrand. Note that it
>> take a while to compute but memory consumption is under control.)
>>
>> In[1]:= Integrate[Cos[5/2*x]*Exp[I*z*Cos[x]], {x, -Pi, Pi}]
>>
>> Out[1]=
>>
>>           I z Cos[x]     5 x
>> Integrate[E           Cos[---], {x, -Pi, Pi}]
>>                           2

```

• Prev by Date: Re: NDSolve precision and velocity problem
• Next by Date: Re: NDSolve precision and velocity problem
• Previous by thread: Re: Another Out of Memory Problem
• Next by thread: Re: Another Out of Memory Problem