| Alternative 1 | |
|---|---|
| Accuracy | 99.3% |
| Cost | 2512 |
(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 (/ z y)))
(if (<= t_0 -1e-78)
t_0
(if (<= t_0 2e+34)
(fma x (/ (- z) y) x)
(if (<= t_0 9.08e+271) t_0 (- x (/ x (/ 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 = x - (x * (z / y));
} else if (t_0 <= -1e-78) {
tmp = t_0;
} else if (t_0 <= 2e+34) {
tmp = fma(x, (-z / y), x);
} else if (t_0 <= 9.08e+271) {
tmp = t_0;
} else {
tmp = x - (x / (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(x - Float64(x * Float64(z / y))); elseif (t_0 <= -1e-78) tmp = t_0; elseif (t_0 <= 2e+34) tmp = fma(x, Float64(Float64(-z) / y), x); elseif (t_0 <= 9.08e+271) tmp = t_0; else tmp = Float64(x - Float64(x / Float64(y / z))); end return 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[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1e-78], t$95$0, If[LessEqual[t$95$0, 2e+34], N[(x * N[((-z) / y), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 9.08e+271], t$95$0, N[(x - N[(x / 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:\\
\;\;\;\;x - x \cdot \frac{z}{y}\\
\mathbf{elif}\;t_0 \leq -1 \cdot 10^{-78}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{-z}{y}, x\right)\\
\mathbf{elif}\;t_0 \leq 9.08 \cdot 10^{+271}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\
\end{array}
| Original | 80.0% |
|---|---|
| Target | 94.7% |
| Herbie | 99.3% |
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-*r/ [<=]99.9 | \[ \color{blue}{x \cdot \frac{y - z}{y}}
\] |
div-sub [=>]99.9 | \[ x \cdot \color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)}
\] |
distribute-rgt-out-- [<=]99.9 | \[ \color{blue}{\frac{y}{y} \cdot x - \frac{z}{y} \cdot x}
\] |
*-inverses [=>]99.9 | \[ \color{blue}{1} \cdot x - \frac{z}{y} \cdot x
\] |
*-lft-identity [=>]99.9 | \[ \color{blue}{x} - \frac{z}{y} \cdot x
\] |
associate-*l/ [=>]66.2 | \[ x - \color{blue}{\frac{z \cdot x}{y}}
\] |
*-commutative [<=]66.2 | \[ x - \frac{\color{blue}{x \cdot z}}{y}
\] |
associate-/l* [=>]99.9 | \[ x - \color{blue}{\frac{x}{\frac{y}{z}}}
\] |
Applied egg-rr99.9%
[Start]99.9 | \[ x - \frac{x}{\frac{y}{z}}
\] |
|---|---|
associate-/l* [<=]66.2 | \[ x - \color{blue}{\frac{x \cdot z}{y}}
\] |
*-commutative [=>]66.2 | \[ x - \frac{\color{blue}{z \cdot x}}{y}
\] |
associate-*l/ [<=]99.9 | \[ x - \color{blue}{\frac{z}{y} \cdot x}
\] |
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -9.99999999999999999e-79 or 1.99999999999999989e34 < (/.f64 (*.f64 x (-.f64 y z)) y) < 9.0800000000000003e271Initial program 99.5%
if -9.99999999999999999e-79 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.99999999999999989e34Initial program 88.6%
Simplified99.8%
[Start]88.6 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
*-commutative [=>]88.6 | \[ \frac{\color{blue}{\left(y - z\right) \cdot x}}{y}
\] |
associate-*l/ [<=]99.8 | \[ \color{blue}{\frac{y - z}{y} \cdot x}
\] |
div-sub [=>]99.8 | \[ \color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)} \cdot x
\] |
sub-neg [=>]99.8 | \[ \color{blue}{\left(\frac{y}{y} + \left(-\frac{z}{y}\right)\right)} \cdot x
\] |
+-commutative [=>]99.8 | \[ \color{blue}{\left(\left(-\frac{z}{y}\right) + \frac{y}{y}\right)} \cdot x
\] |
*-inverses [=>]99.8 | \[ \left(\left(-\frac{z}{y}\right) + \color{blue}{1}\right) \cdot x
\] |
distribute-lft1-in [<=]99.8 | \[ \color{blue}{\left(-\frac{z}{y}\right) \cdot x + x}
\] |
*-commutative [=>]99.8 | \[ \color{blue}{x \cdot \left(-\frac{z}{y}\right)} + x
\] |
fma-def [=>]99.8 | \[ \color{blue}{\mathsf{fma}\left(x, -\frac{z}{y}, x\right)}
\] |
distribute-neg-frac [=>]99.8 | \[ \mathsf{fma}\left(x, \color{blue}{\frac{-z}{y}}, x\right)
\] |
if 9.0800000000000003e271 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 20.7%
Simplified96.1%
[Start]20.7 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
associate-*r/ [<=]96.0 | \[ \color{blue}{x \cdot \frac{y - z}{y}}
\] |
div-sub [=>]96.0 | \[ x \cdot \color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)}
\] |
distribute-rgt-out-- [<=]96.0 | \[ \color{blue}{\frac{y}{y} \cdot x - \frac{z}{y} \cdot x}
\] |
*-inverses [=>]96.0 | \[ \color{blue}{1} \cdot x - \frac{z}{y} \cdot x
\] |
*-lft-identity [=>]96.0 | \[ \color{blue}{x} - \frac{z}{y} \cdot x
\] |
associate-*l/ [=>]76.2 | \[ x - \color{blue}{\frac{z \cdot x}{y}}
\] |
*-commutative [<=]76.2 | \[ x - \frac{\color{blue}{x \cdot z}}{y}
\] |
associate-/l* [=>]96.1 | \[ x - \color{blue}{\frac{x}{\frac{y}{z}}}
\] |
Final simplification99.3%
| Alternative 1 | |
|---|---|
| Accuracy | 99.3% |
| Cost | 2512 |
| Alternative 2 | |
|---|---|
| Accuracy | 68.2% |
| Cost | 1444 |
| Alternative 3 | |
|---|---|
| Accuracy | 68.1% |
| Cost | 1440 |
| Alternative 4 | |
|---|---|
| Accuracy | 67.9% |
| Cost | 1440 |
| Alternative 5 | |
|---|---|
| Accuracy | 87.5% |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Accuracy | 94.8% |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Accuracy | 95.2% |
| Cost | 448 |
| Alternative 8 | |
|---|---|
| Accuracy | 59.4% |
| Cost | 64 |
herbie shell --seed 2023133
(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))