For example, I want to covert y + Sqrt[x] to y + x^0.5, where y and x can be very complicated expressions.
Edit:
Here's why I want to do this.
I want to generate C++ expression from Mathematica expression. The method I can think of is to do some sort of recursion down the expression tree. I don't want to have things like 1/2 or 2/3 anywhere in the expression (but rather, 0.5 or 0.66666666666666667 is fine). However, the function N doesn't apply to the exponent.
Moreover, if this walking down the expression tree can recognize Sqrt, it would be even better. However, Head[Sqrt[x]] is Power, not Sqrt.
Edit:
Problem solved: use SymbolicC`CExpression and SymbolicC`ToCCodeString, together with some macros.
0.5changes an exact expression into one that is considered to be approximate. The linked question addresses the display formatting which is probably what you really want. – george2079 Jan 02 '15 at 21:55x,(x^0.5)^2 == xdoes not evaluate toTrue, and even evaluates toFalseon some numeric input (e.g.x -> I). – Michael E2 Jan 02 '15 at 22:22N不会把Sqrt[x]变成x^(0.5)– Chen Stats Yu Jan 02 '15 at 23:21SetPrecision[expr,MachinePrecision]on your expression. – Daniel Lichtblau Jan 03 '15 at 21:03