
(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}
(FPCore (x) :precision binary64 (pow (exp (+ x 1.0)) (+ x -1.0)))
double code(double x) {
return pow(exp((x + 1.0)), (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((x + 1.0d0)) ** (x + (-1.0d0))
end function
public static double code(double x) {
return Math.pow(Math.exp((x + 1.0)), (x + -1.0));
}
def code(x): return math.pow(math.exp((x + 1.0)), (x + -1.0))
function code(x) return exp(Float64(x + 1.0)) ^ Float64(x + -1.0) end
function tmp = code(x) tmp = exp((x + 1.0)) ^ (x + -1.0); end
code[x_] := N[Power[N[Exp[N[(x + 1.0), $MachinePrecision]], $MachinePrecision], N[(x + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{x + 1}\right)}^{\left(x + -1\right)}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
difference-of-sqr--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
(FPCore (x) :precision binary64 (pow E (fma x x -1.0)))
double code(double x) {
return pow(((double) M_E), fma(x, x, -1.0));
}
function code(x) return exp(1) ^ fma(x, x, -1.0) end
code[x_] := N[Power[E, N[(x * x + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
{e}^{\left(\mathsf{fma}\left(x, x, -1\right)\right)}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
*-un-lft-identity100.0%
exp-prod100.0%
exp-1-e100.0%
fma-define100.0%
Applied egg-rr100.0%
(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(-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^{-1 + x \cdot x}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (pow E (+ x -1.0)))
double code(double x) {
return pow(((double) M_E), (x + -1.0));
}
public static double code(double x) {
return Math.pow(Math.E, (x + -1.0));
}
def code(x): return math.pow(math.e, (x + -1.0))
function code(x) return exp(1) ^ Float64(x + -1.0) end
function tmp = code(x) tmp = 2.71828182845904523536 ^ (x + -1.0); end
code[x_] := N[Power[E, N[(x + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
{e}^{\left(x + -1\right)}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
difference-of-sqr--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.9%
exp-1-e75.9%
Simplified75.9%
(FPCore (x) :precision binary64 (/ (exp x) E))
double code(double x) {
return exp(x) / ((double) M_E);
}
public static double code(double x) {
return Math.exp(x) / Math.E;
}
def code(x): return math.exp(x) / math.e
function code(x) return Float64(exp(x) / exp(1)) end
function tmp = code(x) tmp = exp(x) / 2.71828182845904523536; end
code[x_] := N[(N[Exp[x], $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x}}{e}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
difference-of-sqr--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.9%
exp-1-e75.9%
Simplified75.9%
unpow-prod-up75.9%
pow-to-exp75.9%
log-E75.9%
*-un-lft-identity75.9%
inv-pow75.9%
un-div-inv75.9%
Applied egg-rr75.9%
(FPCore (x) :precision binary64 (+ (/ 1.0 E) (* x (+ (/ 1.0 E) (* x (+ (* 0.16666666666666666 (/ x E)) (* 0.5 (/ 1.0 E))))))))
double code(double x) {
return (1.0 / ((double) M_E)) + (x * ((1.0 / ((double) M_E)) + (x * ((0.16666666666666666 * (x / ((double) M_E))) + (0.5 * (1.0 / ((double) M_E)))))));
}
public static double code(double x) {
return (1.0 / Math.E) + (x * ((1.0 / Math.E) + (x * ((0.16666666666666666 * (x / Math.E)) + (0.5 * (1.0 / Math.E))))));
}
def code(x): return (1.0 / math.e) + (x * ((1.0 / math.e) + (x * ((0.16666666666666666 * (x / math.e)) + (0.5 * (1.0 / math.e))))))
function code(x) return Float64(Float64(1.0 / exp(1)) + Float64(x * Float64(Float64(1.0 / exp(1)) + Float64(x * Float64(Float64(0.16666666666666666 * Float64(x / exp(1))) + Float64(0.5 * Float64(1.0 / exp(1)))))))) end
function tmp = code(x) tmp = (1.0 / 2.71828182845904523536) + (x * ((1.0 / 2.71828182845904523536) + (x * ((0.16666666666666666 * (x / 2.71828182845904523536)) + (0.5 * (1.0 / 2.71828182845904523536)))))); end
code[x_] := N[(N[(1.0 / E), $MachinePrecision] + N[(x * N[(N[(1.0 / E), $MachinePrecision] + N[(x * N[(N[(0.16666666666666666 * N[(x / E), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e} + x \cdot \left(\frac{1}{e} + x \cdot \left(0.16666666666666666 \cdot \frac{x}{e} + 0.5 \cdot \frac{1}{e}\right)\right)
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
difference-of-sqr--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.9%
exp-1-e75.9%
Simplified75.9%
unpow-prod-up75.9%
pow-to-exp75.9%
log-E75.9%
*-un-lft-identity75.9%
inv-pow75.9%
un-div-inv75.9%
Applied egg-rr75.9%
Taylor expanded in x around 0 65.6%
Final simplification65.6%
(FPCore (x) :precision binary64 (/ (+ 1.0 (* x (+ 1.0 (* x (+ 0.5 (* x 0.16666666666666666)))))) E))
double code(double x) {
return (1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))) / ((double) M_E);
}
public static double code(double x) {
return (1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))) / Math.E;
}
def code(x): return (1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))) / math.e
function code(x) return Float64(Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.16666666666666666)))))) / exp(1)) end
function tmp = code(x) tmp = (1.0 + (x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))))) / 2.71828182845904523536; end
code[x_] := N[(N[(1.0 + N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + x \cdot \left(1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)}{e}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
difference-of-sqr--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.9%
exp-1-e75.9%
Simplified75.9%
unpow-prod-up75.9%
pow-to-exp75.9%
log-E75.9%
*-un-lft-identity75.9%
inv-pow75.9%
un-div-inv75.9%
Applied egg-rr75.9%
Taylor expanded in x around 0 65.6%
*-commutative65.6%
Simplified65.6%
(FPCore (x) :precision binary64 (/ (+ 1.0 (* x (+ 1.0 (* x 0.5)))) E))
double code(double x) {
return (1.0 + (x * (1.0 + (x * 0.5)))) / ((double) M_E);
}
public static double code(double x) {
return (1.0 + (x * (1.0 + (x * 0.5)))) / Math.E;
}
def code(x): return (1.0 + (x * (1.0 + (x * 0.5)))) / math.e
function code(x) return Float64(Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * 0.5)))) / exp(1)) end
function tmp = code(x) tmp = (1.0 + (x * (1.0 + (x * 0.5)))) / 2.71828182845904523536; end
code[x_] := N[(N[(1.0 + N[(x * N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + x \cdot \left(1 + x \cdot 0.5\right)}{e}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
difference-of-sqr--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.9%
exp-1-e75.9%
Simplified75.9%
unpow-prod-up75.9%
pow-to-exp75.9%
log-E75.9%
*-un-lft-identity75.9%
inv-pow75.9%
un-div-inv75.9%
Applied egg-rr75.9%
Taylor expanded in x around 0 73.4%
*-commutative73.4%
Simplified73.4%
(FPCore (x) :precision binary64 (/ (+ x 1.0) E))
double code(double x) {
return (x + 1.0) / ((double) M_E);
}
public static double code(double x) {
return (x + 1.0) / Math.E;
}
def code(x): return (x + 1.0) / math.e
function code(x) return Float64(Float64(x + 1.0) / exp(1)) end
function tmp = code(x) tmp = (x + 1.0) / 2.71828182845904523536; end
code[x_] := N[(N[(x + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + 1}{e}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
difference-of-sqr--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 75.9%
exp-1-e75.9%
Simplified75.9%
Taylor expanded in x around 0 50.3%
log-E50.3%
metadata-eval50.3%
log-E50.3%
log-E50.3%
metadata-eval50.3%
associate-/l*50.3%
Simplified50.3%
Taylor expanded in x around 0 50.3%
metadata-eval50.3%
associate-/r*50.3%
neg-mul-150.3%
remove-double-neg50.3%
distribute-neg-frac250.3%
sub-neg50.3%
div-sub50.3%
distribute-frac-neg250.3%
distribute-neg-frac50.3%
sub-neg50.3%
metadata-eval50.3%
distribute-neg-in50.3%
+-commutative50.3%
remove-double-neg50.3%
Simplified50.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%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
*-un-lft-identity100.0%
exp-prod100.0%
exp-1-e100.0%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 51.0%
herbie shell --seed 2024141
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))