I want to simply expression into specific form that I want to have. For example,

$e^{-v^2}\frac{ (a*v-b)}{c*v^2-d*v+e}$

(-b + a v)/(e - d v + c v^2) Exp[-v^2]

I want to factor this and make a form as

$A*e^{-v^2} * \frac{ (v-\text{a1})}{(v-b1) (v-\text{b2})}$

A ((v - a1) Exp[-v^2])/((v -b1) (v-b2))

Of course, I can just do it manually one by one, solve the numerator, find root etc. Does MMA have any way to do it automatically?


Use SolveAlways to obtain relations between {A, a1, b1, b2} and {a, b, c, d, e} for arbitrary v and then apply Solve to those relations to express the new coefficients in terms of the old.

SolveAlways[(-b + a v)/(e - d v + c v^2) Exp[-v^2] == 
    A ((v - a1) Exp[-v^2])/((v - b1) (v - b2)), v];
Flatten[Solve[#, {A, a1, b1, b2}] & /@ (% /. Rule -> Equal), 1]
(* {{A -> a/c, a1 -> b/a, 
     b1 -> (d - Sqrt[d^2 - 4 c e])/(2 c), b2 -> (d + Sqrt[d^2 - 4 c e])/(2 c)}, 
    {A -> a/c, a1 -> b/a, 
     b1 -> (d + Sqrt[d^2 - 4 c e])/(2 c), b2 -> (d - Sqrt[d^2 - 4 c e])/(2 c)}} *)

The two sets of relations differ only by interchanging the definitions of b1 and b2. as expected. No knowledge of the details of the expressions is needed, provided that the expressions are not too complicated for SolveAlways to handle.


Here is a way

(E^-v^2 (-b + a v))/(
 e - d v + c v^2) /. {(-b + a v) -> a (v - sol1[[1, 1, 2]]), 
  e - d v + c v^2 -> (v - sol2[[1, 1, 2]]) (v - sol2[[2, 1, 2]])}

which gives

(a E^-v^2 (-(b/a) + v))/((-((d - Sqrt[d^2 - 4 c e])/(2 c)) + 
   v) (-((d + Sqrt[d^2 - 4 c e])/(2 c)) + v))
  • $\begingroup$ Really? $\endgroup$ – corey979 Jan 14 '17 at 22:02
  • $\begingroup$ corey979 I was not aware of SolveAlways $\endgroup$ – cyrille.piatecki Jan 15 '17 at 4:21
  • $\begingroup$ I say that your code doesn't give the output you claim. And what are sol1 and sol2? They don't appear in the OP. As it stands, this does not answer the question. $\endgroup$ – corey979 Jan 15 '17 at 5:28
  • $\begingroup$ Corey Sorry I have forgotten the definition of sol1 and sol2. I have made an edit $\endgroup$ – cyrille.piatecki Jan 15 '17 at 5:56

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.