Files
pplus-library/modules/special/erf-approx/ref/mojo/plain.mojo
T
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

12 lines
345 B
Mojo

from std.math import exp
def erf_approx(x: Float64) -> Float64:
var sign: Float64 = 1.0
if x < 0.0:
sign = -1.0
var a = abs(x)
var t = 1.0 / (1.0 + 0.3275911 * a)
var poly = ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t
return sign * (1.0 - poly * exp(-a * a))