Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

click to hide/show revision 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)
dg

dg

sage output: D0(x)

D[0](g)(x) dg.subs(g==h*x)

dg.subs(g==h*x)

sage output: D0(x)

D[0](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

click to hide/show revision 3
retagged

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[0](g)(x)

dg.subs(g==h*x)

sage output: D[0](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