
(FPCore (x) :precision binary64 (exp (- (- 1.0 (* x x)))))
double code(double x) {
return exp(-(1.0 - (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(-(1.0d0 - (x * x)))
end function
public static double code(double x) {
return Math.exp(-(1.0 - (x * x)));
}
def code(x): return math.exp(-(1.0 - (x * x)))
function code(x) return exp(Float64(-Float64(1.0 - Float64(x * x)))) end
function tmp = code(x) tmp = exp(-(1.0 - (x * x))); end
code[x_] := N[Exp[(-N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]
\begin{array}{l}
\\
e^{-\left(1 - x \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (exp (- (- 1.0 (* x x)))))
double code(double x) {
return exp(-(1.0 - (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(-(1.0d0 - (x * x)))
end function
public static double code(double x) {
return Math.exp(-(1.0 - (x * x)));
}
def code(x): return math.exp(-(1.0 - (x * x)))
function code(x) return exp(Float64(-Float64(1.0 - Float64(x * x)))) end
function tmp = code(x) tmp = exp(-(1.0 - (x * x))); end
code[x_] := N[Exp[(-N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]
\begin{array}{l}
\\
e^{-\left(1 - x \cdot x\right)}
\end{array}
(FPCore (x) :precision binary64 (exp (fma x x -1.0)))
double code(double x) {
return exp(fma(x, x, -1.0));
}
function code(x) return exp(fma(x, x, -1.0)) end
code[x_] := N[Exp[N[(x * x + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(x, x, -1\right)}
\end{array}
Initial program 100.0%
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
accelerator-lowering-fma.f64100.0
Applied egg-rr100.0%
(FPCore (x) :precision binary64 (if (<= (* x x) 5e-11) (fma x (/ x E) (/ 1.0 E)) (exp (* x x))))
double code(double x) {
double tmp;
if ((x * x) <= 5e-11) {
tmp = fma(x, (x / ((double) M_E)), (1.0 / ((double) M_E)));
} else {
tmp = exp((x * x));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 5e-11) tmp = fma(x, Float64(x / exp(1)), Float64(1.0 / exp(1))); else tmp = exp(Float64(x * x)); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-11], N[(x * N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], N[Exp[N[(x * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{e}, \frac{1}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{x \cdot x}\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000000018e-11Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
distribute-rgt-inN/A
associate-*l*N/A
un-div-invN/A
div-invN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64100.0
Applied egg-rr100.0%
if 5.00000000000000018e-11 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around inf
unpow2N/A
*-lowering-*.f64100.0
Simplified100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) 0.5)) (t_1 (fma x t_0 x)) (t_2 (* x t_1)))
(if (<= (* x x) 1e+143)
(/ (fma t_2 t_2 -1.0) (* E (fma x t_1 -1.0)))
(* x (* x (/ t_0 E))))))
double code(double x) {
double t_0 = (x * x) * 0.5;
double t_1 = fma(x, t_0, x);
double t_2 = x * t_1;
double tmp;
if ((x * x) <= 1e+143) {
tmp = fma(t_2, t_2, -1.0) / (((double) M_E) * fma(x, t_1, -1.0));
} else {
tmp = x * (x * (t_0 / ((double) M_E)));
}
return tmp;
}
function code(x) t_0 = Float64(Float64(x * x) * 0.5) t_1 = fma(x, t_0, x) t_2 = Float64(x * t_1) tmp = 0.0 if (Float64(x * x) <= 1e+143) tmp = Float64(fma(t_2, t_2, -1.0) / Float64(exp(1) * fma(x, t_1, -1.0))); else tmp = Float64(x * Float64(x * Float64(t_0 / exp(1)))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0 + x), $MachinePrecision]}, Block[{t$95$2 = N[(x * t$95$1), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 1e+143], N[(N[(t$95$2 * t$95$2 + -1.0), $MachinePrecision] / N[(E * N[(x * t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(t$95$0 / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot 0.5\\
t_1 := \mathsf{fma}\left(x, t\_0, x\right)\\
t_2 := x \cdot t\_1\\
\mathbf{if}\;x \cdot x \leq 10^{+143}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_2, t\_2, -1\right)}{e \cdot \mathsf{fma}\left(x, t\_1, -1\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{t\_0}{e}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1e143Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
*-lowering-*.f64N/A
Simplified80.0%
*-commutativeN/A
flip-+N/A
frac-timesN/A
*-rgt-identityN/A
/-lowering-/.f64N/A
Applied egg-rr92.1%
if 1e143 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
*-lowering-*.f64N/A
Simplified100.0%
Taylor expanded in x around inf
Simplified100.0%
Taylor expanded in x around inf
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
cube-multN/A
unpow2N/A
metadata-evalN/A
associate-*r/N/A
associate-*l*N/A
*-lowering-*.f64N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
E-lowering-E.f64100.0
Simplified100.0%
Final simplification95.5%
(FPCore (x) :precision binary64 (fma x (/ (fma (fma x (* x 0.16666666666666666) 0.5) (* x (* x x)) x) E) (/ 1.0 E)))
double code(double x) {
return fma(x, (fma(fma(x, (x * 0.16666666666666666), 0.5), (x * (x * x)), x) / ((double) M_E)), (1.0 / ((double) M_E)));
}
function code(x) return fma(x, Float64(fma(fma(x, Float64(x * 0.16666666666666666), 0.5), Float64(x * Float64(x * x)), x) / exp(1)), Float64(1.0 / exp(1))) end
code[x_] := N[(x * N[(N[(N[(x * N[(x * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \frac{\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right), x \cdot \left(x \cdot x\right), x\right)}{e}, \frac{1}{e}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified93.3%
distribute-rgt-inN/A
div-invN/A
associate-*l*N/A
un-div-invN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr93.4%
(FPCore (x) :precision binary64 (fma x (/ (fma (* (* x x) 0.16666666666666666) (* x (* x x)) x) E) (/ 1.0 E)))
double code(double x) {
return fma(x, (fma(((x * x) * 0.16666666666666666), (x * (x * x)), x) / ((double) M_E)), (1.0 / ((double) M_E)));
}
function code(x) return fma(x, Float64(fma(Float64(Float64(x * x) * 0.16666666666666666), Float64(x * Float64(x * x)), x) / exp(1)), Float64(1.0 / exp(1))) end
code[x_] := N[(x * N[(N[(N[(N[(x * x), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot 0.16666666666666666, x \cdot \left(x \cdot x\right), x\right)}{e}, \frac{1}{e}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified93.3%
distribute-rgt-inN/A
div-invN/A
associate-*l*N/A
un-div-invN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr93.4%
Taylor expanded in x around inf
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6493.4
Simplified93.4%
(FPCore (x) :precision binary64 (if (<= (* x x) 5e-11) (fma x (/ x E) (/ 1.0 E)) (* (* x x) (* x (* x (/ (fma x (* x 0.16666666666666666) 0.5) E))))))
double code(double x) {
double tmp;
if ((x * x) <= 5e-11) {
tmp = fma(x, (x / ((double) M_E)), (1.0 / ((double) M_E)));
} else {
tmp = (x * x) * (x * (x * (fma(x, (x * 0.16666666666666666), 0.5) / ((double) M_E))));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 5e-11) tmp = fma(x, Float64(x / exp(1)), Float64(1.0 / exp(1))); else tmp = Float64(Float64(x * x) * Float64(x * Float64(x * Float64(fma(x, Float64(x * 0.16666666666666666), 0.5) / exp(1))))); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-11], N[(x * N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * N[(N[(x * N[(x * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{e}, \frac{1}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \frac{\mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right)}{e}\right)\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000000018e-11Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
distribute-rgt-inN/A
associate-*l*N/A
un-div-invN/A
div-invN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64100.0
Applied egg-rr100.0%
if 5.00000000000000018e-11 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified87.9%
Taylor expanded in x around inf
Simplified87.9%
(FPCore (x) :precision binary64 (if (<= (* x x) 5e-11) (fma x (/ x E) (/ 1.0 E)) (* (* (* x x) (* x x)) (* 0.16666666666666666 (/ (* x x) E)))))
double code(double x) {
double tmp;
if ((x * x) <= 5e-11) {
tmp = fma(x, (x / ((double) M_E)), (1.0 / ((double) M_E)));
} else {
tmp = ((x * x) * (x * x)) * (0.16666666666666666 * ((x * x) / ((double) M_E)));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 5e-11) tmp = fma(x, Float64(x / exp(1)), Float64(1.0 / exp(1))); else tmp = Float64(Float64(Float64(x * x) * Float64(x * x)) * Float64(0.16666666666666666 * Float64(Float64(x * x) / exp(1)))); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-11], N[(x * N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 * N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{e}, \frac{1}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(0.16666666666666666 \cdot \frac{x \cdot x}{e}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000000018e-11Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
distribute-rgt-inN/A
associate-*l*N/A
un-div-invN/A
div-invN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64100.0
Applied egg-rr100.0%
if 5.00000000000000018e-11 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified87.9%
Taylor expanded in x around inf
associate-*r/N/A
metadata-evalN/A
pow-sqrN/A
cube-prodN/A
unpow2N/A
unpow3N/A
pow-sqrN/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
pow-sqrN/A
associate-*r*N/A
associate-*r/N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
Simplified87.9%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -100000.0) (* x (* (/ x E) (fma x (* x 0.5) 1.0))) (fma x (/ x E) (/ 1.0 E))))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -100000.0) {
tmp = x * ((x / ((double) M_E)) * fma(x, (x * 0.5), 1.0));
} else {
tmp = fma(x, (x / ((double) M_E)), (1.0 / ((double) M_E)));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(1.0 - Float64(x * x)) <= -100000.0) tmp = Float64(x * Float64(Float64(x / exp(1)) * fma(x, Float64(x * 0.5), 1.0))); else tmp = fma(x, Float64(x / exp(1)), Float64(1.0 / exp(1))); end return tmp end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -100000.0], N[(x * N[(N[(x / E), $MachinePrecision] * N[(x * N[(x * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -100000:\\
\;\;\;\;x \cdot \left(\frac{x}{e} \cdot \mathsf{fma}\left(x, x \cdot 0.5, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{e}, \frac{1}{e}\right)\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -1e5Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
*-lowering-*.f64N/A
Simplified79.1%
Taylor expanded in x around inf
Simplified79.1%
if -1e5 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
distribute-rgt-inN/A
associate-*l*N/A
un-div-invN/A
div-invN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64100.0
Applied egg-rr100.0%
Final simplification88.6%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -100000.0) (* x (* x (/ (* (* x x) 0.5) E))) (fma x (/ x E) (/ 1.0 E))))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -100000.0) {
tmp = x * (x * (((x * x) * 0.5) / ((double) M_E)));
} else {
tmp = fma(x, (x / ((double) M_E)), (1.0 / ((double) M_E)));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(1.0 - Float64(x * x)) <= -100000.0) tmp = Float64(x * Float64(x * Float64(Float64(Float64(x * x) * 0.5) / exp(1)))); else tmp = fma(x, Float64(x / exp(1)), Float64(1.0 / exp(1))); end return tmp end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -100000.0], N[(x * N[(x * N[(N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -100000:\\
\;\;\;\;x \cdot \left(x \cdot \frac{\left(x \cdot x\right) \cdot 0.5}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{e}, \frac{1}{e}\right)\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -1e5Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
*-lowering-*.f64N/A
Simplified79.1%
Taylor expanded in x around inf
Simplified79.1%
Taylor expanded in x around inf
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
cube-multN/A
unpow2N/A
metadata-evalN/A
associate-*r/N/A
associate-*l*N/A
*-lowering-*.f64N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
E-lowering-E.f6479.1
Simplified79.1%
if -1e5 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
distribute-rgt-inN/A
associate-*l*N/A
un-div-invN/A
div-invN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64100.0
Applied egg-rr100.0%
(FPCore (x) :precision binary64 (/ (fma x (fma (fma x (* x 0.16666666666666666) 0.5) (* x (* x x)) x) 1.0) E))
double code(double x) {
return fma(x, fma(fma(x, (x * 0.16666666666666666), 0.5), (x * (x * x)), x), 1.0) / ((double) M_E);
}
function code(x) return Float64(fma(x, fma(fma(x, Float64(x * 0.16666666666666666), 0.5), Float64(x * Float64(x * x)), x), 1.0) / exp(1)) end
code[x_] := N[(N[(x * N[(N[(x * N[(x * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right), x \cdot \left(x \cdot x\right), x\right), 1\right)}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified93.3%
*-commutativeN/A
un-div-invN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
accelerator-lowering-fma.f64N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
E-lowering-E.f6493.3
Applied egg-rr93.3%
(FPCore (x) :precision binary64 (/ (fma x (fma x (* (* x x) 0.5) x) 1.0) E))
double code(double x) {
return fma(x, fma(x, ((x * x) * 0.5), x), 1.0) / ((double) M_E);
}
function code(x) return Float64(fma(x, fma(x, Float64(Float64(x * x) * 0.5), x), 1.0) / exp(1)) end
code[x_] := N[(N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] + x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \left(x \cdot x\right) \cdot 0.5, x\right), 1\right)}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
*-lowering-*.f64N/A
Simplified88.5%
*-commutativeN/A
un-div-invN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
accelerator-lowering-fma.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
E-lowering-E.f6488.5
Applied egg-rr88.5%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -100000.0) (* x (/ x E)) (/ 1.0 E)))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -100000.0) {
tmp = x * (x / ((double) M_E));
} else {
tmp = 1.0 / ((double) M_E);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -100000.0) {
tmp = x * (x / Math.E);
} else {
tmp = 1.0 / Math.E;
}
return tmp;
}
def code(x): tmp = 0 if (1.0 - (x * x)) <= -100000.0: tmp = x * (x / math.e) else: tmp = 1.0 / math.e return tmp
function code(x) tmp = 0.0 if (Float64(1.0 - Float64(x * x)) <= -100000.0) tmp = Float64(x * Float64(x / exp(1))); else tmp = Float64(1.0 / exp(1)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((1.0 - (x * x)) <= -100000.0) tmp = x * (x / 2.71828182845904523536); else tmp = 1.0 / 2.71828182845904523536; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -100000.0], N[(x * N[(x / E), $MachinePrecision]), $MachinePrecision], N[(1.0 / E), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -100000:\\
\;\;\;\;x \cdot \frac{x}{e}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -1e5Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f6454.9
Simplified54.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
E-lowering-E.f6454.9
Simplified54.9%
associate-*l/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f6454.9
Applied egg-rr54.9%
if -1e5 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Taylor expanded in x around 0
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f6499.3
Simplified99.3%
Final simplification75.0%
(FPCore (x) :precision binary64 (fma x (/ x E) (/ 1.0 E)))
double code(double x) {
return fma(x, (x / ((double) M_E)), (1.0 / ((double) M_E)));
}
function code(x) return fma(x, Float64(x / exp(1)), Float64(1.0 / exp(1))) end
code[x_] := N[(x * N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \frac{x}{e}, \frac{1}{e}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f6475.3
Simplified75.3%
distribute-rgt-inN/A
associate-*l*N/A
un-div-invN/A
div-invN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f6475.3
Applied egg-rr75.3%
(FPCore (x) :precision binary64 (/ (fma (* x x) E E) (* E E)))
double code(double x) {
return fma((x * x), ((double) M_E), ((double) M_E)) / (((double) M_E) * ((double) M_E));
}
function code(x) return Float64(fma(Float64(x * x), exp(1), exp(1)) / Float64(exp(1) * exp(1))) end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] * E + E), $MachinePrecision] / N[(E * E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x \cdot x, e, e\right)}{e \cdot e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f6475.3
Simplified75.3%
distribute-rgt-inN/A
un-div-invN/A
div-invN/A
frac-addN/A
/-lowering-/.f64N/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
E-lowering-E.f64N/A
E-lowering-E.f64N/A
*-lowering-*.f64N/A
E-lowering-E.f64N/A
E-lowering-E.f6475.3
Applied egg-rr75.3%
(FPCore (x) :precision binary64 (/ (fma x x 1.0) E))
double code(double x) {
return fma(x, x, 1.0) / ((double) M_E);
}
function code(x) return Float64(fma(x, x, 1.0) / exp(1)) end
code[x_] := N[(N[(x * x + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x, x, 1\right)}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f64N/A
unpow2N/A
accelerator-lowering-fma.f6475.3
Simplified75.3%
*-commutativeN/A
un-div-invN/A
/-lowering-/.f64N/A
accelerator-lowering-fma.f64N/A
E-lowering-E.f6475.3
Applied egg-rr75.3%
(FPCore (x) :precision binary64 (/ 1.0 E))
double code(double x) {
return 1.0 / ((double) M_E);
}
public static double code(double x) {
return 1.0 / Math.E;
}
def code(x): return 1.0 / math.e
function code(x) return Float64(1.0 / exp(1)) end
function tmp = code(x) tmp = 1.0 / 2.71828182845904523536; end
code[x_] := N[(1.0 / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
metadata-evalN/A
rec-expN/A
/-lowering-/.f64N/A
exp-1-eN/A
E-lowering-E.f6446.7
Simplified46.7%
herbie shell --seed 2024198
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))