MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Symbolic complex conjugation

  • To: mathgroup at
  • Subject: [mg26150] Re: [mg26125] Symbolic complex conjugation
  • From: Andrzej Kozlowski <andrzej at>
  • Date: Thu, 30 Nov 2000 01:03:57 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Are you sure you did not get your two cases mixed up?
Here is why:

2 + I /. Complex[0, n_] -> -Complex[0, n]
2 + I
2 + I /. Complex[m_, n_] -> Complex[m, -n]
2 - I

The first method does will work only with purely symbolic examples:

a + b*I /. Complex[0, n_] -> -Complex[0, n]
a - I b

while the second works with both symbolic and numerical ones:

a + b*I /. Complex[m_, n_] -> Complex[m, -n]
a - I b

The reason is that the FullForm of a+b*I and 2+3*I is different:

FullForm[a + b*I]
Plus[a, Times[Complex[0, 1], b]]

FullForm[2 + 3*I]
Complex[2, 3]

So the pattern Complex[a_,b_] finds a match in both cases while the pattern
Complex[0,n_] only in the symbolic case.

Another way to do this is as follows:

ComplexExpand[Conjugate[a + 3 + b*I + 2I]]
3 + a + I (-2 - b)

This again works in both numerical and symbolic cases and is my preferred
approach. It may be slower in cases when you want to do nothing more than
conjugate the expression because as you can see this way does more than just
replace I by -I. By contrast the other two approaches give:

a + 3 + b*I + 2I /. Complex[0, n_] -> -Complex[0, n]
3 + 2 I + a - I b

(quite wrong!) 

a + 3 + b*I + 2I /. Complex[m_, n_] -> Complex[m, -n]
3 - 2 I + a - I b

Correct but not as nice.

Andrzej Kozlowski
Toyama International University

on 11/28/00 3:56 PM, A. E. Siegman at siegman at wrote:

> Suppose one wishes to do symbolic complex conjugation on a complicated
> symbolic expression in which all symbols are assumed purely real -- that
> is, given a symbolic expression of arbitrary complexity with multiple
> instances of I occuring inside it, change every instance of I to -I, and
> nothing more.
> The best approach I'm aware of seems to be the method described in the
> 4.0 Help files, namely
> new_expr = old_expr  /. Complex[0, n_] -> -Complex[0, n]
> Is there a better approach than this?
> And, for educational purposes, can someone explain how and why this
> approach works?  In particular, why isn't the rule something like
> Complex[a_, b_] -> Complex[a, -b]
> Is the "0" significant?  Is the "n" supposed to be integer?

  • Prev by Date: Re: vector multiplication
  • Next by Date: Re: Equivalent functions generate different plots
  • Previous by thread: Re: Symbolic complex conjugation
  • Next by thread: Re: Symbolic complex conjugation