| Alternative 1 | |
|---|---|
| Error | 18.9 |
| Cost | 6464 |
\[e^{x}
\]
(FPCore (x y z) :precision binary64 (exp (- (+ x (* y (log y))) z)))
(FPCore (x y z) :precision binary64 (if (<= z 3.35e-15) (exp x) (exp (- z))))
double code(double x, double y, double z) {
return exp(((x + (y * log(y))) - z));
}
double code(double x, double y, double z) {
double tmp;
if (z <= 3.35e-15) {
tmp = exp(x);
} else {
tmp = exp(-z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = exp(((x + (y * log(y))) - z))
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 3.35d-15) then
tmp = exp(x)
else
tmp = exp(-z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return Math.exp(((x + (y * Math.log(y))) - z));
}
public static double code(double x, double y, double z) {
double tmp;
if (z <= 3.35e-15) {
tmp = Math.exp(x);
} else {
tmp = Math.exp(-z);
}
return tmp;
}
def code(x, y, z): return math.exp(((x + (y * math.log(y))) - z))
def code(x, y, z): tmp = 0 if z <= 3.35e-15: tmp = math.exp(x) else: tmp = math.exp(-z) return tmp
function code(x, y, z) return exp(Float64(Float64(x + Float64(y * log(y))) - z)) end
function code(x, y, z) tmp = 0.0 if (z <= 3.35e-15) tmp = exp(x); else tmp = exp(Float64(-z)); end return tmp end
function tmp = code(x, y, z) tmp = exp(((x + (y * log(y))) - z)); end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 3.35e-15) tmp = exp(x); else tmp = exp(-z); end tmp_2 = tmp; end
code[x_, y_, z_] := N[Exp[N[(N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[z, 3.35e-15], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
e^{\left(x + y \cdot \log y\right) - z}
\begin{array}{l}
\mathbf{if}\;z \leq 3.35 \cdot 10^{-15}:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{-z}\\
\end{array}
Results
| Original | 0.0 |
|---|---|
| Target | 0.0 |
| Herbie | 1.3 |
if z < 3.35e-15Initial program 0.0
Simplified11.0
Taylor expanded in z around 0 11.5
Taylor expanded in y around 0 1.6
Simplified1.6
if 3.35e-15 < z Initial program 0.0
Taylor expanded in z around inf 0.9
Simplified0.9
Final simplification1.3
| Alternative 1 | |
|---|---|
| Error | 18.9 |
| Cost | 6464 |
| Alternative 2 | |
|---|---|
| Error | 44.5 |
| Cost | 192 |

herbie shell --seed 2022228
(FPCore (x y z)
:name "Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(exp (+ (- x z) (* (log y) y)))
(exp (- (+ x (* y (log y))) z)))