
(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 10 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)))
(fma
0.047619047619047616
(pow (fabs x) 7.0)
(fma
(fabs x)
(fma x (* x 0.6666666666666666) 2.0)
(* 0.2 (pow (fabs x) 5.0)))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, \mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(x, x \cdot 0.6666666666666666, 2\right), 0.2 \cdot {\left(\left|x\right|\right)}^{5}\right)\right)\right|
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower-fabs.f64N/A
+-commutativeN/A
+-commutativeN/A
unpow3N/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ 1.0 (sqrt (PI)))
(fma
(* x (* x (* x (* x (* x x)))))
(* 0.047619047619047616 x)
(* (fabs x) (fma x (* x (fma x (* x 0.2) 0.6666666666666666)) 2.0))))))\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), 0.047619047619047616 \cdot x, \left|x\right| \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.2, 0.6666666666666666\right), 2\right)\right)\right|
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Applied rewrites76.1%
Final simplification76.1%
(FPCore (x)
:precision binary64
(*
(/ 1.0 (sqrt (PI)))
(fabs
(*
x
(fma
x
(*
x
(fma x (* x (fma x (* 0.047619047619047616 x) 0.2)) 0.6666666666666666))
2.0)))))\begin{array}{l}
\\
\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left|x \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, 0.047619047619047616 \cdot x, 0.2\right), 0.6666666666666666\right), 2\right)\right|
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x)
:precision binary64
(/
(fabs
(*
x
(fma
(* x x)
(fma (* x x) (fma x (* 0.047619047619047616 x) 0.2) 0.6666666666666666)
2.0)))
(sqrt (PI))))\begin{array}{l}
\\
\frac{\left|x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, 0.047619047619047616 \cdot x, 0.2\right), 0.6666666666666666\right), 2\right)\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Applied rewrites99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (* (fabs x) (fabs (/ (fma (* x x) (fma x (* x 0.2) 0.6666666666666666) 2.0) (sqrt (PI))))))
\begin{array}{l}
\\
\left|x\right| \cdot \left|\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.2, 0.6666666666666666\right), 2\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right|
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-inN/A
lower-*.f64N/A
lower-fabs.f64N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites93.4%
Applied rewrites92.9%
metadata-evalN/A
lift-PI.f64N/A
lift-sqrt.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-/.f64N/A
Applied rewrites93.4%
(FPCore (x) :precision binary64 (/ (fabs (* x (fma (* x x) (fma x (* x 0.2) 0.6666666666666666) 2.0))) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.2, 0.6666666666666666\right), 2\right)\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
associate-*l*N/A
distribute-rgt-inN/A
lower-*.f64N/A
lower-fabs.f64N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites93.4%
Applied rewrites92.9%
(FPCore (x) :precision binary64 (fabs (* (/ 1.0 (sqrt (PI))) (* (fabs x) (fma 0.6666666666666666 (* x x) 2.0)))))
\begin{array}{l}
\\
\left|\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left|x\right| \cdot \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right|
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-*.f64N/A
lower-fabs.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6487.7
Applied rewrites87.7%
(FPCore (x) :precision binary64 (fabs (* (fabs x) (* (fma 0.6666666666666666 (* x x) 2.0) (sqrt (/ 1.0 (PI)))))))
\begin{array}{l}
\\
\left|\left|x\right| \cdot \left(\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right)\right|
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
distribute-rgt-inN/A
associate-*r*N/A
distribute-rgt-inN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
Applied rewrites87.7%
Final simplification87.7%
(FPCore (x) :precision binary64 (/ (fabs (* x (fma (* x x) 0.6666666666666666 2.0))) (sqrt (PI))))
\begin{array}{l}
\\
\frac{\left|x \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right|}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-*.f64N/A
lower-fabs.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6487.7
Applied rewrites87.7%
lift-PI.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
fabs-divN/A
*-lft-identityN/A
rem-sqrt-squareN/A
sqrt-prodN/A
rem-square-sqrtN/A
Applied rewrites87.2%
(FPCore (x) :precision binary64 (* (fabs x) (/ 2.0 (sqrt (PI)))))
\begin{array}{l}
\\
\left|x\right| \cdot \frac{2}{\sqrt{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 99.9%
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-fabs.f6470.6
Applied rewrites70.6%
lift-PI.f64N/A
lift-sqrt.f64N/A
inv-powN/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
inv-powN/A
lift-/.f64N/A
fabs-fabsN/A
lift-fabs.f64N/A
metadata-evalN/A
fabs-mulN/A
lift-*.f64N/A
fabs-mulN/A
lift-*.f64N/A
fabs-fabsN/A
Applied rewrites70.1%
lift-fabs.f64N/A
lift-PI.f64N/A
lift-sqrt.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6470.6
Applied rewrites70.6%
Final simplification70.6%
herbie shell --seed 2024216
(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)))))))