Re: complex coefficients and rules...
- To: mathgroup at smc.vnet.net
- Subject: [mg28212] Re: [mg28203] complex coefficients and rules...
- From: Mianlai Zhou <lailai at carmen.nikhef.nl>
- Date: Thu, 5 Apr 2001 03:00:27 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hello, You have multiple choices for this. First, if you simply say Conjugate[Exp[4 I y]] you will get an answer Exp[-4 I Conjugate[y]], which is correct when assuming y is potentially complex. You are right, Mathematica always assume an algebraic symbol to be complex without extra declaration. If you want to tell Mathematica that y is real, before it type a command like y /: Conjugate[y] = y; Then you will get answer Exp[-4 I y]. Of course you can define a function SetReal, which set variables to be real, as the following: SetReal[x___] := Module[{protectstuff}, protectstuff = Unprotect[Conjugate]; (Conjugate[#] := #) & /@ {x}; Protect /@ protectstuff; ]; Then you can say SetReal[y] to set y to be real and then use Conjugate to take the conjugation, and get the answer that you want. Of course, there is another alternative way: Simplify[ Conjugate[Exp[4 I y]], y ~Element~ Reals ] you will also get Exp[-4 I y], where ~Element~ can also be replaced by a Greek letter, typed from keyboard by "<Escape> elem <Escape>". Finally, your approach is also a good way though it seems somewhat cumbersome. But you should better use :> (RuleDelayed) instead of -> (Rule): Exp[-4 I y] /. Complex[a_, b_] :> Complex[a, -b] Otherwise it would be dangerous when a or b have already had a value. Good luck! On Wed, 4 Apr 2001, Richard Easther wrote: > > Hi, > > I am having some trouble applying some simple rules to complex > expressions. > > For instance, > > Exp[-4 I y] /. I-> -I > > yields > > Exp[-4 I y] > > This seemed a bit odd, so I looked at the "full form" and found, > > Power[E, Times[Complex[0, -4], y]] > > However, trying the match > > Exp[-4 I y] /. a_ I -> -a I > > doesn't work either, since FullForm[a I ] is Times[Complex[0, -1], a] > and so the patterns do not match. > > All I want is a simple complex conjugate (the Conjugate function does > not assume that y is real), that maps I->-I. The more tricky > > Exp[-4 I y] /. Complex[a_ ,b_] -> Complex[a,-b] > > does work, but it is seems a little cumbersome. > > In any case my question is: is there a general way to avoid having to do > this, or is Mathematica always going to assume that any algebraic > constant is potentially complex? > > Richard >