Tanh v0.1.0

Source
Returns the hyperbolic tangent.

Package: Math

Signature

func Tanh(x: float64) -> float64;
func Tanh(x: float32) -> float32;

Parameters

NameTypeDescription
xfloat64 / float32Any value.

Returns

The hyperbolic tangent of x, in the range (-1, 1). Tanh(±0.0) is ±0.0, preserving the sign, and Tanh saturates to ±1.0 once |x| is large enough that the distinction is no longer representable. A NaN argument propagates.

Example

import Math::Tanh;

func Main() -> int {
    let a = Tanh(0.0); // 0.0
    let b = Tanh(1.0); // 0.7615941559557649
    return 0;
}

See also

  • Math — the package overview
  • Sinh / Cosh — hyperbolic sine and cosine
  • Cotanh — the reciprocal function, with a pole at zero