How can i prevent Mathematica from automatically simplifying the expression Sqrt[a/b]?

In case a=1 and b=2, Mathematica will print 1/Sqrt[2], whereas case a=3 and b=4, Mathematica will print Sqrt[3/4].

The output of my program would be better readable, if the fractions stayed unsimplified under the square-root symbol.


You can use Format and a custom head, e.g. mySqrt, along with HoldForm:

Format[mySqrt[body_]] := Sqrt @ HoldForm @ body


mySqrt /@ {1/2, 3/4}

enter image description here

If you want to use these expressions as live input (where this holding behavior will not be preserved) you should use Interpretation:

Format[mySqrt[body_]] := Interpretation[Sqrt @ HoldForm @ body, Sqrt @ body]
| improve this answer | |

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.