First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I don't know about using Sage's symbolic sum, but this seems to work (based on the documentation for Sage's function, obtained by looking at function? and also at https://doc.sagemath.org/html/en/reference/calculus/sage/calculus/var.html#sage.calculus.var.function):

sage: def ev(self, x):
....:     if x == 0:
....:         return 1
....:     else:
....:         return sum(1+self(j) for j in range(x))
....: 
sage: f = function("f", nargs=1, eval_func=ev)
click to hide/show revision 2
No.2 Revision

I don't know about using Sage's symbolic sum, but this seems to work (based (idea based on the documentation for Sage's function, obtained by looking at function? and also at https://doc.sagemath.org/html/en/reference/calculus/sage/calculus/var.html#sage.calculus.var.function):

sage: def ev(self, x):
....:     if x == 0:
....:         return 1
....:     else:
....:         return sum(1+self(j) for j in range(x))
....: 
sage: f = function("f", nargs=1, eval_func=ev)