Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following code shows the differences in type and parent of the names g , h , j and k

g(x)=function('g',x)
h=function('h',x)
function('j',x)
k = function('k')

L = [g,h,j,k]
for func in L: print func,' : ',type(func)
print '---'
for func in L: 
    try: print func,' : ', func.parent()
    except: print func, 'has no parent'

Output:

x |--> g(x)  :  <type 'sage.symbolic.expression.Expression'>
h(x)  :  <type 'sage.symbolic.expression.Expression'>
j  :  <class 'sage.symbolic.function_factory.NewSymbolicFunction'>
k  :  <class 'sage.symbolic.function_factory.NewSymbolicFunction'>
---
x |--> g(x)  :  Callable function ring with arguments (x,)
h(x)  :  Symbolic Ring
j  :  j has no parent
k  :  k has no parent

IMHO the following doesn't look complicated

function('g')
function('h')
z = h(x)*x^2
dg = g(x).diff(x)
dg ; dg.substitute_function(g,z)