JS Built-ins
← Math207 / 215
Mathtanhintermediate

Math.tanh() β€” tanh(1) β‰ˆ 0.762

πŸ“– Usage Example
// Hyperbolic tangent (output in (-1, 1))
Math.tanh(0)   // β†’ 0
Math.tanh(1)   // β†’ 0.7615...

Use Math.tanh() to compute the hyperbolic tangent, commonly used as an activation function in neural networks.

Math.tanh()

Returns the hyperbolic tangent of a number.

Challenge: Verify that Math.tanh(1) is approximately 0.7615941559557649.

πŸ’‘ Hints (1)
  • β€’ tanh(1) = (e - 1/e) / (e + 1/e) β‰ˆ 0.7616