1
$\begingroup$

In the following expression, how can I group apart the terms in the exponential with a and b coefficients so that I can express the expression as the product of two exponentials with same-kind coefficients?

expr = C * E^(a1*w[i] + b1*x[i] + (a2 + b2) p[i])

I would like to be able to simplify the above expression to get

C * E^(a1*w[i] + a2*p[i]) * E^(b1*x[i] + b2*p[i])

Edit:

Thanks to J. M. needs help. I realize that in attempting to simplify my original problem I was asking for something non-sensical. So here is a bigger part the expression I'm trying to simplify

toSimplify = (E^((a2 + b2) p[i] + a1 w[i] + b x[i]) w[i])/(1 + E^(a2 p[i] + a1 w[i]))^2

using

fA[i] = E^(a2*p[i] + a1*w[i])/(1 + E^(a2*p[i] + a1*w[i]))
fB[i] = E^(b2*p[i] + b1*w[i])

So that I can get something like this

desired = fA[i]*((1 - fA[i])*fB[id]*w[i]
$\endgroup$
  • $\begingroup$ Did you try evaluating E^(a1*w[i] + a2*p[i])*E^(b1*x[i] + b2*p[i]) yourself to see what happens? $\endgroup$ – J. M. will be back soon Apr 10 '18 at 1:56
  • $\begingroup$ @J.M. Thanks for pointing that out. I have edited my question to something more meaningful. $\endgroup$ – Maturin Apr 10 '18 at 3:38
1
$\begingroup$

One can use the ComplexityFunction option in FullSimplify. In your example the following works:

toSimplify = (E^((a2 + b2) p[i] + a1 w[i] + b x[i]) w[i])/(1 +E^(a2 p[i] + a1 w[i]))^2
varsa = a1 | a2
varsb = b | b2
f[e_] := LeafCount[e] + 
      1000 Total@ Boole@(! Or[FreeQ[#, varsa], FreeQ[#, varsb]] & /@ List @@ e)
FullSimplify[toSimplify, ComplexityFunction -> f]

$$\frac{w(i) e^{b x(i)+\text{b2} p(i)}}{2 \cosh (\text{a1} w(i)+\text{a2} p(i))+2}$$

$\endgroup$
1
$\begingroup$

You might make the following steps:

expr1 = MapAt[Expand, 
    toSimplify, {1, 2}] /. {a2 p[i] + a1 w[i] -> X} /. 
  b2 p[i] + b x[i] -> Y

(*   (E^(X + Y) w[i])/(1 + E^X)^2   *)

Then

expr2 = expr1 /. (Exp[X + Y]*a_)/(1 + Exp[X])^2 -> 
   fA*HoldForm[Exp[Y]/(1 + Exp[X])]*a

enter image description here

and

expr3 = ReleaseHold[expr2] /. E^Y -> fB

(* (fA fB w[i])/(1 + E^X)  *)

I guess that it is not exactly what you had in mind, but that's how you have defined the transformations, and I followed them strictly.

Have fun

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.