- #1
earth2
- 86
- 0
Hi guys,
i have expressions of the type (X*a)(X*b). I want replace this by X^2(a*b).
So i tried building a block which does nothing but
%//.(X*a_)(X*b_)->X^2(a*b).
However, this works only if a is distinct from b. If a and b are equal if HAVE to use the replacement command
%//.(X*a_)(X*a_)->X^2(a*a).
Can I tweak the replace command s.t. Mathematica does the replacement even if a is equal to b, too, without having to write a new replacement command? That would be cool :)
Cheers,
earth2
i have expressions of the type (X*a)(X*b). I want replace this by X^2(a*b).
So i tried building a block which does nothing but
%//.(X*a_)(X*b_)->X^2(a*b).
However, this works only if a is distinct from b. If a and b are equal if HAVE to use the replacement command
%//.(X*a_)(X*a_)->X^2(a*a).
Can I tweak the replace command s.t. Mathematica does the replacement even if a is equal to b, too, without having to write a new replacement command? That would be cool :)
Cheers,
earth2