Open In App

Ruby CMath cosh() Method with example

Last Updated : 01 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

cosh() method is Math class which is used to returns the hyperbolic cosine of the given value.

Syntax: Math.cosh(z) Parameter: Here, z is the value whose hyperbolic cosine is to be calculated. Returns: This method returns the hyperbolic cosine value of the z.

Example 1: 

Ruby




# Ruby code for cosh() method
require 'cmath'
 
# Initializing value 
a = 0.3584
b = 2
 
# Printing result  
puts "cosh value of a : #{CMath.cosh(a)}\n\n" 
puts "cosh value of b : #{CMath.cosh(b)}\n\n"


Output:

cosh value of a : 1.0649157114377563

cosh value of b : 3.7621956910836314

Example 2: 

Ruby




# Ruby code for cosh() method
require 'cmath'
 
# Initializing values 
a = 0
b = -0.247
 
# Printing result  
puts "cosh value of a : #{CMath.cosh(a)}\n\n" 
puts "cosh value of b : #{CMath.cosh(b)}\n\n"


Output:

cosh value of a : 1.0

cosh value of b : 1.0306599031548231

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads