
(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 8 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 2.0)) (* x 0.5)) E))
double code(double x) {
return pow(exp((x * 2.0)), (x * 0.5)) / ((double) M_E);
}
public static double code(double x) {
return Math.pow(Math.exp((x * 2.0)), (x * 0.5)) / Math.E;
}
def code(x): return math.pow(math.exp((x * 2.0)), (x * 0.5)) / math.e
function code(x) return Float64((exp(Float64(x * 2.0)) ^ Float64(x * 0.5)) / exp(1)) end
function tmp = code(x) tmp = (exp((x * 2.0)) ^ (x * 0.5)) / 2.71828182845904523536; end
code[x_] := N[(N[Power[N[Exp[N[(x * 2.0), $MachinePrecision]], $MachinePrecision], N[(x * 0.5), $MachinePrecision]], $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(e^{x \cdot 2}\right)}^{\left(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%
*-un-lft-identity100.0%
exp-prod99.9%
expm1-log1p-u99.9%
expm1-undefine99.9%
pow-sub99.9%
fma-define99.9%
metadata-eval99.9%
fma-neg99.9%
pow199.9%
pow-to-exp99.9%
expm1-define99.9%
log1p-expm1-u99.9%
pow-to-exp100.0%
pow1100.0%
exp-prod100.0%
*-un-lft-identity100.0%
pow2100.0%
pow1100.0%
exp-1-e100.0%
Applied egg-rr100.0%
unpow2100.0%
Applied egg-rr100.0%
pow-exp100.0%
sqr-pow100.0%
pow-prod-down100.0%
pow2100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
unpow2100.0%
Applied egg-rr100.0%
exp-lft-sqr100.0%
Simplified100.0%
(FPCore (x) :precision binary64 (/ (pow (exp x) x) E))
double code(double x) {
return pow(exp(x), x) / ((double) M_E);
}
public static double code(double x) {
return Math.pow(Math.exp(x), x) / Math.E;
}
def code(x): return math.pow(math.exp(x), x) / math.e
function code(x) return Float64((exp(x) ^ x) / exp(1)) end
function tmp = code(x) tmp = (exp(x) ^ x) / 2.71828182845904523536; end
code[x_] := N[(N[Power[N[Exp[x], $MachinePrecision], x], $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(e^{x}\right)}^{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%
*-un-lft-identity100.0%
exp-prod99.9%
expm1-log1p-u99.9%
expm1-undefine99.9%
pow-sub99.9%
fma-define99.9%
metadata-eval99.9%
fma-neg99.9%
pow199.9%
pow-to-exp99.9%
expm1-define99.9%
log1p-expm1-u99.9%
pow-to-exp100.0%
pow1100.0%
exp-prod100.0%
*-un-lft-identity100.0%
pow2100.0%
pow1100.0%
exp-1-e100.0%
Applied egg-rr100.0%
unpow2100.0%
exp-prod100.0%
Applied egg-rr100.0%
(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 (/ (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-prod99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 71.8%
exp-1-e71.8%
Simplified71.8%
unpow-prod-up71.8%
pow-to-exp71.8%
log-E71.8%
*-un-lft-identity71.8%
inv-pow71.8%
un-div-inv71.8%
Applied egg-rr71.8%
(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-prod99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 71.8%
exp-1-e71.8%
Simplified71.8%
unpow-prod-up71.8%
pow-to-exp71.8%
log-E71.8%
*-un-lft-identity71.8%
inv-pow71.8%
un-div-inv71.8%
Applied egg-rr71.8%
Taylor expanded in x around 0 63.3%
*-commutative63.3%
Simplified63.3%
(FPCore (x) :precision binary64 (/ (+ 1.0 (* x (+ (* x 0.5) 1.0))) E))
double code(double x) {
return (1.0 + (x * ((x * 0.5) + 1.0))) / ((double) M_E);
}
public static double code(double x) {
return (1.0 + (x * ((x * 0.5) + 1.0))) / Math.E;
}
def code(x): return (1.0 + (x * ((x * 0.5) + 1.0))) / math.e
function code(x) return Float64(Float64(1.0 + Float64(x * Float64(Float64(x * 0.5) + 1.0))) / exp(1)) end
function tmp = code(x) tmp = (1.0 + (x * ((x * 0.5) + 1.0))) / 2.71828182845904523536; end
code[x_] := N[(N[(1.0 + N[(x * N[(N[(x * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + x \cdot \left(x \cdot 0.5 + 1\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-prod99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 71.8%
exp-1-e71.8%
Simplified71.8%
unpow-prod-up71.8%
pow-to-exp71.8%
log-E71.8%
*-un-lft-identity71.8%
inv-pow71.8%
un-div-inv71.8%
Applied egg-rr71.8%
Taylor expanded in x around 0 74.3%
*-commutative74.3%
Simplified74.3%
Final simplification74.3%
(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-prod99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 71.8%
exp-1-e71.8%
Simplified71.8%
Taylor expanded in x around 0 46.0%
log-E46.0%
metadata-eval46.0%
log-E46.0%
log-E46.0%
metadata-eval46.0%
*-commutative46.0%
*-commutative46.0%
associate-/l*46.0%
distribute-rgt1-in46.0%
+-commutative46.0%
associate-*r/46.0%
+-commutative46.0%
distribute-rgt1-in46.0%
*-rgt-identity46.0%
Simplified46.0%
Final simplification46.0%
(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-prod99.9%
expm1-log1p-u99.9%
expm1-undefine99.9%
pow-sub99.9%
fma-define99.9%
metadata-eval99.9%
fma-neg99.9%
pow199.9%
pow-to-exp99.9%
expm1-define99.9%
log1p-expm1-u99.9%
pow-to-exp100.0%
pow1100.0%
exp-prod100.0%
*-un-lft-identity100.0%
pow2100.0%
pow1100.0%
exp-1-e100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 46.7%
herbie shell --seed 2024144
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))