
(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 9 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
(let* ((t_0 (sqrt (sqrt (PI)))))
(*
(/ (exp (* x x)) (* t_0 t_0))
(-
(- (/ (- (/ 0.5 (* x x)) -1.0) (fabs x)) (/ -1.875 (pow (fabs x) 7.0)))
(/ -0.75 (pow (fabs x) 5.0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\sqrt{\mathsf{PI}\left(\right)}}\\
\frac{e^{x \cdot x}}{t\_0 \cdot t\_0} \cdot \left(\left(\frac{\frac{0.5}{x \cdot x} - -1}{\left|x\right|} - \frac{-1.875}{{\left(\left|x\right|\right)}^{7}}\right) - \frac{-0.75}{{\left(\left|x\right|\right)}^{5}}\right)
\end{array}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow-expN/A
lift-exp.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
lift-*.f64N/A
lift-exp.f64100.0
Applied rewrites100.0%
lift-sqrt.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64100.0
Applied rewrites100.0%
(FPCore (x) :precision binary64 (* (/ (exp (* x x)) (sqrt (PI))) (- (- (/ (- (/ 0.5 (* x x)) -1.0) (fabs x)) (/ -1.875 (pow (fabs x) 7.0))) (/ -0.75 (pow (fabs x) 5.0)))))
\begin{array}{l}
\\
\frac{e^{x \cdot x}}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\frac{\frac{0.5}{x \cdot x} - -1}{\left|x\right|} - \frac{-1.875}{{\left(\left|x\right|\right)}^{7}}\right) - \frac{-0.75}{{\left(\left|x\right|\right)}^{5}}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow-expN/A
lift-exp.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
lift-*.f64N/A
lift-exp.f64100.0
Applied rewrites100.0%
(FPCore (x) :precision binary64 (* (/ (exp (* x x)) (sqrt (PI))) (- (- (/ 1.0 (fabs x)) (/ -1.875 (pow (fabs x) 7.0))) (/ -0.75 (pow (fabs x) 5.0)))))
\begin{array}{l}
\\
\frac{e^{x \cdot x}}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \left(\left(\frac{1}{\left|x\right|} - \frac{-1.875}{{\left(\left|x\right|\right)}^{7}}\right) - \frac{-0.75}{{\left(\left|x\right|\right)}^{5}}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow-expN/A
lift-exp.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
lift-*.f64N/A
lift-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ -0.75 (pow (fabs x) 5.0))) (t_1 (sqrt (PI))))
(if (<= x 2e+77)
(* (* (/ 1.0 t_1) (exp (* x x))) (- (/ 0.5 (* (* x x) x)) t_0))
(*
(/ (fma (fma (* x x) 0.5 1.0) (* x x) 1.0) t_1)
(-
(- (/ (- (/ 0.5 (* x x)) -1.0) (fabs x)) (/ -1.875 (pow (fabs x) 7.0)))
t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.75}{{\left(\left|x\right|\right)}^{5}}\\
t_1 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+77}:\\
\;\;\;\;\left(\frac{1}{t\_1} \cdot e^{x \cdot x}\right) \cdot \left(\frac{0.5}{\left(x \cdot x\right) \cdot x} - t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right), x \cdot x, 1\right)}{t\_1} \cdot \left(\left(\frac{\frac{0.5}{x \cdot x} - -1}{\left|x\right|} - \frac{-1.875}{{\left(\left|x\right|\right)}^{7}}\right) - t\_0\right)\\
\end{array}
\end{array}
if x < 1.99999999999999997e77Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites98.8%
Applied rewrites98.8%
if 1.99999999999999997e77 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow-expN/A
lift-exp.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ -0.75 (pow (fabs x) 5.0))) (t_1 (sqrt (PI))))
(if (<= x 6e+107)
(* (* (/ 1.0 t_1) (exp (* x x))) (- (/ (/ 0.5 (fabs x)) (* x x)) t_0))
(*
(/ (fma x x 1.0) t_1)
(-
(- (/ (- (/ 0.5 (* x x)) -1.0) (fabs x)) (/ -1.875 (pow (fabs x) 7.0)))
t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.75}{{\left(\left|x\right|\right)}^{5}}\\
t_1 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;x \leq 6 \cdot 10^{+107}:\\
\;\;\;\;\left(\frac{1}{t\_1} \cdot e^{x \cdot x}\right) \cdot \left(\frac{\frac{0.5}{\left|x\right|}}{x \cdot x} - t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 1\right)}{t\_1} \cdot \left(\left(\frac{\frac{0.5}{x \cdot x} - -1}{\left|x\right|} - \frac{-1.875}{{\left(\left|x\right|\right)}^{7}}\right) - t\_0\right)\\
\end{array}
\end{array}
if x < 6.00000000000000046e107Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites91.7%
Applied rewrites99.1%
if 6.00000000000000046e107 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow-expN/A
lift-exp.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites79.3%
Final simplification86.6%
(FPCore (x) :precision binary64 (* (* (/ 1.0 (sqrt (PI))) (exp (* x x))) (- (/ (/ 0.5 (fabs x)) (* x x)) (/ -0.75 (pow (fabs x) 5.0)))))
\begin{array}{l}
\\
\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{x \cdot x}\right) \cdot \left(\frac{\frac{0.5}{\left|x\right|}}{x \cdot x} - \frac{-0.75}{{\left(\left|x\right|\right)}^{5}}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites33.7%
Applied rewrites36.4%
Final simplification36.4%
(FPCore (x) :precision binary64 (* (* (/ 1.0 (sqrt (PI))) (exp (* x x))) (- (/ 0.5 (* (* x x) x)) (/ -0.75 (pow (fabs x) 5.0)))))
\begin{array}{l}
\\
\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{x \cdot x}\right) \cdot \left(\frac{0.5}{\left(x \cdot x\right) \cdot x} - \frac{-0.75}{{\left(\left|x\right|\right)}^{5}}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites33.7%
Applied rewrites33.7%
Final simplification33.7%
(FPCore (x) :precision binary64 (* (/ (exp (* x x)) (sqrt (PI))) (/ 0.5 (pow (fabs x) 3.0))))
\begin{array}{l}
\\
\frac{e^{x \cdot x}}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{0.5}{{\left(\left|x\right|\right)}^{3}}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-abs-revN/A
pow-expN/A
lift-exp.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
lift-*.f64N/A
lift-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites33.7%
(FPCore (x) :precision binary64 (/ (/ -0.5 (* (- x) x)) (* (sqrt (PI)) x)))
\begin{array}{l}
\\
\frac{\frac{-0.5}{\left(-x\right) \cdot x}}{\sqrt{\mathsf{PI}\left(\right)} \cdot x}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites1.9%
Applied rewrites1.9%
Applied rewrites1.9%
Final simplification1.9%
herbie shell --seed 2025018
(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)))))))