
(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 11 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 (* 3.0 (fma x x -1.0))) 0.3333333333333333))
double code(double x) {
return pow(exp((3.0 * fma(x, x, -1.0))), 0.3333333333333333);
}
function code(x) return exp(Float64(3.0 * fma(x, x, -1.0))) ^ 0.3333333333333333 end
code[x_] := N[Power[N[Exp[N[(3.0 * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.3333333333333333], $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{3 \cdot \mathsf{fma}\left(x, x, -1\right)}\right)}^{0.3333333333333333}
\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%
add-cbrt-cube100.0%
pow1/399.2%
add-exp-log100.0%
pow3100.0%
log-pow100.0%
add-log-exp100.0%
fma-define100.0%
Applied egg-rr100.0%
(FPCore (x) :precision binary64 (exp (* (+ x -1.0) (+ x 1.0))))
double code(double x) {
return 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.exp(((x + -1.0) * (x + 1.0)));
}
def code(x): return math.exp(((x + -1.0) * (x + 1.0)))
function code(x) return exp(Float64(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[Exp[N[(N[(x + -1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(x + -1\right) \cdot \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%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification100.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 74.9%
exp-1-e74.9%
Simplified74.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 74.9%
exp-1-e74.9%
Simplified74.9%
e-exp-174.9%
pow-exp74.9%
*-un-lft-identity74.9%
expm1-log1p-u74.0%
expm1-undefine74.0%
exp-diff74.0%
Applied egg-rr74.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 74.9%
exp-1-e74.9%
Simplified74.9%
e-exp-174.9%
pow-exp74.9%
*-un-lft-identity74.9%
expm1-log1p-u74.0%
expm1-undefine74.0%
exp-diff74.0%
Applied egg-rr74.9%
Taylor expanded in x around 0 66.9%
Final simplification66.9%
(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 74.9%
exp-1-e74.9%
Simplified74.9%
e-exp-174.9%
pow-exp74.9%
*-un-lft-identity74.9%
expm1-log1p-u74.0%
expm1-undefine74.0%
exp-diff74.0%
Applied egg-rr74.9%
Taylor expanded in x around 0 66.9%
*-commutative66.9%
Simplified66.9%
(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 74.9%
exp-1-e74.9%
Simplified74.9%
e-exp-174.9%
pow-exp74.9%
*-un-lft-identity74.9%
expm1-log1p-u74.0%
expm1-undefine74.0%
exp-diff74.0%
Applied egg-rr74.9%
Taylor expanded in x around 0 76.5%
*-commutative76.5%
Simplified76.5%
(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--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 74.9%
exp-1-e74.9%
Simplified74.9%
Taylor expanded in x around 0 50.6%
log-E50.6%
metadata-eval50.6%
log-E50.6%
associate-/l*50.6%
log-E50.6%
metadata-eval50.6%
/-rgt-identity50.6%
associate-*r/50.6%
associate-*l/50.6%
/-rgt-identity50.6%
Simplified50.6%
Taylor expanded in x around 0 50.6%
Final simplification50.6%
(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 74.9%
exp-1-e74.9%
Simplified74.9%
Taylor expanded in x around 0 50.6%
log-E50.6%
metadata-eval50.6%
log-E50.6%
associate-/l*50.6%
log-E50.6%
metadata-eval50.6%
/-rgt-identity50.6%
associate-*r/50.6%
associate-*l/50.6%
/-rgt-identity50.6%
distribute-rgt1-in50.6%
associate-*r/50.6%
*-rgt-identity50.6%
+-commutative50.6%
Simplified50.6%
Final simplification50.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%
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 74.9%
exp-1-e74.9%
Simplified74.9%
Taylor expanded in x around 0 51.2%
herbie shell --seed 2024131
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))