The tan method in Julia

Overview

In Julia, tan() is an in-built function used to calculate the trigonometric tangent value of a variable specified in radians.

tan(x)=opposite sideadjacent sidetan(x) = \frac{opposite\space side}{adjacent\space side}

The code snippet below shows how to use the tan() function in Julia.

tan(x)

The tan() method accepts one argument: x. The angle for which the user seeks the trigonometric tangent is specified in radians. It returns the tan for x.

Example

Let's run a script that uses the tan() method.

## find tan of 30 degree
degree = 30
radian = deg2rad(degree)
println( "tan($(radian)) => $(tan(radian))")
## find tan of 90 degree
degree = 90
radian = deg2rad(degree)
println( "tan($(radian)) => $(tan(radian))")

Explanation

  • In line 2 we create a new variable degree and initialize it to 30.
  • In line 3 we use deg2rad() to convert the value of degree to radian and store it in radian.
  • In line 4 we use the tan method with the variable radian as an argument. This line will calculate the tangent value of radian.
  • In line 7 we update the value of degree to 90.
  • In line 8 we use deg2rad() to convert the value of degree to radian and store it in radian.
  • In line 9 we use the tan method with the variable radian as an argument. This line will calculate the tangent value of radian.