Encontrar la tangente hiperbólica inversa del número especificado en Golang

El lenguaje Go brinda soporte incorporado para constantes básicas y funciones matemáticas para realizar operaciones en los números con la ayuda del paquete matemático. Puede encontrar la tangente hiperbólica inversa del número especificado con la ayuda de la función Atanh() proporcionada por el paquete matemático . Por lo tanto, debe agregar un paquete matemático en su programa con la ayuda de la palabra clave de importación para acceder a la función Atanh().

Sintaxis:

func Atanh(y float64) float64
  • Si pasa 1 en esta función, esta función devolverá +Inf.
  • Si pasa -1 en esta función, esta función devolverá -Inf.
  • Si pasa -0 o +0 en esta función, esta función devolverá -0 o +0.
  • Si pasa NaN en esta función, esta función devolverá NaN.
  • Si y < -1 o y > 1, esta función devolverá NaN.

Ejemplo 1:

// Golang program to illustrate how to find the
// inverse hyperbolic tangent of the given number
  
package main
  
import (
    "fmt"
    "math"
)
  
// Main function
func main() {
  
    // Finding the inverse hyperbolic
    // tangent of the given value
    // Using Atanh() function
    res_1 := math.Atanh(math.Pi / 4)
    res_2 := math.Atanh(math.Inf(-3))
    res_3 := math.Atanh(0)
    res_4 := math.Atanh(math.NaN())
    res_5 := math.Atanh(-1)
  
    // Displaying the result
    fmt.Printf("Result 1: %.1f", res_1)
    fmt.Printf("\nResult 2: %.1f", res_2)
    fmt.Printf("\nResult 3: %.1f", res_3)
    fmt.Printf("\nResult 4: %.1f", res_4)
    fmt.Printf("\nResult 5: %.1f", res_5)
}

Producción:

Result 1: 1.1
Result 2: NaN
Result 3: 0.0
Result 4: NaN
Result 5: -Inf

Ejemplo 2:

// Golang program to illustrate how to find the
// inverse hyperbolic tangent of the given number
  
package main
  
import (
    "fmt"
    "math"
)
  
// Main function
func main() {
  
    // Finding inverse hyperbolic 
    // tangent of the given number
    nvalue_1 := math.Atanh(math.Pi / 3)
    nvalue_2 := math.Atanh(math.Pi / 6)
  
    // Sum of the given values
    res := nvalue_1 + nvalue_2
  
    // Displaying results
    fmt.Printf("%.1f + %.1f = %.1f", 
            nvalue_1, nvalue_2, res)
  
}

Producción:

NaN + 0.6 = NaN

Publicación traducida automáticamente

Artículo escrito por Kirti_Mangal y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *