MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: how to make conditional summation


Xiao Jun Jun wrote:
> Hi, All,
> 
> Say, Sum[f[m],{m,-N,N}] with N != 0
> Any suggestions?
> 
> Regards.
> Xun 
> 

Xun, the easiest way is to use Conditions on the input.  In this case, 
the condition code is:

        /; N != 0


In[1]:= func[N_ /; N != 0] := Sum[f[m], {m, -N, N}]

In[2]:= func[2]

Out[2]= f[-2] + f[-1] + f[0] + f[1] + f[2]

In[5]:= func[0]

Out[5]= func[0]


-- 


Igor Antonio
Wolfram Research, Inc.
http://www.wolfram.com

To email me personally, remove the dash.


  • Prev by Date: Re: Position function
  • Next by Date: Re: Position function
  • Previous by thread: how to make conditional summation
  • Next by thread: Re: how to make conditional summation