VOOZH about

URL: https://www.geeksforgeeks.org/ruby/ruby-math-tanh-function/

⇱ Ruby | Math tanh() function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby | Math tanh() function

Last Updated : 12 Jul, 2025

The tanh() is an inbuilt function in Ruby returns the hyperbolic tangent of value given in radians. The value passed is in range [-inf, +inf]. The returned value is in range [-1, +1].

Syntax: Math.tanh(value) Parameters: The function accepts one mandatory parameter value whose corresponding hyperbolic tangent value is returned. Return Value: It returns the hyperbolic tangent value.

Example 1

Output:

-1.0
0.5849798828807289
1.0
-1.0

Example 2

Output:

0.0
1.0
-1.0
-0.9999877116507956

Reference: https://devdocs.io/ruby~2.5/math#method-c-tanh

Comment