| Alternative 1 | |
|---|---|
| Error | 20.3 |
| Cost | 584 |
\[\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -2.9 \cdot 10^{+201}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+56}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\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)))
(if (<= t_0 (- INFINITY))
(* x (/ (+ y z) z))
(if (<= t_0 -2e+174) t_0 (+ x (* x (/ y z)))))))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 tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x * ((y + z) / z);
} else if (t_0 <= -2e+174) {
tmp = t_0;
} else {
tmp = x + (x * (y / z));
}
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 tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = x * ((y + z) / z);
} else if (t_0 <= -2e+174) {
tmp = t_0;
} else {
tmp = x + (x * (y / z));
}
return tmp;
}
def code(x, y, z): return (x * (y + z)) / z
def code(x, y, z): t_0 = (x * (y + z)) / z tmp = 0 if t_0 <= -math.inf: tmp = x * ((y + z) / z) elif t_0 <= -2e+174: tmp = t_0 else: tmp = x + (x * (y / z)) 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) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(x * Float64(Float64(y + z) / z)); elseif (t_0 <= -2e+174) tmp = t_0; else tmp = Float64(x + Float64(x * Float64(y / z))); 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; tmp = 0.0; if (t_0 <= -Inf) tmp = x * ((y + z) / z); elseif (t_0 <= -2e+174) tmp = t_0; else tmp = x + (x * (y / z)); 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]}, If[LessEqual[t$95$0, (-Infinity)], N[(x * N[(N[(y + z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -2e+174], t$95$0, N[(x + N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y + z\right)}{z}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\
\mathbf{elif}\;t_0 \leq -2 \cdot 10^{+174}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \frac{y}{z}\\
\end{array}
Results
| Original | 12.5 |
|---|---|
| Target | 2.9 |
| Herbie | 2.3 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0Initial program 64.0
Simplified0.1
if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -2.00000000000000014e174Initial program 0.2
if -2.00000000000000014e174 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 8.8
Taylor expanded in y around 0 3.6
Simplified2.7
Final simplification2.3
| Alternative 1 | |
|---|---|
| Error | 20.3 |
| Cost | 584 |
| Alternative 2 | |
|---|---|
| Error | 21.0 |
| Cost | 584 |
| Alternative 3 | |
|---|---|
| Error | 3.1 |
| Cost | 448 |
| Alternative 4 | |
|---|---|
| Error | 3.1 |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Error | 25.4 |
| Cost | 64 |
herbie shell --seed 2022325
(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))