
(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 8 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 (* (* (pow (sqrt (PI)) -1.0) (pow (exp (- x)) (- x))) (+ (fma (pow (fabs x) -5.0) 0.75 (* (pow (fabs x) -7.0) 1.875)) (fma (pow x -3.0) 0.5 (pow (fabs x) -1.0)))))
\begin{array}{l}
\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot {\left(e^{-x}\right)}^{\left(-x\right)}\right) \cdot \left(\mathsf{fma}\left({\left(\left|x\right|\right)}^{-5}, 0.75, {\left(\left|x\right|\right)}^{-7} \cdot 1.875\right) + \mathsf{fma}\left({x}^{-3}, 0.5, {\left(\left|x\right|\right)}^{-1}\right)\right)
\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
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-plusN/A
lift-/.f64N/A
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
metadata-evalN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
inv-powN/A
metadata-evalN/A
frac-timesN/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
neg-fabsN/A
lift-neg.f64N/A
lift-fabs.f64N/A
neg-fabsN/A
lift-neg.f64N/A
sqr-absN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (pow (fabs x) -1.0)))
(*
(* (pow (sqrt (PI)) -1.0) (pow (exp x) x))
(+
(-
(/ (+ (/ 0.5 (* x x)) 1.0) (fabs x))
(* (/ 3.0 4.0) (* (/ -1.0 (* (* x x) (* x x))) t_0)))
(*
(/ 15.0 8.0)
(* (* (* (/ -1.0 (* (* (* x x) -1.0) (* x x))) t_0) t_0) t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\left|x\right|\right)}^{-1}\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot {\left(e^{x}\right)}^{x}\right) \cdot \left(\left(\frac{\frac{0.5}{x \cdot x} + 1}{\left|x\right|} - \frac{3}{4} \cdot \left(\frac{-1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot t\_0\right)\right) + \frac{15}{8} \cdot \left(\left(\left(\frac{-1}{\left(\left(x \cdot x\right) \cdot -1\right) \cdot \left(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%
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
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-plusN/A
lift-/.f64N/A
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
metadata-evalN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
inv-powN/A
metadata-evalN/A
frac-timesN/A
Applied rewrites100.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-plusN/A
lift-/.f64N/A
inv-powN/A
metadata-evalN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
inv-powN/A
metadata-evalN/A
frac-timesN/A
clear-numN/A
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 (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) (* (/ -1.0 (* (* x x) (* x x))) t_0)))
(*
(/ 15.0 8.0)
(* (* (* (/ -1.0 (* (* (* x x) -1.0) (* x x))) t_0) t_0) t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\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(\frac{-1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot t\_0\right)\right) + \frac{15}{8} \cdot \left(\left(\left(\frac{-1}{\left(\left(x \cdot x\right) \cdot -1\right) \cdot \left(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%
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
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-plusN/A
lift-/.f64N/A
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
metadata-evalN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
inv-powN/A
metadata-evalN/A
frac-timesN/A
Applied rewrites100.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-plusN/A
lift-/.f64N/A
inv-powN/A
metadata-evalN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
inv-powN/A
metadata-evalN/A
frac-timesN/A
clear-numN/A
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(*
(* (pow (sqrt (PI)) -1.0) (pow (exp (- x)) (- x)))
(+
(-
(/ (+ (/ 0.5 (* x x)) 1.0) (fabs x))
(* (/ 3.0 4.0) (* (/ -1.0 (* (* x x) (* x x))) (pow (fabs x) -1.0))))
(* (/ 15.0 8.0) (pow (fabs x) -7.0)))))\begin{array}{l}
\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot {\left(e^{-x}\right)}^{\left(-x\right)}\right) \cdot \left(\left(\frac{\frac{0.5}{x \cdot x} + 1}{\left|x\right|} - \frac{3}{4} \cdot \left(\frac{-1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot {\left(\left|x\right|\right)}^{-1}\right)\right) + \frac{15}{8} \cdot {\left(\left|x\right|\right)}^{-7}\right)
\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
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
pow-plusN/A
lift-/.f64N/A
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
metadata-evalN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
inv-powN/A
metadata-evalN/A
frac-timesN/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
neg-fabsN/A
lift-neg.f64N/A
lift-fabs.f64N/A
neg-fabsN/A
lift-neg.f64N/A
sqr-absN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
inv-powN/A
lift-*.f64N/A
associate-*l*N/A
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (* (* (pow (sqrt (PI)) -1.0) (exp (* x x))) (/ -1.0 (- (/ 0.5 (fabs x)) (fabs x)))))
\begin{array}{l}
\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot e^{x \cdot x}\right) \cdot \frac{-1}{\frac{0.5}{\left|x\right|} - \left|x\right|}
\end{array}
Initial program 100.0%
Applied rewrites46.8%
Taylor expanded in x around 0
lower-/.f64N/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
lft-mult-inverseN/A
distribute-rgt-neg-inN/A
*-lft-identityN/A
unsub-negN/A
Applied rewrites99.8%
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (* (exp (fma x x (* -0.5 (log (PI))))) (/ -1.0 (- (/ 0.5 (fabs x)) (fabs x)))))
\begin{array}{l}
\\
e^{\mathsf{fma}\left(x, x, -0.5 \cdot \log \mathsf{PI}\left(\right)\right)} \cdot \frac{-1}{\frac{0.5}{\left|x\right|} - \left|x\right|}
\end{array}
Initial program 100.0%
Applied rewrites46.8%
Taylor expanded in x around 0
lower-/.f64N/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
lft-mult-inverseN/A
distribute-rgt-neg-inN/A
*-lft-identityN/A
unsub-negN/A
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
div-expN/A
lower-exp.f64N/A
lower--.f64N/A
rem-log-expN/A
pow-to-expN/A
pow1/2N/A
lift-sqrt.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
neg-logN/A
lift-sqrt.f64N/A
pow1/2N/A
metadata-evalN/A
pow-flipN/A
log-powN/A
lift-PI.f64N/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
lift-PI.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
(FPCore (x) :precision binary64 (* (* (pow (sqrt (PI)) -1.0) 1.0) (/ -1.0 (- (/ 0.5 (fabs x)) (fabs x)))))
\begin{array}{l}
\\
\left({\left(\sqrt{\mathsf{PI}\left(\right)}\right)}^{-1} \cdot 1\right) \cdot \frac{-1}{\frac{0.5}{\left|x\right|} - \left|x\right|}
\end{array}
Initial program 100.0%
Applied rewrites46.8%
Taylor expanded in x around 0
lower-/.f64N/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
lft-mult-inverseN/A
distribute-rgt-neg-inN/A
*-lft-identityN/A
unsub-negN/A
Applied rewrites99.8%
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites2.3%
Final simplification2.3%
(FPCore (x) :precision binary64 (* (/ (fma x x 1.0) (sqrt (PI))) (/ -1.0 (- (/ 0.5 (fabs x)) (fabs x)))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x, x, 1\right)}{\sqrt{\mathsf{PI}\left(\right)}} \cdot \frac{-1}{\frac{0.5}{\left|x\right|} - \left|x\right|}
\end{array}
Initial program 100.0%
Applied rewrites46.8%
Taylor expanded in x around 0
lower-/.f64N/A
sub-negN/A
distribute-lft-inN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
unpow2N/A
sqr-absN/A
associate-*r*N/A
lft-mult-inverseN/A
distribute-rgt-neg-inN/A
*-lft-identityN/A
unsub-negN/A
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lift-exp.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-fabs.f64N/A
sqr-absN/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
pow-to-expN/A
div-expN/A
lower-exp.f64N/A
lower--.f64N/A
rem-log-expN/A
pow-to-expN/A
pow1/2N/A
lift-sqrt.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
distribute-rgt1-inN/A
exp-negN/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
rem-exp-logN/A
lower-sqrt.f64N/A
lower-PI.f6454.9
Applied rewrites54.9%
herbie shell --seed 2024312
(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)))))))