| Alternative 1 | |
|---|---|
| Error | 7.5 |
| Cost | 712 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{+181}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+192}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (- y z)) y)))
(if (<= t_0 (- INFINITY))
(* (- y z) (/ x y))
(if (<= t_0 -4e+158) t_0 (/ x (/ y (- y z)))))))double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
double t_0 = (x * (y - z)) / y;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (y - z) * (x / y);
} else if (t_0 <= -4e+158) {
tmp = t_0;
} else {
tmp = x / (y / (y - z));
}
return tmp;
}
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
public static double code(double x, double y, double z) {
double t_0 = (x * (y - z)) / y;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (y - z) * (x / y);
} else if (t_0 <= -4e+158) {
tmp = t_0;
} else {
tmp = x / (y / (y - z));
}
return tmp;
}
def code(x, y, z): return (x * (y - z)) / y
def code(x, y, z): t_0 = (x * (y - z)) / y tmp = 0 if t_0 <= -math.inf: tmp = (y - z) * (x / y) elif t_0 <= -4e+158: tmp = t_0 else: tmp = x / (y / (y - z)) return tmp
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y - z)) / y) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(y - z) * Float64(x / y)); elseif (t_0 <= -4e+158) tmp = t_0; else tmp = Float64(x / Float64(y / Float64(y - z))); end return tmp end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
function tmp_2 = code(x, y, z) t_0 = (x * (y - z)) / y; tmp = 0.0; if (t_0 <= -Inf) tmp = (y - z) * (x / y); elseif (t_0 <= -4e+158) tmp = t_0; else tmp = x / (y / (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -4e+158], t$95$0, N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\mathbf{elif}\;t_0 \leq -4 \cdot 10^{+158}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\end{array}
Results
| Original | 12.6 |
|---|---|
| Target | 2.9 |
| Herbie | 2.1 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -inf.0Initial program 64.0
Simplified0.2
[Start]64.0 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
*-commutative [=>]64.0 | \[ \frac{\color{blue}{\left(y - z\right) \cdot x}}{y}
\] |
associate-*r/ [<=]0.2 | \[ \color{blue}{\left(y - z\right) \cdot \frac{x}{y}}
\] |
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -3.99999999999999981e158Initial program 0.2
if -3.99999999999999981e158 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 9.4
Simplified2.4
[Start]9.4 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
associate-/l* [=>]2.4 | \[ \color{blue}{\frac{x}{\frac{y}{y - z}}}
\] |
Final simplification2.1
| Alternative 1 | |
|---|---|
| Error | 7.5 |
| Cost | 712 |
| Alternative 2 | |
|---|---|
| Error | 18.3 |
| Cost | 649 |
| Alternative 3 | |
|---|---|
| Error | 19.1 |
| Cost | 648 |
| Alternative 4 | |
|---|---|
| Error | 3.1 |
| Cost | 448 |
| Alternative 5 | |
|---|---|
| Error | 25.0 |
| Cost | 64 |
herbie shell --seed 2023010
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:herbie-target
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))