MathGroup Archive 2005

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

Search the Archive

Re: Simplifying Conjugate[] with 5.2 Mac

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59828] Re: Simplifying Conjugate[] with 5.2 Mac
  • From: sbjensen at midway.uchicago.edu (Steuard Jensen)
  • Date: Tue, 23 Aug 2005 04:51:23 -0400 (EDT)
  • Organization: The University of Chicago
  • References: <de45i8$qtf$1@smc.vnet.net> <de6maf$cj5$1@smc.vnet.net> <de9cqi$q5a$1@smc.vnet.net> <debt13$9bu$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Quoth "James Gilmore" <james.gilmore at yale.edu> in article
<debt13$9bu$1 at smc.vnet.net>:
>  "Steuard Jensen" <sbjensen at midway.uchicago.edu> wrote:
> > Quoth "James Gilmore" <james.gilmore at yale.edu>:
> > [I wrote:]
> >> > In[5]:= Simplify[Conjugate[x+I y]]
> >> >
> >> > Out[5]= Conjugate[x + I y]

> >> With regard to this behaviour, it may be useful to use PlusMap
> >> (or Map if there are always at least two terms when expanded)...

> > This approach would presumably work in principle (since we've seen
> > that Simplify can deal with one term at a time).  But in practice, my
> > expressions often involve products and sums of many terms at many
> > levels.  So I would either need to devise a way to Map Conjugate
> > properly onto each term by hand (at which point I might as well just
> > change all the I's to -I's myself!), or come up with an automated way
> > of doing it

> Are you just interested in changing I's to -I's? If so, I would
> suggest that you forget about Conjugate altogether and use pattern
> matching instead.

I'm not just interested in changing I's to -I's, but this solution is
still awfully intriguing.  I hadn't really thought about it before,
and I'm still somewhat nervous that it could miss mathematical
subtleties.  But it might be plausible.

The context in which I'm using this stuff is a package that implements
Grassmann variables using NonCommutativeMultiply.  My expressions are
_supposed_ to be written in terms of real or complex numbers,
variables defined to be real, and pairs of variables defined to be
complex conjugates of each other.  If variables without a defined real
or complex status somehow slip in, they should be treated as complex.

At any rate, the upshot is that I know the proper conjugates for each
of those parts.  For the pure numbers, {I -> -I} is all that's
necessary.  Or, well, hmm.  Actually, I've got lots of terms like "-2
I x" which wouldn't end up being matched by this rule.  So I think
what I'd really want is {Complex[r_,i_] :> Complex[r,-i]}.

Moving on, for real variables no substitution is needed.  For defined
complex pairs, just swap them: if {q,qb} are defined as conjugates,
then {q->qb, qb->q}.  And for anything undefined, {x_ ->
Conjugate[x]}.

Now I just need to figure out where a simple replacement rule like
this would give the wrong results. :)  (That's the advantage of
sticking with built-in functions like Refine or ComplexExpand, of
course: I know that a _lot_ of thought has been put into mathematical
subtleties there.)

> This will give you an efficient method that will not depend on the
> internals of Conjugate. You will also not have to deal with changes
> in future versions of Mathematica.

That's starting to seem like an awfully pleasant thought!

> The other suggestions in this thread are compared to the pattern matching 
> method below. It is clear pattern matching is the most efficient for the 
> simple form tested:

> ConjugateSimple[z_] := z /. {I -> -I, -I -> I}
> ConjugateSimple[{x - I*y, x + I*y, Exp[(-I)*z], Log[I + q]}] (*Works fine on 
> _simple_ conjugations*)
> Timing[Table[ConjugateSimple[x + I*y], {i, 1, 10^4}]; ]
> {x + I*y, x - I*y, E^(I*z), Log[-I + q]}
> {0.391*Second, Null}

> ComplexExpand[Conjugate[x + I*y]];
> Timing[Table[ComplexExpand[Conjugate[x + I*y]],
> {i, 1, 10^4}]; ]
> {8.882*Second, Null}

> $Assumptions = {{x, y} \[Element] Reals};
> Refine[Conjugate[x + I*y]];
> Timing[Table[Refine[Conjugate[x + I*y]], {i, 1, 10^4}]; ]
> {1.402000000000001*Second, Null}

> FullSimplify[Conjugate[x + I*y]];
> Timing[Table[FullSimplify[Conjugate[x + I*y]],
> {i, 1, 10^4}]; ]
> {1.4519999999999982*Second, Null}

I'm actually very surprised to see how slow ComplexExpand is here!
It's enormously slower than even FullSimplify.  I've gotten similar
results myself after applying these transformations to the more
complicated Conjugate[(x+I y)(z+I w)] case, too.  Of course, if these
pieces were part of a more complicated expression, I expect that
FullSimplify would start to take a lot longer.

> Extend the definition to include purely complex variables:
> ConjugateVariables[z_] := z /. {w -> -w, -w -> w,
...

(Do you mean "purely imaginary variables"?  I don't think we have many
quaternions here. :) )

> Of course, the safeguards of Conjugate are lost using
> pattern-matching, but if you already know which variables are real
> and complex then that wont be an issue.

I'd like to hope so!  But as I said above, I know that I haven't spent
anywhere near the time thinking about such things that the Mathematica
developers have.  Still, I'm willing to bet that this approach will at
least _almost_ always work.  And that may be enough for my needs.

						Steuard Jensen


  • Prev by Date: Re: Units, simplification
  • Next by Date: Commercial Mathematica Server
  • Previous by thread: Re: with 5.2 Mac
  • Next by thread: Re: Simplifying Conjugate[] with 5.2 Mac