What is the reason of insufficient memory error while using FindRoot?

Hello,

Can anybody tell me why the following code produces an insufficient memory error, and what can be done to avoid this error?

F[x_,y_,g_]:=x-(Exp[y]-Exp[-g*y]);
y0=2*ArcSinh[x];
x=10;
g=10^10;
FindRoot[F[x,y,g],{y,y0},WorkingPrecision->50,PrecisionGoal->30,AccuracyGoal->∞];

I don’t understand why the Newton method requires so much memory; what has to be stored during the calculations? The requested precision also does not seem to me to be too demanding, and for a large value of gy there should be Exp[-gy] negligible in comparison with Exp[y], which should lead to a trivial solution y=Log[x].

Leslaw

I get Log[10] to 50 digits with your code in V14.1 without any trouble. I can’t imagine the version matters. Maybe try ClearAll[x, y, F, y0, g]; before executing. Or restarting the kernel. As you say, this computation shouldn’t have a memory problem.

I run the test code in batch mode under version 14.1 on a supercomputing cluster, and there is an insufficient memory error independently of whether I request 3850 MB or 7700 MB of memory. I have not tried more, because this seems nonsensical to me to expect that so much memory is needed.
In the batch mode, I believe, everything is cleared before any program is run, as every run begins
with loading the MATHEMATICA package.
So, I still don’t know what might cause such a memory demand. I would appreciate any suggestions.
Some other of my tests suggest that changing the method to Brent makes things even worse.
Is there here any potential problem with overflow or underflow in Exp? Maybe Newton iterations
cause the consecutive approximations to the root to escape into regions of overflow or underflow?
Is there any way to get an information about how these consecutive approximations look like?

Leslaw

I tried your code with clear kernel it seems a bug!!!. and tried with NSolve is the same bug.

The same code in Maple 2024 uses only 6 MB. Time to write e-mail to WRI.

Regards M.I.

On my PC (which is a long way from being a “Supercomputer”) this is what I get on a fresh kernel:

In[1]:= 
MemoryInUse[]
MaxMemoryUsed[]
Out[1]= 97675416
Out[2]= 98118248

In[3]:=
F[x_,y_,g_]:=x-(Exp[y]-Exp[-g*y]);
y0=2*ArcSinh[x];
x=10;
g=10^10;
y/.FindRoot[F[x,y,g],{y,y0},WorkingPrecision->50,PrecisionGoal->30,AccuracyGoal->\[Infinity]]
Out[7]= 2.3025850929940456840179914546843642076011014886288

In[8]:= 
MemoryInUse[]
MaxMemoryUsed[]
Out[8]= 94880360
Out[9]= 10908680648

Finding the root takes less than 5 seconds

Just to confirm: Mariusz’s code works without trouble on "14.1.0 for Mac OS X ARM (64-bit) (July 16, 2024)"

It seems to be a Windows problem. (Maybe Linux?)

The supercomputing cluster on which I run the program does not use Windows.

Leslaw

The maximum memory used in the successful test by Hans Milton is ca 10 GB !
So, his PC must have a pretty large memory available. And this may indicate that there is no bug,
but for some (unclear to me) reason, the calculations need a lot of memory.

Leslaw

My PC is a pretty basic Asus X415JA. Installed RAM is 8 GB. SystemInformation gives:

The virtual memory may contribute to explaining that 10 GB can be handled.