Ask Your Question

Revision history [back]

Not sure Sage supports that kind of "holding".

Here is a workaround.

Define two versions of the function f, one "anonymous" and one "explicit":

sage: f = function('f')
sage: ff(x) = x**2

Use the symbolic one to define g:

sage: g(y) = f(y) + 2*y
sage: g
y |--> 2*y + f(y)

When you need it, substitute:

sage: g.substitute_function(f, ff)
y^2 + 2*y