Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am using the ratio between two error probabilities in various functions. I want Mathematica to display this ratio in the most simple manner. How do I let Mathematica know that, in this case, the simplest manner is as the top line in the picture below? How do I let Mathematica factor the expression into (e1), (e2), (1 - e1) and (1 - e2)?

http://i.stack.imgur.com/89eol.png

share|improve this question
1  
Welcome to Mathematica.SE! Next time post the actual code instead of a picture, that makes it quicker for people to try it out and answer the question. –  ssch Nov 7 '13 at 20:13

2 Answers 2

When Simiplify isn't doing what you want, always have a look at the FullForm to see why:

(1 - e1)/(1 - e2) // FullForm
(* Times[Plus[1, Times[-1, e1]], Power[Plus[1, Times[-1, e2]], -1]] *)

(-1 + e1)/(-1 + e2) // FullForm
(* Times[Plus[-1, e1], Power[Plus[-1, e2], -1]] *)

We see that it's related to -1 being very simple while -e2 is actually -1 * e2 we could use this to construct an appropriate ComplexityFunction but in many cases StringLength @ ToString @ # & is easier and gives good results:

StringLength@ToString[(1 - e1)/(1 - e2)]
(* 20 *)

StringLength@ToString[(-1 + e1)/(-1 + e2)]
(* 23 *)

Simplify[(-1 + e1)/(-1 + e2),
 ComplexityFunction :> (StringLength @ ToString @ # &)
 ]
(* (1 - e1)/(1 - e2) *)
share|improve this answer
(-1 + e1)/(-1 + e2) // TraditionalForm // StandardForm

(e1-1)/(e2-1)

Simplify[(-1 + e1)/(-1 + e2), 
 ComplexityFunction :> (LeafCount@# + 10 Count[#, -1 + _, -1] &)]

(1 - e1)/(1 - e2)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.