Re: For loop problem in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg90258] Re: For loop problem in mathematica
- From: "Dana DeLouis" <dana.del at gmail.com>
- Date: Thu, 3 Jul 2008 06:14:17 -0400 (EDT)
> For[i = 1, i < 10,000,000, i++, x = x + 1/(i^2)]; Just to add. The "HarmonicNumber" of 10,000,000 is very large to be done quickly. If you wish Machine Precision, perhaps another idea: Timing[Sqrt[6*HarmonicNumber[10000000., 2]]] {0.`, 3.1415925580968302`} Just a note: The Numerator of just 100,000 has about 87,000 digits in it. HarmonicNumber[100000, 2] // Numerator // IntegerLength 86904 -- HTH :>) Dana DeLouis Mathematica 6.01 (Windows Vista) Having to Read 5.0 Help Files "PhysNova" <skhoshbinfar at gmail.com> wrote in message news:g4d2qf$emo$1 at smc.vnet.net... > 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 >