Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Substitute differential operators in an expression.

Let's say I am taking derivatives of an expression involving unknow function.

var('x,a,b');

f=(x^(a+b)).function(x,a,b);

h=function('h',nargs=1)(x);

g=h(f(x,a,b));

dg=diff(g,x);

dg

This gives the output

(a + b)*x^(a + b - 1)*D[0](h)(x^(a + b))

How do I replace D[0](h)(x^(a + b)) with something like direvative_of_h(x^(a + b))? In this simple case, I can just do this manually using .operands, but if I have a rather complicated equation, how I can I do it?