I would like to 'Simplify'




I've tried to penalize Times and Rational using ComplexityFunction, but something like

mysim[e_] := 
 100 (Count[e, _Times, {0, Infinity}] + 
     Count[e, _Rational, {0, Infinity}]) + LeafCount[e]

did not do work.

Suggestions are appreciated

  • 1
    $\begingroup$ Mathematica brings some simple expressions to a canonical form. For example, 2/4 (i.e. Rational[2,4]) is immediately and automatically transformed to 1/2. Divide[a, b] is immediately transformed to Times[a,Power[b,-1]]. b+a becomes a+b. Such canonicalization aids equality testing. Similarly, Sqrt[5/24] immediately evaluates to Sqrt[5/6]/2. Thus Simplify can never return the former. $\endgroup$
    – Szabolcs
    Dec 9, 2015 at 10:48
  • $\begingroup$ Ref: reference.wolfram.com/language/tutorial/… To maintain Sqrt[5/24] in its given form, Hold or HoldForm must be applied. I'm not commenting on whether that can be done with Simplify conveniently or whether it is worth doing, but it's likely not very simple to do. $\endgroup$
    – Szabolcs
    Dec 9, 2015 at 10:50
  • $\begingroup$ Thanks Szabolcs, that put me on the way to an answer. $\endgroup$
    – maurits
    Dec 9, 2015 at 19:20

1 Answer 1


The following function works (under the side condition that everything is real...

ToSingleFractionForm[a_] := Block[{b}, b = a^2; Sign[a] Sqrt[TraditionalForm[b]]]

The TraditionalForm wrapper is enough to stop Mathematica from putting things in canonical form. And TeXForm on it still works.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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