Updates:
Status: Invalid
Comment #1 on issue 2393 by asmeurer: Sum error
http://code.google.com/p/sympy/issues/detail?id=2393
Well, you can't do symbolic manipulation with a Python function (or else we
wouldn't need SymPy!). The function just evaluates a(k) to 0, because k is
not an Integer.
This is the proper way to define your own function in SymPy. Notice that
if you make it always return 0 when it's not an integer:
In [32]: class a(Function):
nargs = 1
@classmethod
def eval(cls, arg):
if arg.is_Integer:
return S.One
return S.Zero
....:
....:
In [39]: Sum(a(k), (k, 1, 10))
Out[39]:
10
__
\ `
) 0
/_,
k = 1
In [40]: class a(Function):
nargs = 1
@classmethod
def eval(cls, arg):
if arg.is_Integer:
return S.One
....:
....:
In [47]: Sum(a(k), (k, 1, 10))
Out[47]:
10
__
\ `
) a(k)
/_,
k = 1
In [48]: Sum(a(k), (k, 1, 10)).doit()
Out[48]: 10
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.