cosh()

artyspangler's avatar
Published Oct 23, 2023
Contribute to Docs

The cosh() method in Kotlin’s math class computes the hyperbolic cosine of a angle given in radians.

Syntax

import kotlin.math.*
val y = cosh(x)

x: An angle of type Double or Float.

Special cases:

  • cosh(NaN) yields NaN
  • cosh(+Inf|-Inf) yields +Inf

Example

The following code is basic implementation of math.cosh().

import kotlin.math.*
fun main(){
val x = 30.0
val y = cosh(x)
//print results
println(y)
}

This example will output:

1.1402383210764286

All contributors

Contribute to Docs

Learn Kotlin on Codecademy