Kotlin atanh()

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

The atanh() method in Kotlin’s math class returns the inverse hyperbolic tangent of any number between -1.0 and 1.0 in radians.

  • 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

Syntax

import kotlin.math.*
val y = atanh(x)
  • x: A number between -1.0 and 1.0, of type Double or Float.

Special Cases:

  • atanh(NaN) = NaN
  • atanh(x) = NaN if x > 1 || x < -1
  • atanh(1.0) = +Inf
  • atanh(-1.0) = -Inf

Example

The following code is a basic implementation of math.atanh(x).

import kotlin.math.*
fun main() {
val x = -0.1
val y = atanh(x)
// Print results
println(y)
}

It will output:

-0.100335348

The returned value is y such that tanh(y) == x.

All contributors

Contribute to 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