Discussion:
Sequences
(too old to reply)
Douw
2009-08-23 16:56:56 UTC
Permalink
How do I Evaluate a sequence of 1-1/3+1/5-1/7+1/9-.........+1/1001 on
Octave.
Mirek
2009-08-23 19:27:19 UTC
Permalink
Post by Douw
How do I Evaluate a sequence of 1-1/3+1/5-1/7+1/9-.........+1/1001 on
Octave.
n=1:1001/2; result = sum( (-1).^(n-1) ./ (1+2*n) )
or
n=1:1001/2; sequence = cumsum( (-1).^(n-1) ./ (1+2*n) );
AMX
2009-09-02 08:48:56 UTC
Permalink
On Sun, 23 Aug 2009 09:56:56 -0700 (PDT),
Post by Douw
How do I Evaluate a sequence of 1-1/3+1/5-1/7+1/9-.........+1/1001 on
Octave.
One of many possibilities:

S=0;
sign=1;
for i=0:500
d=2*i+1;
S=S+sign/d;
sign=-sign;
end%for
disp(S);

AMX
--
adres w rot13
Nyrxfnaqre Znghfmnx r-***@b2.cy
Loading...