Re: Symbolic complex conjugation?
- To: mathgroup at smc.vnet.net
- Subject: [mg89985] Re: Symbolic complex conjugation?
- From: "David Park" <djmpark at comcast.net>
- Date: Wed, 25 Jun 2008 06:32:05 -0400 (EDT)
- References: <g3q7vb$aus$1@smc.vnet.net>
It was the rule matching that tripped things up. Clear[p, pStar, a, b] eqnp = {((dwa/2) + I (w - wa)) p - I (kappa/(2 w)) dN e == 0} solnp = Solve[eqnp, p] p = p /. solnp[[1]] pStar = p /. {I -> -I} % // FullForm Looking at the FullForm we see that I == Complex[0,1] does not actually appear in the p expression. Instead we have Complex[0,-1]. So the rule does not match. To do complex conjugation use: Clear[p, pStar, a, b] eqnp = {((dwa/2) + I (w - wa)) p - I (kappa/(2 w)) dN e == 0} solnp = Solve[eqnp, p] p = p /. solnp[[1]] pStar = p /. {Complex[a_, b_] -> Complex[a, -b]} You could also use: pStar = ComplexExpand[Conjugate[p]] // Simplify // Factor which seems like a little more work than it ought to be. -- David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ "AES" <siegman at stanford.edu> wrote in message news:g3q7vb$aus$1 at smc.vnet.net... > I'm sorry, but I just don't understand why the following test case works > just fine: > > [In copying it, I've substituted "Isymbol" for the \[ImaginaryI] that > actually appears in the Out[] cells.] > > In[202]:= eqna={a+I b==0}; > solna=Solve[eqna,b]; > b=b/.solna[[1]]; > bStar=b/.{I->-I}; > {b, Star} > > Out[205]={ -Isymbol a, Isymbol a } > > but the actual calculation that prompted the test case doesn't: > > In[206]:= eqnp={((dwa/2)+I(w-wa))p-I (kappa/(2 w))dN e==0}; > solnp=Solve[eqnp,p]; > p=p/.solnp[[1]]; > pStar=p/.{I->-I} > > Out[208]= { (dN e kappa)/(w (-Isymbol dwa+2 w-2 wa)), > (dN e kappa)/(w (-Isymbol dwa+2 w-2 wa)) } > > And actually, I guess my real concern is not understanding "how it > happens" -- but more "how it can happen" that Mathematica can do > something this potentially damaging to some innocent user. >