
(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 9 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)))
(-
(+
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0))
(* (pow 5.0 -1.0) (fabs (* (* (* (* x x) x) x) x))))
(* (/ -1.0 21.0) (* (* (* (pow x 4.0) (fabs x)) (fabs 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) + {5}^{-1} \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({x}^{4} \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow-prod-downN/A
pow-sqrN/A
lower-pow.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))) (t_1 (* (* (* (* x x) x) x) x)))
(if (<=
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* x x) (fabs x))))
(* (pow 5.0 -1.0) (fabs t_1)))
(* (pow 21.0 -1.0) (* (fabs (* t_1 x)) (fabs x))))
2e-6)
(/ (fabs (* (* 2.0 t_0) (fabs x))) (PI))
(fabs (* (fabs x) (* (* x x) (/ 0.6666666666666666 t_0)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
t_1 := \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\\
\mathbf{if}\;\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(x \cdot x\right) \cdot \left|x\right|\right)\right) + {5}^{-1} \cdot \left|t\_1\right|\right) + {21}^{-1} \cdot \left(\left|t\_1 \cdot x\right| \cdot \left|x\right|\right) \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\left|\left(2 \cdot t\_0\right) \cdot \left|x\right|\right|}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\left|\left|x\right| \cdot \left(\left(x \cdot x\right) \cdot \frac{0.6666666666666666}{t\_0}\right)\right|\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (*.f64 #s(literal 2 binary64) (fabs.f64 x)) (*.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 5 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 21 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))) < 1.99999999999999991e-6Initial program 99.9%
Applied rewrites99.5%
Applied rewrites99.5%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-PI.f64N/A
lower-fabs.f6499.4
Applied rewrites99.4%
if 1.99999999999999991e-6 < (+.f64 (+.f64 (+.f64 (*.f64 #s(literal 2 binary64) (fabs.f64 x)) (*.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 5 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))) (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 21 binary64)) (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (*.f64 (fabs.f64 x) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)) (fabs.f64 x)))) Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites71.3%
Applied rewrites71.3%
Final simplification90.8%
(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))))
(* 0.047619047619047616 (* (pow (fabs x) 6.0) (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) + 0.047619047619047616 \cdot \left({\left(\left|x\right|\right)}^{6} \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in x around 0
lower-pow.f64N/A
lower-fabs.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= (fabs x) 1e-6)
(* (pow (PI) -1.0) (fabs (* (* 2.0 (fabs x)) t_0)))
(fabs (* (pow x 7.0) (/ 0.047619047619047616 t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;\left|x\right| \leq 10^{-6}:\\
\;\;\;\;{\mathsf{PI}\left(\right)}^{-1} \cdot \left|\left(2 \cdot \left|x\right|\right) \cdot t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;\left|{x}^{7} \cdot \frac{0.047619047619047616}{t\_0}\right|\\
\end{array}
\end{array}
if (fabs.f64 x) < 9.99999999999999955e-7Initial program 99.9%
Applied rewrites99.5%
Applied rewrites99.5%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-PI.f64N/A
lower-fabs.f6499.4
Applied rewrites99.4%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lift-/.f64N/A
lower-*.f6499.5
lift-/.f64N/A
inv-powN/A
lower-pow.f6499.5
Applied rewrites99.5%
if 9.99999999999999955e-7 < (fabs.f64 x) Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow-prod-downN/A
pow-sqrN/A
lower-pow.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Applied rewrites98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= (fabs x) 1e-6)
(/ (fabs (* (* (fabs x) t_0) (fma (* 0.6666666666666666 x) x 2.0))) (PI))
(fabs (* (pow x 7.0) (/ 0.047619047619047616 t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;\left|x\right| \leq 10^{-6}:\\
\;\;\;\;\frac{\left|\left(\left|x\right| \cdot t\_0\right) \cdot \mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right)\right|}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\left|{x}^{7} \cdot \frac{0.047619047619047616}{t\_0}\right|\\
\end{array}
\end{array}
if (fabs.f64 x) < 9.99999999999999955e-7Initial program 99.9%
Applied rewrites99.5%
Applied rewrites99.5%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-outN/A
+-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.5%
Applied rewrites99.5%
if 9.99999999999999955e-7 < (fabs.f64 x) Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow-prod-downN/A
pow-sqrN/A
lower-pow.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Applied rewrites98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= (fabs x) 1e-6)
(/ (fabs (* (* (fabs x) t_0) (fma (* 0.6666666666666666 x) x 2.0))) (PI))
(fabs (* (/ (pow x 7.0) t_0) 0.047619047619047616)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;\left|x\right| \leq 10^{-6}:\\
\;\;\;\;\frac{\left|\left(\left|x\right| \cdot t\_0\right) \cdot \mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right)\right|}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{{x}^{7}}{t\_0} \cdot 0.047619047619047616\right|\\
\end{array}
\end{array}
if (fabs.f64 x) < 9.99999999999999955e-7Initial program 99.9%
Applied rewrites99.5%
Applied rewrites99.5%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-outN/A
+-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.5%
Applied rewrites99.5%
if 9.99999999999999955e-7 < (fabs.f64 x) Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow-prod-downN/A
pow-sqrN/A
lower-pow.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Applied rewrites98.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (* (* x x) x) x) x)))
(fabs
(*
(/ -1.0 (sqrt (PI)))
(+
(+ (* (fabs x) (fma (* x x) 0.6666666666666666 2.0)) (* 0.2 (fabs t_0)))
(* 0.047619047619047616 (* (fabs (* t_0 x)) (fabs x))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\\
\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|t\_0\right|\right) + 0.047619047619047616 \cdot \left(\left|t\_0 \cdot x\right| \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (/ (fabs (* (* (fabs x) (sqrt (PI))) (fma (* 0.6666666666666666 x) x 2.0))) (PI)))
\begin{array}{l}
\\
\frac{\left|\left(\left|x\right| \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right)\right|}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 99.9%
Applied rewrites99.6%
Applied rewrites84.1%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-outN/A
+-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.9%
Applied rewrites90.9%
(FPCore (x) :precision binary64 (/ (fabs (* (* 2.0 (sqrt (PI))) (fabs x))) (PI)))
\begin{array}{l}
\\
\frac{\left|\left(2 \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot \left|x\right|\right|}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 99.9%
Applied rewrites99.6%
Applied rewrites84.1%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-PI.f64N/A
lower-fabs.f6470.9
Applied rewrites70.9%
herbie shell --seed 2024315
(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)))))))