
(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 15 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
(let* ((t_0 (fma (fma x x 0.0) (fma x x 0.0) 0.0)))
(if (<= (* x x) 5e-11)
(+ (/ (fma x x 0.0) E) (/ 1.0 E))
(if (<= (* x x) 1e+143)
(/
(*
(fma (fma x x 0.0) t_0 0.0)
(* x (* x (/ (fma x (* x 0.16666666666666666) 0.5) E))))
t_0)
(* x (* x (* x (/ (* x 0.5) E))))))))
double code(double x) {
double t_0 = fma(fma(x, x, 0.0), fma(x, x, 0.0), 0.0);
double tmp;
if ((x * x) <= 5e-11) {
tmp = (fma(x, x, 0.0) / ((double) M_E)) + (1.0 / ((double) M_E));
} else if ((x * x) <= 1e+143) {
tmp = (fma(fma(x, x, 0.0), t_0, 0.0) * (x * (x * (fma(x, (x * 0.16666666666666666), 0.5) / ((double) M_E))))) / t_0;
} else {
tmp = x * (x * (x * ((x * 0.5) / ((double) M_E))));
}
return tmp;
}
function code(x) t_0 = fma(fma(x, x, 0.0), fma(x, x, 0.0), 0.0) tmp = 0.0 if (Float64(x * x) <= 5e-11) tmp = Float64(Float64(fma(x, x, 0.0) / exp(1)) + Float64(1.0 / exp(1))); elseif (Float64(x * x) <= 1e+143) tmp = Float64(Float64(fma(fma(x, x, 0.0), t_0, 0.0) * Float64(x * Float64(x * Float64(fma(x, Float64(x * 0.16666666666666666), 0.5) / exp(1))))) / t_0); else tmp = Float64(x * Float64(x * Float64(x * Float64(Float64(x * 0.5) / exp(1))))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(x * x + 0.0), $MachinePrecision] * N[(x * x + 0.0), $MachinePrecision] + 0.0), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-11], N[(N[(N[(x * x + 0.0), $MachinePrecision] / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+143], N[(N[(N[(N[(x * x + 0.0), $MachinePrecision] * t$95$0 + 0.0), $MachinePrecision] * N[(x * N[(x * N[(N[(x * N[(x * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(x * N[(x * N[(x * N[(N[(x * 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x, 0\right), 0\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 0\right)}{e} + \frac{1}{e}\\
\mathbf{elif}\;x \cdot x \leq 10^{+143}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), t\_0, 0\right) \cdot \left(x \cdot \left(x \cdot \frac{\mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right)}{e}\right)\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot \frac{x \cdot 0.5}{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-lft-inN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.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) < 1e143Initial program 100.0%
Taylor expanded in x around 0
Simplified45.2%
Taylor expanded in x around inf
Simplified45.2%
associate-*r*N/A
+-rgt-identityN/A
flip3-+N/A
associate-*l/N/A
+-rgt-identityN/A
+-rgt-identityN/A
metadata-evalN/A
sub0-negN/A
mul0-rgtN/A
sub-negN/A
/-lowering-/.f64N/A
Applied egg-rr78.3%
if 1e143 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
Simplified100.0%
Taylor expanded in x around inf
Simplified100.0%
Taylor expanded in x around 0
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
E-lowering-E.f64100.0
Simplified100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (fma (fma x x 0.0) (fma x x 0.0) 0.0)))
(if (<= (* x x) 5e-11)
(+ (/ (fma x x 0.0) E) (/ 1.0 E))
(if (<= (* x x) 1e+143)
(/
(*
(fma (fma x x 0.0) t_0 0.0)
(fma (fma x x 0.0) (fma (fma x x 0.0) 0.16666666666666666 0.0) 0.0))
(* E t_0))
(* x (* x (* x (/ (* x 0.5) E))))))))
double code(double x) {
double t_0 = fma(fma(x, x, 0.0), fma(x, x, 0.0), 0.0);
double tmp;
if ((x * x) <= 5e-11) {
tmp = (fma(x, x, 0.0) / ((double) M_E)) + (1.0 / ((double) M_E));
} else if ((x * x) <= 1e+143) {
tmp = (fma(fma(x, x, 0.0), t_0, 0.0) * fma(fma(x, x, 0.0), fma(fma(x, x, 0.0), 0.16666666666666666, 0.0), 0.0)) / (((double) M_E) * t_0);
} else {
tmp = x * (x * (x * ((x * 0.5) / ((double) M_E))));
}
return tmp;
}
function code(x) t_0 = fma(fma(x, x, 0.0), fma(x, x, 0.0), 0.0) tmp = 0.0 if (Float64(x * x) <= 5e-11) tmp = Float64(Float64(fma(x, x, 0.0) / exp(1)) + Float64(1.0 / exp(1))); elseif (Float64(x * x) <= 1e+143) tmp = Float64(Float64(fma(fma(x, x, 0.0), t_0, 0.0) * fma(fma(x, x, 0.0), fma(fma(x, x, 0.0), 0.16666666666666666, 0.0), 0.0)) / Float64(exp(1) * t_0)); else tmp = Float64(x * Float64(x * Float64(x * Float64(Float64(x * 0.5) / exp(1))))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(x * x + 0.0), $MachinePrecision] * N[(x * x + 0.0), $MachinePrecision] + 0.0), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-11], N[(N[(N[(x * x + 0.0), $MachinePrecision] / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+143], N[(N[(N[(N[(x * x + 0.0), $MachinePrecision] * t$95$0 + 0.0), $MachinePrecision] * N[(N[(x * x + 0.0), $MachinePrecision] * N[(N[(x * x + 0.0), $MachinePrecision] * 0.16666666666666666 + 0.0), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision] / N[(E * t$95$0), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(x * N[(N[(x * 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x, 0\right), 0\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 0\right)}{e} + \frac{1}{e}\\
\mathbf{elif}\;x \cdot x \leq 10^{+143}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), t\_0, 0\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), 0.16666666666666666, 0\right), 0\right)}{e \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot \frac{x \cdot 0.5}{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-lft-inN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.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) < 1e143Initial program 100.0%
Taylor expanded in x around 0
Simplified45.2%
Taylor expanded in x around inf
Simplified45.2%
Taylor expanded in x around inf
associate-*r/N/A
metadata-evalN/A
pow-sqrN/A
associate-*l*N/A
*-commutativeN/A
/-lowering-/.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
unpow3N/A
*-lowering-*.f64N/A
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
E-lowering-E.f6445.2
Simplified45.2%
Applied egg-rr78.3%
if 1e143 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
Simplified100.0%
Taylor expanded in x around inf
Simplified100.0%
Taylor expanded in x around 0
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
E-lowering-E.f64100.0
Simplified100.0%
Final simplification97.4%
(FPCore (x) :precision binary64 (if (<= (* x x) 5e-11) (+ (/ (fma x x 0.0) E) (/ 1.0 E)) (* (/ (* x x) E) (fma (* x x) (fma x (* x 0.16666666666666666) 0.5) 1.0))))
double code(double x) {
double tmp;
if ((x * x) <= 5e-11) {
tmp = (fma(x, x, 0.0) / ((double) M_E)) + (1.0 / ((double) M_E));
} else {
tmp = ((x * x) / ((double) M_E)) * fma((x * x), fma(x, (x * 0.16666666666666666), 0.5), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 5e-11) tmp = Float64(Float64(fma(x, x, 0.0) / exp(1)) + Float64(1.0 / exp(1))); else tmp = Float64(Float64(Float64(x * x) / exp(1)) * fma(Float64(x * x), fma(x, Float64(x * 0.16666666666666666), 0.5), 1.0)); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-11], N[(N[(N[(x * x + 0.0), $MachinePrecision] / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 0\right)}{e} + \frac{1}{e}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{e} \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right), 1\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-lft-inN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.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
Simplified87.9%
flip-+N/A
/-lowering-/.f64N/A
Applied egg-rr35.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6487.9
Simplified87.9%
Taylor expanded in x around inf
Simplified87.9%
(FPCore (x) :precision binary64 (if (<= (* x x) 5e-11) (+ (/ (fma x x 0.0) 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, 0.0) / ((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 = Float64(Float64(fma(x, x, 0.0) / exp(1)) + Float64(1.0 / exp(1))); else tmp = Float64(x * Float64(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[(N[(N[(x * x + 0.0), $MachinePrecision] / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(x * N[(x * N[(N[(x * N[(x * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 0\right)}{e} + \frac{1}{e}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{\mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right)}{e}\right)\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-lft-inN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.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
Simplified87.9%
Taylor expanded in x around inf
Simplified87.9%
(FPCore (x) :precision binary64 (if (<= (* x x) 5e-11) (+ (/ (fma x x 0.0) E) (/ 1.0 E)) (* x (* x (* x (* x (/ (* (* x x) 0.16666666666666666) E)))))))
double code(double x) {
double tmp;
if ((x * x) <= 5e-11) {
tmp = (fma(x, x, 0.0) / ((double) M_E)) + (1.0 / ((double) M_E));
} else {
tmp = x * (x * (x * (x * (((x * x) * 0.16666666666666666) / ((double) M_E)))));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 5e-11) tmp = Float64(Float64(fma(x, x, 0.0) / exp(1)) + Float64(1.0 / exp(1))); else tmp = Float64(x * Float64(x * Float64(x * Float64(x * Float64(Float64(Float64(x * x) * 0.16666666666666666) / exp(1)))))); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-11], N[(N[(N[(x * x + 0.0), $MachinePrecision] / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(x * N[(x * N[(N[(N[(x * x), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 0\right)}{e} + \frac{1}{e}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{\left(x \cdot x\right) \cdot 0.16666666666666666}{e}\right)\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-lft-inN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.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
Simplified87.9%
Taylor expanded in x around inf
Simplified87.9%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
E-lowering-E.f6487.9
Simplified87.9%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -100000.0) (* x (* (fma x (* x 0.5) 1.0) (/ x E))) (+ (/ (fma x x 0.0) E) (/ 1.0 E))))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -100000.0) {
tmp = x * (fma(x, (x * 0.5), 1.0) * (x / ((double) M_E)));
} else {
tmp = (fma(x, x, 0.0) / ((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(fma(x, Float64(x * 0.5), 1.0) * Float64(x / exp(1)))); else tmp = Float64(Float64(fma(x, x, 0.0) / 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 * N[(x * 0.5), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x + 0.0), $MachinePrecision] / 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(\mathsf{fma}\left(x, x \cdot 0.5, 1\right) \cdot \frac{x}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 0\right)}{e} + \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
*-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-lft-inN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.f64N/A
E-lowering-E.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64100.0
Applied egg-rr100.0%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -100000.0) (* x (* x (* x (/ (* x 0.5) E)))) (+ (/ (fma x x 0.0) 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, 0.0) / ((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(x * Float64(Float64(x * 0.5) / exp(1))))); else tmp = Float64(Float64(fma(x, x, 0.0) / 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[(x * N[(N[(x * 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x + 0.0), $MachinePrecision] / 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 \left(x \cdot \frac{x \cdot 0.5}{e}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, 0\right)}{e} + \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
Simplified87.9%
Taylor expanded in x around inf
Simplified87.9%
Taylor expanded in x around 0
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/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-lft-inN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.f64N/A
E-lowering-E.f64N/A
/-lowering-/.f64N/A
E-lowering-E.f64100.0
Applied egg-rr100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (- 1.0 (* x x))))
(if (<= t_0 -100000.0)
(* x (* x (* x (/ (* x 0.5) E))))
(/ 1.0 (* E t_0)))))
double code(double x) {
double t_0 = 1.0 - (x * x);
double tmp;
if (t_0 <= -100000.0) {
tmp = x * (x * (x * ((x * 0.5) / ((double) M_E))));
} else {
tmp = 1.0 / (((double) M_E) * t_0);
}
return tmp;
}
public static double code(double x) {
double t_0 = 1.0 - (x * x);
double tmp;
if (t_0 <= -100000.0) {
tmp = x * (x * (x * ((x * 0.5) / Math.E)));
} else {
tmp = 1.0 / (Math.E * t_0);
}
return tmp;
}
def code(x): t_0 = 1.0 - (x * x) tmp = 0 if t_0 <= -100000.0: tmp = x * (x * (x * ((x * 0.5) / math.e))) else: tmp = 1.0 / (math.e * t_0) return tmp
function code(x) t_0 = Float64(1.0 - Float64(x * x)) tmp = 0.0 if (t_0 <= -100000.0) tmp = Float64(x * Float64(x * Float64(x * Float64(Float64(x * 0.5) / exp(1))))); else tmp = Float64(1.0 / Float64(exp(1) * t_0)); end return tmp end
function tmp_2 = code(x) t_0 = 1.0 - (x * x); tmp = 0.0; if (t_0 <= -100000.0) tmp = x * (x * (x * ((x * 0.5) / 2.71828182845904523536))); else tmp = 1.0 / (2.71828182845904523536 * t_0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], N[(x * N[(x * N[(x * N[(N[(x * 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(E * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - x \cdot x\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot \frac{x \cdot 0.5}{e}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e \cdot t\_0}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -1e5Initial program 100.0%
Taylor expanded in x around 0
Simplified87.9%
Taylor expanded in x around inf
Simplified87.9%
Taylor expanded in x around 0
associate-*r/N/A
/-lowering-/.f64N/A
*-commutativeN/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
Simplified100.0%
associate-*l/N/A
clear-numN/A
/-lowering-/.f64N/A
*-lft-identityN/A
/-lowering-/.f64N/A
E-lowering-E.f64N/A
+-rgt-identityN/A
associate-*l*N/A
Applied egg-rr100.0%
Taylor expanded in x around 0
associate-*r*N/A
distribute-rgt1-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
E-lowering-E.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f64100.0
Simplified100.0%
(FPCore (x) :precision binary64 (/ (fma x (* x (fma x (* x (fma x (* x 0.16666666666666666) 0.5)) 1.0)) 1.0) E))
double code(double x) {
return fma(x, (x * fma(x, (x * fma(x, (x * 0.16666666666666666), 0.5)), 1.0)), 1.0) / ((double) M_E);
}
function code(x) return Float64(fma(x, Float64(x * fma(x, Float64(x * fma(x, Float64(x * 0.16666666666666666), 0.5)), 1.0)), 1.0) / exp(1)) end
code[x_] := N[(N[(x * N[(x * N[(x * N[(x * N[(x * N[(x * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right), 1\right), 1\right)}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Simplified93.3%
*-commutativeN/A
un-div-invN/A
/-lowering-/.f64N/A
Applied egg-rr93.3%
(FPCore (x) :precision binary64 (/ (fma x (* x (fma (fma x x 0.0) 0.5 1.0)) 1.0) E))
double code(double x) {
return fma(x, (x * fma(fma(x, x, 0.0), 0.5, 1.0)), 1.0) / ((double) M_E);
}
function code(x) return Float64(fma(x, Float64(x * fma(fma(x, x, 0.0), 0.5, 1.0)), 1.0) / exp(1)) end
code[x_] := N[(N[(x * N[(x * N[(N[(x * x + 0.0), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), 0.5, 1\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
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
*-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 0
/-lowering-/.f64N/A
E-lowering-E.f6454.9
Simplified54.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%
(FPCore (x) :precision binary64 (/ (fma (fma x x 0.0) E E) (* E E)))
double code(double x) {
return fma(fma(x, x, 0.0), ((double) M_E), ((double) M_E)) / (((double) M_E) * ((double) M_E));
}
function code(x) return Float64(fma(fma(x, x, 0.0), exp(1), exp(1)) / Float64(exp(1) * exp(1))) end
code[x_] := N[(N[(N[(x * x + 0.0), $MachinePrecision] * E + E), $MachinePrecision] / N[(E * E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), 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
div-invN/A
un-div-invN/A
frac-addN/A
/-lowering-/.f64N/A
*-commutativeN/A
*-un-lft-identityN/A
accelerator-lowering-fma.f64N/A
+-rgt-identityN/A
accelerator-lowering-fma.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)))))