Ruby Tutorial Ruby References

Ruby - Math.acosh() Method



The Ruby Math.acosh() method returns inverse hyperbolic cosine of a value. The inverse hyperbolic cosine of x is defined as:

acosh

Syntax

Math.acosh(x)

Parameters

x Specify the value equal to or greater than 1.

Return Value

Returns the inverse hyperbolic cosine of a value. If x is less than 1, DomainError is thrown.

Example:

In the example below, Math.acosh() method is used to find out the inverse hyperbolic cosine of a value.

puts "Math.acosh(1) = #{Math.acosh(1)}"
puts "Math.acosh(1.5) = #{Math.acosh(1.5)}"
puts "Math.acosh(2) = #{Math.acosh(2)}"
puts "Math.acosh(4) = #{Math.acosh(4)}"

The output of the above code will be:

Math.acosh(1) = 0.0
Math.acosh(1.5) = 0.9624236501192069
Math.acosh(2) = 1.3169578969248166
Math.acosh(4) = 2.0634370688955608

❮ Ruby Math Module

5