# Everything You Wanted to Know About Numpy Arctan2

Hello geeks and welcome in this article, we will cover NumPy arctan2. Along with that, for an overall better understanding, we will also look at its syntax and parameter. Then we will see the application of all the theory part through a couple of examples. But at first, let us try to analyze the function through its definition.

First of all, the arctan means the inverse of a tan function. Now the function NumPy arctan2 helps us calculate the arc tan value between the X1 and X2 in radians. Here X1 and 2 are parameters that we will discuss later. As we move ahead in this article, things will become more clear to you. Up next, let us look at the syntax associated with it.

Contents

## Syntax

`numpy.arctan2()`

This is the general syntax for our function. In the next section, we will see different parameters associated with our function.

## Parameter

1. Y: ARRAY_LIKE

This array contains the points to be plotted along the Y-axis.

2. X: ARRAY_LIKE

This array contains points to be plotted along the X-axis. The shape of this array must be similar to the Y-axis.

3. OUT: NDARRAY, NDARRAY OF TUPLE

This parameter represents an array of the same shape as the input array. It represents the location where the output will be stored. By default, the value is none.

4. WHERE:ARRAY_LIKE

This is another optional parameter, and by default, it is none. In that case, the array will retain its original value. But in case it is equal to true, the output array will be set to calculate a universal value at that position.

## NumPy arctan2 range

Arctan2 is a 4 quadrant inverse function. That being said, it gives out the value between 0 to 2pi. The range of this function is -180 to 180 degrees. These are 2 key points that differentiate Arctan2 from the arctan function. A more detailed comparison between the 2 is discussed later in the article.

## Examples

As we are done with all the theory portion related to NumPy arctan2. This section will be looking at how this function works and how it helps us achieve our desired output. We will start with an elementary level example and gradually move our way to more complicated examples.

### 1. Basic example

```import numpy as ppool
y=[1,1]
x=[1,1.732]
print(ppool.arctan2(y,x))
```
```[0.78539816 0.52361148]
```

Above, we can see a straightforward example of our arctan2 function. Now let us go line by line and understand how we achieved the output. At first, we have imported the NumPy function. After which, we have defined our 2 sets of the array. Using the syntax of our function and a print statement, we get our desired output.

Here both the values are in radian. Now, if you wish to cross-check the result to a degree. To do so, we need to use this particular formula

`Angle in degree = angle in radian * 180/pi`

If we perform the calculations concerning our outputs, we get an answer of 45 and 30 degrees. Here we have considered pi to 3.14. The answers match, and hence the output is verified.

### 2.Output in degree

Now suppose you wish to get the values in degree as well. It is a straightforward process and can be done with the help of for loop and the formula discussed above. Let us see how

```import numpy as ppool
degree=0
y=[-1,1.732]
x=[2,1]
b=ppool.arctan2(y,x)
print(b)
for vals in b:
degree=vals*(180/3.14)
print(degree)
```

Output:

``````[-0.46364761  1.04718485]
-26.578525356734104
60.02970472117416``````

See how we get the values in radian as well as degree. All the steps are similar to that of the first example. The only difference that we have used a “for loop“. If you want something more straightforward we can use another method also

```import numpy as ppool
y=[-1,1.732]
x=[2,1]
b=ppool.arctan2(y,x)*(180/3.14)
print(b)
```

Output:

``[-26.57852536  60.02970472]``

Here all you need to do is just multiply the value (180/3.14) or (180/ppool.pi) to the array. You can definitely use this method over the for loop method. But in both cases, you will get your desired output that is value in degree.

## Difference Between Arctan and Arctan2

In this section we will discuss the difference between 2 Numpy functions. 