Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Ruby – Find Inverse Hyperbolic Cosine – cosh() Method with Examples

cosh() is a method in CMath class which is used to find the inverse hyperbolic cosine of any given complex number in Ruby language and this number must be in radians. To find out cosine of any given complex number CMath.cosh() method is used.

cosh() Method in Ruby

cosh() method exists in Standard CMath Library of Ruby. The purpose of this method is to provide inverse hyperbolic cosine of any given complex number and this number must be in radians.

 

Syntax of the cosh() Method in Ruby

Syntax of cosh() method is:

 

Parameter of cosh() Method in Ruby

Parameter Description
xAny valid complex number. This parameter is required.

Note: If the x parameter is not a complex number, cosh() method will return an error.

 

Return Value of cosh()

cosh() method will return inverse hyperbolic cosine of any given complex number and this number must be in radians.

 

Ruby – Get cosh() of the Given Values


Output

21.050556181654844-71.1552598809822i

 

Ruby cosh() Method Example 1


Output

3124.0377191320576+10560.856346071183i

 

Ruby cosh() Method Example 2


Output

11013.232920103323+0.0i

 

Ruby – Non-Complex Numbers in cosh() Method Produces Error Example 3


Output

Error

Note: Non-Complex number as shwoing in the above code always produces error.

 

Ruby cosh() Method Example 4


Output

-0.8390715290764524+0.0i

 

Loading...
LearnAndLearn.com © 2018 - All rights reserved