help-octave
[Top][All Lists]
Advanced

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

Re: Evaluating a series


From: Nicholas Jankowski
Subject: Re: Evaluating a series
Date: Thu, 9 Aug 2012 08:26:13 -0400

On Thu, Aug 9, 2012 at 3:22 AM,  <address@hidden> wrote:
> Please assist me to do this:
> Evaluate the series
>
> 1-1/3+1/5-1/7+1/9-...+1/1001
>
> Duncan
> Sent from my BlackBerry® wireless device
>

While there may be more elegant ways to do this, you're basically
trying to repeat an addition operation of items with changing value.
So, you need two things:

(1) an expression for the changing value. Something as a function of
'n' that gives you the right value (i.e., n=1, you get 1, n=2, you get
-1/3...)
(2) you need a way of adding them all together until you get up to
1/1001.  For programming or scripting languages like Octave, you can
use a looping structure. maybe a for loop if you know how many
elements, or a do-while loop if you want it to run until a condition
is met. from within Octave, to get the syntaxyou can type:

help for
or
help do

But, it sounds like you might need something more basic to get
started. I would recommend you flip through this to get a quick feel
for how to use Octave:

http://people.sc.fsu.edu/~sshanbhag/matlab.primer.pdf
(the filename says matlab, but the document title is "GNU
Octave/Matlab Primer" and it walks you through the basics.

Nick J.


reply via email to

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