Hi Stefan,
On Mon, 25 Jan 2010 06:49:55 -0800 (PST)
Ichnich <[email protected]> wrote:
> there seems to be a bug in substitute:
>
> var('k1 k2 k3')
> f = (k1+k2)^2
> f.substitute(k1+k2==k3)
>
> gives k3^2 as expected.
>
> var('k1 k2 k3')
> f = (k1+k2)*2
> f.substitute(k1+k2==k3)
>
> gives 2*k1 + 2*k2. The same happens for +2 instead of *2.
In your example, (k1 + k2) is not a subexpression of f, so there is
nothing to substitute.
sage: var('k1 k2 k3')
(k1, k2, k3)
sage: f = (k1+k2)*2
sage: f
2*k1 + 2*k2
sage: f.has(k1+k2)
False
> Is there an alternative to do a substitution?
You can rephrase your substitution as k1 == k3 - k2:
sage: f.substitute(k1==k3-k2)
2*k3
Cheers,
Burcin
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org