
(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 12 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 x 6.0) (fabs x)) 0.047619047619047616)
(+
(* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) 0.2)
(* (fma (* x x) 0.6666666666666666 2.0) (fabs x))))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\left({x}^{6} \cdot \left|x\right|\right) \cdot 0.047619047619047616 + \left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot 0.2 + \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot \left|x\right|\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
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.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-*.f64N/A
sqr-absN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
cube-unmultN/A
unpow-prod-downN/A
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x))))
(fabs
(*
(+
(* (* (* t_0 (fabs x)) (fabs x)) 0.047619047619047616)
(+ (* t_0 0.2) (* (fma (* x x) 0.6666666666666666 2.0) (fabs x))))
(/ 1.0 (sqrt (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\left(\left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot 0.047619047619047616 + \left(t\_0 \cdot 0.2 + \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot \left|x\right|\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
\end{array}
Initial program 99.8%
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.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(*
(* (* (* (* (* x x) (* x x)) (fabs x)) (fabs x)) (fabs x))
0.047619047619047616)
(+
(* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) 0.2)
(* (fma (* x x) 0.6666666666666666 2.0) (fabs x))))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\left(\left(\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot 0.047619047619047616 + \left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot 0.2 + \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot \left|x\right|\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
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.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.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-absN/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x))))
(fabs
(*
(+
(+ (* 2.0 (fabs x)) (* t_0 0.2))
(* (* (* t_0 (fabs x)) (fabs x)) 0.047619047619047616))
(/ 1.0 (sqrt (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\left(\left(2 \cdot \left|x\right| + t\_0 \cdot 0.2\right) + \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot 0.047619047619047616\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
\end{array}
Initial program 99.8%
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.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.3%
Final simplification99.3%
(FPCore (x)
:precision binary64
(/
1.0
(/
(sqrt (PI))
(fabs
(* (fma (* (fma 0.2 (* x x) 0.6666666666666666) x) x 2.0) (fabs x))))))\begin{array}{l}
\\
\frac{1}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{\left|\mathsf{fma}\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right) \cdot x, x, 2\right) \cdot \left|x\right|\right|}}
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Applied rewrites71.2%
Taylor expanded in x around 0
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
pow-sqrN/A
metadata-evalN/A
distribute-rgt-inN/A
Applied rewrites93.0%
lift-fabs.f64N/A
lift-/.f64N/A
fabs-divN/A
rem-sqrt-squareN/A
sqrt-prodN/A
rem-square-sqrtN/A
clear-numN/A
Applied rewrites93.0%
(FPCore (x)
:precision binary64
(fabs
(/
(fma
(* (* (fma 0.2 (* x x) 0.6666666666666666) x) x)
(fabs x)
(* 2.0 (fabs x)))
(sqrt (PI)))))\begin{array}{l}
\\
\left|\frac{\mathsf{fma}\left(\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right) \cdot x\right) \cdot x, \left|x\right|, 2 \cdot \left|x\right|\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Applied rewrites71.2%
Taylor expanded in x around 0
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
pow-sqrN/A
metadata-evalN/A
distribute-rgt-inN/A
Applied rewrites93.0%
Applied rewrites93.0%
(FPCore (x) :precision binary64 (fabs (/ (* (fma (* x x) (fma (* x x) 0.2 0.6666666666666666) 2.0) (fabs x)) (sqrt (PI)))))
\begin{array}{l}
\\
\left|\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right) \cdot \left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Applied rewrites71.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-fabs.f6466.5
Applied rewrites66.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-inN/A
Applied rewrites93.0%
Final simplification93.0%
(FPCore (x) :precision binary64 (fabs (* (* (fma 0.6666666666666666 (* x x) 2.0) (fabs x)) (/ 1.0 (sqrt (PI))))))
\begin{array}{l}
\\
\left|\left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot \left|x\right|\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
Applied rewrites44.5%
Taylor expanded in x around inf
Applied rewrites90.0%
Applied rewrites90.0%
Final simplification90.0%
(FPCore (x) :precision binary64 (fabs (* (* (sqrt (/ 1.0 (PI))) (fabs x)) (fma (* x x) 0.6666666666666666 2.0))))
\begin{array}{l}
\\
\left|\left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} \cdot \left|x\right|\right) \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Applied rewrites71.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites90.0%
(FPCore (x) :precision binary64 (fabs (* (/ (fabs x) (sqrt (PI))) (fma 0.6666666666666666 (* x x) 2.0))))
\begin{array}{l}
\\
\left|\frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Applied rewrites71.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites90.0%
Applied rewrites89.6%
Final simplification89.6%
(FPCore (x) :precision binary64 (fabs (* (sqrt (/ 1.0 (PI))) (* 2.0 (fabs x)))))
\begin{array}{l}
\\
\left|\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} \cdot \left(2 \cdot \left|x\right|\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Applied rewrites71.2%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6466.9
Applied rewrites66.9%
Final simplification66.9%
(FPCore (x) :precision binary64 (fabs (/ (* 2.0 (fabs x)) (sqrt (PI)))))
\begin{array}{l}
\\
\left|\frac{2 \cdot \left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Applied rewrites71.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-fabs.f6466.5
Applied rewrites66.5%
herbie shell --seed 2024332
(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)))))))