java atanh
Python math.atanh()方法 (Python math.atanh() method)
math.atanh() method is a library method of math module, it is used to get the hyperbolic arc tangent of given number in radians, it accepts a number and returns hyperbolic arc tangent.
math.atanh()方法是数学模块的库方法,用于获取以弧度为单位的给定数字的双曲反正切,它接受一个数字并返回双曲反正切。
Note: math.atanh() method accepts only numbers, if we provide any number which is not in the range it returns a ValueError – "ValueError: math domain error", if we provide anything else except the number, it returns error TypeError – "TypeError: a float is required".
注意: math.atanh()方法仅接受数字,如果提供的数字不在范围内,则返回ValueError – “ ValueError:数学域错误” ;如果提供数字以外的其他信息,则返回错误TypeError – “ TypeError:需要浮点数” 。
Syntax of math.atanh() method:
math.atanh()方法的语法:
math.atanh(x)
Parameter(s): x – is the number whose hyperbolic arc tangent to be calculated.
参数: x –是要计算其双曲反正切的数字。
Return value: float – it returns a float value that is the hyperbolic arc tangent value of the number x.
返回值: float-返回一个浮点值,该浮点值是数字x的双曲线反正切值。
Example:
例:
Input:
x = .99
# function call
print(math.atanh(x))
Output:
2.6466524123622457
Python代码演示math.atanh()方法的示例 (Python code to demonstrate example of math.atanh() method)
# Python code to demonstrate example of
# math.atanh() method
# importing math module
import math
# number
x = -0.23
print("math.atanh(",x,"): ", math.atanh(x))
x = 0
print("math.atanh(",x,"): ", math.atanh(x))
x = .99
print("math.atanh(",x,"): ", math.atanh(x))
Output
输出量
math.atanh( -0.23 ): -0.2341894667593668
math.atanh( 0 ): 0.0
math.atanh( 0.99 ): 2.6466524123622457
ValueError example
ValueError示例
# Python code to demonstrate example of
# math.atanh() method with exception
# importing math module
import math
# number
x = -1
print("math.atanh(",x,"): ", math.atanh(x))
Output
输出量
Traceback (most recent call last):
File "/home/main.py", line 9, in <module>
print("math.atanh(",x,"): ", math.atanh(x))
ValueError: math domain error
TypeError example
TypeError示例
# Python code to demonstrate example of
# math.atanh() method with exception
# importing math module
import math
# number
x = "2"
print("math.atanh(",x,"): ", math.atanh(x))
Output
输出量
Traceback (most recent call last):
File "/home/main.py", line 9, in <module>
print("math.atanh(",x,"): ", math.atanh(x))
TypeError: a float is required
翻译自: https://www.includehelp.com/python/math-atanh-method-with-example.aspx
java atanh