# Ruby – Find Arc Tangent using atan2() Method for Complex Number – Examples & Explanation

In Ruby, `atan2()` is a method in `CMath` class which is used to find the arc tangent of specified given complex numbers in Ruby language to determine the quadrant. To get the arc tangent of given complex numbers we use `CMath.atan2(x, y)` method.

## `atan2()` method in Ruby

`atan2()` method exists in Standard `atan2()` Library of Ruby. The purpose of this method is to provide perfect arc tangent of specified given complex numbers to determine the quadrant.

## Syntax of the `atan2()` method in Ruby

Syntax of `atan2()` method is:

`CMathath.atan(x, y)`

## Parameters of `atan2()` method in Ruby

 Parameter Description `x` Any valid complex numbers. These parameter are required.

Note: if the x parameter is not a complex number, `atan2()` method will return an error.

## Return Value of `atan2()`

`atan2()` method will return the arc tangent of given complex numbers.

## Ruby `atan2()` Example 1

```    # import CMath library
require 'cmath'

x = CMath.atan2(5 + 5i, 0)

puts x
```

Output:
`1.5707963267948966+0.0i`

## Ruby `atan2()` Example 2

```    # import CMath library
require 'cmath'

x = CMath.atan2(-5 + 5i, 1)

puts x
```

Output:
`-1.4701377726075762+0.09932544936725085i`

## Ruby `atan2()` Example 3

```    # import CMath library
require 'cmath'

x = CMath.atan2(-5 + 0i, 1)

puts x
```

Output:
`-1.373400766945016-0.0i`

## Ruby `atan2()` Example 4

```    # import CMath library
require 'cmath'

x = CMath.atan2(a5 - b5i, 0)

puts x
```

Output:
`Error`