
(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%
lift-neg.f64N/A
neg-sub0N/A
lift--.f64N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x) :precision binary64 (if (<= (exp (- (* x x) 1.0)) 0.5) (/ (fma (fma (* x x) 0.5 1.0) (* x x) 1.0) E) (* (/ (* x x) E) (fma (fma 0.16666666666666666 (* x x) 0.5) (* x x) 1.0))))
double code(double x) {
double tmp;
if (exp(((x * x) - 1.0)) <= 0.5) {
tmp = fma(fma((x * x), 0.5, 1.0), (x * x), 1.0) / ((double) M_E);
} else {
tmp = ((x * x) / ((double) M_E)) * fma(fma(0.16666666666666666, (x * x), 0.5), (x * x), 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (exp(Float64(Float64(x * x) - 1.0)) <= 0.5) tmp = Float64(fma(fma(Float64(x * x), 0.5, 1.0), Float64(x * x), 1.0) / exp(1)); else tmp = Float64(Float64(Float64(x * x) / exp(1)) * fma(fma(0.16666666666666666, Float64(x * x), 0.5), Float64(x * x), 1.0)); end return tmp end
code[x_] := If[LessEqual[N[Exp[N[(N[(x * x), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision], 0.5], N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision] * N[(N[(0.16666666666666666 * N[(x * x), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{x \cdot x - 1} \leq 0.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right), x \cdot x, 1\right)}{e}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{e} \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x \cdot x, 0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x)))) < 0.5Initial program 100.0%
Taylor expanded in x around 0
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt1-inN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Applied rewrites99.9%
if 0.5 < (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x)))) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites82.6%
Taylor expanded in x around inf
Applied rewrites82.6%
Final simplification91.5%
(FPCore (x) :precision binary64 (if (<= (exp (- (* x x) 1.0)) 0.5) (/ (fma (fma (* x x) 0.5 1.0) (* x x) 1.0) E) (* (* (/ (* x x) E) x) (* (* 0.16666666666666666 (* x x)) x))))
double code(double x) {
double tmp;
if (exp(((x * x) - 1.0)) <= 0.5) {
tmp = fma(fma((x * x), 0.5, 1.0), (x * x), 1.0) / ((double) M_E);
} else {
tmp = (((x * x) / ((double) M_E)) * x) * ((0.16666666666666666 * (x * x)) * x);
}
return tmp;
}
function code(x) tmp = 0.0 if (exp(Float64(Float64(x * x) - 1.0)) <= 0.5) tmp = Float64(fma(fma(Float64(x * x), 0.5, 1.0), Float64(x * x), 1.0) / exp(1)); else tmp = Float64(Float64(Float64(Float64(x * x) / exp(1)) * x) * Float64(Float64(0.16666666666666666 * Float64(x * x)) * x)); end return tmp end
code[x_] := If[LessEqual[N[Exp[N[(N[(x * x), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision], 0.5], N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision], N[(N[(N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision] * x), $MachinePrecision] * N[(N[(0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{x \cdot x - 1} \leq 0.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right), x \cdot x, 1\right)}{e}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x \cdot x}{e} \cdot x\right) \cdot \left(\left(0.16666666666666666 \cdot \left(x \cdot x\right)\right) \cdot x\right)\\
\end{array}
\end{array}
if (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x)))) < 0.5Initial program 100.0%
Taylor expanded in x around 0
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt1-inN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Applied rewrites99.9%
if 0.5 < (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x)))) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites82.6%
Taylor expanded in x around inf
Applied rewrites82.6%
Final simplification91.5%
(FPCore (x)
:precision binary64
(if (<= (* x x) 2e-5)
(fma
(/ x E)
(* (fma (* x x) (fma (* 0.16666666666666666 x) x 0.5) 1.0) x)
(/ 1.0 E))
(exp (* x x))))
double code(double x) {
double tmp;
if ((x * x) <= 2e-5) {
tmp = fma((x / ((double) M_E)), (fma((x * x), fma((0.16666666666666666 * x), x, 0.5), 1.0) * x), (1.0 / ((double) M_E)));
} else {
tmp = exp((x * x));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 2e-5) tmp = fma(Float64(x / exp(1)), Float64(fma(Float64(x * x), fma(Float64(0.16666666666666666 * x), x, 0.5), 1.0) * x), Float64(1.0 / exp(1))); else tmp = exp(Float64(x * x)); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e-5], N[(N[(x / E), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * N[(N[(0.16666666666666666 * x), $MachinePrecision] * x + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] * x), $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 2 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{e}, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.16666666666666666 \cdot x, x, 0.5\right), 1\right) \cdot x, \frac{1}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{x \cdot x}\\
\end{array}
\end{array}
if (*.f64 x x) < 2.00000000000000016e-5Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
if 2.00000000000000016e-5 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (fma (/ x E) (* (fma (* x x) (fma (* 0.16666666666666666 x) x 0.5) 1.0) x) (/ 1.0 E)))
double code(double x) {
return fma((x / ((double) M_E)), (fma((x * x), fma((0.16666666666666666 * x), x, 0.5), 1.0) * x), (1.0 / ((double) M_E)));
}
function code(x) return fma(Float64(x / exp(1)), Float64(fma(Float64(x * x), fma(Float64(0.16666666666666666 * x), x, 0.5), 1.0) * x), Float64(1.0 / exp(1))) end
code[x_] := N[(N[(x / E), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * N[(N[(0.16666666666666666 * x), $MachinePrecision] * x + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{e}, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.16666666666666666 \cdot x, x, 0.5\right), 1\right) \cdot x, \frac{1}{e}\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites91.5%
Applied rewrites91.5%
Applied rewrites91.5%
Final simplification91.5%
(FPCore (x) :precision binary64 (if (<= (* x x) 2e-5) (/ (fma (fma (* x x) 0.5 1.0) (* x x) 1.0) E) (* (/ (fma 0.16666666666666666 (* x x) 0.5) E) (* (* (* x x) x) x))))
double code(double x) {
double tmp;
if ((x * x) <= 2e-5) {
tmp = fma(fma((x * x), 0.5, 1.0), (x * x), 1.0) / ((double) M_E);
} else {
tmp = (fma(0.16666666666666666, (x * x), 0.5) / ((double) M_E)) * (((x * x) * x) * x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 2e-5) tmp = Float64(fma(fma(Float64(x * x), 0.5, 1.0), Float64(x * x), 1.0) / exp(1)); else tmp = Float64(Float64(fma(0.16666666666666666, Float64(x * x), 0.5) / exp(1)) * Float64(Float64(Float64(x * x) * x) * x)); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e-5], N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision], N[(N[(N[(0.16666666666666666 * N[(x * x), $MachinePrecision] + 0.5), $MachinePrecision] / E), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right), x \cdot x, 1\right)}{e}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.16666666666666666, x \cdot x, 0.5\right)}{e} \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 2.00000000000000016e-5Initial program 100.0%
Taylor expanded in x around 0
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt1-inN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Applied rewrites99.9%
if 2.00000000000000016e-5 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites82.6%
Taylor expanded in x around inf
Applied rewrites82.6%
Taylor expanded in x around 0
Applied rewrites82.6%
Final simplification91.5%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -500.0) (* (* (fma 0.5 (* x x) 1.0) (/ x E)) x) (- (/ (* x x) E) (/ -1.0 E))))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -500.0) {
tmp = (fma(0.5, (x * x), 1.0) * (x / ((double) M_E))) * x;
} else {
tmp = ((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)) <= -500.0) tmp = Float64(Float64(fma(0.5, Float64(x * x), 1.0) * Float64(x / exp(1))) * x); else tmp = Float64(Float64(Float64(x * x) / exp(1)) - Float64(-1.0 / exp(1))); end return tmp end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -500.0], N[(N[(N[(0.5 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x / E), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision] - N[(-1.0 / E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -500:\\
\;\;\;\;\left(\mathsf{fma}\left(0.5, x \cdot x, 1\right) \cdot \frac{x}{e}\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{e} - \frac{-1}{e}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -500Initial program 100.0%
Taylor expanded in x around 0
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt1-inN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites76.6%
Taylor expanded in x around inf
Applied rewrites76.6%
Applied rewrites76.6%
Applied rewrites76.6%
if -500 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6499.5
Applied rewrites99.5%
Applied rewrites99.5%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -500.0) (* (* (/ 0.5 E) x) (* (* x x) x)) (- (/ (* x x) E) (/ -1.0 E))))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -500.0) {
tmp = ((0.5 / ((double) M_E)) * x) * ((x * x) * x);
} else {
tmp = ((x * x) / ((double) M_E)) - (-1.0 / ((double) M_E));
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -500.0) {
tmp = ((0.5 / Math.E) * x) * ((x * x) * x);
} else {
tmp = ((x * x) / Math.E) - (-1.0 / Math.E);
}
return tmp;
}
def code(x): tmp = 0 if (1.0 - (x * x)) <= -500.0: tmp = ((0.5 / math.e) * x) * ((x * x) * x) else: tmp = ((x * x) / math.e) - (-1.0 / math.e) return tmp
function code(x) tmp = 0.0 if (Float64(1.0 - Float64(x * x)) <= -500.0) tmp = Float64(Float64(Float64(0.5 / exp(1)) * x) * Float64(Float64(x * x) * x)); else tmp = Float64(Float64(Float64(x * x) / exp(1)) - Float64(-1.0 / exp(1))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((1.0 - (x * x)) <= -500.0) tmp = ((0.5 / 2.71828182845904523536) * x) * ((x * x) * x); else tmp = ((x * x) / 2.71828182845904523536) - (-1.0 / 2.71828182845904523536); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -500.0], N[(N[(N[(0.5 / E), $MachinePrecision] * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision] - N[(-1.0 / E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -500:\\
\;\;\;\;\left(\frac{0.5}{e} \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{e} - \frac{-1}{e}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -500Initial program 100.0%
Taylor expanded in x around 0
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt1-inN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites76.6%
Taylor expanded in x around inf
Applied rewrites76.6%
if -500 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6499.5
Applied rewrites99.5%
Applied rewrites99.5%
Final simplification88.3%
(FPCore (x) :precision binary64 (/ (fma (fma (fma 0.16666666666666666 (* x x) 0.5) (* x x) 1.0) (* x x) 1.0) E))
double code(double x) {
return fma(fma(fma(0.16666666666666666, (x * x), 0.5), (x * x), 1.0), (x * x), 1.0) / ((double) M_E);
}
function code(x) return Float64(fma(fma(fma(0.16666666666666666, Float64(x * x), 0.5), Float64(x * x), 1.0), Float64(x * x), 1.0) / exp(1)) end
code[x_] := N[(N[(N[(N[(0.16666666666666666 * N[(x * x), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x \cdot x, 0.5\right), x \cdot x, 1\right), x \cdot x, 1\right)}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites91.5%
Applied rewrites91.5%
(FPCore (x) :precision binary64 (/ (fma (fma (* x x) 0.5 1.0) (* x x) 1.0) E))
double code(double x) {
return fma(fma((x * x), 0.5, 1.0), (x * x), 1.0) / ((double) M_E);
}
function code(x) return Float64(fma(fma(Float64(x * x), 0.5, 1.0), Float64(x * x), 1.0) / exp(1)) end
code[x_] := N[(N[(N[(N[(x * x), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right), x \cdot x, 1\right)}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt1-inN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites88.5%
Applied rewrites88.5%
(FPCore (x) :precision binary64 (- (/ (* x x) E) (/ -1.0 E)))
double code(double x) {
return ((x * x) / ((double) M_E)) - (-1.0 / ((double) M_E));
}
public static double code(double x) {
return ((x * x) / Math.E) - (-1.0 / Math.E);
}
def code(x): return ((x * x) / math.e) - (-1.0 / math.e)
function code(x) return Float64(Float64(Float64(x * x) / exp(1)) - Float64(-1.0 / exp(1))) end
function tmp = code(x) tmp = ((x * x) / 2.71828182845904523536) - (-1.0 / 2.71828182845904523536); end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision] - N[(-1.0 / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot x}{e} - \frac{-1}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6477.6
Applied rewrites77.6%
Applied rewrites77.6%
(FPCore (x) :precision binary64 (/ 1.0 (/ E (fma x x 1.0))))
double code(double x) {
return 1.0 / (((double) M_E) / fma(x, x, 1.0));
}
function code(x) return Float64(1.0 / Float64(exp(1) / fma(x, x, 1.0))) end
code[x_] := N[(1.0 / N[(E / N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{e}{\mathsf{fma}\left(x, x, 1\right)}}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6477.6
Applied rewrites77.6%
Applied rewrites77.6%
(FPCore (x) :precision binary64 (if (<= (* x x) 2e-5) (/ 1.0 E) (* (/ x E) x)))
double code(double x) {
double tmp;
if ((x * x) <= 2e-5) {
tmp = 1.0 / ((double) M_E);
} else {
tmp = (x / ((double) M_E)) * x;
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x * x) <= 2e-5) {
tmp = 1.0 / Math.E;
} else {
tmp = (x / Math.E) * x;
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 2e-5: tmp = 1.0 / math.e else: tmp = (x / math.e) * x return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 2e-5) tmp = Float64(1.0 / exp(1)); else tmp = Float64(Float64(x / exp(1)) * x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * x) <= 2e-5) tmp = 1.0 / 2.71828182845904523536; else tmp = (x / 2.71828182845904523536) * x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e-5], N[(1.0 / E), $MachinePrecision], N[(N[(x / E), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{e}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{e} \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 2.00000000000000016e-5Initial program 100.0%
Taylor expanded in x around 0
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6498.0
Applied rewrites98.0%
if 2.00000000000000016e-5 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
lower-*.f64N/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6454.5
Applied rewrites54.5%
Taylor expanded in x around inf
Applied rewrites54.5%
Applied rewrites54.5%
(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%
lift-neg.f64N/A
neg-sub0N/A
lift--.f64N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
metadata-evalN/A
rec-expN/A
e-exp-1N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
lower-E.f6477.6
Applied rewrites77.6%
(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
lower-/.f64N/A
exp-1-eN/A
lower-E.f6451.7
Applied rewrites51.7%
herbie shell --seed 2024240
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))