Question: How to factor out an integer?

 

restart:
tmp:=Vector(
[
1+(-s[2]-s[4]+2*w[1]/(1+1/exp(mu[p]))^2+(2*(-w[1]+1))/(1+1/(exp(mu[p])*exp(eta[p2])))^2)*s[1]^3+(-s[2]+s[3])*s[1]^2-s[2]*s[1],

(s[2]+s[4]-2*w[1]/(1+1/exp(mu[p]))^2-(2*(-w[1]+1))/(1+1/(exp(mu[p])*exp(eta[p2])))^2)*s[1]^3
]
);

tmp := Vector(2, {(1) = 1+(-s[2]-s[4]+2*w[1]/(1+1/exp(mu[p]))^2+(-2*w[1]+2)/(1+1/(exp(mu[p])*exp(eta[p2])))^2)*s[1]^3+(-s[2]+s[3])*s[1]^2-s[2]*s[1], (2) = (s[2]+s[4]-2*w[1]/(1+1/exp(mu[p]))^2-(-2*w[1]+2)/(1+1/(exp(mu[p])*exp(eta[p2])))^2)*s[1]^3})

(1)

rule3:=w[1]/(1+1/exp(mu[p]))^2+(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2 = s[3];

w[1]/(1+1/exp(mu[p]))^2+(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2 = s[3]

(2)

applyrule(rule3,tmp[1]);

1+(-s[2]-s[4]+2*w[1]/(1+1/exp(mu[p]))^2+2*(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2)*s[1]^3+(-s[2]+s[3])*s[1]^2-s[2]*s[1]

(3)

 

``

 

Download problem.mw

 

This is part of a large simplifcation where lots of terms are being substituted. In two of those terms, it did not simplify as we would expect.

I think the main thing is trying to find a way to factor out the "2".

 

I could do this

> rule3:=w[1]/(1+1/exp(mu[p]))^2+(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2 = s[3];
>rule3:=2*rule3;

> rule3ne:=-(w[1]/(1+1/exp(mu[p]))^2+(-w[1]+1)/(1+1/(exp(mu[p])*exp(eta[p2])))^2) = -s[3];
> rule3ne:=2*rule3ne;

> applyrule(rule3,tmp[1]);
> applyrule(rule3ne,tmp[2]);

For this example, this works.

But I hope for a more generic approach.

 

Thanks,

 

casper

 

 

 

Please Wait...