Open In App

Ruby | Math sinh() function

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

Syntax: Math.sinh(value)



Parameters: The function accepts one mandatory parameter value whose corresponding hyperbolic sine value is returned.

Return Value: It returns the hyperbolic sine value.



Example 1:




#Ruby program for sinh() function
  
#Assigning values
val1 = 0 val2 = 0.67 val3 = 1 val4 = 2
  
#Prints the sinh() value
                                     puts Math.sinh(val1)
                                         puts Math.sinh(val2)
                                             puts Math.sinh(val3)
                                                 puts Math.sinh(val4)

Output:

0.0
0.7212643714246986
1.1752011936438014
3.626860407847019

Example 2:




#Ruby program for sinh() function
  
#Assigning values
val1 = 131 val2 = -0.9 val3 = -98 val4 = -767
  
#Prints the sinh() value
                                          puts Math.sinh(val1)
                                              puts Math.sinh(val2)
                                                  puts Math.sinh(val3)
                                                      puts Math.sinh(val4)

Output:

3.9043355367595756e+56
-1.0265167257081753
-1.8189854738044024e+42
-Infinity

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


Article Tags :