
(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 6 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%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
exp-sum100.0%
unpow-prod-down72.6%
exp-prod72.6%
*-un-lft-identity72.6%
Applied egg-rr72.6%
metadata-eval72.6%
sub-neg72.6%
exp-diff72.6%
associate-*r/72.6%
pow-plus100.0%
+-commutative100.0%
exp-1-e100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (pow (exp (+ -2.0 (* x 2.0))) (+ 0.5 (* x 0.5))))
double code(double x) {
return pow(exp((-2.0 + (x * 2.0))), (0.5 + (x * 0.5)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(((-2.0d0) + (x * 2.0d0))) ** (0.5d0 + (x * 0.5d0))
end function
public static double code(double x) {
return Math.pow(Math.exp((-2.0 + (x * 2.0))), (0.5 + (x * 0.5)));
}
def code(x): return math.pow(math.exp((-2.0 + (x * 2.0))), (0.5 + (x * 0.5)))
function code(x) return exp(Float64(-2.0 + Float64(x * 2.0))) ^ Float64(0.5 + Float64(x * 0.5)) end
function tmp = code(x) tmp = exp((-2.0 + (x * 2.0))) ^ (0.5 + (x * 0.5)); end
code[x_] := N[Power[N[Exp[N[(-2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(0.5 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{-2 + x \cdot 2}\right)}^{\left(0.5 + x \cdot 0.5\right)}
\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-prod100.0%
sub-neg100.0%
metadata-eval100.0%
unpow-prod-up76.9%
Applied egg-rr76.9%
unpow-176.9%
Simplified76.9%
inv-pow76.9%
unpow-prod-up100.0%
pow-exp99.9%
add-log-exp99.9%
log-pow99.9%
sqr-pow99.9%
add-exp-log100.0%
pow-prod-down100.0%
pow2100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
exp-prod100.0%
*-commutative100.0%
+-commutative100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
*-commutative100.0%
+-commutative100.0%
distribute-lft-in100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(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 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%
*-commutative99.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification100.0%
(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 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-prod100.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 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 -1.0))
double code(double x) {
return exp(-1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((-1.0d0))
end function
public static double code(double x) {
return Math.exp(-1.0);
}
def code(x): return math.exp(-1.0)
function code(x) return exp(-1.0) end
function tmp = code(x) tmp = exp(-1.0); end
code[x_] := N[Exp[-1.0], $MachinePrecision]
\begin{array}{l}
\\
e^{-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%
Taylor expanded in x around 0 49.3%
Final simplification49.3%
herbie shell --seed 2023333
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))