# How to Pattern Match complicated patterns? [closed]

How can I get the output expressed in terms of p1 and p2 instead of exponentials?

gau[x_, v_] := Exp[-(x^2)/(2*v)]/Sqrt[2*Pi*v];
p1[x_] := gau[x - m, B + v]/2 + gau[x + m, B + v]/2;
p2[x_] := gau[x - m, B + v]/2 - gau[x + m, B + v]/2;
Simplify[D[Log[p1[x]], {v, 3}]]


I want to substitute:

Exp[(x+m)^2/(2*(B+v))]/2 + Exp[(x-m)^2/(2*(B+v))]/2 -> p1
Exp[(x+m)^2/(2*(B+v))]/2 - Exp[(x-m)^2/(2*(B+v))]/2 -> p2


but obvious that doesn't work.

## closed as unclear what you're asking by Dr. belisarius, MarcoB, bbgodfrey, Jens, dr.blochwaveJun 3 '15 at 7:56

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Probable duplicate: (3822) (Still not answered to my full satisfaction.) – Mr.Wizard Jun 3 '15 at 4:31