MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Two Argument ArcTan Function

  • To: mathgroup at
  • Subject: [mg43409] Re: Two Argument ArcTan Function
  • From: John Tanner <john at>
  • Date: Tue, 16 Sep 2003 04:36:06 -0400 (EDT)
  • References: <bfrk3t$rcv$>
  • Sender: owner-wri-mathgroup at

In article <bfrk3t$rcv$1 at>, "Wolf, Hartmut" 
<Hartmut.Wolf at> writes
>>-----Original Message-----
>>From: David Park [mailto:djmp at]
To: mathgroup at
>>Sent: Friday, July 25, 2003 11:09 AM
>>To: mathgroup at
>>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
>>I'm curious to know if there is a method to get Mathematica to
>>produce that
>>David Park
>>djmp at
>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
>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.
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[]:

   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]};

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:


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
   mantra - curse Microsoft, curse...   work -  john.tanner at
I hate this 'orrible computer,  I really ought to sell it:
It never does what I want,      but only what I tell it.

  • Prev by Date: Re: Pattern Matching Problem
  • Next by Date: problem with the cells in my last NDSolve error post ...
  • Previous by thread: Re: Creating Nested GridBoxes
  • Next by thread: problem with the cells in my last NDSolve error post ...