
(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
(*
(pow (sqrt (PI)) -1.0)
(+
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* x x) (fabs x))))
(* (pow 5.0 -1.0) (fabs (* (* (* (* x x) x) x) x))))
(* (pow 21.0 -1.0) (* (pow x 6.0) (fabs x)))))))\begin{array}{l}
\\
\left|{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \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) + {5}^{-1} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) + {21}^{-1} \cdot \left({x}^{6} \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-*.f64N/A
pow2N/A
pow-powN/A
lower-pow.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
metadata-eval99.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (fabs (* (* (* (* x x) x) x) x))))
(fabs
(*
(pow (sqrt (PI)) -1.0)
(+
(+
(+ (* 2.0 (fabs x)) (* (* x x) (* x 0.6666666666666666)))
(* (pow 5.0 -1.0) t_0))
(* (pow 21.0 -1.0) (* (* t_0 (fabs x)) (fabs x))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\\
\left|{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot \left(\left(\left(2 \cdot \left|x\right| + \left(x \cdot x\right) \cdot \left(x \cdot 0.6666666666666666\right)\right) + {5}^{-1} \cdot t\_0\right) + {21}^{-1} \cdot \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Initial program 99.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
lower-*.f6499.9
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt75.8
lift-/.f64N/A
metadata-eval75.8
Applied rewrites75.8%
Final simplification75.8%
(FPCore (x)
:precision binary64
(fabs
(*
(pow (sqrt (PI)) -1.0)
(+
(+
(+ (* 2.0 (fabs x)) (* (* x x) (* x 0.6666666666666666)))
(* (pow 5.0 -1.0) (fabs (* (* (* (* x x) x) x) x))))
(* (pow 21.0 -1.0) (* (fabs (* (* (* (* x x) (* x x)) x) x)) (fabs x)))))))\begin{array}{l}
\\
\left|{\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot \left(\left(\left(2 \cdot \left|x\right| + \left(x \cdot x\right) \cdot \left(x \cdot 0.6666666666666666\right)\right) + {5}^{-1} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) + {21}^{-1} \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.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
lower-*.f6499.9
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt75.8
lift-/.f64N/A
metadata-eval75.8
Applied rewrites75.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-plusN/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-*.f64N/A
pow1/2N/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow2N/A
lower-*.f6475.8
Applied rewrites75.8%
Final simplification75.8%
(FPCore (x)
:precision binary64
(fabs
(*
(fma
(sqrt (pow (PI) -1.0))
(fma (* x x) 0.6666666666666666 2.0)
(* (pow x 4.0) (/ (fma (* x x) 0.047619047619047616 0.2) (sqrt (PI)))))
x)))\begin{array}{l}
\\
\left|\mathsf{fma}\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}}, \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right), {x}^{4} \cdot \frac{\mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right) \cdot x\right|
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Applied rewrites99.9%
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= x 2.2)
(fabs
(*
(-
(/ 2.0 t_0)
(* (/ -1.0 t_0) (* (* (fma 0.2 (* x x) 0.6666666666666666) x) x)))
x))
(fabs
(*
(* (sqrt (pow (PI) -1.0)) (pow x 7.0))
(+ (/ 0.2 (* x x)) 0.047619047619047616))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;x \leq 2.2:\\
\;\;\;\;\left|\left(\frac{2}{t\_0} - \frac{-1}{t\_0} \cdot \left(\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right) \cdot x\right) \cdot x\right)\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}} \cdot {x}^{7}\right) \cdot \left(\frac{0.2}{x \cdot x} + 0.047619047619047616\right)\right|\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites93.9%
Applied rewrites93.9%
if 2.2000000000000002 < x Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around inf
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f64N/A
Applied rewrites35.7%
Final simplification93.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= x 2.2)
(fabs
(*
(-
(/ 2.0 t_0)
(* (/ -1.0 t_0) (* (* (fma 0.2 (* x x) 0.6666666666666666) x) x)))
x))
(fabs
(*
(* (sqrt (pow (PI) -1.0)) (- (/ 0.2 (* x x)) -0.047619047619047616))
(pow x 7.0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;x \leq 2.2:\\
\;\;\;\;\left|\left(\frac{2}{t\_0} - \frac{-1}{t\_0} \cdot \left(\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right) \cdot x\right) \cdot x\right)\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}} \cdot \left(\frac{0.2}{x \cdot x} - -0.047619047619047616\right)\right) \cdot {x}^{7}\right|\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites93.9%
Applied rewrites93.9%
if 2.2000000000000002 < x Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites35.7%
Final simplification93.9%
(FPCore (x) :precision binary64 (if (<= x 1.75) (fabs (* (/ 2.0 (sqrt (PI))) x)) (fabs (* (* (sqrt (pow (PI) -1.0)) (* (* x x) 0.6666666666666666)) x))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75:\\
\;\;\;\;\left|\frac{2}{\sqrt{\mathsf{PI}\left(\right)}} \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}} \cdot \left(\left(x \cdot x\right) \cdot 0.6666666666666666\right)\right) \cdot x\right|\\
\end{array}
\end{array}
if x < 1.75Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
lower-/.f64N/A
lower-PI.f6466.9
Applied rewrites66.9%
Applied rewrites66.9%
if 1.75 < x Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites89.4%
Taylor expanded in x around inf
Applied rewrites28.3%
Final simplification66.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= x 2.7)
(fabs
(*
(-
(/ 2.0 t_0)
(* (/ -1.0 t_0) (* (* (fma 0.2 (* x x) 0.6666666666666666) x) x)))
x))
(fabs (* (pow x 7.0) (/ 0.047619047619047616 t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;x \leq 2.7:\\
\;\;\;\;\left|\left(\frac{2}{t\_0} - \frac{-1}{t\_0} \cdot \left(\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right) \cdot x\right) \cdot x\right)\right) \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|{x}^{7} \cdot \frac{0.047619047619047616}{t\_0}\right|\\
\end{array}
\end{array}
if x < 2.7000000000000002Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites93.9%
Applied rewrites93.9%
if 2.7000000000000002 < x Initial program 99.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-*.f64N/A
pow2N/A
pow-powN/A
lower-pow.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in x around inf
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
lower-/.f64N/A
lower-PI.f64N/A
lower-fabs.f6437.8
Applied rewrites37.8%
Applied rewrites37.8%
Applied rewrites37.8%
(FPCore (x) :precision binary64 (fabs (* (* (fma (* x x) 0.6666666666666666 2.0) x) (sqrt (pow (PI) -1.0)))))
\begin{array}{l}
\\
\left|\left(\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x\right) \cdot \sqrt{{\mathsf{PI}\left(\right)}^{-1}}\right|
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
rem-square-sqrtN/A
Applied rewrites89.4%
Final simplification89.4%
(FPCore (x) :precision binary64 (fabs (* (* (sqrt (pow (PI) -1.0)) (fma (* 0.6666666666666666 x) x 2.0)) x)))
\begin{array}{l}
\\
\left|\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}} \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
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites89.4%
Applied rewrites89.4%
Final simplification89.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(fabs
(*
(-
(/ 2.0 t_0)
(* (/ -1.0 t_0) (* (* (fma 0.2 (* x x) 0.6666666666666666) x) x)))
x))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\left|\left(\frac{2}{t\_0} - \frac{-1}{t\_0} \cdot \left(\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right) \cdot x\right) \cdot x\right)\right) \cdot x\right|
\end{array}
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites93.9%
Applied rewrites93.9%
(FPCore (x) :precision binary64 (fabs (* (/ (fma 0.6666666666666666 (* x x) 2.0) (sqrt (PI))) x)))
\begin{array}{l}
\\
\left|\frac{\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}{\sqrt{\mathsf{PI}\left(\right)}} \cdot x\right|
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites89.4%
Applied rewrites89.4%
Final simplification89.4%
(FPCore (x) :precision binary64 (fabs (* (/ 2.0 (sqrt (PI))) x)))
\begin{array}{l}
\\
\left|\frac{2}{\sqrt{\mathsf{PI}\left(\right)}} \cdot x\right|
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
rem-square-sqrtN/A
lower-sqrt.f64N/A
rem-square-sqrtN/A
lower-/.f64N/A
lower-PI.f6466.9
Applied rewrites66.9%
Applied rewrites66.9%
herbie shell --seed 2024340
(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)))))))