The Python cmath.cosh() function returns the hyperbolic cosine of a given complex number.
The hyperbolic cosine function is denoted as cosh(x), where this is the mathematical function that calculates the value of the cosine complex number or a real number x. This function returns the real values that are greater than or equal to 1.
The mathematical representation of the hyperbolic cosine function is defined as −
cosh(x) = (ex + e-x)/ 2
Where e (e = 2.71828) is the base of the natural logarithm. This function is symmetric with respect to the y-axis; cosh(x) = cosh(-X).
SyntaxFollowing is the basic syntax of the Python cmath.cosh() function −
cmath.cosh(x)Parameters
This function accepts real numbers, for which we need to find the hyperbolic cosine as a parameter.
Return ValueThis function returns the hyperbolic cosine of the given number in the range of [1,).
Example 1In the below example, we are calculating the hyperbolic cosine of positive numbers using cmath.cosh() function −
import cmath x = 4.0 result = cmath.cosh(x) print(result)Output
Following is the output for the above code −
(27.308232836016487+0j)Example 2
When we pass a fraction value to the cmath.cosh() function, then it returns a positive complex number −
import cmath from fractions import Fraction x = Fraction(3, -5) result = cmath.cosh(-x) print(result)Output
The output obtained is as follows −
(1.1854652182422676+0j)Example 3
In the following example, we are retrieving the hyperbolic cosine of a negative number using the cmath.cosh() function.
import cmath x = -0.67 result = cmath.cosh(x) print(result)Output
Following is the output of the above code −
(1.232972949211241-0j)Example 4
Here, we are creating a loop to calculate the hyperbolic cosine values using the cmath.cosh() function. The loop will iterate through each value of a list.
import cmath values = [3.0, 4.0, 7.0] for x in values: result = cmath.cosh(x) print("cosh({}) = {}".format(x, result))Output
Output is produced as shown below −
cosh(3.0) = (10.067661995777765+0j) cosh(4.0) = (27.308232836016487+0j) cosh(7.0) = (548.317035155212+0j)
python_modules.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4