FullSimplify only simplifies the result of the following calculation halfway, leaving a lot of $e^{x^2/v}$ and $e^{m^2/v}$ terms that could have been cancelled:

gau[x_, v_] = (1/Sqrt[2*Pi*v])*E^-((x^2)/(2*v));
f[x_] = gau[x - m, v]/2 + gau[x + m, v]/2;
FullSimplify[D[Log[f[x]], {v, 4}]]

I tried combinations of Simplify, FullSimplify, Expand, and PowerExpand, and the cancellations don't happen.

Question 1: How can I make it to those cancellations? Ultimately I'd like the entire expression with all the $e^{n\ x/v}$ replaced with $y^n$, but that's the next step after I solve this current problem.

Question 2: Maybe this is a Meta question, but is there a page somewhere (on this site or elsewhere) on tricks and hacks for simplifying expressions that Mathematica built-ins don't nail? Or just how to get the simplifying juuuust the way you want it? Controlling simplification and more complete simplification seem to be a recurring themes in SE questions. Could such a page be started on SE if it doesn't already exist?

gau[x_, v_] = (1/Sqrt[2*Pi*v])*E^-((x^2)/(2*v));

f[x_] = gau[x - m, v]/2 + gau[x + m, v]/2;

expr1 = FullSimplify[D[Log[f[x]], {v, 4}]];

expr2 = expr1 // ExpandAll // Simplify

(1/((1 + E^((2*m*x)/v))^4*v^8))* (24*(-1 + E^((2*mx)/v)) (1 + E^((2*m*x)/v))^3*m*v^3*x - 96*E^((2*mx)/v) (-1 + E^((4*m*x)/v))*m^3*v* x^3 + 16*E^((2*mx)/v) (1 - 4*E^((2*m*x)/v) + E^((4*m*x)/v))*m^4*x^4 + 3*(1 + E^((2*m*x)/v))^4*v^3* (v - 4*x^2) - 12*(1 + E^((2*m*x)/v))^2*m^2*v^2* ((1 + E^((2*m*x)/v))^2*v - 12*E^((2*m*x)/v)*x^2))

expr3 = expr2 /. Power[E, Times[a_, m, Power[v, -1], x]] -> y^a

(1/(v^8*(1 + y^2)^4))* (24*m*v^3*x*(-1 + y^2)* (1 + y^2)^3 + 3*v^3*(v - 4*x^2)* (1 + y^2)^4 - 96*m^3*v*x^3*y^2* (-1 + y^4) + 16*m^4*x^4*y^2* (1 - 4*y^2 + y^4) - 12*m^2*v^2*(1 + y^2)^2* (-12*x^2*y^2 + v*(1 + y^2)^2))

expr2 == (expr3 /. y^a_ -> Exp[a*m*x/v]) == (expr3 /. y -> Exp[m*x/v])


  • $\begingroup$ Perfect! I didn't know about ExpandAll[]. This is an aspect of MMa is confusing. Why do Expand[] and Simplify[] exist at all when in order to accomplish what they're supposed to accomplish, you usually have to use ExpandAll[] and FullSimplify[]? Are there other functions in this family that a relative noob should read up on? $\endgroup$ – Jerry Guern May 31 '15 at 1:50
  • 4
    $\begingroup$ I recommend that you make greater use of the See Also section in the documentation. Expand points to ExpandAll (and vice versa). $\endgroup$ – Bob Hanlon May 31 '15 at 2:00

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.