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?


1 Answer 1


Because sometimes I is not I...

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

Results in:

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] *)
  • 1
    $\begingroup$ Oops. I checked that I in Hold[I] was not changed but I forgot that I in rule might have been changed. $\endgroup$ Commented Apr 30, 2015 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.