Question: No doubt that someone will provide a smarter solut...

No doubt that someone will provide a smarter solution: 

 

# the main idea

f := exp(a-b);
subs(B=-b, expand(subs(b=-B, f)));

exp(a-b)

 

exp(a)*exp(-b)

(1)

# ad hoc application
restart:

f := 2*gamma(t, r)-2*alpha(t, r)-2*beta(t, r);
c := op~(1, [op(f)]);
C := [seq(u[i], i=1..numelems(c))];

subs(C=~c, expand(subs(c=~C, exp(f))))
 

2*gamma(t, r)-2*alpha(t, r)-2*beta(t, r)

 

[2, -2, -2]

 

[u[1], u[2], u[3]]

 

exp(2*gamma(t, r))*exp(-2*alpha(t, r))*exp(-2*beta(t, r))

(2)

 


 

Download exp.mw

Please Wait...