# Simplifying expression and arranging terms in power of exponent

I have lots of expressions like below which I want to simplify but I am not sure how to do it in Mathematica. I am looking to simplify them in the form of $$\Sigma _i A_i e^{y_i}$$ where $$A_i$$ will be the simplest fraction corresponding to different values of exponential powers $$y_i$$. Can someone help and also point me to resources for Mathematica programming so that I can learn?

My expression: $$\frac{\lambda _1^3 e^{-\Gamma \left(\lambda _2 \mu +\lambda _1+\lambda _r\right)} \left(\lambda _r e^{\Gamma \left(\lambda _2 \mu +\lambda _1\right)} \left(e^{\Gamma \lambda _r}-1\right)-\lambda _2 \mu \left(e^{\Gamma \lambda _2 \mu } \left(e^{\Gamma \lambda _1}+e^{\Gamma \lambda _r}-e^{\Gamma \left(\lambda _1+\lambda _r\right)}\right)-1\right)\right)}{\left(-\lambda _2 \mu +\lambda _1-\lambda _r\right) \left(\lambda _2 \mu +\lambda _1-\lambda _r\right) \left(\lambda _2 \mu +\lambda _r\right) \left(\lambda _2 \mu +\lambda _1+\lambda _r\right)} + \frac{\lambda _1^2 e^{-\Gamma \left(\lambda _2 \mu +\lambda _1+\lambda _r\right)} \left(e^{\Gamma \left(\lambda _2 \mu +\lambda _r\right)} \left(\lambda _2^2 \mu ^2 \left(e^{\Gamma \lambda _1}-1\right)-\left(e^{\Gamma \lambda _1}-1\right) \lambda _r^2+2 \lambda _2 \mu \lambda _r\right)-2 \lambda _2 \mu \lambda _r\right)}{\left(-\lambda _2 \mu +\lambda _1-\lambda _r\right) \left(\lambda _2 \mu +\lambda _1-\lambda _r\right) \left(\lambda _2 \mu +\lambda _r\right) \left(\lambda _2 \mu +\lambda _1+\lambda _r\right)}$$ with assumptions:
$$\mu >0,\mu \in \mathbb{R},\mu <1,\Gamma >0,\Gamma \in \mathbb{R},\lambda _1>0,\lambda _1\in \mathbb{R},\lambda _2>0,\lambda _2\in \mathbb{R},\lambda _r>0,\lambda _r\in \mathbb{R}$$

Following is the input form

(Subscript[λ, 1]^3*
(-((-1 + E^(Γ*μ*Subscript[λ, 2])*
(E^(Γ*Subscript[λ, 1]) +
E^(Γ*Subscript[λ, r]) -
E^(Γ*(Subscript[λ, 1] +
Subscript[λ, r]))))*μ*Subscript[λ, 2]) +
E^(Γ*(Subscript[λ, 1] + μ*Subscript[λ, 2]))*
(-1 + E^(Γ*Subscript[λ, r]))*
Subscript[λ, r]))/
E^(Γ*(Subscript[λ, 1] + μ*Subscript[λ, 2] +
Subscript[λ, r]))/
((Subscript[λ, 1] - μ*Subscript[λ, 2] -
Subscript[λ, r])*(Subscript[λ, 1] +
μ*Subscript[λ, 2] - Subscript[λ, r])*
(μ*Subscript[λ, 2] + Subscript[λ, r])*
(Subscript[λ, 1] + μ*Subscript[λ, 2] +
Subscript[λ, r])) +
(Subscript[λ, 1]^2*(-2*μ*Subscript[λ, 2]*
Subscript[λ, r] +
E^(Γ*(μ*Subscript[λ, 2] +
Subscript[λ, r]))*
((-1 + E^(Γ*Subscript[λ, 1]))*μ^2*
Subscript[λ, 2]^2 + 2*μ*Subscript[λ, 2]*
Subscript[λ, r] -
(-1 + E^(Γ*Subscript[λ, 1]))*
Subscript[λ, r]^2)))/
E^(Γ*(Subscript[λ, 1] + μ*
Subscript[λ, 2] + Subscript[λ, r]))/
((Subscript[λ, 1] - μ*Subscript[λ, 2] -
Subscript[λ, r])*(Subscript[λ, 1] +
μ*Subscript[λ, 2] - Subscript[λ, r])*
(μ*Subscript[λ, 2] + Subscript[λ, r])*
(Subscript[λ, 1] + μ*Subscript[λ, 2] +
Subscript[λ, r]));

assume = {0 < μ <
1, {Γ, Subscript[λ, 1], Subscript[λ, 2],
Subscript[λ, r]} ∈ PositiveReals};

• What do you know about the variables? Are any real or positive or negative or constrained to an interval or .… To get the simplest form you must tell Mathematica all that you know. May 16, 2023 at 16:30
• Assuming that there are some constraints on the variables, when you edit your question to include the constraints, also include the Mathematica code (InputForm) for your expression so that it can be copy and pasted into a notebook. May 16, 2023 at 16:55
• @BobHanlon Updated the question as per your comments. May 16, 2023 at 18:26

\$Version

(* "13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)" *)

Clear["Global*"]


The InputForm of an expression does not display any of the box structure. The InputForm of your expression is

expr = (Subscript[λ, 1]^3*
(-((-1 + E^(Γ*μ*Subscript[λ, 2])*
(E^(Γ*Subscript[λ, 1]) +
E^(Γ*Subscript[λ, r]) -
E^(Γ*(Subscript[λ, 1] +
Subscript[λ, r]))))*μ*Subscript[λ, 2]) +
E^(Γ*(Subscript[λ, 1] + μ*Subscript[λ, 2]))*
(-1 + E^(Γ*Subscript[λ, r]))*
Subscript[λ, r]))/
E^(Γ*(Subscript[λ, 1] + μ*Subscript[λ, 2] +
Subscript[λ, r]))/
((Subscript[λ, 1] - μ*Subscript[λ, 2] -
Subscript[λ, r])*(Subscript[λ, 1] +
μ*Subscript[λ, 2] - Subscript[λ, r])*
(μ*Subscript[λ, 2] + Subscript[λ, r])*
(Subscript[λ, 1] + μ*Subscript[λ, 2] +
Subscript[λ, r])) +
(Subscript[λ, 1]^2*(-2*μ*Subscript[λ, 2]*
Subscript[λ, r] +
E^(Γ*(μ*Subscript[λ, 2] +
Subscript[λ, r]))*
((-1 + E^(Γ*Subscript[λ, 1]))*μ^2*
Subscript[λ, 2]^2 + 2*μ*Subscript[λ, 2]*
Subscript[λ, r] -
(-1 + E^(Γ*Subscript[λ, 1]))*
Subscript[λ, r]^2)))/
E^(Γ*(Subscript[λ, 1] + μ*
Subscript[λ, 2] + Subscript[λ, r]))/
((Subscript[λ, 1] - μ*Subscript[λ, 2] -
Subscript[λ, r])*(Subscript[λ, 1] +
μ*Subscript[λ, 2] - Subscript[λ, r])*
(μ*Subscript[λ, 2] + Subscript[λ, r])*
(Subscript[λ, 1] + μ*Subscript[λ, 2] +
Subscript[λ, r]));

assume = {0 < μ <
1, {Γ, Subscript[λ, 1], Subscript[λ, 2],
Subscript[λ, r]} ∈ PositiveReals};

LeafCount /@ {expr, Simplify[expr], Simplify[expr, assume],
FullSimplify[expr], FullSimplify[expr, assume]}

(* {303, 249, 249, 242, 242} *)


So, in this case, the assumptions don't help in the simplification

expr2 = expr // FullSimplify


EDIT 4: Amended to handle terms without exponential

{coef, exp} =
Transpose[(If[FreeQ[#, Power[E, _]], {#, 0}, #] & /@
(List @@ Expand[expr2])) /.
a_*Exp[b_] :> {a, Simplify[b]}];


EDIT 3: To combine terms with like exponents

{coef, exp} =
Transpose[
Transpose[{coef, exp}] //. {start___, {c1_, e1_}, mid___, {c2_, e1_},
end___} :> {start, {Simplify[c1 + c2], e1}, mid, end}];

expr2 == (coef . Exp[exp]) // Simplify

(* True *)

• I dont quite understand what you mean...what do you mean by "does not display any of the box structure"...do you mean to say that it cannot be simplified any further? Is there anyway to arrange the expression such that it expands it in different power of exponential.... meaning something of the form A.e^y where A is simplified factor corresponding to e^y and y will be taking different values in above expression. May 16, 2023 at 19:37
• The code that you posted contains SubsuperscriptBox, i.e., box structure. Note that this is not in the expression that I pasted. Perhaps you want expr3 = expr2 // Expand`; however, this is somewhat the opposite of simplification. May 16, 2023 at 19:49
• Got it. Thanks regarding box structure. What I am looking for is expressing this large expression (I have atleast 5 more such terms in the expression I am trying to simplify) to be simplified and arranged in form of \sum Ai * e^yi where Ai will be different for different yi ..... since yi will be different, it cannot be simplified any further, but the corresponding Ai will be the most simplified fraction for that particular yi. Is there anyway I can do that in mathematica?.... of course using pen and paper is last resort. May 16, 2023 at 19:55
• Edit your question to reflect what you are actually trying to accomplish. People cannot guess that from what you posted. May 16, 2023 at 20:02
• I have edited the question and updated the input form as per your answer. Hopefully its clear now what I am trying to ask. May 16, 2023 at 20:10