# Ruby – Find Tangent – tan() Method – Examples & Explanation

In Ruby, `tan()` method can be used to find the tangent of the any given complex number in Ruby language where this number is given in radians. `tan()` method exists in `CMath` library of Ruby programming language.

## `tan()` method in Ruby

`tan()` method exists in Standard `tan()` Library of Ruby. The purpose of this method is to provide perfect tangent for any given complex number where this number is given in radians.

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

Syntax of `tan()` method is `cmath.tan(x)`

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

 Parameter Description `x` Any valid complex number. This parameter is required.

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

## Return Value of `tan()`

`tan()` method will return the tangent of any given complex number where this number is given in radians.

## Ruby `tan()` Example 1

`# import CMath library`
`require 'cmath'`
`x = CMath.tan(5 + 5i)`
`puts x `
`# -4.9400804073229665e-05+1.0000761892591823i`

## Ruby `tan()` Example 2

`# import CMath library`
`require 'cmath'`
`x = CMath.tan(-5 + 5i)`
`puts x `
`# 4.9400804073229665e-05+1.0000761892591823i`

## Ruby `tan()` Example 3

`# import CMath library`
`require 'cmath'`
`x = CMath.tan(a5 - b5i)`
`puts x`
`# Error`

## Ruby `tan()` Example 4

`# import CMath library`
`require 'cmath'`
`x = CMath.tan(-5 - 5i)`
`puts x`
`# 4.9400804073229665e-05-1.0000761892591823i`

## Ruby `tan()` Example 5

`# import CMath library`
`require 'cmath'`
`x = CMath.tan(8)`
`puts x`
`# -6.799711455220379`