Python acosh() method is one of the Python Math functions, which calculates the Trigonometric Hyperbolic ArcCosine for the specified expression or number. Python acosh() function is also called an inverse of hyperbolic Cosine. Please refer to the Python cos Function article to understand a cosine function.
Python acosh()
Python acosh() is a built-in method defined under the math module to calculate the hyperbolic arc cosine of the given parameter in radians. For example, if x is passed as an acosh function (acosh(x)) parameter, it returns the hyperbolic arc cosine value.
Another essential point to note is that the math acosh() function only takes parameter values of integer or float data type, which is greater or equal than 1; if any other value is passed, it returns a math domain error, and if any different datatype is passed it returns type error.
Syntax
math.acosh(var)
Here var is the variable of which hyperbolic cosine arc we have to find.
Parameters
It takes one parameter var, which takes values of numeric datatype and throws TypeError if the argument is of any other data type is passed.
Return Value
It returns the hyperbolic arc cosine value of the number in the float datatype.
import math var = 2 print(math.acosh(var))
Example programs on acosh() method in Python
Example 1: Write the program to show the working of the acosh() method in Python.
import math a1 = 3.5 b1 = 1 c1 = 7 d1 = 5.3 print("Value for parameter ", a1, " is ", math.acosh(a1)) print("Value for parameter ", b1, " is ", math.acosh(b1)) print("Value for parameter ", c1, " is ", math.acosh(c1)) print("Value for parameter ", d1, " is ", math.acosh(d1))
Output
Value for parameter 3.5 is 1.9248473002384139 Value for parameter 1 is 0.0 Value for parameter 7 is 2.6339157938496336 Value for parameter 5.3 is 2.351832816454804
In this example, we have seen that by passing a valid parameter that is different for different examples, we get the desired acosh() method solution, which is the hyperbolic cosine value of the parameter.
Example 2: Write a program to pass the value out of range from the acosh() function and display the output.
import math q = 0.5 print(math.acosh(q))
Output
ValueError: math domain error
In this example, we’ve seen that we get a math domain error by passing a parameter that is less than 1.
Conclusion
Python acosh() function enables you to find the Trigonometric Hyperbolic ArcCosine of the numeric values. If we provide a negative value, it returns a ValueError – “ValueError: math domain error”, and if we provide anything else except the number.