tan()
data22944095104 total contributions
Published Oct 31, 2023
Contribute to Docs
The tan()
function is used to calculate the tangent of an angle. The tangent of an angle is the ratio of the length of the opposite side to the length of the adjacent side in a right triangle.
Syntax
tan(x)
- The function accepts one mandatory parameter
x
. They all take an angle in radians asDouble
orFloat
as a parameter. - The function returns a
Double
value, which is the tangent of the angle.
Example
The example below demonstrates how to use the tan()
function in Kotlin to calculate the tangent of the angle 45
degrees in radians.
import kotlin.math.*fun main() {val angleInRadians = Math.toRadians(45.0)val tangent = tan(angleInRadians)println(tangent)}
The output will be:
1.0
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.