How to Simplify exponents?

I need to divide a Gaussian Mixture by it's widest component. When I do this, the exponents of the output end up a mess of terms in need of simplification, but Simplify[] doesn't do it. How can I make this work?

gauMix[x_, means_, vars_] :=
(1/Length[vars])*Total[(E^-(((x -means)^2)/(2*vars)))/Sqrt[2*Pi*vars]];
means = {-2, 2, 5};
vars = {1, 2, 2};
widest = Flatten[Position[vars, _?(# == Max[vars] &)]];
h[x_, v_] :=
gauMix[x, means, vars + v]/gauMix[x, {Mean[means[[widest]]]},{vars[[Min[widest]]] + v}];
Expand[h[x, v]]


$$\frac{\sqrt{v+2} \exp \left(\frac{\left(x-\frac{7}{2}\right)^2}{2 (v+2)}-\frac{(x+2)^2}{2 (v+1)}\right)}{3 \sqrt{v+1}}+\frac{1}{3} \exp \left(\frac{\left(x-\frac{7}{2}\right)^2}{2 (v+2)}-\frac{(x-5)^2}{2 (v+2)}\right)+\frac{1}{3} \exp \left(\frac{\left(x-\frac{7}{2}\right)^2}{2 (v+2)}-\frac{(x-2)^2}{2 (v+2)}\right)$$

I would like to see, the exponents individually Simplify[]'d and Together[]'d into something like this:

$$\frac{\sqrt{v+2} \exp \left(\frac{-44 v x+33 v-4 x^2-60 x+17}{8 (v+1) (v+2)}\right)}{3 \sqrt{v+1}}+\frac{1}{3} e^{\frac{33-12 x}{8 v+16}}+\frac{1}{3} e^{\frac{3 (4 x-17)}{8 (v+2)}}$$

• h[x, v] // Simplify ? Feb 21, 2015 at 0:34
• $\frac{1}{3} e^{\frac{(7-2 x)^2}{8 (v+2)}} \left(e^{-\frac{(x-5)^2}{2 (v+2)}}+e^{-\frac{(x-2)^2}{2 (v+2)}}+\frac{e^{-\frac{(x+2)^2}{2 (v+1)}}}{\sqrt{\frac{v+1}{v+2}}}\right)$ Feb 21, 2015 at 0:36
• @belisarius No, that's just dividing back out the wide gaussian that I just multiplied in. What I want is for each of those exponents to get individually simplified. For example, in the 2nd and 3rd terms, the x^2 term of the exponent polynomials will cancel out. Feb 21, 2015 at 0:41
• perhaps you should write down the expected result Feb 21, 2015 at 0:46
• @belisarius Okay, I did that. Feb 21, 2015 at 1:16

Explicitly replacing the exponents with simplifications:

expr /. {Exp[x_] :> Exp[Together@FullSimplify[x]]}


This results in:

$$\frac{\sqrt{v+2} \exp \left(\frac{-44 v x+33 v-4 x^2-60 x+17}{8 (v+1) (v+2)}\right)}{3 \sqrt{v+1}}+\frac{1}{3} e^{\frac{3 (4 x-17)}{8 (v+2)}}+\frac{1}{3} e^{-\frac{3 (4 x-11)}{8 (v+2)}}$$

• P.S. A simpler way to find the parameters of the widest gaussian: Mean@MaximalBy[Transpose[{means, vars}], Last]. You can apply Sequence to put it into your function without extracting the parts separately. Feb 21, 2015 at 2:28
• I didn't really understand you PS comment, but thank you for this answer. Apr 10, 2016 at 7:38
• Genius and simple trick! How didn't I think of that? Kudos !! Sep 14, 2021 at 10:48
gauMix[x_, means_, vars_] := (1/Length[vars])*
Total[(E^-(((x - means)^2)/(2*vars)))/Sqrt[2*Pi*vars]];
means = {-2, 2, 5};
vars = {1, 2, 2};
widest = Flatten[Position[vars, _?(# == Max[vars] &)]];
h[x_, v_] :=
gauMix[x, means, vars + v]/
gauMix[x, {Mean[means[[widest]]]}, {vars[[Min[widest]]] + v}];
Simplify[Expand[h[x, v]] /. E^(a__ /b__ + c__ /b__) -> E^((a + c)/b)]


$\frac{1}{3} e^{\frac{8 x^2-44 x+65}{4 v+8}}+\frac{1}{3} e^{\frac{(x-5)^2+\left(x-\frac{7}{2}\right)^2}{v+2}}+\frac{e^{\frac{1}{2} \left(\frac{\left(x-\frac{7}{2}\right)^2}{v+2}-\frac{(x+2)^2}{v+1}\right)}}{3 \sqrt{\frac{v+1}{v+2}}}$

• This gives wrong results. The x^2 terms should be cancelling out of the exponents of two of the terms. Feb 21, 2015 at 1:15