
(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
(*
(sqrt (/ 1.0 (PI)))
(fma
(fma (* x x) 0.6666666666666666 2.0)
(fabs x)
(fma
(pow (fabs x) 7.0)
0.047619047619047616
(* 0.2 (pow (fabs x) 5.0)))))))\begin{array}{l}
\\
\left|\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} \cdot \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right), \left|x\right|, \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, 0.2 \cdot {\left(\left|x\right|\right)}^{5}\right)\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(*
(* (* (* (* (pow x 3.0) x) (fabs x)) (fabs x)) (fabs x))
0.047619047619047616)
(+
(*
(* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x))
(/ 1.0 5.0))
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0))))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\left(\left(\left(\left({x}^{3} \cdot x\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot 0.047619047619047616 + \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 \frac{1}{5} + \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
associate-*r*N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow3N/A
lower-*.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(*
(*
(* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x))
(fabs x))
(/ 1.0 21.0))
(fma (fma (* 0.6666666666666666 x) x 2.0) (fabs x) (* (pow x 5.0) 0.2)))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\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) \cdot \frac{1}{21} + \mathsf{fma}\left(\mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right), \left|x\right|, {x}^{5} \cdot 0.2\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow2N/A
pow-prod-upN/A
metadata-evalN/A
lift-pow.f64N/A
Applied rewrites68.5%
Final simplification68.5%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(* (* (pow (* x x) 3.0) (fabs x)) 0.047619047619047616)
(+
(*
(* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x))
(/ 1.0 5.0))
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0))))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\left({\left(x \cdot x\right)}^{3} \cdot \left|x\right|\right) \cdot 0.047619047619047616 + \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 \frac{1}{5} + \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
associate-*r*N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow3N/A
lower-*.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-pow.f64N/A
associate-*r*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
cube-multN/A
unpow-prod-downN/A
lift-*.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x))))
(fabs
(*
(+
(* (* (* t_0 (fabs x)) (fabs x)) 0.047619047619047616)
(+
(* t_0 (/ 1.0 5.0))
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0))))
(/ 1.0 (sqrt (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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|\\
\left|\left(\left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot 0.047619047619047616 + \left(t\_0 \cdot \frac{1}{5} + \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(fabs
(*
(+
(*
(* (* (* (* (* x x) (* x x)) (fabs x)) (fabs x)) (fabs x))
0.047619047619047616)
(+
(*
(* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x))
(/ 1.0 5.0))
(* (fabs x) (fma (* x x) 0.6666666666666666 2.0))))
(/ 1.0 (sqrt (PI))))))\begin{array}{l}
\\
\left|\left(\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) \cdot 0.047619047619047616 + \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 \frac{1}{5} + \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (fabs (* (* (pow x 7.0) 0.047619047619047616) (/ 1.0 (sqrt (PI))))))
\begin{array}{l}
\\
\left|\left({x}^{7} \cdot 0.047619047619047616\right) \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
associate-*r*N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow3N/A
lower-*.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
cube-multN/A
sqr-absN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-fabs.f64N/A
unpow2N/A
associate-*r*N/A
pow-plusN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f6439.7
Applied rewrites39.7%
Applied rewrites39.7%
Final simplification39.7%
(FPCore (x) :precision binary64 (/ (fabs (* (pow x 7.0) 0.047619047619047616)) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|{x}^{7} \cdot 0.047619047619047616\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lower-*.f6499.8
lift-/.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
associate-*r*N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow3N/A
lower-*.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
cube-multN/A
sqr-absN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-fabs.f64N/A
unpow2N/A
associate-*r*N/A
pow-plusN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f6439.7
Applied rewrites39.7%
Applied rewrites39.7%
(FPCore (x) :precision binary64 (fabs (* (* (* (/ 0.6666666666666666 (sqrt (PI))) x) x) x)))
\begin{array}{l}
\\
\left|\left(\left(\frac{0.6666666666666666}{\sqrt{\mathsf{PI}\left(\right)}} \cdot x\right) \cdot x\right) \cdot x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-absN/A
unpow3N/A
lower-pow.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6431.2
Applied rewrites31.2%
Applied rewrites31.2%
Applied rewrites31.2%
Final simplification31.2%
herbie shell --seed 2024273
(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)))))))