AppDividend
Latest Code Tutorials

Python acosh() Function | Math.acosh() in Python Example

Python acosh() is an inbuilt method that is defined under the math module, which is used to find the hyperbolic arc cosine of the given parameter in radians. For example, if x is passed as a parameter in acosh function (acosh(x)), it returns the hyperbolic arc cosine value.

Another essential point to note is that 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.

Python acosh()

Content Overview

Python acosh() method is one of the Python Math function, which calculates the Trigonometric Hyperbolic ArcCosine for the specified expression or number. Python acosh() function also called an inverse of hyperbolic Cosine. Please refer to the Python cos Function article to understand a cosine function.

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 which 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 by passing a parameter that is less than 1, we get a math domain error.

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.

See also

Python degrees()

Python tan()

Python sin()

Python hypot()

Python atan()

This site uses Akismet to reduce spam. Learn how your comment data is processed.