I am doing numerical calculations with a For loop of 2000 cycles. In each cycle, there are hundreds of floating point calculations.
If I set the number of cycles to 100, it takes about 4 sec to finish. However, when the number of cycles is 2000, the code
goes fast for the first about 400 cycles but then slows down badly. The total calculation takes about 12 min = 720 sec.
But the expected time is about 4 x 20 = 80 sec.
I have never seen this before. Can anyone give me some hints?
Thanks.
Thanks to everyone. Problem solved but do not know why. My previous code had many expressions of “f[array]” with f a function, and arithmetic operations on those arrays and “f[array]”. All those were in the For loop. Now I changed the code in a way that function calculations are outside of the For loop and in the loop, only simple list manipulations. With everything calculated, 4000 cycles only costs 9 sec.
I even reinstalled Mathematica and it turned out it was not system problem. I guess over/underflow could be a reason.
Thanks again.