
(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 9 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 (+ (* x x) -1.0)))
double code(double x) {
return exp(((x * x) + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(((x * x) + (-1.0d0)))
end function
public static double code(double x) {
return Math.exp(((x * x) + -1.0));
}
def code(x): return math.exp(((x * x) + -1.0))
function code(x) return exp(Float64(Float64(x * x) + -1.0)) end
function tmp = code(x) tmp = exp(((x * x) + -1.0)); end
code[x_] := N[Exp[N[(N[(x * x), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{x \cdot x + -1}
\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%
(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--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 74.2%
exp-1-e74.2%
Simplified74.2%
(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--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 74.2%
exp-1-e74.2%
Simplified74.2%
unpow-prod-up74.2%
pow-to-exp74.2%
log-E74.2%
*-un-lft-identity74.2%
inv-pow74.2%
un-div-inv74.2%
Applied egg-rr74.2%
(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--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 74.2%
exp-1-e74.2%
Simplified74.2%
unpow-prod-up74.2%
pow-to-exp74.2%
log-E74.2%
*-un-lft-identity74.2%
inv-pow74.2%
un-div-inv74.2%
Applied egg-rr74.2%
Taylor expanded in x around 0 62.7%
Final simplification62.7%
(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--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 74.2%
exp-1-e74.2%
Simplified74.2%
unpow-prod-up74.2%
pow-to-exp74.2%
log-E74.2%
*-un-lft-identity74.2%
inv-pow74.2%
un-div-inv74.2%
Applied egg-rr74.2%
Taylor expanded in x around 0 62.7%
*-commutative62.7%
Simplified62.7%
(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--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 74.2%
exp-1-e74.2%
Simplified74.2%
unpow-prod-up74.2%
pow-to-exp74.2%
log-E74.2%
*-un-lft-identity74.2%
inv-pow74.2%
un-div-inv74.2%
Applied egg-rr74.2%
Taylor expanded in x around 0 70.6%
*-commutative70.6%
Simplified70.6%
(FPCore (x) :precision binary64 (+ (/ x E) (/ 1.0 E)))
double code(double x) {
return (x / ((double) M_E)) + (1.0 / ((double) M_E));
}
public static double code(double x) {
return (x / Math.E) + (1.0 / Math.E);
}
def code(x): return (x / math.e) + (1.0 / math.e)
function code(x) return Float64(Float64(x / exp(1)) + Float64(1.0 / exp(1))) end
function tmp = code(x) tmp = (x / 2.71828182845904523536) + (1.0 / 2.71828182845904523536); end
code[x_] := N[(N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{e} + \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%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 74.2%
exp-1-e74.2%
Simplified74.2%
unpow-prod-up74.2%
pow-to-exp74.2%
log-E74.2%
*-un-lft-identity74.2%
inv-pow74.2%
un-div-inv74.2%
Applied egg-rr74.2%
Taylor expanded in x around 0 47.9%
Final simplification47.9%
(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--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 74.2%
exp-1-e74.2%
Simplified74.2%
unpow-prod-up74.2%
pow-to-exp74.2%
log-E74.2%
*-un-lft-identity74.2%
inv-pow74.2%
un-div-inv74.2%
Applied egg-rr74.2%
Taylor expanded in x around 0 47.9%
Final simplification47.9%
(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 48.4%
herbie shell --seed 2024150
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))