Python3 math.erf() 方法 - 求一個數(shù)的誤差函數(shù)值

2023-04-24 16:41 更新

Python math 模塊  math 模塊


描述

math.erf(x) 方法返回一個數(shù)的誤差函數(shù)

math.erf(x) 方法接受 - inf 和 + inf 之間的值,并返回 - 1 到 + 1 之間的值。

該函數(shù)要求python版本至少為Python 3.2!


語法

math.erf() 方法語法如下:

math.erf(x)

參數(shù)說明:

  • x -- 必需,數(shù)字。如果 x 不是一個數(shù)字,返回 TypeError。

返回值

一個浮點值,代表一個數(shù)字的誤差函數(shù)。


實例

以下實例計算相同正負數(shù)的誤差函數(shù):

# 導入 math 包
import math

# 輸出誤差函數(shù)
print (math.erf(1.28))
print (math.erf(-1.28))

輸出結(jié)果:

0.9297341930135782
-0.9297341930135782

Python math 模塊  math 模塊


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號