Python中的math模块

来源:互联网 发布:局域网添加网络打印机 编辑:程序博客网 时间:2024/06/06 00:59
Python Math 函數  必須 import math功能說明指令範例傳回 x 的反餘弦math.acos(x)傳回 x 的反雙曲餘弦math.acosh(x)傳回 x 的反正弦math.asin(x)傳回 x 的反雙曲正弦math.asinh(x)傳回 x 的反正切math.atan(x)傳回 y/x 的反正切math.atan2(y,x)傳回 x 的反雙曲正切math.atanh(x)傳回≧ x 的最小整數math.ceil(x)math.floor(3.4) 結果 4傳回與 y 同號的 x 值math.copysign(x,y)傳回 x 的餘弦math.cos(x)傳回 x 的雙曲餘弦math.cosh(x)將 x (徑) 轉成角度,與 radians 為反函數math.degrees(x)常數 e = 2.7128...math.e傳回 ex也就是 math.e**xmath.exp(x)傳回 x 的絕對值math.fabs(x)傳回 x!math.factorial(x)傳回 ≦ x 的最大整數math.floor(x)math.floor(3.4) 結果 3傳回 y % x,以 float 而言
fmod 優於 %math.fmod(x,y)傳回一個 2 元組 (2-tuple) 分別是假數 m (float)以及
一個指數 n(int),也就是 x = m×2與 ldexp 是反函數math.frexp(x)math.frexp(1.625) 結果 (0.8125,1)傳回 x 陣列值的各項和math.fsum(x)math.frexp([2,5]) 結果  7傳回 math.hypot(x,y)如果 x = ±inf 也就是 ±∞
傳回 Truemath.isinf(x)如果 x = Non (not a number)
傳回 Truemath.isnan(x)傳回 m×2n與 frexp 是反函數math.ldexp(m,n)傳回 ,若不寫a 內定 emath.log(x,a)傳回 math.log10(x)傳回 math.loglp(x)傳回傳回 x 的小數部份與整數部份math.modf(x)傳回常數 π (3.14159...)math.pi傳回 xymath.pow(x,y)將 x(角度) 轉成徑,與 degrees 為反函數math.radians(d)傳回 x 的正弦math.sin(x)傳回 x 的雙曲正弦math.sinh(x)傳回 math.sqrt(x)傳回 x 的正切math.tan(x)傳回 x 的雙曲正切math.tanh(x)傳回 x 的整數部份,等同 intmath.trunc(x) 
0 0
原创粉丝点击