(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 5 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 (* (/ 1.0 (sqrt (PI))) (+ (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) (* (* t_0 (fabs x)) (fabs x)))) (* (/ 1.0 21.0) (* (* (* (* (* x x) (* x x)) (fabs x)) (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|\\ \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 \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \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)\right)\right| \end{array} \end{array}
Initial program 99.8%
lift-*.f64
N/A
lift-*.f64
N/A
associate-*l*
N/A
lift-*.f64
N/A
lower-*.f64
99.8
lift-*.f64
N/A
lift-fabs.f64
N/A
lift-fabs.f64
N/A
sqr-abs
N/A
lower-*.f64
99.8
lift-*.f64
N/A
lift-fabs.f64
N/A
lift-fabs.f64
N/A
sqr-abs
N/A
lower-*.f64
99.8
Applied rewrites99.8%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (+ (+ (* (fma 0.6666666666666666 (* x x) 2.0) x) (* (/ 1.0 5.0) (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)))) (* 0.047619047619047616 (* (* (* (* (* x x) (* x x)) (fabs x)) (fabs x)) (fabs x)))))))
\begin{array}{l} \\ \left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot x + \frac{1}{5} \cdot \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)\right) + 0.047619047619047616 \cdot \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)\right)\right| \end{array}
Initial program 99.8%
lift-*.f64
N/A
lift-*.f64
N/A
associate-*l*
N/A
lift-*.f64
N/A
lower-*.f64
99.8
lift-*.f64
N/A
lift-fabs.f64
N/A
lift-fabs.f64
N/A
sqr-abs
N/A
lower-*.f64
99.8
lift-*.f64
N/A
lift-fabs.f64
N/A
lift-fabs.f64
N/A
sqr-abs
N/A
lower-*.f64
99.8
Applied rewrites99.8%
lift-+.f64
N/A
lift-*.f64
N/A
lift-fabs.f64
N/A
+-commutative
N/A
lift-*.f64
N/A
lift-/.f64
N/A
metadata-eval
N/A
lift-*.f64
N/A
lift-*.f64
N/A
lift-fabs.f64
N/A
lift-fabs.f64
N/A
lift-fabs.f64
N/A
sqr-abs-rev
N/A
lift-*.f64
N/A
associate-*r*
N/A
*-commutative
N/A
distribute-rgt-in
N/A
Applied rewrites78.3%
lift-/.f64
N/A
metadata-eval
78.3
Applied rewrites78.3%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (+ (* x 2.0) (* (/ 1.0 21.0) (* (* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)))))))
\begin{array}{l} \\ \left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(x \cdot 2 + \frac{1}{21} \cdot \left(\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 \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \end{array}
Initial program 99.8%
lift-fabs.f64
N/A
rem-sqrt-square-rev
N/A
sqrt-prod
N/A
lower-*.f64
N/A
lower-sqrt.f64
N/A
lower-sqrt.f64
33.3
Applied rewrites33.3%
Taylor expanded in x around inf
rem-square-sqrt
N/A
sqrt-unprod
N/A
rem-sqrt-square-rev
N/A
*-commutative
N/A
lower-*.f64
N/A
rem-sqrt-square-rev
N/A
sqrt-unprod
N/A
rem-square-sqrt
99.5
Applied rewrites99.5%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* x 2.0))))
\begin{array}{l} \\ \left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(x \cdot 2\right)\right| \end{array}
Initial program 99.8%
lift-fabs.f64
N/A
rem-sqrt-square-rev
N/A
sqrt-prod
N/A
lower-*.f64
N/A
lower-sqrt.f64
N/A
lower-sqrt.f64
33.3
Applied rewrites33.3%
Taylor expanded in x around inf
Applied rewrites70.3%
(FPCore (x) :precision binary64 (/ (fabs (* x 2.0)) (sqrt (PI))))
\begin{array}{l} \\ \frac{\left|x \cdot 2\right|}{\sqrt{\mathsf{PI}\left(\right)}} \end{array}
Initial program 99.8%
lift-fabs.f64
N/A
rem-sqrt-square-rev
N/A
sqrt-prod
N/A
lower-*.f64
N/A
lower-sqrt.f64
N/A
lower-sqrt.f64
33.3
Applied rewrites33.3%
Taylor expanded in x around inf
Applied rewrites70.3%
lift-*.f64
N/A
lift-/.f64
N/A
associate-*l/
N/A
lower-/.f64
N/A
Applied rewrites69.8%
Applied rewrites69.8%
herbie shell --seed 2025065
(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)))))))