.tanh()
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.0val y = tanh(x)// print resultsprintln(y)}
This example will output:
0.7615941559557649
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