summaryrefslogtreecommitdiff
path: root/pypers/erf.py
blob: d1bcc9e1f3c3bd1a4718628147fa941a3ff8dd6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import math
import psyco
psyco.full()
def erfc(x):
    exp = math.exp
    p  =  0.3275911
    a1 =  0.254829592
    a2 = -0.284496736
    a3 =  1.421413741
    a4 = -1.453152027
    a5 =  1.061405429
    t = 1.0 / (1.0 + p*x)
    erfcx = ( (a1 + (a2 + (a3 +
                          (a4 + a5*t)*t)*t)*t)*t ) * exp(-x*x)
    return erfcx
def main():
    erg = 0.0
    for i in xrange(1000000):
        erg += erfc(0.456)
    print "%f" % erg
main()