Movatterモバイル変換


[0]ホーム

URL:


Python Tutorial

Python math.acosh() Method



The Pythonmath.acosh() method is used to find the inverse hyperbolic cosine of a given number.

The inverse hyperbolic cosine method is denoted ascosh-1(x) or sometimes as arccosh(x), is a mathematical method that gives the value whose hyperbolic cosine is a given number x. In simple terms, if you have a value x greater than or equal to 1, theacosh() method will return the value (generally in real numbers) whose hyperbolic cosine equals x.

Mathematically, it can be expressed as −

cosh-1(x) = value y such that cosh(y) = x

The domain of the inverse hyperbolic cosine method is restricted to the interval [1, ∞), because the range of hyperbolic cosine method range is [1, ∞)

Syntax

Following is the basic syntax of the Pythonmath.acosh() method −

math.acosh(x)

Parameters

This method accepts a number greater than or equal to 1 for which you want to find the inverse hyperbolic cosine as a parameter.

Return Value

The method returns the inverse hyperbolic cosine of the given number in the range of [0, ∞).

Example 1

In hyperbolic trigonometry, the hyperbolic cosine of 0 is equal to 1. Therefore, when we pass "1" as an argument to themath.acosh() method, it returns 0.0 as the output, indicating that the inverse hyperbolic cosine of 1 is 0 −

import mathresult = math.acosh(1)print(result)

Output

The output obtained is as follows −

0.0

Example 2

If we pass a fraction value to themath.acosh() method, it returns a positive real number −

import mathfrom fractions import Fractionx = Fraction(5, 4)result = math.acosh(x)print(result)

Output

Following is the output of the above code −

0.6931471805599453

Example 3

In the following example, we are passing a larger value "1000" to themath.acosh() method −

import mathx = 1000result = math.acosh(x)print(result)

Output

The result produced is as shown below −

7.600902209541989

Example 4

When we pass a negative number to themath.acosh() method, it results in a domain error because the inverse hyperbolic cosine method is defined only for numbers greater than or equal to 1 −

import mathx = -2.0result = math.acosh(x)print(result)

Output

We get the output as shown below −

Traceback (most recent call last):  File "/home/cg/root/65fbd333dfa67/main.py", line 3, in <module>result = math.acosh(x)ValueError: math domain error
python_maths.htm
Print Page
Advertisements

[8]ページ先頭

©2009-2025 Movatter.jp