| Alternative 1 | |
|---|---|
| Accuracy | 92.5% |
| Cost | 713 |
\[\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-219} \lor \neg \left(z \leq 2.5 \cdot 10^{-147}\right):\\
\;\;\;\;x - z \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 -2e+295)
(- x (* z (/ x y)))
(if (or (<= t_0 -2e-101) (and (not (<= t_0 2e+133)) (<= t_0 2e+292)))
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 <= -2e+295) {
tmp = x - (z * (x / y));
} else if ((t_0 <= -2e-101) || (!(t_0 <= 2e+133) && (t_0 <= 2e+292))) {
tmp = t_0;
} else {
tmp = x - (x / (y / z));
}
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 <= (-2d+295)) then
tmp = x - (z * (x / y))
else if ((t_0 <= (-2d-101)) .or. (.not. (t_0 <= 2d+133)) .and. (t_0 <= 2d+292)) then
tmp = t_0
else
tmp = x - (x / (y / z))
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 <= -2e+295) {
tmp = x - (z * (x / y));
} else if ((t_0 <= -2e-101) || (!(t_0 <= 2e+133) && (t_0 <= 2e+292))) {
tmp = t_0;
} else {
tmp = x - (x / (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 <= -2e+295: tmp = x - (z * (x / y)) elif (t_0 <= -2e-101) or (not (t_0 <= 2e+133) and (t_0 <= 2e+292)): 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 <= -2e+295) tmp = Float64(x - Float64(z * Float64(x / y))); elseif ((t_0 <= -2e-101) || (!(t_0 <= 2e+133) && (t_0 <= 2e+292))) tmp = t_0; else tmp = Float64(x - Float64(x / 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 <= -2e+295) tmp = x - (z * (x / y)); elseif ((t_0 <= -2e-101) || (~((t_0 <= 2e+133)) && (t_0 <= 2e+292))) tmp = t_0; else tmp = x - (x / (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, -2e+295], N[(x - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -2e-101], And[N[Not[LessEqual[t$95$0, 2e+133]], $MachinePrecision], LessEqual[t$95$0, 2e+292]]], 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 -2 \cdot 10^{+295}:\\
\;\;\;\;x - z \cdot \frac{x}{y}\\
\mathbf{elif}\;t_0 \leq -2 \cdot 10^{-101} \lor \neg \left(t_0 \leq 2 \cdot 10^{+133}\right) \land t_0 \leq 2 \cdot 10^{+292}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\
\end{array}
Results
| Original | 80.1% |
|---|---|
| Target | 95.0% |
| Herbie | 98.6% |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -2e295Initial program 9.7%
Simplified94.9%
[Start]9.7 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
associate-*l/ [<=]94.8 | \[ \color{blue}{\frac{x}{y} \cdot \left(y - z\right)}
\] |
distribute-rgt-out-- [<=]94.8 | \[ \color{blue}{y \cdot \frac{x}{y} - z \cdot \frac{x}{y}}
\] |
associate-*r/ [=>]11.9 | \[ \color{blue}{\frac{y \cdot x}{y}} - z \cdot \frac{x}{y}
\] |
associate-*l/ [<=]94.9 | \[ \color{blue}{\frac{y}{y} \cdot x} - z \cdot \frac{x}{y}
\] |
*-inverses [=>]94.9 | \[ \color{blue}{1} \cdot x - z \cdot \frac{x}{y}
\] |
*-lft-identity [=>]94.9 | \[ \color{blue}{x} - z \cdot \frac{x}{y}
\] |
if -2e295 < (/.f64 (*.f64 x (-.f64 y z)) y) < -2.0000000000000001e-101 or 2e133 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2e292Initial program 99.5%
if -2.0000000000000001e-101 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2e133 or 2e292 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 77.0%
Simplified94.9%
[Start]77.0 | \[ \frac{x \cdot \left(y - z\right)}{y}
\] |
|---|---|
associate-*l/ [<=]75.1 | \[ \color{blue}{\frac{x}{y} \cdot \left(y - z\right)}
\] |
distribute-rgt-out-- [<=]75.1 | \[ \color{blue}{y \cdot \frac{x}{y} - z \cdot \frac{x}{y}}
\] |
associate-*r/ [=>]77.4 | \[ \color{blue}{\frac{y \cdot x}{y}} - z \cdot \frac{x}{y}
\] |
associate-*l/ [<=]94.9 | \[ \color{blue}{\frac{y}{y} \cdot x} - z \cdot \frac{x}{y}
\] |
*-inverses [=>]94.9 | \[ \color{blue}{1} \cdot x - z \cdot \frac{x}{y}
\] |
*-lft-identity [=>]94.9 | \[ \color{blue}{x} - z \cdot \frac{x}{y}
\] |
Taylor expanded in z around 0 90.3%
Simplified98.6%
[Start]90.3 | \[ x - \frac{z \cdot x}{y}
\] |
|---|---|
*-commutative [=>]90.3 | \[ x - \frac{\color{blue}{x \cdot z}}{y}
\] |
associate-/l* [=>]98.6 | \[ x - \color{blue}{\frac{x}{\frac{y}{z}}}
\] |
Final simplification98.6%
| Alternative 1 | |
|---|---|
| Accuracy | 92.5% |
| Cost | 713 |
| Alternative 2 | |
|---|---|
| Accuracy | 97.0% |
| Cost | 713 |
| Alternative 3 | |
|---|---|
| Accuracy | 69.5% |
| Cost | 649 |
| Alternative 4 | |
|---|---|
| Accuracy | 60.6% |
| Cost | 64 |
herbie shell --seed 2023151
(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))