
(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 10 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}
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (pow (exp (- -1.0 x_m)) (- 1.0 x_m)))
x_m = fabs(x);
double code(double x_m) {
return pow(exp((-1.0 - x_m)), (1.0 - x_m));
}
x_m = abs(x)
real(8) function code(x_m)
real(8), intent (in) :: x_m
code = exp(((-1.0d0) - x_m)) ** (1.0d0 - x_m)
end function
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.pow(Math.exp((-1.0 - x_m)), (1.0 - x_m));
}
x_m = math.fabs(x) def code(x_m): return math.pow(math.exp((-1.0 - x_m)), (1.0 - x_m))
x_m = abs(x) function code(x_m) return exp(Float64(-1.0 - x_m)) ^ Float64(1.0 - x_m) end
x_m = abs(x); function tmp = code(x_m) tmp = exp((-1.0 - x_m)) ^ (1.0 - x_m); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[Power[N[Exp[N[(-1.0 - x$95$m), $MachinePrecision]], $MachinePrecision], N[(1.0 - x$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
{\left(e^{-1 - x\_m}\right)}^{\left(1 - x\_m\right)}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
exp-prod99.9%
exp-1-e99.9%
fma-define99.9%
Applied egg-rr99.9%
e-exp-199.9%
pow-exp99.9%
*-un-lft-identity99.9%
metadata-eval99.9%
fmm-def99.9%
difference-of-sqr-199.9%
add-log-exp99.9%
sub-neg99.9%
metadata-eval99.9%
pow-to-exp100.0%
add-sqr-sqrt99.2%
unpow-prod-down100.0%
Applied egg-rr100.0%
pow-sqr99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in x around -inf 99.9%
associate-*r*99.9%
mul-1-neg99.9%
sub-neg99.9%
exp-prod100.0%
Simplified99.9%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (pow E (fma x_m x_m -1.0)))
x_m = fabs(x);
double code(double x_m) {
return pow(((double) M_E), fma(x_m, x_m, -1.0));
}
x_m = abs(x) function code(x_m) return exp(1) ^ fma(x_m, x_m, -1.0) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[Power[E, N[(x$95$m * x$95$m + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
{e}^{\left(\mathsf{fma}\left(x\_m, x\_m, -1\right)\right)}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
exp-prod99.9%
exp-1-e99.9%
fma-define99.9%
Applied egg-rr99.9%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (exp (+ -1.0 (* x_m x_m))))
x_m = fabs(x);
double code(double x_m) {
return exp((-1.0 + (x_m * x_m)));
}
x_m = abs(x)
real(8) function code(x_m)
real(8), intent (in) :: x_m
code = exp(((-1.0d0) + (x_m * x_m)))
end function
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.exp((-1.0 + (x_m * x_m)));
}
x_m = math.fabs(x) def code(x_m): return math.exp((-1.0 + (x_m * x_m)))
x_m = abs(x) function code(x_m) return exp(Float64(-1.0 + Float64(x_m * x_m))) end
x_m = abs(x); function tmp = code(x_m) tmp = exp((-1.0 + (x_m * x_m))); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[Exp[N[(-1.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
e^{-1 + x\_m \cdot x\_m}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
Final simplification99.9%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (pow E (+ -1.0 x_m)))
x_m = fabs(x);
double code(double x_m) {
return pow(((double) M_E), (-1.0 + x_m));
}
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.pow(Math.E, (-1.0 + x_m));
}
x_m = math.fabs(x) def code(x_m): return math.pow(math.e, (-1.0 + x_m))
x_m = abs(x) function code(x_m) return exp(1) ^ Float64(-1.0 + x_m) end
x_m = abs(x); function tmp = code(x_m) tmp = 2.71828182845904523536 ^ (-1.0 + x_m); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[Power[E, N[(-1.0 + x$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
{e}^{\left(-1 + x\_m\right)}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 72.8%
exp-1-e72.8%
Simplified72.8%
Final simplification72.8%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ (exp x_m) E))
x_m = fabs(x);
double code(double x_m) {
return exp(x_m) / ((double) M_E);
}
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.exp(x_m) / Math.E;
}
x_m = math.fabs(x) def code(x_m): return math.exp(x_m) / math.e
x_m = abs(x) function code(x_m) return Float64(exp(x_m) / exp(1)) end
x_m = abs(x); function tmp = code(x_m) tmp = exp(x_m) / 2.71828182845904523536; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[Exp[x$95$m], $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{e^{x\_m}}{e}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 72.8%
exp-1-e72.8%
Simplified72.8%
unpow-prod-up72.8%
pow-to-exp72.8%
log-E72.8%
*-un-lft-identity72.8%
inv-pow72.8%
un-div-inv72.8%
Applied egg-rr72.8%
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(+
(/ 1.0 E)
(*
x_m
(+
(/ 1.0 E)
(* x_m (+ (* 0.16666666666666666 (/ x_m E)) (* 0.5 (/ 1.0 E))))))))x_m = fabs(x);
double code(double x_m) {
return (1.0 / ((double) M_E)) + (x_m * ((1.0 / ((double) M_E)) + (x_m * ((0.16666666666666666 * (x_m / ((double) M_E))) + (0.5 * (1.0 / ((double) M_E)))))));
}
x_m = Math.abs(x);
public static double code(double x_m) {
return (1.0 / Math.E) + (x_m * ((1.0 / Math.E) + (x_m * ((0.16666666666666666 * (x_m / Math.E)) + (0.5 * (1.0 / Math.E))))));
}
x_m = math.fabs(x) def code(x_m): return (1.0 / math.e) + (x_m * ((1.0 / math.e) + (x_m * ((0.16666666666666666 * (x_m / math.e)) + (0.5 * (1.0 / math.e))))))
x_m = abs(x) function code(x_m) return Float64(Float64(1.0 / exp(1)) + Float64(x_m * Float64(Float64(1.0 / exp(1)) + Float64(x_m * Float64(Float64(0.16666666666666666 * Float64(x_m / exp(1))) + Float64(0.5 * Float64(1.0 / exp(1)))))))) end
x_m = abs(x); function tmp = code(x_m) tmp = (1.0 / 2.71828182845904523536) + (x_m * ((1.0 / 2.71828182845904523536) + (x_m * ((0.16666666666666666 * (x_m / 2.71828182845904523536)) + (0.5 * (1.0 / 2.71828182845904523536)))))); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(1.0 / E), $MachinePrecision] + N[(x$95$m * N[(N[(1.0 / E), $MachinePrecision] + N[(x$95$m * N[(N[(0.16666666666666666 * N[(x$95$m / E), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{e} + x\_m \cdot \left(\frac{1}{e} + x\_m \cdot \left(0.16666666666666666 \cdot \frac{x\_m}{e} + 0.5 \cdot \frac{1}{e}\right)\right)
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 72.8%
exp-1-e72.8%
Simplified72.8%
unpow-prod-up72.8%
pow-to-exp72.8%
log-E72.8%
*-un-lft-identity72.8%
inv-pow72.8%
un-div-inv72.8%
Applied egg-rr72.8%
Taylor expanded in x around 0 65.0%
Final simplification65.0%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ (+ 1.0 (* x_m (+ 1.0 (* x_m (+ 0.5 (* x_m 0.16666666666666666)))))) E))
x_m = fabs(x);
double code(double x_m) {
return (1.0 + (x_m * (1.0 + (x_m * (0.5 + (x_m * 0.16666666666666666)))))) / ((double) M_E);
}
x_m = Math.abs(x);
public static double code(double x_m) {
return (1.0 + (x_m * (1.0 + (x_m * (0.5 + (x_m * 0.16666666666666666)))))) / Math.E;
}
x_m = math.fabs(x) def code(x_m): return (1.0 + (x_m * (1.0 + (x_m * (0.5 + (x_m * 0.16666666666666666)))))) / math.e
x_m = abs(x) function code(x_m) return Float64(Float64(1.0 + Float64(x_m * Float64(1.0 + Float64(x_m * Float64(0.5 + Float64(x_m * 0.16666666666666666)))))) / exp(1)) end
x_m = abs(x); function tmp = code(x_m) tmp = (1.0 + (x_m * (1.0 + (x_m * (0.5 + (x_m * 0.16666666666666666)))))) / 2.71828182845904523536; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(1.0 + N[(x$95$m * N[(1.0 + N[(x$95$m * N[(0.5 + N[(x$95$m * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1 + x\_m \cdot \left(1 + x\_m \cdot \left(0.5 + x\_m \cdot 0.16666666666666666\right)\right)}{e}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 72.8%
exp-1-e72.8%
Simplified72.8%
unpow-prod-up72.8%
pow-to-exp72.8%
log-E72.8%
*-un-lft-identity72.8%
inv-pow72.8%
un-div-inv72.8%
Applied egg-rr72.8%
Taylor expanded in x around 0 65.0%
*-commutative65.0%
Simplified65.0%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ (+ 1.0 (* x_m (+ 1.0 (* x_m 0.5)))) E))
x_m = fabs(x);
double code(double x_m) {
return (1.0 + (x_m * (1.0 + (x_m * 0.5)))) / ((double) M_E);
}
x_m = Math.abs(x);
public static double code(double x_m) {
return (1.0 + (x_m * (1.0 + (x_m * 0.5)))) / Math.E;
}
x_m = math.fabs(x) def code(x_m): return (1.0 + (x_m * (1.0 + (x_m * 0.5)))) / math.e
x_m = abs(x) function code(x_m) return Float64(Float64(1.0 + Float64(x_m * Float64(1.0 + Float64(x_m * 0.5)))) / exp(1)) end
x_m = abs(x); function tmp = code(x_m) tmp = (1.0 + (x_m * (1.0 + (x_m * 0.5)))) / 2.71828182845904523536; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(1.0 + N[(x$95$m * N[(1.0 + N[(x$95$m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1 + x\_m \cdot \left(1 + x\_m \cdot 0.5\right)}{e}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 72.8%
exp-1-e72.8%
Simplified72.8%
unpow-prod-up72.8%
pow-to-exp72.8%
log-E72.8%
*-un-lft-identity72.8%
inv-pow72.8%
un-div-inv72.8%
Applied egg-rr72.8%
Taylor expanded in x around 0 75.6%
*-commutative75.6%
Simplified75.6%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ (+ x_m 1.0) E))
x_m = fabs(x);
double code(double x_m) {
return (x_m + 1.0) / ((double) M_E);
}
x_m = Math.abs(x);
public static double code(double x_m) {
return (x_m + 1.0) / Math.E;
}
x_m = math.fabs(x) def code(x_m): return (x_m + 1.0) / math.e
x_m = abs(x) function code(x_m) return Float64(Float64(x_m + 1.0) / exp(1)) end
x_m = abs(x); function tmp = code(x_m) tmp = (x_m + 1.0) / 2.71828182845904523536; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(x$95$m + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{x\_m + 1}{e}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 72.8%
exp-1-e72.8%
Simplified72.8%
unpow-prod-up72.8%
pow-to-exp72.8%
log-E72.8%
*-un-lft-identity72.8%
inv-pow72.8%
un-div-inv72.8%
Applied egg-rr72.8%
Taylor expanded in x around 0 50.6%
Final simplification50.6%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ 1.0 E))
x_m = fabs(x);
double code(double x_m) {
return 1.0 / ((double) M_E);
}
x_m = Math.abs(x);
public static double code(double x_m) {
return 1.0 / Math.E;
}
x_m = math.fabs(x) def code(x_m): return 1.0 / math.e
x_m = abs(x) function code(x_m) return Float64(1.0 / exp(1)) end
x_m = abs(x); function tmp = code(x_m) tmp = 1.0 / 2.71828182845904523536; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(1.0 / E), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{e}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
exp-prod99.9%
exp-1-e99.9%
fma-define99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 51.5%
herbie shell --seed 2024172
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))