Sometimes it is needed to keep the powers as the fractional form. However Mathematica tends to write x^(1/2)
as Sqrt[x]
.
How do I keep x^(1/2) as it is in the output without writing it as Sqrt[x]?
Here is a simple example:
expr = Rationalize[1+x^(0.5),0.0000001] >> output.m
Output is
1 + Sqrt[x]
Instead I want the output to have the form
1 + x^(1/2)
I could not find any solution for this.
1 + x^(1/2) /. Sqrt[z_] :> z^HoldForm[1/2]
is close. You would need toReleaseHold
to do much with it. $\endgroup$ReleaseHold
before. For me then easiest way is to manipulate the expression in the output file by other means. But I hope there must be some better ways to do it in Mathematica itself. $\endgroup$