acosh()
method can be used to find the inverse hyperbolic cosine of the any given complex number in Ruby. acosh()
method exists in CMath
library of Ruby.
acosh()
Method in Ruby
acosh()
method exists in Standard CMath Library of Ruby. The purpose of this method is to provide perfect inverse hyperbolic cosine for the given complex number.
Syntax of the acosh()
Method in Ruby
Syntax of
acosh()
method is:
cmath.acosh(x)
Parameter of acosh()
Method in Ruby
Parameter | Description |
x |
Any valid complex number. This parameter is required. |
Note: If the x
parameter is not a complex number,acosh()
method will return an error
.
Return Value of acosh()
acosh()
method will return the inverse hyperbolic cosine of the given numeric complex number.
Ruby – Get the acosh()
of the Given Numbers Example 1
# import CMath library require 'cmath' x = CMath.acosh(1 + 1i) puts x
Output
1.0612750619050357+0.9045568943023813i
Ruby – Get the acosh()
of the Given Numbers Example 2
# import CMath library require 'cmath' x = CMath.acosh(-1 + 1i) puts x
Output
-1.0612750619050355-2.2370357592874117i
Ruby – Get the acosh()
of the Given Numbers Example 3
# import CMath library require 'cmath' x = CMath.acosh(0 + 0i) puts x
Output
0.0+1.5707963267948966i
Ruby – Handle Negative Values in acosh()
Method Example 1
# import CMath library
require 'cmath'
x = CMath.acosh(-5 - 5i) puts x
Output
-2.649196177806475+2.3511949067802878i
Ruby – Handle Negative Values in acosh()
Method Example 2
# import CMath library require 'cmath' x = CMath.acosh(-5) puts x
Output
-2.2924316695611733+3.141592653589793i
Ruby – Getting the acosh()
of a Particular Number
# import CMath library require 'cmath' x = CMath.acosh(9) puts x
Output
2.8872709503576206