| Alternative 1 | |
|---|---|
| Accuracy | 85.6% |
| Cost | 713 |
\[\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{-140} \lor \neg \left(z \leq 1.08 \cdot 10^{-172}\right):\\
\;\;\;\;\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))
(- x (/ x (/ y z)))
(if (or (<= t_0 -2e-63) (and (not (<= t_0 1e-24)) (<= t_0 1e+260)))
t_0
(- x (* x (/ z y)))))))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 = x - (x / (y / z));
} else if ((t_0 <= -2e-63) || (!(t_0 <= 1e-24) && (t_0 <= 1e+260))) {
tmp = t_0;
} else {
tmp = x - (x * (z / 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 t_0 = (x * (y - z)) / y;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = x - (x / (y / z));
} else if ((t_0 <= -2e-63) || (!(t_0 <= 1e-24) && (t_0 <= 1e+260))) {
tmp = t_0;
} else {
tmp = x - (x * (z / y));
}
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 = x - (x / (y / z)) elif (t_0 <= -2e-63) or (not (t_0 <= 1e-24) and (t_0 <= 1e+260)): tmp = t_0 else: tmp = x - (x * (z / y)) 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(x - Float64(x / Float64(y / z))); elseif ((t_0 <= -2e-63) || (!(t_0 <= 1e-24) && (t_0 <= 1e+260))) tmp = t_0; else tmp = Float64(x - Float64(x * Float64(z / y))); 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 = x - (x / (y / z)); elseif ((t_0 <= -2e-63) || (~((t_0 <= 1e-24)) && (t_0 <= 1e+260))) tmp = t_0; else tmp = x - (x * (z / y)); 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[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -2e-63], And[N[Not[LessEqual[t$95$0, 1e-24]], $MachinePrecision], LessEqual[t$95$0, 1e+260]]], t$95$0, N[(x - N[(x * N[(z / y), $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:\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\
\mathbf{elif}\;t_0 \leq -2 \cdot 10^{-63} \lor \neg \left(t_0 \leq 10^{-24}\right) \land t_0 \leq 10^{+260}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot \frac{z}{y}\\
\end{array}
Results
| Original | 80.5% |
|---|---|
| Target | 95.2% |
| Herbie | 99.2% |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -inf.0Initial program 0.0%
Simplified99.9%
[Start]0.0 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
associate-*l/ [<=]99.7 | \[ \color{blue}{\frac{x}{y} \cdot \left(y - z\right)}
\] |
distribute-rgt-out-- [<=]99.7 | \[ \color{blue}{y \cdot \frac{x}{y} - z \cdot \frac{x}{y}}
\] |
associate-*r/ [=>]9.4 | \[ \color{blue}{\frac{y \cdot x}{y}} - z \cdot \frac{x}{y}
\] |
associate-*l/ [<=]99.9 | \[ \color{blue}{\frac{y}{y} \cdot x} - z \cdot \frac{x}{y}
\] |
*-inverses [=>]99.9 | \[ \color{blue}{1} \cdot x - z \cdot \frac{x}{y}
\] |
*-lft-identity [=>]99.9 | \[ \color{blue}{x} - z \cdot \frac{x}{y}
\] |
Taylor expanded in z around 0 65.1%
Simplified99.9%
[Start]65.1 | \[ x - \frac{z \cdot x}{y}
\] |
|---|---|
*-commutative [=>]65.1 | \[ x - \frac{\color{blue}{x \cdot z}}{y}
\] |
associate-/l* [=>]99.9 | \[ x - \color{blue}{\frac{x}{\frac{y}{z}}}
\] |
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -2.00000000000000013e-63 or 9.99999999999999924e-25 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.00000000000000007e260Initial program 99.6%
if -2.00000000000000013e-63 < (/.f64 (*.f64 x (-.f64 y z)) y) < 9.99999999999999924e-25 or 1.00000000000000007e260 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 72.8%
Simplified93.1%
[Start]72.8 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
associate-*l/ [<=]69.9 | \[ \color{blue}{\frac{x}{y} \cdot \left(y - z\right)}
\] |
distribute-rgt-out-- [<=]69.9 | \[ \color{blue}{y \cdot \frac{x}{y} - z \cdot \frac{x}{y}}
\] |
associate-*r/ [=>]71.4 | \[ \color{blue}{\frac{y \cdot x}{y}} - z \cdot \frac{x}{y}
\] |
associate-*l/ [<=]93.1 | \[ \color{blue}{\frac{y}{y} \cdot x} - z \cdot \frac{x}{y}
\] |
*-inverses [=>]93.1 | \[ \color{blue}{1} \cdot x - z \cdot \frac{x}{y}
\] |
*-lft-identity [=>]93.1 | \[ \color{blue}{x} - z \cdot \frac{x}{y}
\] |
Taylor expanded in z around 0 89.9%
Simplified98.6%
[Start]89.9 | \[ x - \frac{z \cdot x}{y}
\] |
|---|---|
associate-*l/ [<=]98.6 | \[ x - \color{blue}{\frac{z}{y} \cdot x}
\] |
Final simplification99.2%
| Alternative 1 | |
|---|---|
| Accuracy | 85.6% |
| Cost | 713 |
| Alternative 2 | |
|---|---|
| Accuracy | 93.4% |
| Cost | 713 |
| Alternative 3 | |
|---|---|
| Accuracy | 97.4% |
| Cost | 713 |
| Alternative 4 | |
|---|---|
| Accuracy | 97.0% |
| Cost | 712 |
| Alternative 5 | |
|---|---|
| Accuracy | 70.9% |
| Cost | 648 |
| Alternative 6 | |
|---|---|
| Accuracy | 70.9% |
| Cost | 648 |
| Alternative 7 | |
|---|---|
| Accuracy | 71.3% |
| Cost | 648 |
| Alternative 8 | |
|---|---|
| Accuracy | 61.3% |
| Cost | 64 |
herbie shell --seed 2023147
(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))