Kotlin cosh()
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)yieldsNaNcosh(+Inf|-Inf)yields+Inf
Example
The following code is basic implementation of math.cosh().
import kotlin.math.*fun main(){val x = 30.0val y = cosh(x)//print resultsprintln(y)}
This example will output:
1.1402383210764286
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
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn Kotlin, the expressive, open-source programming language developed by JetBrains.
- Beginner Friendly.9 hours