Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to change variables in differential equation?

Hey guys,

I'd like to find a way to make a change of variables in diff equation(why is there no intrinsic method?) My attempt: Assume that I have some random equation :

  equa = diff(F,r,2)+diff(F,t)F

and let's say I'd like to change the variable r to z = r^2 - a^2.

The way I do it now is using the following trick:

p=solve(z==(r^2-a^2) ,r)
T = function('T')(z)
final = equat.substitute_function(G,T).subs(r=p[0].rhs()).full_simplify()

It gives the following depreciation message:

DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)

It's very clumsy, but at least it is working.

But that is not it. The following code just gives rubbish output using more or less the same logic

exm = function('exam')(x,y)
diffequ= diff(exm,x)
diffexp= function('probe')(m+y^2,y/x)

output: D_0(probe)(y^2+x,1)

Which is just plain wrong!

Is there a way to work around those problems?