
(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 10 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)))
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* x x) (fabs x))))
(* (/ 1.0 5.0) (fabs (* (* (* (* x x) x) x) x))))
(* (pow (fabs x) 5.0) (* (* x x) 0.047619047619047616))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(x \cdot x\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) + {\left(\left|x\right|\right)}^{5} \cdot \left(\left(x \cdot x\right) \cdot 0.047619047619047616\right)\right)\right|
\end{array}
Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(+
(* (fma (* x x) 0.6666666666666666 2.0) x)
(* 0.2 (* (* (* x x) (* x x)) (fabs x))))
(* (pow (fabs x) 6.0) (* (fabs x) 0.047619047619047616))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x + 0.2 \cdot \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|\right)\right) + {\left(\left|x\right|\right)}^{6} \cdot \left(\left|x\right| \cdot 0.047619047619047616\right)\right)\right|
\end{array}
Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow2N/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
Applied rewrites77.5%
lift-/.f64N/A
metadata-eval77.5
Applied rewrites77.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow2N/A
associate-*l*N/A
sqr-abs-revN/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6477.5
Applied rewrites77.5%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(+
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0))
(* 0.2 (fabs (* (* (* (* x x) x) x) x))))
(* (/ 1.0 21.0) (* (fabs (* (* (* (* x x) (* x x)) x) x)) (fabs x)))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) + 0.2 \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) + \frac{1}{21} \cdot \left(\left|\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x\right| \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow2N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
associate-*l*N/A
sqr-abs-revN/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (sqrt (PI)))))
(/
(fabs
(*
(fma
(fma (fma (* x x) 0.047619047619047616 0.2) (* x x) 0.6666666666666666)
(* x x)
2.0)
x))
(* t_0 t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\sqrt{\mathsf{PI}\left(\right)}}\\
\frac{\left|\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right), x \cdot x, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right|}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites50.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.3%
lift-PI.f64N/A
lift-sqrt.f64N/A
add-sqr-sqrtN/A
lift-sqrt.f64N/A
lift-PI.f64N/A
lift-sqrt.f64N/A
lift-PI.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6499.6
Applied rewrites99.6%
(FPCore (x)
:precision binary64
(/
(fabs
(*
(fma
(*
(fma (fma (* x x) 0.047619047619047616 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(x \cdot x, 0.047619047619047616, 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.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites50.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f6499.3
Applied rewrites99.3%
(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), x \cdot x, 2\right) \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites50.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6498.5
Applied rewrites98.5%
(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.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites50.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= x 1.75)
(/ (fabs (+ x x)) t_0)
(/ (fabs (* (* (* x x) 0.6666666666666666) x)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;x \leq 1.75:\\
\;\;\;\;\frac{\left|x + x\right|}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot x\right|}{t\_0}\\
\end{array}
\end{array}
if x < 1.75Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites50.8%
Taylor expanded in x around 0
lower-*.f6470.4
Applied rewrites70.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f6470.4
Applied rewrites70.4%
if 1.75 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
pow2N/A
sqr-abs-revN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lower-*.f6426.8
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
pow3N/A
lower-pow.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrt26.8
Applied rewrites26.8%
lift-*.f64N/A
lift-pow.f64N/A
sqr-powN/A
pow-prod-downN/A
sqr-abs-revN/A
pow-prod-downN/A
sqr-powN/A
pow3N/A
sqr-abs-revN/A
pow2N/A
associate-*r*N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6426.8
Applied rewrites26.8%
(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.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites50.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites91.4%
(FPCore (x) :precision binary64 (/ (fabs (+ x x)) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|x + x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites50.8%
Taylor expanded in x around 0
lower-*.f6470.4
Applied rewrites70.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f6470.4
Applied rewrites70.4%
herbie shell --seed 2025037
(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)))))))