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.

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.

share|improve this question
add comment

1 Answer 1

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

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

Now:

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]
share|improve this answer
add comment

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.