Why does
I/.I->-I
return
-I
but
Exp[-I]/.I->-I
yields
Exp[-I]
? As mentioned below the problem seems to be the improper input type of the complex unit: Instead of I one should use Complex[0,1]. But if this is true, why does the first replacement above work at all? This behavior is inconsistent, or is there a good explanation for this result?
E^-I-- seems to work (V10.1 and V9.0.1). – Michael E2 May 13 '15 at 14:03Exp[I] /. I -> -IreturnsE^-I. – Mr.Wizard May 13 '15 at 14:25Exp[I], should not be possible, becauseExp[I]evaluates toE^Iautomatically. – Michael E2 May 13 '15 at 14:29Expdoes not evaluate properly, which might be connected to the replacement not working. DoesExp[x]returnExp[x]orE^x? (Try restarting the kernel, etc., too.) This is what it looks like for me: http://i.stack.imgur.com/tzQmP.png – Michael E2 May 13 '15 at 14:50Exp[-a I] /. I -> -I E^(-I a)
however:
Exp[-a x] /. x -> -x E^(x a) is evaluated correctly
– pawel_winzig May 13 '15 at 14:58Exp[I]/.I->-Iworks, butExp[-I]/.I->-Idoes not. Just likeExp[2] /. 2 -> -2works butExp[-2] /. 2 -> -2does not. – Michael E2 May 13 '15 at 15:04Conjugate? E.g.Exp[-a I] /. z_Complex :> Conjugate[z]andConjugate[Exp[-I]]. – Michael E2 May 13 '15 at 15:08Ishould not necessarily be entered asComplex[0,1]– Sjoerd C. de Vries May 14 '15 at 15:23Exp[I]/.I->-Iworks for me in 8, 9, and 10 (and for everybody else too). It seems your problem is actuallyExp[-I] /. I -> -Iwhich does not get you the result you expect. The point here is that ReplaceAll looks for structural matches in terms of the internal form of the expression. This internal form may differ from the way it is printed.1-xfor instance, is represented asPlus[1,Times[-1,x]]. You have to take this into account when replacing. [continues...] – Sjoerd C. de Vries May 14 '15 at 20:18-I, which is represented asComplex[0,-1]andIasComplex[0,1]. So-I/.I->-1does nothing as it is equivalent toComplex[0,-1] /. Complex[0,1]->Complex[0,-1]. No match, so no replacement. – Sjoerd C. de Vries May 14 '15 at 20:25