# Mathematica does not replace \[ImaginaryI] inside Hold

Mathematica 10.1 does not replace I (i.e. \[ImaginaryI], the square root of -1) inside functions with the Hold attribute. Example:

In[1]:= Hold[I] /. I -> a
Out[1]= Hold[I]


I don't understand why this happens. I have not found any other symbols with the same behavior. If I create a new symbol with the same Attributes as I, it replaces without problem.

Why is it doing this, and is it the intended behavior?

Because sometimes I is not I...

Hold[I] // FullForm
I -> a // FullForm


Results in:

Hold[\[ImaginaryI]]
Rule[Complex[0, 1], a]


You can see that in the first expression I is held and remains the same. However, in the second expression I is evaluated (since Rule does not have any Attributes to hold its arguments). I gets evaluated into a Complex number; and since there is no instance of Complex inside the Hold, nothing is replaced. You can get around this with HoldPattern:

Hold[I] /. HoldPattern[I] -> a
(* Hold[a] *)

• Oops. I checked that I in Hold[I] was not changed but I forgot that I in rule might have been changed. Apr 30 '15 at 16:14