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:1 | cmath.tanh(x) |
Parameter of tanh()
Method in Ruby
Parameter | Description |
x | Any 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
1 2 3 4 | # import CMath library require 'cmath' x = CMath.tanh(5 + 5i) puts x |
Output
1.0000761892591823-4.9400804073229665e-05i
Ruby – Get the hyperbolic tangent (tanh()
) of the Given Numbers Example 2
1 2 3 4 | # import CMath library require 'cmath' x = CMath.tanh(-5 + 5i) puts x |
Output
-1.0000761892591823-4.9400804073229665e-05i
Ruby – Get the hyperbolic tangent (tanh()
) of the Given Numbers Example 3
1 2 3 4 | # import CMath library require 'cmath' x = CMath.tanh(a5 - b5i) puts x |
Output
Error
Ruby – Get the hyperbolic tangent (tanh()
) of the Given Numbers Example 4
1 2 3 4 | # import CMath library require 'cmath' x = CMath.tanh(-5 - 5i) puts x |
Output
-1.0000761892591823+4.9400804073229665e-05i
Ruby – Get the tanh()
of any Particular Number
1 2 3 4 | # import CMath library require 'cmath' x = CMath.tanh(8) puts x |
Output
0.9999997749296758
Loading...