
(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 14 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
(pow x 5.0)
0.2
(fma
x
(fma 0.6666666666666666 (* x x) 2.0)
(* (* 0.047619047619047616 (pow x 6.0)) x))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \mathsf{fma}\left({x}^{5}, 0.2, \mathsf{fma}\left(x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right), \left(0.047619047619047616 \cdot {x}^{6}\right) \cdot x\right)\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
lift-*.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow-plusN/A
lift-pow.f64N/A
metadata-evalN/A
lift-/.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lift-fabs.f64N/A
lower-*.f6475.6
lift-fabs.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow199.8
Applied rewrites99.8%
(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))))
(* (/ 1.0 21.0) (* (pow x 6.0) (fabs x)))))))\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) + \frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.8%
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.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 (PI)))))
(fabs
(*
(fma
(pow x 4.0)
(* t_0 (fma 0.047619047619047616 (* x x) 0.2))
(* t_0 (fma (* x x) 0.6666666666666666 2.0)))
x))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\\
\left|\mathsf{fma}\left({x}^{4}, t\_0 \cdot \mathsf{fma}\left(0.047619047619047616, x \cdot x, 0.2\right), t\_0 \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right) \cdot x\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (fabs (* (* (* (* x x) x) x) x))))
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(+
(+ (* 2.0 (fabs x)) (* (* x x) (* x 0.6666666666666666)))
(* (/ 1.0 5.0) t_0))
(* (/ 1.0 21.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|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \left(x \cdot x\right) \cdot \left(x \cdot 0.6666666666666666\right)\right) + \frac{1}{5} \cdot t\_0\right) + \frac{1}{21} \cdot \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
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.8
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt80.7
lift-/.f64N/A
metadata-eval80.7
Applied rewrites80.7%
Final simplification80.7%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(+
(+ (* 2.0 (fabs x)) (* (* x x) (* x 0.6666666666666666)))
(* (/ 1.0 5.0) (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(2 \cdot \left|x\right| + \left(x \cdot x\right) \cdot \left(x \cdot 0.6666666666666666\right)\right) + \frac{1}{5} \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
*-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.8
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt80.7
lift-/.f64N/A
metadata-eval80.7
Applied rewrites80.7%
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
lift-*.f64N/A
lower-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
lift-*.f64N/A
lower-*.f6480.7
Applied rewrites80.7%
Final simplification80.7%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(*
(fma
(fma (* (fma (* x x) 0.047619047619047616 0.2) x) x 0.6666666666666666)
(* x x)
2.0)
x))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right) \cdot x, x, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f6468.5
Applied rewrites68.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(*
(fma
(fma (* (* x x) 0.047619047619047616) (* x x) 0.6666666666666666)
(* x x)
2.0)
x))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \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)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f6468.5
Applied rewrites68.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites99.5%
(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), x \cdot x, 2\right) \cdot x\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f6468.5
Applied rewrites68.5%
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
fabs-divN/A
*-lft-identityN/A
rem-sqrt-squareN/A
Applied rewrites68.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.3
Applied rewrites99.3%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fma (fma 0.2 (* x x) 0.6666666666666666) (* x x) 2.0) x))))
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6491.8
Applied rewrites91.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt (PI)))))
(if (<= x 1.75)
(fabs (* t_0 (* 2.0 x)))
(fabs (* t_0 (* (* (* x x) 0.6666666666666666) x))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\\
\mathbf{if}\;x \leq 1.75:\\
\;\;\;\;\left|t\_0 \cdot \left(2 \cdot x\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_0 \cdot \left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot x\right)\right|\\
\end{array}
\end{array}
if x < 1.75Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f6468.5
Applied rewrites68.5%
if 1.75 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
remove-double-negN/A
*-commutativeN/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6486.9
Applied rewrites86.9%
Taylor expanded in x around inf
Applied rewrites24.2%
(FPCore (x) :precision binary64 (/ (* (fma (fma (* x x) 0.2 0.6666666666666666) (* x x) 2.0) x) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), x \cdot x, 2\right) \cdot x}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6491.8
Applied rewrites91.8%
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
fabs-divN/A
Applied rewrites91.3%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt32.6
Applied rewrites32.6%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fma (* 0.6666666666666666 x) x 2.0) x))))
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right) \cdot x\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
remove-double-negN/A
*-commutativeN/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6486.9
Applied rewrites86.9%
Applied rewrites86.9%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* 2.0 x))))
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(2 \cdot x\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f6468.5
Applied rewrites68.5%
(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.8%
Taylor expanded in x around 0
lower-*.f6468.5
Applied rewrites68.5%
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
fabs-divN/A
*-lft-identityN/A
rem-sqrt-squareN/A
Applied rewrites68.1%
Applied rewrites68.1%
herbie shell --seed 2025006
(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)))))))