LIVE·WAITING…
connecting to the live quote stream…
--:--:--UTC
#30
Normal CDF, Abramowitz–Stegun
easyMathsacceptance —~15 min
Implement norm_cdf(x) — the standard normal CDF Φ(x) with the Abramowitz–Stegun 26.2.17 approximation, no libraries: for x >= 0, t = 1 / (1 + 0.2316419·x) and Φ = 1 - φ(x)·(b1·t + b2·t² + b3·t³ + b4·t⁴ + b5·t⁵) with b = [0.319381530, -0.356563782, 1.781477937, -1.821255978, 1.330274429] and φ the standard normal density. For negative x use symmetry: Φ(x) = 1 - Φ(-x).
This one polynomial is why the workbench prices a whole options chain in under a hundred milliseconds — it is the CDF inside lib/pricing.ts. Return Φ rounded to 6 decimal places.
example 1
input
x=1.0
output
0.841345
example 2
input
x=-1.0
output
0.158655
note
Φ(−1) must equal 1 − Φ(1).
constraints
- -8 ≤ x ≤ 8
teacher · 2 hints · the first is free
↗ read the theory
the chapter this problem is cut from
▶ open in the workbench
run the same math on a real tape
●solution.py· utf-8 · spaces:4
ln 1, col 1tab indent · esc leave editor
python 3.13 · pyodide
+ 6 hidden on submit
input · keyword arguments to norm_cdf()
x=0.0
expected
0.5
the judge calls norm_cdf() with exactly these inputs · outputs are compared to 6 decimal places
● standing bypython 3.13 in your browser · pyodide 0.28.3 · judged on the server to 6 dp⌘↵ run · ⌘⇧↵ submit
paper only · educational · not advice