MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: For loop problem in mathematica


Mathematica does what *you* want, and *if* you wish tho get
exact results and later use N[_,25] you have to live with
the very long number you create. Look what

(i = 1;
   Nest[# + 1/(i++)^2 &, 0, 100]
    Sqrt[6*x]) // Timing

gives. You mean

(i = 1;
   Nest[# + 1/(i++)^2 &, N[0, 25], 100000]
    N[Sqrt[6*x], 25]) // Timing

to avoid the infinite precision calculation.
But it will still be very slow.


PhysNova wrote:
> Hi,
> i wrote a simple program of evaluating Pi number in M6 to test cpu
> computation timing, to do this a simple for loop
> was used:
> x=0;For[i = 1, i < 10,000,000, i++, x = x + 1/(i^2)];N[Sqrt(6*x),25]//
> Timing
> the result was catastrophe! it take few minuates. but i first expect
> to do this very simple job in few
> seconds.computation time is just satisfactory up to 100000 cycle.
> could anyone interperet this falut?
> our get an idea to improve the result?
> Tanks

  • Prev by Date: Re: Possible Bug in Mathematica 6
  • Next by Date: Re: Controling the color of line segments in a Log plot
  • Previous by thread: RE: For loop problem in mathematica
  • Next by thread: Re: For loop problem in mathematica