
(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 4 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 -0.6666666666666666) (* (exp -0.3333333333333333) (pow (exp x) x))))
double code(double x) {
return exp(-0.6666666666666666) * (exp(-0.3333333333333333) * pow(exp(x), x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((-0.6666666666666666d0)) * (exp((-0.3333333333333333d0)) * (exp(x) ** x))
end function
public static double code(double x) {
return Math.exp(-0.6666666666666666) * (Math.exp(-0.3333333333333333) * Math.pow(Math.exp(x), x));
}
def code(x): return math.exp(-0.6666666666666666) * (math.exp(-0.3333333333333333) * math.pow(math.exp(x), x))
function code(x) return Float64(exp(-0.6666666666666666) * Float64(exp(-0.3333333333333333) * (exp(x) ^ x))) end
function tmp = code(x) tmp = exp(-0.6666666666666666) * (exp(-0.3333333333333333) * (exp(x) ^ x)); end
code[x_] := N[(N[Exp[-0.6666666666666666], $MachinePrecision] * N[(N[Exp[-0.3333333333333333], $MachinePrecision] * N[Power[N[Exp[x], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{-0.6666666666666666} \cdot \left(e^{-0.3333333333333333} \cdot {\left(e^{x}\right)}^{x}\right)
\end{array}
Initial program 100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
difference-of-sqr--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
pow-exp100.0%
metadata-eval100.0%
sub-neg100.0%
difference-of-sqr-1100.0%
sub-neg100.0%
add-log-exp100.0%
pow-exp100.0%
metadata-eval100.0%
add-log-exp100.0%
log-prod100.0%
add-exp-log100.0%
*-commutative100.0%
add-cube-cbrt98.4%
associate-*l*98.4%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (* (pow (exp x) x) (exp -1.0)))
double code(double x) {
return pow(exp(x), x) * exp(-1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) ** x) * exp((-1.0d0))
end function
public static double code(double x) {
return Math.pow(Math.exp(x), x) * Math.exp(-1.0);
}
def code(x): return math.pow(math.exp(x), x) * math.exp(-1.0)
function code(x) return Float64((exp(x) ^ x) * exp(-1.0)) end
function tmp = code(x) tmp = (exp(x) ^ x) * exp(-1.0); end
code[x_] := N[(N[Power[N[Exp[x], $MachinePrecision], x], $MachinePrecision] * N[Exp[-1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{x}\right)}^{x} \cdot e^{-1}
\end{array}
Initial program 100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
exp-sum100.0%
exp-prod100.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%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(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 100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 51.4%
Final simplification51.4%
herbie shell --seed 2023230
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))