| Alternative 1 | |
|---|---|
| Error | 20.6 |
| Cost | 584 |
\[\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-70}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-201}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (+ y z)) z)) (t_1 (/ x (/ z (+ y z)))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 -5e+94) (+ x (/ (* x y) z)) t_1))))double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
double t_0 = (x * (y + z)) / z;
double t_1 = x / (z / (y + z));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= -5e+94) {
tmp = x + ((x * y) / z);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
public static double code(double x, double y, double z) {
double t_0 = (x * (y + z)) / z;
double t_1 = x / (z / (y + z));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_0 <= -5e+94) {
tmp = x + ((x * y) / z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): return (x * (y + z)) / z
def code(x, y, z): t_0 = (x * (y + z)) / z t_1 = x / (z / (y + z)) tmp = 0 if t_0 <= -math.inf: tmp = t_1 elif t_0 <= -5e+94: tmp = x + ((x * y) / z) else: tmp = t_1 return tmp
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y + z)) / z) t_1 = Float64(x / Float64(z / Float64(y + z))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= -5e+94) tmp = Float64(x + Float64(Float64(x * y) / z)); else tmp = t_1; end return tmp end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
function tmp_2 = code(x, y, z) t_0 = (x * (y + z)) / z; t_1 = x / (z / (y + z)); tmp = 0.0; if (t_0 <= -Inf) tmp = t_1; elseif (t_0 <= -5e+94) tmp = x + ((x * y) / z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(z / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, -5e+94], N[(x + N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y + z\right)}{z}\\
t_1 := \frac{x}{\frac{z}{y + z}}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -5 \cdot 10^{+94}:\\
\;\;\;\;x + \frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 12.9 |
|---|---|
| Target | 2.8 |
| Herbie | 1.6 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0 or -5.0000000000000001e94 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 14.9
Applied egg-rr12.6
Taylor expanded in x around 0 14.9
Simplified1.8
if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -5.0000000000000001e94Initial program 0.2
Simplified9.7
Taylor expanded in y around 0 0.2
Final simplification1.6
| Alternative 1 | |
|---|---|
| Error | 20.6 |
| Cost | 584 |
| Alternative 2 | |
|---|---|
| Error | 19.9 |
| Cost | 584 |
| Alternative 3 | |
|---|---|
| Error | 19.9 |
| Cost | 584 |
| Alternative 4 | |
|---|---|
| Error | 2.8 |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Error | 25.0 |
| Cost | 64 |

herbie shell --seed 2022306
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))