Re: Simplifying Conjugate[] with 5.2 Mac
- To: mathgroup at smc.vnet.net
- Subject: [mg59871] Re: Simplifying Conjugate[] with 5.2 Mac
- From: Peter Pein <petsie at dordos.net>
- Date: Wed, 24 Aug 2005 06:31:32 -0400 (EDT)
- 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> <deeonh$3ru$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
James Gilmore schrieb: > Hi, > > > Thank you so much! This is a great definition, ConjugateSimple[z_] := z /. > Complex[a_,b_]->Complex[a,-b]. Significantly better than my wrong hack > attempt. > > > Does anybody know of any cases where this definition fails to conjugate a > term, when all variables apart from the I's in the expression, are known to > be real? > > James Gilmore > > ------------------------------------------------------ > >>This definition is too simple: >> > > >>In[6]:= >>ConjugateSimple[1+2I]//OutputForm >>Out[6]//OutputForm= >>1 + 2 I >> > > >>A better definition would use Complex, as in Complex[a_,b_]->Complex[a,-b]. >> > > >>[snip] >> > > >>Carl Woll >>Wolfram Research >> > > -------------------------------------------------------- > > "James Gilmore" <james.gilmore at yale.edu> wrote in message > news:debt13$9bu$1 at smc.vnet.net... > >>"Steuard Jensen" <sbjensen at midway.uchicago.edu> wrote in message >>news:de9cqi$q5a$1 at smc.vnet.net... >> >>>Quoth "James Gilmore" <james.gilmore at yale.edu> in article >>><de6maf$cj5$1 at smc.vnet.net>: >>>[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), see FurtherExamples, >>>>in >>>>the Map documentation. >>>>$Assumptions = {{a, b} \[Element] Reals}; >>>>PlusMap[f_, expr_ /; Head[expr] =!= Plus, ___] := f[expr]; >>>>PlusMap[f_, expr_Plus, r___] := Map[f, expr, r]; >>>>Trace[Simplify[PlusMap[Conjugate, Expand[a + I*b]]]] >>>>Trace[Simplify[PlusMap[Conjugate, Expand[a + b]]]] >>> >>>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. >>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. >> >>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: >>$ProductInformation >>{"ProductIDName" -> "Mathematica", "ProductKernelName" -> >>"Mathematica 5 Kernel", "ProductVersion" -> >>"5.0 for Microsoft Windows (June 11, 2003)", >>"ProductVersionNumber" -> 5.} >>ConjugateSimple[z_] := z /. {I -> -I, -I -> I} > > > Well, you'll say I'm cheating: In[1]:= N[{Root[#1^3 + I & , 1], Conjugate[Root[#1^3 + I & , 1]], Root[#1^3 + I & , 1] /. Complex[a_, b_] :> Complex[a, -b]}] Out[1]= -0.8660254037844386 - 0.5*I -0.8660254037844386 + 0.5*I -0.8660254037844386 - 0.5*I and - yes, I am. Root[#1^3+I&,1] is instantly "simplified" to Root[1 - #1^2 + #1^4 & , 1] by Mathematica. There's no possibility for the matcher to recognize a Complex[_,_]-pattern . -- Peter Pein, Berlin GnuPG Key ID: 0xA34C5A82 http://people.freenet.de/Peter_Berlin/