.tanh()

data2294409510's avatar
Published Oct 31, 2023
Contribute to Docs

The .tanh() method in Kotlin’s math class computes the hyperbolic tangent of an angle given in radians. The method takes the angle as its one and only parameter and returns the computed value as Double or Float type.

Syntax

tanh(x)

-x: This parameter takes a value of an angle in Double or Float type.

Example

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

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

This example will output:

0.7615941559557649

All contributors

Contribute to Docs

Learn Kotlin on Codecademy