I don't see why this should be called a bug. The behaviour is exactly as it should be, although it is not achieved through NHoldRest
, but through other means.
Why is it not achieved through NHoldRest
? I don't know, but the most reasonable guess is that there are cases where a naïve use of NHoldRest
would cause behaviour that seems unreasonable from a mathematical perspective. Let us try to find such a case.
It seems to me that the following would be such a case:
In[]:= N@Power[x, Power[2, y]]
Out[]= x^2.^y
More generally, Power[x, f[someExplicitNumber]]
would be such a case, e.g. Power[x, Sin[2]]
.
Why treat Sin[2]
differently from 2
? Well, x^2
is x*x
. The same is not valid for x^2.0
. Thus there is value in retaining the exact 2
in x^2
. More importantly, retaining integer powers in polynomial expression would seem essential.
What about rational powers? One would expect N@Sqrt[x]
to stay Sqrt[x]
and not turn into x^0.5
.
The same does not apply to something like x^Sin[2]
.