| Alternative 1 | |
|---|---|
| Error | 4.7 |
| Cost | 1480 |
\[\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;x\\
\mathbf{elif}\;t_0 \leq 10^{+301}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z) :precision binary64 (if (<= (/ (* x (- y z)) y) (- INFINITY)) x (+ x (- (/ (* z x) y)))))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
double tmp;
if (((x * (y - z)) / y) <= -((double) INFINITY)) {
tmp = x;
} else {
tmp = x + -((z * x) / y);
}
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 tmp;
if (((x * (y - z)) / y) <= -Double.POSITIVE_INFINITY) {
tmp = x;
} else {
tmp = x + -((z * x) / y);
}
return tmp;
}
def code(x, y, z): return (x * (y - z)) / y
def code(x, y, z): tmp = 0 if ((x * (y - z)) / y) <= -math.inf: tmp = x else: tmp = x + -((z * x) / y) return tmp
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function code(x, y, z) tmp = 0.0 if (Float64(Float64(x * Float64(y - z)) / y) <= Float64(-Inf)) tmp = x; else tmp = Float64(x + Float64(-Float64(Float64(z * x) / y))); end return tmp end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((x * (y - z)) / y) <= -Inf) tmp = x; else tmp = x + -((z * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], (-Infinity)], x, N[(x + (-N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision])), $MachinePrecision]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -\infty:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \left(-\frac{z \cdot x}{y}\right)\\
\end{array}
Results
| Original | 12.0 |
|---|---|
| Target | 3.1 |
| Herbie | 3.8 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -inf.0Initial program 64.0
Taylor expanded in y around inf 10.5
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 8.0
Taylor expanded in y around 0 3.3
Simplified3.3
[Start]3.3 | \[ -1 \cdot \frac{z \cdot x}{y} + x
\] |
|---|---|
rational.json-simplify-1 [=>]3.3 | \[ \color{blue}{x + -1 \cdot \frac{z \cdot x}{y}}
\] |
rational.json-simplify-2 [=>]3.3 | \[ x + \color{blue}{\frac{z \cdot x}{y} \cdot -1}
\] |
rational.json-simplify-9 [=>]3.3 | \[ x + \color{blue}{\left(-\frac{z \cdot x}{y}\right)}
\] |
Final simplification3.8
| Alternative 1 | |
|---|---|
| Error | 4.7 |
| Cost | 1480 |
| Alternative 2 | |
|---|---|
| Error | 19.0 |
| Cost | 648 |
| Alternative 3 | |
|---|---|
| Error | 26.0 |
| Cost | 64 |
herbie shell --seed 2023077
(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))