# Revision history [back]

### How to substitute a function within derivatives?

I want to simplify an ODE by making a substitution, say g(x) -> h(x)*x, but can't get it to work. I tried:

g=function('g', x) h=function('h', x) dg = g.diff(x) dg

sage output: D0(x)

dg.subs(g==h*x)

sage output: D0(x)

The substitution is not done for the g function within derivatives. I tried dg.subs(g(x)==h(x)*x) too, got deprecation warnings and the same results. How can I make this work? This is a simplified example, in reality, instead of dg, I have the lhs of an ODE defined interms of g(x).

Thanks 2 No.2 Revision

### How to substitute a function within derivatives?

I want to simplify an ODE by making a substitution, say g(x) -> h(x)*x, but can't get it to work. I tried:

g=function('g', x)
h=function('h', x)
dg = g.diff(x)
dgdg
sage output: D0(x)D(g)(x)
dg.subs(g==h*x)
dg.subs(g==h*x) sage output: D0(x)D(g)(x)


The substitution is not done for the g function within derivatives. I tried dg.subs(g(x)==h(x)*x) too, got deprecation warnings and the same results. How can I make this work? This is a simplified example, in reality, instead of dg, I have the lhs of an ODE defined interms of g(x).

Thanks 3 retagged FrédéricC 2564 ●3 ●28 ●53

### How to substitute a function within derivatives?

I want to simplify an ODE by making a substitution, say g(x) -> h(x)*x, but can't get it to work. I tried:

g=function('g', x)
h=function('h', x)
dg = g.diff(x)
dg

sage output: D(g)(x)

dg.subs(g==h*x)

sage output: D(g)(x)


The substitution is not done for the g function within derivatives. I tried dg.subs(g(x)==h(x)*x) too, got deprecation warnings and the same results. How can I make this work? This is a simplified example, in reality, instead of dg, I have the lhs of an ODE defined interms of g(x).

Thanks