| Alternative 1 | |
|---|---|
| Accuracy | 68.0% |
| Cost | 649 |
\[\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+61} \lor \neg \left(z \leq 1.6 \cdot 10^{+95}\right):\\
\;\;\;\;x \cdot \frac{-z}{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 (or (<= t_0 -4e+263) (not (<= t_0 -2e+94))) (- x (/ x (/ y z))) t_0)))
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 <= -4e+263) || !(t_0 <= -2e+94)) {
tmp = x - (x / (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (y - z)) / y
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x * (y - z)) / y
if ((t_0 <= (-4d+263)) .or. (.not. (t_0 <= (-2d+94)))) then
tmp = x - (x / (y / z))
else
tmp = t_0
end if
code = tmp
end function
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 <= -4e+263) || !(t_0 <= -2e+94)) {
tmp = x - (x / (y / z));
} else {
tmp = t_0;
}
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 <= -4e+263) or not (t_0 <= -2e+94): tmp = x - (x / (y / z)) else: tmp = t_0 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 <= -4e+263) || !(t_0 <= -2e+94)) tmp = Float64(x - Float64(x / Float64(y / z))); else tmp = t_0; 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 <= -4e+263) || ~((t_0 <= -2e+94))) tmp = x - (x / (y / z)); else tmp = t_0; 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[Or[LessEqual[t$95$0, -4e+263], N[Not[LessEqual[t$95$0, -2e+94]], $MachinePrecision]], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\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 -4 \cdot 10^{+263} \lor \neg \left(t_0 \leq -2 \cdot 10^{+94}\right):\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Results
| Original | 80.9% |
|---|---|
| Target | 95.2% |
| Herbie | 96.6% |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -4.00000000000000006e263 or -2e94 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 78.5%
Simplified96.2%
[Start]78.5 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
associate-*r/ [<=]95.8 | \[ \color{blue}{x \cdot \frac{y - z}{y}}
\] |
div-sub [=>]95.8 | \[ x \cdot \color{blue}{\left(\frac{y}{y} - \frac{z}{y}\right)}
\] |
distribute-rgt-out-- [<=]95.9 | \[ \color{blue}{\frac{y}{y} \cdot x - \frac{z}{y} \cdot x}
\] |
*-inverses [=>]95.9 | \[ \color{blue}{1} \cdot x - \frac{z}{y} \cdot x
\] |
*-lft-identity [=>]95.9 | \[ \color{blue}{x} - \frac{z}{y} \cdot x
\] |
associate-*l/ [=>]91.7 | \[ x - \color{blue}{\frac{z \cdot x}{y}}
\] |
*-commutative [<=]91.7 | \[ x - \frac{\color{blue}{x \cdot z}}{y}
\] |
associate-/l* [=>]96.2 | \[ x - \color{blue}{\frac{x}{\frac{y}{z}}}
\] |
if -4.00000000000000006e263 < (/.f64 (*.f64 x (-.f64 y z)) y) < -2e94Initial program 99.7%
Final simplification96.6%
| Alternative 1 | |
|---|---|
| Accuracy | 68.0% |
| Cost | 649 |
| Alternative 2 | |
|---|---|
| Accuracy | 70.5% |
| Cost | 649 |
| Alternative 3 | |
|---|---|
| Accuracy | 95.1% |
| Cost | 448 |
| Alternative 4 | |
|---|---|
| Accuracy | 59.5% |
| Cost | 64 |
herbie shell --seed 2023135
(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))