
(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 7 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 (sqrt (PI))))
(fabs
(*
(fma
(* (* (/ (fma (* 0.047619047619047616 x) x 0.2) t_0) (* x x)) (- x))
(- x)
(/ (fma 0.6666666666666666 (* x x) 2.0) t_0))
x))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\left|\mathsf{fma}\left(\left(\frac{\mathsf{fma}\left(0.047619047619047616 \cdot x, x, 0.2\right)}{t\_0} \cdot \left(x \cdot x\right)\right) \cdot \left(-x\right), -x, \frac{\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}{t\_0}\right) \cdot x\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6469.7
Applied rewrites69.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (pow (PI) -1.0))))
(fabs
(*
(fma (* t_0 (fma (* x x) 0.2 0.6666666666666666)) (* x x) (* t_0 2.0))
x))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{{\mathsf{PI}\left(\right)}^{-1}}\\
\left|\mathsf{fma}\left(t\_0 \cdot \mathsf{fma}\left(x \cdot x, 0.2, 0.6666666666666666\right), x \cdot x, t\_0 \cdot 2\right) \cdot x\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6469.7
Applied rewrites69.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites92.3%
Final simplification92.3%
(FPCore (x) :precision binary64 (fabs (* (* (fma (* x x) 0.6666666666666666 2.0) x) (sqrt (pow (PI) -1.0)))))
\begin{array}{l}
\\
\left|\left(\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right) \cdot x\right) \cdot \sqrt{{\mathsf{PI}\left(\right)}^{-1}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Taylor expanded in x around 0
distribute-rgt-inN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
unpow3N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.9%
Final simplification89.9%
(FPCore (x) :precision binary64 (fabs (* (* (sqrt (pow (PI) -1.0)) (fma (* x x) 0.6666666666666666 2.0)) x)))
\begin{array}{l}
\\
\left|\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}} \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right) \cdot x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6469.7
Applied rewrites69.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites89.9%
Final simplification89.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(fabs
(*
(fma
(* (/ (fma (* 0.047619047619047616 x) x 0.2) t_0) (* x x))
(* x x)
(/ (fma 0.6666666666666666 (* x x) 2.0) t_0))
x))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\left|\mathsf{fma}\left(\frac{\mathsf{fma}\left(0.047619047619047616 \cdot x, x, 0.2\right)}{t\_0} \cdot \left(x \cdot x\right), x \cdot x, \frac{\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)}{t\_0}\right) \cdot x\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6469.7
Applied rewrites69.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Applied rewrites99.8%
(FPCore (x) :precision binary64 (fabs (* x (/ 2.0 (sqrt (PI))))))
\begin{array}{l}
\\
\left|x \cdot \frac{2}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6469.7
Applied rewrites69.7%
Applied rewrites69.3%
Applied rewrites69.7%
(FPCore (x) :precision binary64 (fabs (/ (+ x x) (sqrt (PI)))))
\begin{array}{l}
\\
\left|\frac{x + x}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
Applied rewrites99.5%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6469.7
Applied rewrites69.7%
Applied rewrites69.3%
Applied rewrites69.3%
herbie shell --seed 2024305
(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)))))))