Open In App

Python – math.cosh() function

Last Updated : 28 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

Math module contains a number of functions which is used for mathematical operations. The math.cosh() function returns the hyperbolic cosine value of a number.

Syntax: math.cosh(x)

Parameter:This method accepts only single parameters.

  • x :This parameter is the value to be passed to cosh()

Returns:This function returns the hyperbolic cosine value of a number.

Below examples illustrate the use of above function:

Example 1:




# Python code to implement
# the cosh()function
        
# importing "math"
# for mathematical operations  
import math  
       
a = math.pi / 6
        
# Return the hyperbolic cosine value of numbers 
print (math.cosh(7))
print (math.cosh(56))
print (math.cosh(2.45))
print (math.cosh(1))


Output:

548.3170351552121
1.045829748006498e+24
5.8373201528613805
1.5430806348152437

Example 2:




# Python code implementation of 
# the cosh() function
import math 
import numpy as np 
import matplotlib.pyplot as plt  
     
in_array = np.linspace(1, np.pi**2, 30
     
out_array = [] 
     
for i in range(len(in_array)): 
    out_array.append(math.cosh(in_array[i])) 
    i += 1
      
print("Input_Array : \n", in_array)  
print("\nOutput_Array : \n", out_array)  
   
   
plt.plot(in_array, out_array, "go-")  
plt.title("math.cosh()")  
plt.xlabel("X")  
plt.ylabel("Y")  
plt.show() 


Output:

Input_Array : 
 [1.         1.30584843 1.61169686 1.91754528 2.22339371 2.52924214
 2.83509057 3.14093899 3.44678742 3.75263585 4.05848428 4.3643327
 4.67018113 4.97602956 5.28187799 5.58772641 5.89357484 6.19942327
 6.5052717  6.81112012 7.11696855 7.42281698 7.72866541 8.03451384
 8.34036226 8.64621069 8.95205912 9.25790755 9.56375597 9.8696044 ]

Output_Array : 
 [1.5430806348152437, 1.9808808604882286, 2.6054281010353004, 3.475601381008832, 
4.673436054326172, 6.311857665383541, 8.545327974639738, 11.584406799892538, 
15.715602486950852, 21.328382407531667, 28.951889891868053, 39.30482907505833, 
53.36322053774325, 72.45241538606689, 98.37204237377239, 133.56566742304807, 
181.35116015020702, 246.23348513897733, 334.32940627527836, 453.94414303138643, 
616.3543428169035, 836.8711839061114, 1136.2838326866956, 1542.8193367770289, 
2094.8037224129744, 2844.275170350752, 3861.889901480525, 5243.583273208655, 
7119.614059693799, 9666.84456304416]



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

Similar Reads