       Re: Symbolic complex conjugation

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

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

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

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

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

while the second works with both symbolic and numerical ones:

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

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

In:=
FullForm[a + b*I]
Out//FullForm=
Plus[a, Times[Complex[0, 1], b]]

In:=
FullForm[2 + 3*I]
Out//FullForm=
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:

In:=
ComplexExpand[Conjugate[a + 3 + b*I + 2I]]
Out=
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:

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

(quite wrong!)
and

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

Correct but not as nice.

--
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/

on 11/28/00 3:56 PM, A. E. Siegman at siegman at stanford.edu 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