Sub macro1() MsgBox Application.Run("atpvbacs.xla!erf", 1) End Sub
对于X<=1,可使用如下自定义函数:
Function erf(ByVal x As Single) As Single Dim i As Long, b(9) As Double b(0) = 1 erf = x For i = 1 To 9 b(i) = b(i - 1) * (2 * i + 1) erf = erf + 2 ^ i * x ^ (2 * i + 1) / b(i) Next erf = erf * Exp(-x * x) / Sqr(Atn(1)) End Function Sub macro1() MsgBox erf(1) End Sub