help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Computation time for newcommer


From: Francesco Potortì
Subject: Re: Computation time for newcommer
Date: Tue, 25 Sep 2012 16:25:15 +0200

>Hi guys, new here!
>
>So I'm trying to compute the value of pi using a series with a billion
>terms (n):
>
>for i=1:1:n
>       x(i) = ( (-1)^(i + 1) ) / ( (2*i) - 1 );
>end
>
>% Sum all the values in the vector x
>
>value = 4*sum(x)
>
>When I run this however, nothing happens ... I just get a blinking prompt
>and have to CTRL+C to get back to normal.

First of all, you should study your problem.  Jordi's answer gives you
some fundamental starting points.

Second, if you do not know your problem well, start with a smaller
problem: try with n=1000, or n=1e6 if you want to experiment.

>I'm running on a 1.3GHz 64-bit machine with 4GB RAM. I'm fairly new to
>numerical computation, but why is this happening?

On my box, which is more then twice faster and with three times the
memory, after preallocation, your example needs almost two hours to run
and uses up almost all available memory.

-- 
Francesco Potortì (ricercatore)        Voice:  +39.050.315.3058 (op.2111)
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Fax:    +39.050.315.2040  
(entrance 20, 1st floor, room C71)     Web:    http://fly.isti.cnr.it


reply via email to

[Prev in Thread] Current Thread [Next in Thread]