ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 04 Dec 2015 11:41:53 +0100Substitution of parametershttps://ask.sagemath.org/question/31314/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!Fri, 04 Dec 2015 10:05:49 +0100https://ask.sagemath.org/question/31314/substitution-of-parameters/Answer by slelievre for <p>I would like to understand what is the correct and more efficient way for performing sostitution of parameters in objects of some category.</p>
<p>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..</p>
<pre><code>E.<x,y> = ExteriorAlgebra(SR)
_=var("t")
theta = 3*x+t*y
print "theta = ", theta
theta2 = theta.substitute({t:0})
print "modified theta = ", theta2
</code></pre>
<p>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.</p>
<pre><code>E.<x,y> = ExteriorAlgebra(SR)
_=var("t")
theta = 3*x+t*y
print "theta = ", theta
assume(t==0)
theta2 = theta
print "modified theta = ", theta2
</code></pre>
<p>Thanks in advance for any suggestions!</p>
https://ask.sagemath.org/question/31314/substitution-of-parameters/?answer=31319#post-id-31319The 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
Fri, 04 Dec 2015 11:41:53 +0100https://ask.sagemath.org/question/31314/substitution-of-parameters/?answer=31319#post-id-31319