Learn and Learn

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

Ruby – Find Hyperbolic Tangent – tanh() Method with Examples

In Ruby, tanh() method can be used to find the hyperbolic tangent of the any given complex number in Ruby language where this number is given in radians. tanh() method exists in CMath library of Ruby programming language.

tanh() Method in Ruby

tanh() method exists in Standard CMath Library of Ruby. The purpose of this method is to provide perfect hyperbolic tangent for any given complex number where this number is given in radians.

Syntax of the tanh() Method in Ruby

Syntax of tanh() method is:

 

Parameter of tanh() Method in Ruby

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

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

 

Return Value of tanh()

tanh() method will return the tangent of any given complex number where this number is given in radians.

 

Ruby – Get the hyperbolic tangent (tanh()) of the Given Numbers Example 1


Output

1.0000761892591823-4.9400804073229665e-05i

 

Ruby – Get the hyperbolic tangent (tanh()) of the Given Numbers Example 2


Output

-1.0000761892591823-4.9400804073229665e-05i

 

Ruby – Get the hyperbolic tangent (tanh()) of the Given Numbers Example 3


Output

Error

 

Ruby – Get the hyperbolic tangent (tanh()) of the Given Numbers Example 4


Output

-1.0000761892591823+4.9400804073229665e-05i

 

Ruby – Get the tanh() of any Particular Number


Output

0.9999997749296758

 

LearnAndLearn.com © 2018 - All rights reserved