Re: For loop problem in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg90288] Re: For loop problem in mathematica
- From: "Dana DeLouis" <dana.del at gmail.com>
- Date: Fri, 4 Jul 2008 04:00:15 -0400 (EDT)
> x=0;For[i = 1, i < 10,000,000, i++, x = x + 1/(i^2)];N[Sqrt(6*x),25] I know this is a question about looping, but just to mention... Sum[1/r^2, {r, Infinity}] Pi^2/6 HarmonicNumber[Infinity, 2] Pi^2/6 Or...just use the '2 (ie i^2) in the Zeta function Zeta[2] Pi^2/6 Hence... Sqrt[6*Zeta[2]] Pi -- HTH Dana DeLouis "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 >