
(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 7 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) 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 99.9%
sqr-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
expm1-log1p-u99.9%
expm1-undefine99.9%
exp-diff99.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-exp99.9%
pow199.9%
pow299.9%
exp-1-e99.9%
Applied egg-rr99.9%
unpow299.9%
exp-prod100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (/ (exp (pow x 2.0)) E))
double code(double x) {
return exp(pow(x, 2.0)) / ((double) M_E);
}
public static double code(double x) {
return Math.exp(Math.pow(x, 2.0)) / Math.E;
}
def code(x): return math.exp(math.pow(x, 2.0)) / math.e
function code(x) return Float64(exp((x ^ 2.0)) / exp(1)) end
function tmp = code(x) tmp = exp((x ^ 2.0)) / 2.71828182845904523536; end
code[x_] := N[(N[Exp[N[Power[x, 2.0], $MachinePrecision]], $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{{x}^{2}}}{e}
\end{array}
Initial program 99.9%
sqr-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
expm1-log1p-u99.9%
expm1-undefine99.9%
exp-diff99.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-exp99.9%
pow199.9%
pow299.9%
exp-1-e99.9%
Applied egg-rr99.9%
Final simplification99.9%
(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 99.9%
sqr-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (exp (+ x -1.0)))
double code(double x) {
return exp((x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((x + (-1.0d0)))
end function
public static double code(double x) {
return Math.exp((x + -1.0));
}
def code(x): return math.exp((x + -1.0))
function code(x) return exp(Float64(x + -1.0)) end
function tmp = code(x) tmp = exp((x + -1.0)); end
code[x_] := N[Exp[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{x + -1}
\end{array}
Initial program 99.9%
sqr-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 78.4%
exp-1-e78.4%
Simplified78.4%
Taylor expanded in x around inf 78.4%
log-E78.4%
sub-neg78.4%
metadata-eval78.4%
*-lft-identity78.4%
Simplified78.4%
Final simplification78.4%
(FPCore (x) :precision binary64 (+ (/ 1.0 E) (/ x E)))
double code(double x) {
return (1.0 / ((double) M_E)) + (x / ((double) M_E));
}
public static double code(double x) {
return (1.0 / Math.E) + (x / Math.E);
}
def code(x): return (1.0 / math.e) + (x / math.e)
function code(x) return Float64(Float64(1.0 / exp(1)) + Float64(x / exp(1))) end
function tmp = code(x) tmp = (1.0 / 2.71828182845904523536) + (x / 2.71828182845904523536); end
code[x_] := N[(N[(1.0 / E), $MachinePrecision] + N[(x / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e} + \frac{x}{e}
\end{array}
Initial program 99.9%
sqr-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 78.4%
exp-1-e78.4%
Simplified78.4%
Taylor expanded in x around 0 49.7%
exp-1-e49.7%
rec-exp49.7%
metadata-eval49.7%
log-E49.7%
associate-*r/49.7%
exp-1-e49.7%
rec-exp49.7%
metadata-eval49.7%
distribute-rgt1-in49.7%
metadata-eval49.7%
rec-exp49.7%
exp-1-e49.7%
associate-*r/49.7%
distribute-rgt1-in49.7%
*-rgt-identity49.7%
Simplified49.7%
Taylor expanded in x around 0 49.7%
Final simplification49.7%
(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 99.9%
sqr-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 78.4%
exp-1-e78.4%
Simplified78.4%
Taylor expanded in x around 0 49.7%
exp-1-e49.7%
rec-exp49.7%
metadata-eval49.7%
log-E49.7%
associate-*r/49.7%
exp-1-e49.7%
rec-exp49.7%
metadata-eval49.7%
distribute-rgt1-in49.7%
metadata-eval49.7%
rec-exp49.7%
exp-1-e49.7%
associate-*r/49.7%
distribute-rgt1-in49.7%
*-rgt-identity49.7%
Simplified49.7%
Final simplification49.7%
(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 99.9%
sqr-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
expm1-log1p-u99.9%
expm1-undefine99.9%
exp-diff99.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-exp99.9%
pow199.9%
pow299.9%
exp-1-e99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 49.8%
Final simplification49.8%
herbie shell --seed 2024034
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))