Compact quantum group: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
No edit summary
formatting improvements and plain html to {{math|...}}
 
Line 1: Line 1:
{{lowercase|atan2}}
Myrtle Benny is how I'm called and  [http://raybana.com/chat/pg/profile/GIsaachse over the counter std test] I really feel comfortable when individuals use the full name. South Dakota is exactly where me and my spouse live. To gather badges is what her family members and over the counter std test her appreciate. Managing people is what I do and the salary has been really [http://samedaystdtesting.com/testing-clinics/florida-fl/hialeah-std-testing/2750-west-68th-street-suite-225-226-33016 satisfying].<br><br>Feel over the counter [http://computerrepairredlands.com/solid-advice-terms-candida-albicans/ at home std test] std test free to surf to my site: [http://flashtrue.com/stay-yeast-infection-free-using-these-useful-tips/ http://flashtrue.com/stay-yeast-infection-free-using-these-useful-tips]
In a variety of [[computer languages]], the [[function (mathematics)|function]] '''atan2''' is the [[arctangent]] function with two arguments. The purpose of using two arguments instead of one is to gather information on the signs of the inputs in order to return the appropriate quadrant of the computed angle, which is not possible for the single-argument [[arctangent]] function.
 
For any [[real number]] (e.g., [[floating point]]) arguments {{mvar|x}} and {{mvar|y}} not both equal to zero, {{math|atan2(''y'', ''x'')}} is the angle in [[radian]]s between the positive {{mvar|x}}-axis of a plane and the point given by the [[Cartesian coordinate system|coordinates]] {{math|(''x'', ''y'')}} on it. The angle is positive for counter-clockwise angles (upper half-plane, {{math|''y'' &gt; 0}}), and negative for clockwise angles (lower half-plane, {{math|''y'' &lt; 0}}).
 
==History and motivation==
 
The atan2 function was first introduced in computer [[programming language]]s, but now it is also common in other fields of science and engineering. It dates back at least as far as the [[FORTRAN]] programming language<ref>{{Cite book
| last = Organick
| first = Elliott I.
| authorlink =
| coauthors =
| year =1966
| title =A FORTRAN IV Primer
| publisher = Addison-Wesley
| location =
| quote ="Some processors also offer the library function called ATAN2, a function of two arguments (opposite and adjacent)."
  | pages = 42
}}</ref>
and is currently found in [[C (programming language)|C]]'s [[math.h]] [[C standard library|standard library]], the [[Java (programming language)|Java]] Math library, .NET's System.Math (usable from [[C Sharp (programming language)|C#]], [[VB.NET]], etc.), the [[Python (programming language)|Python]] math module, the [[Ruby (programming language)|Ruby]] Math module, and elsewhere. Many scripting languages, such as [[Perl]], include the C-style <tt>atan2</tt> function.<ref>The [[Linux API|Linux Programmer's Manual]] [http://linux.die.net/man/3/atan2] says:
:"The '''atan2'''() function calculates the [[arc tangent]] of the two variables '''''y''''' and '''''x'''''.  It is similar to calculating the arc tangent of '''''y''''' / '''''x''''', except that the [[positive and negative numbers|signs]] of both arguments are used to determine the [[Cartesian coordinate system|quadrant]] of the result."</ref>
 
In mathematical terms, {{math|atan2}} computes the [[principal value]] of the [[arg (mathematics)|argument]] function applied to the [[complex number]] {{math|''x''+i''y''}}. That is, {{math|atan2(''y'', ''x'') {{=}} Pr arg(''x''+i''y'') {{=}} Arg(''x''+i''y'')}}. The argument can be changed by {{math|2π}} (corresponding to a complete turn around the origin) without making any difference to the angle, but to define {{math|atan2}} uniquely one uses the principal value in the range [[interval (mathematics)|{{open-closed|−''π'', ''π''}}]].  That is, {{math|−''π'' < atan2(''y'', ''x'') ≤ ''π''}}.
 
The atan2 function is useful in many applications involving [[Euclidean vector|vectors]] in [[Euclidean space]], such as finding the direction from one point to another. A principal use is in computer graphics rotations, for converting [[rotation matrix]] representations into [[Euler angle]]s.
 
In some computer programming languages, the order of the parameters is reversed (for example, in some [[spreadsheet]]s) or a different name is used for the function (for example, Mathematica uses ArcTan[x,y]). On scientific calculators the function can often be calculated as the angle given when {{math|(''x'', ''y'')}} is converted from [[rectangular coordinates]] to [[polar coordinates]].
The one-argument [[arctangent]] function cannot distinguish between diametrically opposite directions. For example, the anticlockwise angle from the {{mvar|x}}-axis to the vector {{math|(1, 1)}}, calculated in the usual way as {{math|arctan(1/1)}}, is {{math|π/4}} (radians), or {{math|45°}}. However, the angle between the {{mvar|x}}-axis and the vector {{math|(−1, −1)}} appears, by the same method, to be {{math|arctan(−1/−1)}}, again {{math|π/4}}, even though the answer clearly should be {{math|−3π/4}}, or {{math|−135°}}.  
 
The {{math|atan2}} function takes into account the signs of both vector components, and places the angle in the correct quadrant. Thus, {{math|1=atan2(1, 1) = π/4}} and {{math|1=atan2(−1, −1) = −3π/4}}.
 
Additionally, the ordinary arctangent method breaks down when required to produce an angle of {{math|±π/2}} (or {{math|±90°}}). For example, an attempt to find the angle between the {{mvar|x}}-axis and the vector {{math|(0, 1)}} requires evaluation of {{math|arctan(1/0)}}, which fails on division by zero. In contrast, {{math|atan2(1, 0)}} gives the correct answer of {{math|π/2}}.
 
When calculations are performed manually, the necessary quadrant corrections and exception handling can be done by inspection, but in computer programs it is extremely useful to have a single function that always gives an unambiguous correct result.
 
==Definition and computation==
{{anchor|Definition}}
In terms of the standard {{math|arctan}} function, whose range is {{open-open|−π/2, π/2}}, it can be expressed as follows:
 
:<math>\operatorname{atan2}(y, x) = \begin{cases}
\arctan\left(\frac y x\right) & \qquad x > 0 \\
\arctan\left(\frac y x\right) + \pi& \qquad y \ge 0 , x < 0 \\
\arctan\left(\frac y x\right) - \pi& \qquad y < 0 , x < 0 \\
+\frac{\pi}{2} & \qquad y > 0 , x = 0 \\
-\frac{\pi}{2} & \qquad y < 0 , x = 0 \\
\text{undefined} & \qquad y = 0, x = 0
\end{cases}</math>
 
Notes''':'''
* This produces results in the range {{open-closed|−π, π}}, which can be mapped to {{closed-open|0, 2π}} by adding {{math|2π}} to negative results. <!--- ADDING 2π IS OK, BECAUSE IT DOES NOT CHANGE THE POSITION ON THE UNIT CIRCLE.  SEVERAL PEOPLE HAVE ERRONEOUSLY CHANGED THIS TO π, AND HAVE BEEN REVERTED. --->
 
* Traditionally, {{math|atan2(0, 0)}} is undefined.
** The C function <tt>atan2</tt>, and most other computer implementations, are designed to reduce the effort of transforming cartesian to polar coordinates and so always define <tt>atan2(0,&nbsp;0)</tt>. On implementations without [[signed zero]], or when given positive zero arguments, it is normally defined as 0. It will always return a value in the range {{closed-closed|−π, π}} rather than raising an error or returning a [[NaN]] (Not a Number).
** Systems supporting symbolic mathematics normally return an undefined value for <tt>atan2(0,0)</tt> or otherwise signal that an abnormal condition has arisen.
 
* For systems implementing [[signed zero]], [[Infinity|infinities]], or [[Not a Number]] (for example, [[IEEE floating point]]), it is common to implement reasonable extensions which may extend the range of values produced to include −{{math|π}} and −0. These also may return NaN or raise an exception when given a NaN argument.
 
* For systems implementing [[signed zero]] (for example, [[IEEE floating point]]), atan2(-0, x), x < 0 returns the value −π.  atan2(+0, x), x < 0 still returns +π.
 
The free math library FDLIBM (Freely Distributable LIBM) available from [[netlib]] has source code showing how it implements <tt>atan2</tt> including handling the various IEEE exceptional values.
 
For systems without a hardware multiplier the function <tt>atan2</tt> can be implemented in a numerically reliable manner by the [[CORDIC]] method.
Thus implementations of <tt>atan(y)</tt> will probably choose to compute <tt>atan2(y,1)</tt>.
 
The following expression derived from the [[tangent half-angle formula]] can also be used to define {{math|atan2}}.
:<math>
  \operatorname{atan2} (y, x)=2 \arctan \frac{y}{\sqrt{x^2+y^2}+x}.
</math>
This expression may be more suited for symbolic use than the definition above. However it is unsuitable for [[floating point]] computational use as it is undefined for {{math|1=''y'' = 0, ''x'' < 0}} and may overflow near these regions. The formula gives an NaN or raises an error for {{math|atan2(0, 0)}}, but this is not an issue since {{math|atan2(0, 0)}} is not defined.
 
A variant of the last formula is sometimes used in high precision computation. This avoids overflow but is always undefined when {{math|1=''y'' = 0}}:
:<math>
  \operatorname{atan2} (y, x)=2 \arctan \frac{\sqrt{x^2+y^2}-x}{y}.
</math>
 
==Variations and notation==
*In [[Common Lisp]], where optional arguments exist, the <tt>atan</tt> function allows one to optionally supply the ''x'' coordinate: <tt>(atan&nbsp;''y''&nbsp;''x'')</tt>.<ref>{{cite web|url=http://www.lispworks.com/documentation/HyperSpec/Body/f_asin_.htm|title=CLHS: Function ASIN, ACOS, ATAN|publisher=LispWorks}}</ref>
*In [[Mathematica]], the form <tt>ArcTan[''x'', ''y'']</tt> is used where the one parameter form supplies the normal arctangent. Mathematica classifies <tt>ArcTan[0,&nbsp;0]</tt> as an indeterminate expression.
* In [[Microsoft Excel]], the <tt>atan2</tt> function has the two arguments reversed.<ref>{{cite web|url=http://msdn2.microsoft.com/en-us/library/bb238940.aspx|title=Atan2 Method|publisher=Microsoft}}</ref> [[OpenOffice.org Calc]] also reverses the arguments, as does the [[Google Docs|Google Spreadsheets]] <<tt>atan2</tt> function.<ref>{{cite web|url=http://docs.google.com/support/bin/answer.py?answer=82712&version=static|title=Function list|publisher=Google}}</ref>
* In the [[Intel]] Architecture [[assembler code]], <tt>atan2</tt> is known as the FPATAN (floating-point partial arctangent) instruction.<ref>IA-32 Intel Architecture Software Developer’s Manual. Volume 2A: Instruction Set Reference, A-M, 2004.</ref> It can deal with infinities and results lie in the closed interval {{closed-closed|−π, π}}, e.g. <tt>atan2(∞, ''x'') = +π</tt>. Particularly, FPATAN is defined when both arguments are zero:
*:<tt>atan2(+0, +0) = +0</tt>
*:<tt>atan2(+0, −0) = +π</tt>
*:<tt>atan2(−0, +0) = −0</tt>
*:<tt>atan2(−0, −0) = −π</tt>
*:This definition is related to the concept of [[signed zero]], i.e. <math> \pm 0\; \overset{def}{=} \lim_{\;x\rightarrow 0^\pm} x</math>
* On most TI graphing calculators (excluding the [[TI-85]] and [[TI-86]]), the equivalent function is called '''R►Pθ''' and has the arguments reversed.
* On TI-85 the {{math|arg}} function is called <tt>angle(x,y)</tt> and although it appears to take two arguments, it really only has one complex argument which is denoted by a pair of numbers: {{math|''x''+i''y'' {{=}} (''x'',''y'')}}
* In mathematical writings other than source code, such as in books and articles, the notations '''Arctan'''<ref>http://books.google.com/books?id=2LIMMD9FVXkC&pg=PA234&dq=four+quadrant+inverse+tangent+mathematical+notation&hl=en&sa=X&ei=Q2Y4UaGTAcmzyAHsooCoBw&ved=0CDgQ6AEwAg#v=onepage&q=four%20quadrant%20inverse%20tangent%20mathematical%20notation&f=false</ref> and '''Tan<sup>-1</sup>'''<ref>http://books.google.com/books?id=7nNjaH9B0_0C&pg=PA345&dq=four+quadrant+inverse+tangent+mathematical+notation&hl=en&sa=X&ei=Q2Y4UaGTAcmzyAHsooCoBw&ved=0CDIQ6AEwAQ#v=onepage&q=four%20quadrant%20inverse%20tangent%20mathematical%20notation&f=false</ref> have been utilized; these are uppercase variants of the [[Inverse trigonometric functions#Notation|regular]] arctan and tan<sup>-1</sup>. This usage is consistent with the [[complex argument#Notation|complex argument notation]], such that {{math|Atan(''y'', ''x'') {{=}} Arg(''x''+i''y'')}}.
 
==Illustrations==
[[File:Atan2 60.svg|thumb|right|350px|atan2 round a circle]]
 
The diagram alongside shows values of atan2 at selected points on the unit circle. The values, in radians, are shown inside the circle. The diagram uses the standard mathematical convention that angles increase [[Clockwise|anticlockwise (counterclockwise)]], and zero is to the right. Note that the order of arguments is reversed; the function {{math|atan2(''y'', ''x'')}} computes the angle corresponding to the point {{math|(''x'', ''y'')}}.
 
The diagram below shows values of {{math|atan2}} for points on the unit circle. On the {{mvar|x}}-axis is the [[Complex plane|complex angle]] of the points, starting from {{math|0}} ( point {{math|(1,0)}} ) and going anticlockwise (counterclockwise), through points:
* {{math|(0, 1)}} with complex angle {{math|π/2}} (in radians),
* {{math|(−1, 0)}} with complex angle {{math|π}},
* {{math|(0, −1)}} with complex angle {{math|3π/2}},
to {{math|(1, 0)}} with complex angle {{math|1=0 = (2''n''π mod 2π)}}.
 
On this diagram one can clearly see the [[Discontinuity (mathematics)|discontinuity]] of the {{math|atan2}} function.<ref>[http://www.mndynamics.com/indexp.html Computation of the external argument by Wolf Jung]</ref>
 
<center>
[[File:Atan2-discontinuity.svg]]
</center>
 
The diagrams below show 3D view of respectively {{math|atan2(''y'', ''x'')}} and {{math|arctan(''y''/''x'')}} over a region of the plane.
 
Note that for {{math|atan2}}, rays emanating from the origin have constant values, but for {{math|atan}} lines passing through the origin have constant values. For {{math|''x'' > 0}}, the two diagrams give identical values.
 
<center>
[[Image:Atan2Diagram.png|400px]] [[Image:AtanDiagram.png|400px]]
</center>
 
==Derivative==
{{details|Winding number}}
As the function atan2 is a function of two variables, it has two [[partial derivative]]s. At points where these derivatives exist, atan2 is, except for a constant, equal to arctan(''y/x''). hence:
 
:<math>
\frac{\partial\operatorname{atan2}(y,x)}{\partial x} =\frac{\partial\arctan(y/x)}{\partial x} = -\frac{y}{x^2 + y^2}
</math>
 
:<math>
\frac{\partial\operatorname{atan2}(y,x)}{\partial y} =\frac{\partial\arctan(y/x)}{\partial y} = \ \frac{x}{x^2 + y^2}
</math>
 
for <math>x > 0\,\text{ or }\,y \neq 0.</math>
 
Informally representing the function atan2 as the angle function <math>\theta(x,y) = \operatorname{atan2}(y,x)</math> (which is only defined up to a constant) yields the following formula for the [[total derivative]]:
:<math>\begin{align}
d\theta
&= \partial_x\left(\operatorname{atan2}(y,x)\right) dx + \partial_y\left(\operatorname{atan2}(y,x)\right) dy \\
&= -\frac{y}{x^2 + y^2} dx + \frac{x}{x^2 + y^2} dy
\end{align}</math>
While the function atan2 is discontinuous along the negative ''y''-axis, reflecting the fact that angle cannot be continuously defined, this derivative is continuously defined except at the origin, reflecting the fact that infinitesimal (and indeed local) ''changes'' in angle can be defined everywhere except the origin. Integrating this derivative along a path gives the total change in angle over the path, and integrating over a closed loop gives the [[winding number]].
 
In the language of [[differential geometry]], this derivative is a [[one-form]], and it is [[closed differential form|closed]] (its derivative is zero) but not [[exact differential form|exact]] (it is not the derivative of a 0-form, i.e., a function), and in fact it generates the first [[de Rham cohomology]] of the [[punctured plane]]. This is the most basic example of such a form, and it is fundamental in differential geometry.
 
The partial derivatives of atan2 do not contain trigonometric functions, making it particularly useful in many applications (e.g. embedded systems) where trigonometric functions can be expensive to evaluate.{{Clarify| reason = how does calculating the derivative of atan2 help with evaluating the trigonometric functions?|date=October 2011}}
 
==References==
{{reflist}}
 
==External links==
*[http://java.sun.com/javase/6/docs/api/java/lang/Math.html#atan2%28double,%20double%29 Java 1.6 SE JavaDoc]
*[http://everything2.com/index.pl?node_id=1008481 atan2] at Everything2
*[http://www.picbasic.co.uk/forum/showthread.php?p=70269#post70269 PicBasic Pro solution] atan2 for a PIC18F
 
===Other implementations/code for atan2===
*[http://mathforum.org/library/drmath/view/55417.html Bearing Between Two Points]
*[http://mathforum.org/library/drmath/view/54114.html Arctan and Polar Coordinates]
*[http://mathforum.org/library/drmath/view/54172.html What's 'Arccos'?]
 
[[Category:Trigonometry]]

Latest revision as of 06:17, 27 April 2014

Myrtle Benny is how I'm called and over the counter std test I really feel comfortable when individuals use the full name. South Dakota is exactly where me and my spouse live. To gather badges is what her family members and over the counter std test her appreciate. Managing people is what I do and the salary has been really satisfying.

Feel over the counter at home std test std test free to surf to my site: http://flashtrue.com/stay-yeast-infection-free-using-these-useful-tips