# Substitution of parameters

I would like to understand what is the correct and more efficient way for performing sostitution of parameters in objects of some category.

For example, a typical problem for me is the following. I have a 1-form in an ExteriorAlgebra, whose coefficients depends on some variable, let's say t. I find conditions on such parameters, let's say, t should be zero in order that some property holds. (In general, i will have solutions of linear systems.) I try to use "substitute" for setting the parameter to be 0, but this does not work to me..

E.<x,y> = ExteriorAlgebra(SR)
_=var("t")
theta = 3*x+t*y
print "theta = ", theta
theta2 = theta.substitute({t:0})
print "modified theta = ", theta2


Another solution I tried is the following. I assume t==0 at a certain point. But this seems to me to force the substitution before too.

E.<x,y> = ExteriorAlgebra(SR)
_=var("t")
theta = 3*x+t*y
print "theta = ", theta
assume(t==0)
theta2 = theta
print "modified theta = ", theta2


Thanks in advance for any suggestions!

edit retag close merge delete

Sort by ยป oldest newest most voted

The substitution needs to happen in each coefficient.

The following works.

sage: E.<x,y> = ExteriorAlgebra(SR)
sage: _ = var('t')
sage: theta = 3*x+t*y
sage: print "theta =", theta
theta = 3*x + t*y
sage: theta.map_coefficients(lambda c: c.substitute({t:0}))
3*x

more