
(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
(fma (pow x 3.0) 0.2 (* 0.6666666666666666 x))
(fma 0.047619047619047616 (pow x 6.0) 2.0))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x, \mathsf{fma}\left({x}^{3}, 0.2, 0.6666666666666666 \cdot x\right), \mathsf{fma}\left(0.047619047619047616, {x}^{6}, 2\right)\right)\right)\right|
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
(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.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) (* x x))))
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(+
(+ (* 2.0 (fabs x)) (* (* x x) (* (fabs x) 0.6666666666666666)))
(* (/ 1.0 5.0) (* t_0 (fabs x))))
(* 0.047619047619047616 (* (fabs (* (* t_0 x) x)) (fabs x))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot \left(x \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(\left|x\right| \cdot 0.6666666666666666\right)\right) + \frac{1}{5} \cdot \left(t\_0 \cdot \left|x\right|\right)\right) + 0.047619047619047616 \cdot \left(\left|\left(t\_0 \cdot x\right) \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
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f64N/A
lower-*.f6499.9
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
lift-*.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
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
lift-*.f6499.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) x)))
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(* (fabs x) (fma (* x x) (fma (* x x) 0.2 0.6666666666666666) 2.0))
(* 0.047619047619047616 (* (* t_0 t_0) (fabs x))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), 2\right) + 0.047619047619047616 \cdot \left(\left(t\_0 \cdot t\_0\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\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-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
unswap-sqrN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
lift-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fabs x) (fma (* x x) (fma (* 0.2 x) x 0.6666666666666666) 2.0)))))
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right), 2\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-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
unswap-sqrN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites95.9%
Applied rewrites95.9%
Final simplification95.9%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fabs x) (fma (* x x) (* (* 0.2 x) x) 2.0)))))
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, \left(0.2 \cdot x\right) \cdot x, 2\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-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
unswap-sqrN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites95.9%
Taylor expanded in x around inf
Applied rewrites95.3%
Applied rewrites95.3%
Final simplification95.3%
(FPCore (x) :precision binary64 (/ (fabs (* (fma (* 0.2 (* x x)) (* x x) 2.0) (fabs x))) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|\mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, 2\right) \cdot \left|x\right|\right|}{\sqrt{\mathsf{PI}\left(\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-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
unswap-sqrN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites95.9%
Taylor expanded in x around inf
Applied rewrites95.3%
Applied rewrites94.8%
Final simplification94.8%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fabs x) (fma (* x x) 0.6666666666666666 2.0)))))
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\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-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
unswap-sqrN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites95.9%
Taylor expanded in x around 0
Applied rewrites92.5%
Final simplification92.5%
(FPCore (x) :precision binary64 (fabs (/ (* (fabs x) 2.0) (sqrt (PI)))))
\begin{array}{l}
\\
\left|\frac{\left|x\right| \cdot 2}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.9%
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites94.8%
Taylor expanded in x around 0
Applied rewrites67.3%
Final simplification67.3%
herbie shell --seed 2025019
(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)))))))