
(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 12 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)))
(-
(+
(+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* x x) (fabs x))))
(* (pow 5.0 -1.0) (fabs (* (* (* (* x x) x) x) x))))
(* (/ -1.0 21.0) (* (pow x 6.0) (fabs x)))))))\begin{array}{l}
\\
\left|\frac{-1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(x \cdot x\right) \cdot \left|x\right|\right)\right) + {5}^{-1} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) - \frac{-1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-*.f64N/A
pow2N/A
pow-powN/A
lower-pow.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
metadata-eval99.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (pow (PI) -1.0))))
(fabs
(*
(fma
(* t_0 (fma (* x x) 0.047619047619047616 0.2))
(pow x 4.0)
(* t_0 (fma (* x x) 0.6666666666666666 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.047619047619047616, 0.2\right), {x}^{4}, t\_0 \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right) \cdot x\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(fabs
(*
(/ -1.0 (sqrt (PI)))
(-
(+
(* (fma (* 0.6666666666666666 x) x 2.0) x)
(* (pow 5.0 -1.0) (fabs (* (* (* (* x x) x) x) x))))
(*
(/ -1.0 21.0)
(* (* (* (* (pow x 3.0) 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 \cdot x, x, 2\right) \cdot x + {5}^{-1} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) - \frac{-1}{21} \cdot \left(\left(\left(\left({x}^{3} \cdot x\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-*.f64N/A
lift-*.f64N/A
pow3N/A
lower-pow.f6499.9
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt75.5
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt99.9
Applied rewrites99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
lift-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
distribute-rgt-outN/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
+-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
unpow1N/A
metadata-evalN/A
Applied rewrites79.5%
Final simplification79.5%
(FPCore (x)
:precision binary64
(if (<= (fabs x) 5e-9)
(* (/ 2.0 (sqrt (PI))) x)
(fabs
(*
(* (sqrt (pow (PI) -1.0)) (fma (* x x) 0.047619047619047616 0.2))
(pow x 5.0)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{2}{\sqrt{\mathsf{PI}\left(\right)}} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}} \cdot \mathsf{fma}\left(x \cdot x, 0.047619047619047616, 0.2\right)\right) \cdot {x}^{5}\right|\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-9Initial program 99.9%
Applied rewrites99.2%
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.f6499.9
Applied rewrites99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt56.7
Applied rewrites56.7%
if 5.0000000000000001e-9 < (fabs.f64 x) Initial program 99.7%
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
Final simplification71.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (fabs (* (* (* (* x x) x) x) x))))
(fabs
(*
(/ -1.0 (sqrt (PI)))
(-
(+
(+ (* 2.0 (fabs x)) (* (* x x) (* x 0.6666666666666666)))
(* (pow 5.0 -1.0) t_0))
(* (/ -1.0 21.0) (* (* t_0 (fabs x)) (fabs x))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\\
\left|\frac{-1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \left(x \cdot x\right) \cdot \left(x \cdot 0.6666666666666666\right)\right) + {5}^{-1} \cdot t\_0\right) - \frac{-1}{21} \cdot \left(\left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
lower-*.f6499.8
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt79.5
lift-/.f64N/A
metadata-eval79.5
Applied rewrites79.5%
Final simplification79.5%
(FPCore (x)
:precision binary64
(fabs
(*
(/ -1.0 (sqrt (PI)))
(-
(+
(+ (* 2.0 (fabs x)) (* (* x x) (* x 0.6666666666666666)))
(* (pow 5.0 -1.0) (fabs (* (* (* (* x x) x) x) x))))
(* (/ -1.0 21.0) (* (fabs (* (* (* (* x x) (* x x)) x) x)) (fabs x)))))))\begin{array}{l}
\\
\left|\frac{-1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \left(x \cdot x\right) \cdot \left(x \cdot 0.6666666666666666\right)\right) + {5}^{-1} \cdot \left|\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right|\right) - \frac{-1}{21} \cdot \left(\left|\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x\right| \cdot \left|x\right|\right)\right)\right|
\end{array}
Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
lower-*.f6499.8
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt79.5
lift-/.f64N/A
metadata-eval79.5
Applied rewrites79.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-plusN/A
metadata-evalN/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
pow2N/A
lower-*.f6479.5
Applied rewrites79.5%
Final simplification79.5%
(FPCore (x) :precision binary64 (if (<= (fabs x) 5e-9) (* (/ 2.0 (sqrt (PI))) x) (fabs (* (* (sqrt (pow (PI) -1.0)) (* (* x x) 0.6666666666666666)) x))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{2}{\sqrt{\mathsf{PI}\left(\right)}} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}} \cdot \left(\left(x \cdot x\right) \cdot 0.6666666666666666\right)\right) \cdot x\right|\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-9Initial program 99.9%
Applied rewrites99.2%
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.f6499.9
Applied rewrites99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt56.7
Applied rewrites56.7%
if 5.0000000000000001e-9 < (fabs.f64 x) Initial program 99.7%
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites63.5%
Taylor expanded in x around inf
Applied rewrites63.5%
Final simplification59.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= (fabs x) 5e-9)
(* (/ 2.0 t_0) x)
(* (/ 0.047619047619047616 t_0) (pow x 7.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{2}{t\_0} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{0.047619047619047616}{t\_0} \cdot {x}^{7}\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-9Initial program 99.9%
Applied rewrites99.2%
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.f6499.9
Applied rewrites99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt56.7
Applied rewrites56.7%
if 5.0000000000000001e-9 < (fabs.f64 x) Initial program 99.7%
Applied rewrites99.9%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6499.5
Applied rewrites99.5%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt0.1
Applied rewrites0.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(if (<= (fabs x) 5e-9)
(* (/ 2.0 t_0) x)
(* 0.047619047619047616 (/ (pow x 7.0) t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{2}{t\_0} \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.047619047619047616 \cdot \frac{{x}^{7}}{t\_0}\\
\end{array}
\end{array}
if (fabs.f64 x) < 5.0000000000000001e-9Initial program 99.9%
Applied rewrites99.2%
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.f6499.9
Applied rewrites99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt56.7
Applied rewrites56.7%
if 5.0000000000000001e-9 < (fabs.f64 x) Initial program 99.7%
Applied rewrites99.9%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-PI.f6499.5
Applied rewrites99.5%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt0.1
Applied rewrites0.1%
Applied rewrites0.1%
(FPCore (x) :precision binary64 (fabs (* (* (sqrt (pow (PI) -1.0)) (fma (* 0.6666666666666666 x) x 2.0)) x)))
\begin{array}{l}
\\
\left|\left(\sqrt{{\mathsf{PI}\left(\right)}^{-1}} \cdot \mathsf{fma}\left(0.6666666666666666 \cdot x, x, 2\right)\right) \cdot x\right|
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites87.8%
Applied rewrites87.8%
Final simplification87.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (PI))))
(fabs
(*
(/
(fma (* (* (fma 0.2 (* x x) 0.6666666666666666) x) x) t_0 (* t_0 2.0))
(PI))
x))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\left|\frac{\mathsf{fma}\left(\left(\mathsf{fma}\left(0.2, x \cdot x, 0.6666666666666666\right) \cdot x\right) \cdot x, t\_0, t\_0 \cdot 2\right)}{\mathsf{PI}\left(\right)} \cdot x\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites91.7%
Applied rewrites91.7%
Final simplification91.7%
(FPCore (x) :precision binary64 (* (/ 2.0 (sqrt (PI))) x))
\begin{array}{l}
\\
\frac{2}{\sqrt{\mathsf{PI}\left(\right)}} \cdot x
\end{array}
Initial program 99.8%
Applied rewrites99.4%
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.f6468.6
Applied rewrites68.6%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt38.0
Applied rewrites38.0%
herbie shell --seed 2024337
(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)))))))