
(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 4 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 (pow (fabs x) -1.0)) (t_1 (/ -1.0 (fabs x))))
(*
(* (pow (sqrt (PI)) -1.0) (exp (* x x)))
(+
(fma (- (fma 0.75 (pow x -4.0) 1.0)) (/ -1.0 x) (* 0.5 (pow x -3.0)))
(* (/ 15.0 8.0) (* (* (* (* t_1 (/ t_1 (* x x))) t_0) t_0) t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\left|x\right|\right)}^{-1}\\
t_1 := \frac{-1}{\left|x\right|}\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot e^{x \cdot x}\right) \cdot \left(\mathsf{fma}\left(-\mathsf{fma}\left(0.75, {x}^{-4}, 1\right), \frac{-1}{x}, 0.5 \cdot {x}^{-3}\right) + \frac{15}{8} \cdot \left(\left(\left(\left(t\_1 \cdot \frac{t\_1}{x \cdot x}\right) \cdot t\_0\right) \cdot t\_0\right) \cdot t\_0\right)\right)
\end{array}
\end{array}
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-/.f64N/A
cube-divN/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
div-invN/A
cube-multN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ -1.0 (fabs x)))
(t_1 (pow (fabs x) -1.0))
(t_2 (* (* t_0 t_0) t_1))
(t_3 (* (* t_2 t_1) t_1)))
(*
(* (pow (sqrt (PI)) -1.0) (exp (* x x)))
(+
(+ (+ t_1 (* (pow 2.0 -1.0) t_2)) (* (/ 3.0 4.0) t_3))
(* (/ 15.0 8.0) (* (* t_3 t_1) t_1))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{\left|x\right|}\\
t_1 := {\left(\left|x\right|\right)}^{-1}\\
t_2 := \left(t\_0 \cdot t\_0\right) \cdot t\_1\\
t_3 := \left(t\_2 \cdot t\_1\right) \cdot t\_1\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot e^{x \cdot x}\right) \cdot \left(\left(\left(t\_1 + {2}^{-1} \cdot t\_2\right) + \frac{3}{4} \cdot t\_3\right) + \frac{15}{8} \cdot \left(\left(t\_3 \cdot t\_1\right) \cdot t\_1\right)\right)
\end{array}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ -1.0 (fabs x))) (t_1 (pow (fabs x) -1.0)))
(*
(* (pow (sqrt (PI)) -1.0) (exp (* x x)))
(+
(+ t_1 (* (/ 3.0 4.0) (* (* t_0 (/ t_0 (* x x))) t_1)))
(*
(/ 15.0 8.0)
(* (* (* (/ (/ -1.0 x) (* (fabs x) (* x x))) t_1) t_1) t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{\left|x\right|}\\
t_1 := {\left(\left|x\right|\right)}^{-1}\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot e^{x \cdot x}\right) \cdot \left(\left(t\_1 + \frac{3}{4} \cdot \left(\left(t\_0 \cdot \frac{t\_0}{x \cdot x}\right) \cdot t\_1\right)\right) + \frac{15}{8} \cdot \left(\left(\left(\frac{\frac{-1}{x}}{\left|x\right| \cdot \left(x \cdot x\right)} \cdot t\_1\right) \cdot t\_1\right) \cdot t\_0\right)\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 rewrites49.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-/.f64N/A
cube-divN/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
div-invN/A
cube-multN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
Applied rewrites49.6%
Applied rewrites49.6%
Taylor expanded in x around inf
unpow2N/A
sqr-absN/A
associate-/r*N/A
*-inversesN/A
lower-/.f64N/A
lower-fabs.f6499.5
Applied rewrites99.5%
Final simplification99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ -1.0 (fabs x))) (t_1 (pow (fabs x) -1.0)))
(*
(* (pow (sqrt (PI)) -1.0) (exp (* x x)))
(+
(+
(/ (+ (/ 0.5 (* x x)) 1.0) (fabs x))
(* (/ 3.0 4.0) (* (* t_0 (/ t_0 (* x x))) t_1)))
(*
(/ 15.0 8.0)
(* (* (* (/ (/ -1.0 x) (* (fabs x) (* x x))) t_1) t_1) t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{\left|x\right|}\\
t_1 := {\left(\left|x\right|\right)}^{-1}\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot e^{x \cdot x}\right) \cdot \left(\left(\frac{\frac{0.5}{x \cdot x} + 1}{\left|x\right|} + \frac{3}{4} \cdot \left(\left(t\_0 \cdot \frac{t\_0}{x \cdot x}\right) \cdot t\_1\right)\right) + \frac{15}{8} \cdot \left(\left(\left(\frac{\frac{-1}{x}}{\left|x\right| \cdot \left(x \cdot x\right)} \cdot t\_1\right) \cdot t\_1\right) \cdot t\_0\right)\right)
\end{array}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
unpow3N/A
unpow2N/A
associate-/r*N/A
associate-*r/N/A
*-lft-identityN/A
associate-*l/N/A
*-rgt-identityN/A
distribute-lft-inN/A
associate-*l/N/A
*-commutativeN/A
*-rgt-identityN/A
lower-/.f64N/A
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-/.f64N/A
cube-divN/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
div-invN/A
cube-multN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
herbie shell --seed 2024308
(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)))))))