
(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
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x))))
(fabs
(*
(+
(* (* (* 0.047619047619047616 (* x x)) (fabs x)) (pow x 4.0))
(+
(* (* (* t_0 (fabs x)) (fabs x)) (/ 1.0 5.0))
(+ (* t_0 (/ 2.0 3.0)) (* (fabs x) 2.0))))
(/ 1.0 (sqrt (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\left(\left(\left(0.047619047619047616 \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|\right) \cdot {x}^{4} + \left(\left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \frac{1}{5} + \left(t\_0 \cdot \frac{2}{3} + \left|x\right| \cdot 2\right)\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
\end{array}
Initial program 99.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(* (* (* 0.047619047619047616 (* x x)) (pow x 4.0)) (fabs x))
(fma
(* (* 0.2 (* x x)) (fabs x))
(* x x)
(* (fma (* x x) 0.6666666666666666 2.0) (fabs x))))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\left(\left(0.047619047619047616 \cdot \left(x \cdot x\right)\right) \cdot {x}^{4}\right) \cdot \left|x\right| + \mathsf{fma}\left(\left(0.2 \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|, x \cdot x, \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.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(* (pow x 5.0) (* 0.047619047619047616 (* x x)))
(fma
(* (* 0.2 (* x x)) (fabs x))
(* x x)
(* (fma (* x x) 0.6666666666666666 2.0) (fabs x))))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left({x}^{5} \cdot \left(0.047619047619047616 \cdot \left(x \cdot x\right)\right) + \mathsf{fma}\left(\left(0.2 \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|, x \cdot x, \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.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites73.6%
Final simplification73.6%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(* (* 0.047619047619047616 x) (pow x 6.0))
(fma
(* (* 0.2 (* x x)) (fabs x))
(* x x)
(* (fma (* x x) 0.6666666666666666 2.0) (fabs x))))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\left(0.047619047619047616 \cdot x\right) \cdot {x}^{6} + \mathsf{fma}\left(\left(0.2 \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|, x \cdot x, \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.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Applied rewrites73.6%
Final simplification73.6%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(* (* (* (* 0.047619047619047616 (* x x)) (* x x)) (* x x)) (fabs x))
(fma
(* (* (fma (* x x) 0.2 0.6666666666666666) x) x)
(fabs x)
(* (fabs x) 2.0)))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\left(\left(\left(0.047619047619047616 \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right) \cdot \left|x\right| + \mathsf{fma}\left(\left(\mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right) \cdot x\right) \cdot x, \left|x\right|, \left|x\right| \cdot 2\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-sqrN/A
pow-prod-downN/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
lift-fma.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
distribute-lft-inN/A
lift-*.f64N/A
associate-+r+N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(* (fma (fma (* x x) 0.2 0.6666666666666666) (* x x) 2.0) (fabs x))
(* (* (* (* 0.047619047619047616 (* x x)) (* x x)) (* x x)) (fabs x)))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), x \cdot x, 2\right) \cdot \left|x\right| + \left(\left(\left(0.047619047619047616 \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-sqrN/A
pow-prod-downN/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-fma.f64N/A
associate-+l+N/A
*-commutativeN/A
distribute-rgt-inN/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
*-commutativeN/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(* (fma (* x x) 0.6666666666666666 2.0) (fabs x))
(* (* (* (* 0.047619047619047616 (* x x)) (* x x)) (* x x)) (fabs x)))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot \left|x\right| + \left(\left(\left(0.047619047619047616 \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-sqrN/A
pow-prod-downN/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-fabs.f6499.3
Applied rewrites99.3%
Final simplification99.3%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(* (fabs x) 2.0)
(* (* (* (* 0.047619047619047616 (* x x)) (* x x)) (* x x)) (fabs x)))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\left|x\right| \cdot 2 + \left(\left(\left(0.047619047619047616 \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right) \cdot \left|x\right|\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-sqrN/A
pow-prod-downN/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-fabs.f6499.1
Applied rewrites99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (fabs (* (* (fma (* x x) (fma 0.2 (* x x) 0.6666666666666666) 2.0) (fabs x)) (/ 1.0 (sqrt (PI))))))
\begin{array}{l}
\\
\left|\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right), 2\right) \cdot \left|x\right|\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Applied rewrites73.6%
Taylor expanded in x around 0
+-commutativeN/A
Applied rewrites93.2%
Final simplification93.2%
(FPCore (x) :precision binary64 (/ (fabs (* (fma (fma (* x x) 0.2 0.6666666666666666) (* x x) 2.0) (fabs 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 \left|x\right|\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Applied rewrites73.6%
Taylor expanded in x around 0
+-commutativeN/A
Applied rewrites93.2%
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
Applied rewrites92.7%
(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 \cdot x, x, 2\right) \cdot \left|x\right|\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Applied rewrites73.6%
Taylor expanded in x around 0
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-fabs.f6487.5
Applied rewrites87.5%
Final simplification87.5%
(FPCore (x) :precision binary64 (fabs (* (* (sqrt (/ 1.0 (PI))) (fabs x)) (fma (* 0.6666666666666666 x) x 2.0))))
\begin{array}{l}
\\
\left|\left(\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} \cdot \left|x\right|\right) \cdot \mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right)\right|
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Applied rewrites73.6%
Taylor expanded in x around 0
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-fabs.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6487.5
Applied rewrites87.5%
(FPCore (x) :precision binary64 (fabs (* (* (fabs x) 2.0) (/ 1.0 (sqrt (PI))))))
\begin{array}{l}
\\
\left|\left(\left|x\right| \cdot 2\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Applied rewrites73.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-fabs.f6468.5
Applied rewrites68.5%
Final simplification68.5%
(FPCore (x) :precision binary64 (/ (fabs (* (fabs x) 2.0)) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|\left|x\right| \cdot 2\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Applied rewrites73.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-fabs.f6468.5
Applied rewrites68.5%
lift-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
fabs-divN/A
Applied rewrites67.9%
Final simplification67.9%
herbie shell --seed 2024254
(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)))))))