[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Evaluating a series
From: |
Przemek Klosowski |
Subject: |
Re: Evaluating a series |
Date: |
Thu, 9 Aug 2012 11:59:24 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 |
On 08/09/2012 03: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
This series looks like sum_{k=0}^{500} (-1)^k/(2k+1) . When you write it
out in Octave:
N=0:500; sum(<appropriate expression on the vector N>)
you should get something close to 0.786. Pay attention to the operators
acting on matrices---you can't just write (-1)^N/(2*N+1) because of the
way the exponentiation operator is defined for matrices in Octave, so
you have to use the element-by-element versions of the operators.
Actually, this problem of evaluating functions on vector arguments pops
in Octave so often that there are facilities to do it automatically:
* vectorize() makes sure a simple expression such as a^b works for
vector arguments.
* inline() makes it easy to construct a function from the expression
created by vectorize().
Therefore, the octave expression
inline(vectorize("(-1)^k/(2*k+1)"))(N)
calculates the elements of the series you want to sum.
- Re: Evaluating a series, (continued)
- Re: Evaluating a series, Jordi Gutiérrez Hermoso, 2012/08/09
- Re: Evaluating a series, Andy Buckle, 2012/08/09
- Re: Evaluating a series, Nicholas Jankowski, 2012/08/09
- Re: Evaluating a series, Jordi Gutiérrez Hermoso, 2012/08/09
- Re: Evaluating a series, Sergei Steshenko, 2012/08/09
Re: Evaluating a series, Francesco Potortì, 2012/08/09
Re: Evaluating a series,
Przemek Klosowski <=