tanh function

double tanh (double angle)

Hyperbolic Tangent in radian.

Implementation

double tanh(double angle) {
  if (angle > 19.1) {
    return 1.0;
  }

  if (angle < -19.1) {
    return -1.0;
  }

  var e1 = stdmath.exp(angle);
  var e2 = stdmath.exp(-angle);
  return (e1 - e2) / (e1 + e2);
}