
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(fma
x
(fma 0.6666666666666666 (* x x) 2.0)
(fma (pow x 7.0) 0.047619047619047616 (* 0.2 (pow x 5.0)))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right), \mathsf{fma}\left({x}^{7}, 0.047619047619047616, 0.2 \cdot {x}^{5}\right)\right)\right|
\end{array}
Initial program 99.9%
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(*
(fabs x)
(fma
(* x x)
(* (* x x) 0.2)
(+
(fma (* x x) 0.6666666666666666 2.0)
(* (pow x 6.0) 0.047619047619047616)))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, \left(x \cdot x\right) \cdot 0.2, \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) + {x}^{6} \cdot 0.047619047619047616\right)\right)\right|
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(*
(fabs x)
(fma
(*
(fma (fma (* x x) 0.047619047619047616 0.2) (* x x) 0.6666666666666666)
x)
x
2.0)))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right), x \cdot x, 0.6666666666666666\right) \cdot x, x, 2\right)\right)\right|
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(/
(fabs
(*
(fma
(*
(fma (fma (* 0.047619047619047616 x) x 0.2) (* x x) 0.6666666666666666)
x)
x
2.0)
x))
(sqrt (PI))))\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.047619047619047616 \cdot x, x, 0.2\right), x \cdot x, 0.6666666666666666\right) \cdot x, x, 2\right) \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Applied rewrites99.4%
Applied rewrites99.4%
(FPCore (x)
:precision binary64
(/
(fabs
(*
(fma
(*
(fma (fma 0.047619047619047616 (* x x) 0.2) (* x x) 0.6666666666666666)
x)
x
2.0)
x))
(sqrt (PI))))\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), x \cdot x, 0.6666666666666666\right) \cdot x, x, 2\right) \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Applied rewrites99.4%
(FPCore (x)
:precision binary64
(/
(fabs
(*
(fma
(* (fma (* (* x x) 0.047619047619047616) (* x x) 0.6666666666666666) x)
x
2.0)
x))
(sqrt (PI))))\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 0.047619047619047616, x \cdot x, 0.6666666666666666\right) \cdot x, x, 2\right) \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Applied rewrites99.4%
Taylor expanded in x around inf
Applied rewrites98.7%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fabs x) (fma (* (fma (* x x) 0.2 0.6666666666666666) x) x 2.0)))))
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right) \cdot x, x, 2\right)\right)\right|
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites94.9%
(FPCore (x) :precision binary64 (/ (fabs (* (fma (fma (* x x) 0.2 0.6666666666666666) (* x x) 2.0) x)) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites88.7%
Applied rewrites88.3%
Taylor expanded in x around 0
Applied rewrites94.4%
(FPCore (x) :precision binary64 (if (<= x 1.75) (fabs (* (+ x x) (sqrt (/ 1.0 (PI))))) (/ (fabs (* (* (* x x) 0.6666666666666666) x)) (sqrt (PI)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75:\\
\;\;\;\;\left|\left(x + x\right) \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\\
\end{array}
\end{array}
if x < 1.75Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites65.0%
Applied rewrites65.0%
if 1.75 < x Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites88.7%
Applied rewrites88.3%
Taylor expanded in x around inf
Applied rewrites29.1%
(FPCore (x) :precision binary64 (fabs (* (* (sqrt (/ 1.0 (PI))) (fma (* 0.6666666666666666 x) x 2.0)) x)))
\begin{array}{l}
\\
\left|\left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} \cdot \mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right)\right) \cdot x\right|
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites88.7%
(FPCore (x) :precision binary64 (/ (fabs (* (fma 0.6666666666666666 (* x x) 2.0) x)) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites88.7%
Applied rewrites88.3%
(FPCore (x) :precision binary64 (fabs (* (+ x x) (sqrt (/ 1.0 (PI))))))
\begin{array}{l}
\\
\left|\left(x + x\right) \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites65.0%
Applied rewrites65.0%
(FPCore (x) :precision binary64 (/ (fabs (* 2.0 x)) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|2 \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites88.7%
Applied rewrites88.3%
Taylor expanded in x around 0
Applied rewrites64.6%
herbie shell --seed 2025020
(FPCore (x)
:name "Jmat.Real.erfi, branch x less than or equal to 0.5"
:precision binary64
:pre (<= x 0.5)
(fabs (* (/ 1.0 (sqrt (PI))) (+ (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* (fabs x) (fabs x)) (fabs x)))) (* (/ 1.0 5.0) (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)))) (* (/ 1.0 21.0) (* (* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)))))))