arctan2

from Wikipedia, the free encyclopedia

The mathematical function arctan2 , also atan2 , is an extension of the inverse trigonometric function arctangent and, like this, an inverse function of the trigonometric function tangent .

It takes two real numbers as arguments, in contrast to the normal arctangent, which has only one real number as an argument. This means that it has enough information to be able to output the function value in a range of values (i.e. all four quadrants ) and does not have to be limited to two quadrants (like the normal arctangent). The full range of values ​​is often required, for example when converting planar Cartesian coordinates into polar coordinates : if the two Cartesian coordinates are given as arguments to the function, the polar angle is obtained which is in the correct quadrant, i.e. H. of the relationships

 and
 With

Fulfills. A mathematically useful additional effect is that angles for which the tangent has a pole , namely the angles can be specified by normal real coordinates, namely by instead of

This comes from the definition of the function of the "perforated" level, which can be provided with a group structure that is isomorphic to the multiplicative group of complex numbers without the zero . These groups are the direct product of the circular group of rotations and the group of elongations by a factor greater than zero, the multiplicative group. The first group can be parameterized by the polar angle , the second by the (positive) amount

Solution: Two arguments

Two points different from the origin and specify the same polar angle if they are on the same ray through . Then they are regarding the through

defined relation equivalent . On the other hand, the tangent value of polar angles is also the same when the beam is rotated around or , i.e. exactly into the opposite beam . From an information-theoretical perspective, the tangent ignores the sign information of (red in the formulas):

 

just take .

Fig. 1: Graph of the arctangent function

Since the tangent is periodic and the function term requires right-hand uniqueness, its definition range must be limited to at least the period length for its inversion (reflection at the 1st angle bisector ) - in this article to the interval (see Fig. 1). As a result, the inverse arctangent function cannot have a larger image than . The whole real axis is allowed as the domain of definition of the arctangent because the image of the tangent below is straight .

In order to achieve a fully-fledged polar angle, there is an extended function in many programming languages and spreadsheets that is loaded with the two Cartesian coordinates and thus has enough information to calculate the polar angle modulo (e.g. in the interval as in Fig. 3) and in to be able to return all four quadrants.

Implementations

The first implementation was no later than 1966 in the Fortran programming language . Today the function is also available in other programming languages.

The function often has the name , for example in the programming languages Fortran 77, C , C ++ , Java , Python , Matlab , R , iWork Numbers , LibreOffice Calc . In many of these programming languages ​​(not for example in LibreOffice Calc) the order of the arguments is reversed, i.e. the coordinate is the first argument. In Common Lisp , where optional arguments that allows the function, the coordinate to pass as an optional second argument, the default setting is.

Another name is , as is the case with the spreadsheet programs Excel and OpenOffice Calc .

In Mathematica is a function defined in the first argument can be omitted.

Please note
This article uses the order and name .

formula

The six cases of function definition

      or  
For (Quadrants and )
  For (Quadrant )
For ( upperlower edge of the image set)
For (Quadrant )
For
For
Fig. 2: Points ● in the (x | y)
plane and their arctan2 value

with as the "perforated" level can be used as a formula

unite. Except for the case (the jump point, see below), the function is point-symmetric at the origin, in formulas:

.

The function value is sometimes assigned to the argument , just as other special cases, e.g. N ot a N umber , are treated differently.

The loss of accuracy due to the division can be used, for example, by forming

reduce (but see also the section # Accuracy control ).

Jump point and continuous rotation of the polar angle

Fig. 3: Graph of  over   for . Target = source quadrant with blue Roman numerals.

With increasing polar angle , i.e., upon rotation in the mathematical sense (and counter -clockwise), that is, the migration from the quadrant on the quadrants and the quadrants , a period begins in Fig. 3 below at (beam through) the point

,

from where it continues on the red graph from bottom left to top right (always in "ONO direction"). As usual, near zero should mean infinitesimally below and infinitesimally above. The rotation continues in the quadrant via the point (located on the 1st bisector and marked in the figure by a small red circle area)

,

to the point

,

which corresponds to one of the poles of the tangent and is therefore an infinitely distant point for the arctangent . The value changes from to . Fig. 3 symbolizes this fact with the red ring on the right in the quadrant as a sink and the red knob on the left in the quadrant as a source. From the point of view of the function , nothing more happens than that the value changes from to .

The further rotation leads through the quadrant over the marked point

to the point

,

which lies in the origin of coordinates, and from there through the quadrant over the marked point

,

to the point

.

This point corresponds to the other pole of the tangent. With it the same coincidence of the sink in the quadrant with the source in the quadrant takes place as with the argument above . The further rotation through the quadrant leads over the marked point

finally to the jump point

.

This case can be added to either the case in the line above or below by slightly modifying the conditions in the formula , according to which the interval of the image set is closed at its upper end and open at the lower end, that is , or vice versa .

If the calculation of the polar angle has to be accompanied by a continuous rotation, then the function can be adapted or extended so that

  • the jump point is at any point (any ray) of the definition area;
  • even with a rotation beyond the period length , the polar angle increases or decreases continuously. This is where the circulation number comes into play.

For example, in applications where continuity within a half-plane is important, the following formulas can be useful:

      For (Quadrants and )
      For (Quadrants and )
For (Quadrants and )
For (Quadrants and )
For (Quadrants and )
      For (Quadrants and )
      For (Quadrants and )

The 7 lines are arranged in such a way that the values ​​of two superimposed functions coincide in the common definition area. Because of the jump point in the ray , equality with one of the continuous functions is not possible.

Isomorphism to the circle group

The precise mathematical representation of the following well-known figure requires additional auxiliary figures on both the original and the image side.

On the definition set of one can (in analogy to the definition of addition in the rational numbers ) the connection

define. It remains well-defined under the equivalence relation above , and the set of factors

turns out to be a commutative group with the neutral element and the formation of the inverse

.

The induced mapping is just as well defined

because equivalent representatives give the same value . From the sum formula of the arctangent follows

If you apply the function to the function

then there is a homomorphism with

on the circle group , whose core is the neutral element with . If and are equipped with the natural topology, then it is continuous in both directions, hence a homeomorphism .

Accuracy control

With a little preparation and with only one comparison more than in the case distinctions of the formula , the convergence behavior of the Taylor series (the arctangent) can be checked and, if necessary, improved.

The angle of is characterized by the fact that it is an integer fraction, namely one eighth, of the full angle of and at the same time its ray goes through integer coordinates. Quadrants can be aligned in the coordinate plane so that their boundaries (which by definition are always rays) come to lie parallel to the coordinate axes. In the case of octants, the bisectors are added as limits. The determination of which of the eight octants a point belongs to is particularly easy with such an alignment.

Notation
In this section, the usual operators  with the tilde written above   are used in the relationships between rays and angles  to express that a ray is an equivalence class  . And with the comparison operators   , the ray is always compared with the angle closest to it.
To avoid confusion with coordinates , the decimal point is used instead of the comma in decimal notations.

In the following, an attempt is made to use any beam, respectively. To turn angles with simple and reversible rotations in the angle interval symmetrical on the polar axis . Then namely the absolute value of the argument is in the Taylor series of the arctangent .

In a first rotation the beam is rotated, i.e. H. the beam

educated. The octant in which this ray falls is the -th, and the numbering of the octants is chosen so that the first covers the angular interval :

Number of the octant its lower and upper limit

 
the upper as a ray
the upper as the polar angle

From the octant determined in this way the upper limiting ray is taken, which can be characterized by a point from the set of rays shown in the table. (All of these points have integer coordinates, and the first octant is, for example .) Then is or

.

It is followed by a turn of , the second, now around , so that

is in the desired angular interval. The result when the arctangent has been calculated must be corrected for this second rotation of with an integer .

The first turn just needs to be approximate . If it deviates slightly from this, for example or even amounts to, then the beam may not be fitted so well into the angle interval symmetrical on the polar axis. However, the convergence behavior deteriorates only slightly because of .

After the second rotation, the Taylor series (at the development point )

developed and the final correction

be made.

Examples
  1. Let the output beam be , which corresponds to an angle of approx . The -addition of brings us up , i.e. in the -th octants. Its upper limit is included . We make the difference and calculate with and adjust with the final result .
  2. Let the output beam be , which corresponds to an angle of approx . The -addition of brings us up , i.e. in the -th octants. The upper end of the octant is included . Since this octant contains the jump point , we apply the correction angle to this -th octant in the case . We make the difference and calculate with and adjust with .

Connection to the complex logarithm

The function for can also be defined via the main value of the complex logarithm as

with the argument function . This function is used, for example, in inverse kinematics to correctly describe joint settings. However, this is just a different formal representation, because for the calculation you have to determine with and to convert the given Cartesian representation from into the polar form, whereby in the end you fall back on the above-defined function with real arguments.

Derivatives

The function depends on two variables and is (except in the origin) continuously differentiable, i.e. it has two partial derivatives . For the condition of the first case (quadrant and ) and its assignment results

,

The restriction to the first case can be dropped retrospectively so that the equations apply to all .

So is

the gradient of the function , and its direction is perpendicular to the radius vector at each point in a mathematically positive direction of rotation. This fits in with the fact that the functional value of , the polar angle, increases in this direction.

Furthermore follows for the total differential

An integration of this differential along a path results in the change in the (polar) angle over the path. If the path is closed, the number of revolutions is obtained (in relation to the origin ).

See also

Web links

Commons : arctangent and arctangent  - collection of images, videos and audio files

References and comments

  1. a b c d In this article, the order of arguments was chosen because most of the time we speak of the level and practically never of the level . More about the function name and the order of arguments can be found in § Implementations .
  2. The concept formation allows u. a. a simpler and more precise specification of the values and which correspond to the pole of the tangent divided into two tangent periods.
  3. Elliott I. Organick: A FORTRAN IV primer . Addison-Wesley, 1966, p. 42: "Some processors also offer the library function called ATAN2, a function of two arguments (opposite and adjacent)."
  4. Fortran Wiki atan2 . GNU Free Documentation License (GFDL). Archived from the original on June 12, 2017. Info: The archive link was inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. Retrieved April 8, 2017. @1@ 2Template: Webachiv / IABot / fortranwiki.org
  5. ^ Numbers' Trigonometric Function List . Apple.
  6. LibreOffice Calc ATAN2 . Libreoffice.org.
  7. CLHS: Function ASIN, ACOS, ATAN . LispWorks.
  8. Microsoft Excel Atan2 Method . Microsoft.
  9. The placement of the quadrants and in Fig. 3 is “reversed” compared to the illustration in the article Quadrant .
  10. According to the 2 arguments of the function , two coordinates are listed as independent variables and not just the quotient .
  11. This definition agrees with the rules of complex multiplication , which also form the basis of the addition theorem of the tangent .
    In this article, their suitability for integer coordinates is particularly important .
  12. From the complex numbers we know that the -inverse of on whole (and not only on )
    and that it is an Abelian group, which is not used in this way in the text.
  13. What is meant is the semi-quadrant, which corresponds to the nautical device octant and the compass rose with the four cardinal directions , and not the three-dimensional octant (geometry) .
  14. The derivatives are broken rational functions and contain no transcendent function. This phenomenon is already known from the arctangent.