tan()
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
Contribute to Docs
- 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.
Learn Kotlin on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Kotlin
Learn Kotlin, the expressive, open-source programming language developed by JetBrains.Beginner Friendly9 hours