Is there a reason why integers are treated so differently to variables?
If, for example, 2 is replaced by a variable, everything works as expected:
h = (k1 + k2)*x
h.subs_expr(k1 + k2 == k3)
k3*x
I don't understand why g is expanded to
2*k1 + 2*k2
but h not to
x*k1 + x*k2
Is there no way
Hi Stefan,
On Mon, 25 Jan 2010 06:49:55 -0800 (PST)
Ichnich 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
Hello everyone,
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.
Is there an alternative to do a substitution?
T