Re: Re: Simplifying Conjugate[] with 5.2 Mac
- To: mathgroup at smc.vnet.net
- Subject: [mg59877] Re: [mg59832] Re: Simplifying Conjugate[] with 5.2 Mac
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Wed, 24 Aug 2005 06:32:02 -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> <200508230851.EAA03009@smc.vnet.net> <8B09B5D2-0003-4529-8281-677494C3F6D9@mimuw.edu.pl>
- Sender: owner-wri-mathgroup at wolfram.com
In fact using Complex[a_,b_]->Complex[a,-b] instead of Conjugate can cause more serious problems and actually give wrong answers. The reason is that if f is a function in the complex plane that is not holomorphic then it it not necessarily true that Conjugate[f[z]] = f [Conjugate[z]]. For example consider u= Im[Sqrt[a+b*I]] with real a and b. Then Conjugate[u] will not in general equal u/.Complex[a_,b_]- >Complex[a,-b]. As an example take u = Im[Sqrt[2 + 3*I]]; then N[Conjugate[u]] 0.895977 but N[u/.Complex[a_,b_]->Complex[a,-b]] -0.895977 Andrzej Kozlowski On 23 Aug 2005, at 15:27, Andrzej Kozlowski wrote: > > On 23 Aug 2005, at 10:51, James Gilmore wrote: > > >> 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 >> > > > It won't work even in numerical cases where complex numbers are > expressed without explicit I such as Root objects or: > > > w = Last[x /. Solve[x^5 == 1, x]] > > > (-1)^(4/5) > > In this case > > > ComplexExpand[Conjugate[(-1)^(4/5)]] > > -(-1)^(1/5) > > or > > > FullSimplify[Conjugate[(-1)^(4/5)], > ComplexityFunction -> > (LeafCount[#1] + 100*Count[#1, Conjugate, Infinity, > Heads -> True] & )] > > -(-1)^(1/5) > > but Complex[a_,b_]->Complex[a,-b] will obviously have no effect. > > Andrzej Kozlowski > > > >> >> ------------------------------------------------------ >> >> >>> >>> 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} >>> >>> >> >> >> >> > >
- References:
- Re: Simplifying Conjugate[] with 5.2 Mac
- From: "James Gilmore" <james.gilmore@yale.edu>
- Re: Simplifying Conjugate[] with 5.2 Mac