Processing math: 100%
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Substitution of several variables

Let f=f(x1(t),x2(t)) be defined as follows:

sage: var('t mu')
sage: x=list()   
sage: x.append( function('x1')(t) )
sage: x.append( function('x2')(t) )
sage: f = x[0] - mu*x[0]^2*x[1]
sage: f

f=x1(t)μx1(t)2x2(t).

Now, I need to to substitute the term containing x21(t)x2(t) in f by some new auxiliary variable x3(t), that is, to obtain f=x1(t)μx3(t). However, this code doesn't work:

sage: x.append( function('x3')(t) )
sage: f.subs({x[0]^2*x[1] : x[2]})

However, this code doesn't work. Some ideas? Thanks.

This code is motivated by symbolic manipulation with ODEs (think of f as being the right-hand side term in the autonomous ODE system ˙x(t)=f(x(t)) ).

click to hide/show revision 2
No.2 Revision

Substitution of several variables

Let f=f(x1(t),x2(t)) be defined as follows:

sage: var('t mu')
sage: x=list()   
sage: x.append( function('x1')(t) )
sage: x.append( function('x2')(t) )
sage: f = x[0] - mu*x[0]^2*x[1]
sage: f

f=x1(t)μx1(t)2x2(t).

Now, I need to to substitute the term containing x21(t)x2(t) in f by some new auxiliary variable x3(t), that is, to obtain f=x1(t)μx3(t). However, this code doesn't work:

sage: x.append( function('x3')(t) )
sage: f.subs({x[0]^2*x[1] : x[2]})

However, this code doesn't work. Some ideas? Thanks.

This code is motivated by symbolic manipulation with ODEs (think of f as being the right-hand side term in the autonomous ODE system ˙x(t)=f(x(t)) ).