Published Oct 27, 2023
Contribute to Docs

The math.sin() method in Kotlin’s math class is used to calculate the sine of an angle in radians.


import kotlin.math.sin
val sineValue = sin(angle)
  • angle: The angle in radians for which you want to calculate the sine.

The math.sin() method returns a value of type Double representing the sine of the input angle.


This example shows how to use the math.sin() method to calculate the sine of an angle:

import kotlin.math.*
fun main() {
val angle = PI / 6.0 // 30 degrees in radians
val sineValue = sin(angle)
println("The sine of $angle radians is $sineValue.")

This results in the following output:

The sine of 0.5235987755982989 radians is 0.49999999999999994.

All contributors

Looking to contribute?

Learn Kotlin on Codecademy