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.
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 degreedegree = 30radian = deg2rad(degree)println( "tan($(radian)) => $(tan(radian))")## find tan of 90 degreedegree = 90radian = deg2rad(degree)println( "tan($(radian)) => $(tan(radian))")
Explanation
- In line
2we create a new variabledegreeand initialize it to30. - In line
3we usedeg2rad()to convert the value ofdegreeto radian and store it inradian. - In line
4we use the tan method with the variableradianas an argument. This line will calculate the tangent value ofradian. - In line
7we update the value ofdegreeto90. - In line
8we usedeg2rad()to convert the value ofdegreeto radian and store it inradian. - In line
9we use the tan method with the variableradianas an argument. This line will calculate the tangent value ofradian.