
(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 6 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}
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(+
(*
x_m
(fma
0.2
(* (* x_m x_m) (* x_m x_m))
(fma (* x_m x_m) 0.6666666666666666 2.0)))
(*
0.047619047619047616
(*
(* (fabs (* (* (* (* x_m x_m) x_m) x_m) x_m)) (fabs x_m))
(fabs x_m)))))))\begin{array}{l}
x_m = \left|x\right|
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(x\_m \cdot \mathsf{fma}\left(0.2, \left(x\_m \cdot x\_m\right) \cdot \left(x\_m \cdot x\_m\right), \mathsf{fma}\left(x\_m \cdot x\_m, 0.6666666666666666, 2\right)\right) + 0.047619047619047616 \cdot \left(\left(\left|\left(\left(\left(x\_m \cdot x\_m\right) \cdot x\_m\right) \cdot x\_m\right) \cdot x\_m\right| \cdot \left|x\_m\right|\right) \cdot \left|x\_m\right|\right)\right)\right|
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
Applied rewrites99.9%
Applied rewrites71.4%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6471.4
Applied rewrites71.4%
lift-/.f64N/A
metadata-eval71.4
Applied rewrites71.4%
Final simplification71.4%
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(*
(fma
(fma
(fma 0.047619047619047616 (* x_m x_m) 0.2)
(* x_m x_m)
0.6666666666666666)
(* x_m x_m)
2.0)
x_m))))\begin{array}{l}
x_m = \left|x\right|
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.047619047619047616, x\_m \cdot x\_m, 0.2\right), x\_m \cdot x\_m, 0.6666666666666666\right), x\_m \cdot x\_m, 2\right) \cdot x\_m\right)\right|
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
Applied rewrites99.9%
Applied rewrites71.4%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fma (fma (* x_m x_m) 0.2 0.6666666666666666) (* x_m x_m) 2.0) x_m))))
\begin{array}{l}
x_m = \left|x\right|
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(x\_m \cdot x\_m, 0.2, 0.6666666666666666\right), x\_m \cdot x\_m, 2\right) \cdot x\_m\right)\right|
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
Applied rewrites99.9%
Applied rewrites71.4%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites95.7%
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(let* ((t_0 (/ 1.0 (sqrt (PI)))))
(if (<= x_m 1.75)
(fabs (* t_0 (* 2.0 x_m)))
(fabs (* t_0 (* (* x_m (* x_m 0.6666666666666666)) x_m))))))\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\\
\mathbf{if}\;x\_m \leq 1.75:\\
\;\;\;\;\left|t\_0 \cdot \left(2 \cdot x\_m\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_0 \cdot \left(\left(x\_m \cdot \left(x\_m \cdot 0.6666666666666666\right)\right) \cdot x\_m\right)\right|\\
\end{array}
\end{array}
if x < 1.75Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
Applied rewrites99.9%
Applied rewrites71.4%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
lower-*.f6469.0
Applied rewrites69.0%
if 1.75 < x Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites28.0%
lift-*.f64N/A
lift-pow.f64N/A
cube-multN/A
pow2N/A
associate-*r*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6428.0
Applied rewrites28.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6428.0
Applied rewrites28.0%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fma 0.6666666666666666 (* x_m x_m) 2.0) x_m))))
\begin{array}{l}
x_m = \left|x\right|
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\mathsf{fma}\left(0.6666666666666666, x\_m \cdot x\_m, 2\right) \cdot x\_m\right)\right|
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
Applied rewrites99.9%
Applied rewrites71.4%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6491.1
Applied rewrites91.1%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* 2.0 x_m))))
\begin{array}{l}
x_m = \left|x\right|
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(2 \cdot x\_m\right)\right|
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
distribute-rgt-outN/A
Applied rewrites99.9%
Applied rewrites71.4%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around 0
lower-*.f6469.0
Applied rewrites69.0%
herbie shell --seed 2025046
(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)))))))