Re: Two Argument ArcTan Function
- To: mathgroup at smc.vnet.net
- Subject: [mg43409] Re: Two Argument ArcTan Function
- From: John Tanner <john at janacek.demon.co.uk>
- Date: Tue, 16 Sep 2003 04:36:06 -0400 (EDT)
- References: <bfrk3t$rcv$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <bfrk3t$rcv$1 at smc.vnet.net>, "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com> writes > >>-----Original Message----- >>From: David Park [mailto:djmp at earthlink.net] To: mathgroup at smc.vnet.net >>Sent: Friday, July 25, 2003 11:09 AM >>To: mathgroup at smc.vnet.net >>Subject: [mg43409] Two Argument ArcTan Function >> >> >>Dear MathGroup, >> >>The two argument function, ArcTan[x,y], is a very nice function and >>Mathematica knows how to do a lot with it. But sometimes it is >>difficult to >>bring it into play without just typing it in. >> >>Consider the case of inverting polar coordinates. >> >>eqns = {x == r Cos[t], y == r Sin[t]}; >>Solve[eqns, {r, t}, {x, y} \[Element] Reals] // Simplify >> >>If we discard the two negative r solutions, we obtain two solutions >>involving ArcCos. But couldn't we have a single solution using >>ArcTan[x,y]? >>I'm curious to know if there is a method to get Mathematica to >>produce that >>solution? >> >>David Park >>djmp at earthlink.net >>http://home.earthlink.net/~djmp/ >> >> > >Dear David, > >if you have cartesian coordinates defined (symbolically) as > >In[1]:= {x, y} = r{ Cos[t], Sin[t]} ; > >then you may revert (symbolically) to polar with > > >In[11]:= >FullSimplify[{Sqrt[{x, y}.{x, y}], ArcTan[x, y]}, > {Positive[r], t \[Element] Reals}, > TransformationFunctions -> {Automatic, TrigToExp, PowerExpand}] > >Out[11]= {r, t} > >(It also works with assuption r \[Element] Reals (but I hate that). > >Of course numerical work is easier. > >-- >Hartmut > ----------------------------------------------------------------------- --------------------------------- I think that it is easier to get results with Arg[] rather than ArcTan[] for an inverse function, so starting from something like Hartmut's case applied to simplification of the Solve[]: In[5]:=Clear[x,y,r,t]; In[6]:=FullSimplify[ Solve[eqns, {r, t}, {x, y} \[Element] Reals], {x, y} \[Element] Reals, TransformationFunctions -> {Automatic, ComplexExpand, PowerExpand}] the neatest however should be when using Exp[] rather than Cos[] and Sin[], but I am annoyed that you have to supply redundant information (Solve[] does not recognise that a complex equation has 2 Real unknowns..) and with the remaining oddities in the result: In[7]:=eqns2={x^2+y^2==r^2,x+I*y == r *Exp[I*t]}; In[8]:=FullSimplify[Solve[eqns2,{r,t},{x,y}\[Element]Reals], {x,y}\[Element]Reals, TransformationFunctions->{Automatic,ComplexExpand,PowerExpand}] The inverse functions (Sqrt[] and Arg[]) are so simple that these subtleties only matter for much more complex expressions: this can be a real voyage of discovery! The deepest darkest notes of Help for FullSimplify, ComplexExpand etc. give fascinating options even before resorting to specific pattern matching rules [oh I do love Mathematica..]. From the MathGroup archives, a good start point is "Re: COMPLEXEXPAND" from Andrzej Kozlowski, 30/3/2000. Using Andrej's function myComplexExpand[] as a transformation, the result of the evaluation looks just what you want: In[9]:=myComplexExpand[z_] := ComplexExpand[Abs[z], TargetFunctions -> {Re, Im}]* Exp[I*ComplexExpand[Arg[z], TargetFunctions -> {Re, Im}]] In[10]:=myComplexExpand[x + I*y] Out[10]:=Exp[I*ArcTan[x, y]]*Sqrt[x^2 + y^2] To get inverse results from Solve with ArcTan[] directly in this case, unfortunately using myComplexExpand directly as a TransformationFunction did not work <<rats>>, but using the hints from Andrej and Hartmut my first imperfect result is: In[11]:=FullSimplify[Solve[eqns,{r,t},{x,y}\[Element]Reals], {x,y}\[Element]Reals, TransformationFunctions->{Automatic, ComplexExpand[#,TargetFunctions->{Re,Im}]&, PowerExpand}] Hopefully somebody can neaten up these examples a bit more, I thought this would be an easy one to link in to Solve[] but I was wrong.. fascinating. Now to delve into the online help to see what more version 5.0 has to offer.. -- from - John Tanner home - john at janacek.demon.co.uk mantra - curse Microsoft, curse... work - john.tanner at baesystems.com I hate this 'orrible computer, I really ought to sell it: It never does what I want, but only what I tell it.