
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs x)))
(t_1 (* (* t_0 t_0) t_0))
(t_2 (* (* t_1 t_0) t_0)))
(*
(* (/ 1.0 (sqrt (PI))) (exp (* (fabs x) (fabs x))))
(+
(+ (+ t_0 (* (/ 1.0 2.0) t_1)) (* (/ 3.0 4.0) t_2))
(* (/ 15.0 8.0) (* (* t_2 t_0) t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\
t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\
\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{\left|x\right| \cdot \left|x\right|}\right) \cdot \left(\left(\left(t\_0 + \frac{1}{2} \cdot t\_1\right) + \frac{3}{4} \cdot t\_2\right) + \frac{15}{8} \cdot \left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right)\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs x)))
(t_1 (* (* t_0 t_0) t_0))
(t_2 (* (* t_1 t_0) t_0)))
(*
(* (/ 1.0 (sqrt (PI))) (exp (* (fabs x) (fabs x))))
(+
(+ (+ t_0 (* (/ 1.0 2.0) t_1)) (* (/ 3.0 4.0) t_2))
(* (/ 15.0 8.0) (* (* t_2 t_0) t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\
t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\
\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{\left|x\right| \cdot \left|x\right|}\right) \cdot \left(\left(\left(t\_0 + \frac{1}{2} \cdot t\_1\right) + \frac{3}{4} \cdot t\_2\right) + \frac{15}{8} \cdot \left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right)\right)
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(*
(sqrt (/ 1.0 (PI)))
(*
(fma
(+ (/ 0.5 (* x x)) 1.0)
(/ 1.0 (fabs x))
(fma (pow (fabs x) -5.0) 0.75 (/ 1.875 (pow x 7.0))))
(pow (pow (exp x) 2.0) (* 0.5 x)))))\begin{array}{l}
\\
\sqrt{\frac{1}{\mathsf{PI}\left(\right)}} \cdot \left(\mathsf{fma}\left(\frac{0.5}{x \cdot x} + 1, \frac{1}{\left|x\right|}, \mathsf{fma}\left({\left(\left|x\right|\right)}^{-5}, 0.75, \frac{1.875}{{x}^{7}}\right)\right) \cdot {\left({\left(e^{x}\right)}^{2}\right)}^{\left(0.5 \cdot x\right)}\right)
\end{array}
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites51.5%
Taylor expanded in x around inf
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs x))))
(*
(+
(* (* (* (* (* (* (* t_0 t_0) t_0) t_0) t_0) t_0) t_0) (/ 15.0 8.0))
(+
(* (* (* (* (/ 1.0 (* x x)) t_0) t_0) t_0) (/ 3.0 4.0))
(/ (+ (/ 0.5 (* x x)) 1.0) (fabs x))))
(* (pow (exp x) x) (/ 1.0 (sqrt (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\left(\left(\left(\left(\left(\left(\left(t\_0 \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{15}{8} + \left(\left(\left(\left(\frac{1}{x \cdot x} \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{3}{4} + \frac{\frac{0.5}{x \cdot x} + 1}{\left|x\right|}\right)\right) \cdot \left({\left(e^{x}\right)}^{x} \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right)
\end{array}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
distribute-lft-inN/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
sqr-absN/A
lower-*.f64N/A
lower-fabs.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
metadata-evalN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
unpow2N/A
sqr-absN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs x))))
(*
(/ (pow (exp x) x) (sqrt (PI)))
(+
(* (* (* (* (* (* (* t_0 t_0) t_0) t_0) t_0) t_0) t_0) (/ 15.0 8.0))
(+
(* (* (* (* (/ 1.0 (* x x)) t_0) t_0) t_0) (/ 3.0 4.0))
(/ (+ (/ 0.5 (* x x)) 1.0) (fabs x)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\frac{{\left(e^{x}\right)}^{x}}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\left(\left(\left(\left(\left(t\_0 \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{15}{8} + \left(\left(\left(\left(\frac{1}{x \cdot x} \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{3}{4} + \frac{\frac{0.5}{x \cdot x} + 1}{\left|x\right|}\right)\right)
\end{array}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
distribute-lft-inN/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
sqr-absN/A
lower-*.f64N/A
lower-fabs.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
metadata-evalN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
pow-expN/A
lift-exp.f64N/A
lift-pow.f64N/A
*-lft-identity100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs x)))
(t_1 (* (* t_0 t_0) t_0))
(t_2 (* (* t_1 t_0) t_0)))
(*
(+
(+ (* t_2 (/ 3.0 4.0)) (+ (* (/ 1.0 2.0) t_1) t_0))
(* (* (* t_2 t_0) t_0) (/ 15.0 8.0)))
(* (exp (* (fabs x) (fabs x))) (/ 1.0 (sqrt (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\
t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\
\left(\left(t\_2 \cdot \frac{3}{4} + \left(\frac{1}{2} \cdot t\_1 + t\_0\right)\right) + \left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{15}{8}\right) \cdot \left(e^{\left|x\right| \cdot \left|x\right|} \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right)
\end{array}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(*
(*
(fma
(+ (/ 0.5 (* x x)) 1.0)
(/ 1.0 (fabs x))
(+ (/ 0.75 (pow (fabs x) 5.0)) (/ 1.875 (pow (fabs x) 7.0))))
(exp (* x x)))
(sqrt (/ 1.0 (PI)))))\begin{array}{l}
\\
\left(\mathsf{fma}\left(\frac{0.5}{x \cdot x} + 1, \frac{1}{\left|x\right|}, \frac{0.75}{{\left(\left|x\right|\right)}^{5}} + \frac{1.875}{{\left(\left|x\right|\right)}^{7}}\right) \cdot e^{x \cdot x}\right) \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites51.5%
Taylor expanded in x around inf
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs x))))
(*
(+
(* (* (* (* (* (* (/ 1.0 (* x x)) t_0) t_0) t_0) t_0) t_0) (/ 15.0 8.0))
(-
(/ (+ (/ 0.5 (* x x)) 1.0) (fabs x))
(* (* (/ -1.0 (* (* x x) (* x x))) t_0) (/ 3.0 4.0))))
(* (exp (* (fabs x) (fabs x))) (/ 1.0 (sqrt (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\left(\left(\left(\left(\left(\left(\frac{1}{x \cdot x} \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{15}{8} + \left(\frac{\frac{0.5}{x \cdot x} + 1}{\left|x\right|} - \left(\frac{-1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot t\_0\right) \cdot \frac{3}{4}\right)\right) \cdot \left(e^{\left|x\right| \cdot \left|x\right|} \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right)
\end{array}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
distribute-lft-inN/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
sqr-absN/A
lower-*.f64N/A
lower-fabs.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
metadata-evalN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
metadata-evalN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
lift-/.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
frac-timesN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
associate-*r/N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (* (* (pow (exp x) x) (sqrt (/ 1.0 (PI)))) (/ 1.0 (fabs x))))
\begin{array}{l}
\\
\left({\left(e^{x}\right)}^{x} \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\right) \cdot \frac{1}{\left|x\right|}
\end{array}
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites51.5%
Taylor expanded in x around 0
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
Applied rewrites33.1%
Taylor expanded in x around inf
Applied rewrites99.4%
Final simplification99.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 (PI)))))
(if (<= (fabs x) 1e+103)
(*
(/ (/ 0.5 (* x x)) x)
(* (exp (* (fabs x) (fabs x))) (/ 1.0 (sqrt (PI)))))
(fma
(* (fma (* x x) 0.5833333333333334 1.25) (/ t_0 (fabs x)))
(* x x)
(* (/ 1.5 (fabs x)) t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\\
\mathbf{if}\;\left|x\right| \leq 10^{+103}:\\
\;\;\;\;\frac{\frac{0.5}{x \cdot x}}{x} \cdot \left(e^{\left|x\right| \cdot \left|x\right|} \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5833333333333334, 1.25\right) \cdot \frac{t\_0}{\left|x\right|}, x \cdot x, \frac{1.5}{\left|x\right|} \cdot t\_0\right)\\
\end{array}
\end{array}
if (fabs.f64 x) < 1e103Initial program 99.9%
lift-+.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
lower-/.f64N/A
unpow2N/A
sqr-absN/A
unpow3N/A
lower-pow.f64N/A
lower-fabs.f6496.9
Applied rewrites96.9%
Applied rewrites98.0%
if 1e103 < (fabs.f64 x) Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites26.6%
Taylor expanded in x around 0
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
Applied rewrites0.0%
Taylor expanded in x around 0
Applied rewrites26.6%
Taylor expanded in x around inf
Applied rewrites100.0%
Final simplification99.3%
(FPCore (x) :precision binary64 (* (* (pow x 4.0) 0.5833333333333334) (/ (sqrt (/ 1.0 (PI))) (fabs x))))
\begin{array}{l}
\\
\left({x}^{4} \cdot 0.5833333333333334\right) \cdot \frac{\sqrt{\frac{1}{\mathsf{PI}\left(\right)}}}{\left|x\right|}
\end{array}
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites51.5%
Taylor expanded in x around 0
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
Applied rewrites33.1%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in x around inf
Applied rewrites75.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 (PI)))))
(fma
(* (fma (* x x) 0.5833333333333334 1.25) (/ t_0 (fabs x)))
(* x x)
(* (/ 1.5 (fabs x)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}\\
\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5833333333333334, 1.25\right) \cdot \frac{t\_0}{\left|x\right|}, x \cdot x, \frac{1.5}{\left|x\right|} \cdot t\_0\right)
\end{array}
\end{array}
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites51.5%
Taylor expanded in x around 0
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
Applied rewrites33.1%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in x around inf
Applied rewrites68.0%
Final simplification68.0%
(FPCore (x) :precision binary64 (* (/ 1.5 (fabs x)) (sqrt (/ 1.0 (PI)))))
\begin{array}{l}
\\
\frac{1.5}{\left|x\right|} \cdot \sqrt{\frac{1}{\mathsf{PI}\left(\right)}}
\end{array}
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites51.5%
Taylor expanded in x around 0
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
*-commutativeN/A
metadata-evalN/A
pow-sqrN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
Applied rewrites33.1%
Taylor expanded in x around 0
Applied rewrites1.3%
Taylor expanded in x around inf
Applied rewrites2.3%
herbie shell --seed 2024285
(FPCore (x)
:name "Jmat.Real.erfi, branch x greater than or equal to 5"
:precision binary64
:pre (>= x 0.5)
(* (* (/ 1.0 (sqrt (PI))) (exp (* (fabs x) (fabs x)))) (+ (+ (+ (/ 1.0 (fabs x)) (* (/ 1.0 2.0) (* (* (/ 1.0 (fabs x)) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))))) (* (/ 3.0 4.0) (* (* (* (* (/ 1.0 (fabs x)) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))))) (* (/ 15.0 8.0) (* (* (* (* (* (* (/ 1.0 (fabs x)) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x)))))))