| Alternative 1 | |
|---|---|
| Accuracy | 92.3% |
| Cost | 320 |
\[x \cdot \frac{y}{z}
\]

(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z) :precision binary64 (if (<= z 2.7e-174) (/ (* x y) z) (* y (/ x z))))
double code(double x, double y, double z) {
return (x * y) / z;
}
double code(double x, double y, double z) {
double tmp;
if (z <= 2.7e-174) {
tmp = (x * y) / z;
} else {
tmp = y * (x / 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
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) :: tmp
if (z <= 2.7d-174) then
tmp = (x * y) / z
else
tmp = y * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (x * y) / z;
}
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2.7e-174) {
tmp = (x * y) / z;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): return (x * y) / z
def code(x, y, z): tmp = 0 if z <= 2.7e-174: tmp = (x * y) / z else: tmp = y * (x / z) return tmp
function code(x, y, z) return Float64(Float64(x * y) / z) end
function code(x, y, z) tmp = 0.0 if (z <= 2.7e-174) tmp = Float64(Float64(x * y) / z); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp = code(x, y, z) tmp = (x * y) / z; end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2.7e-174) tmp = (x * y) / z; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[z, 2.7e-174], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;z \leq 2.7 \cdot 10^{-174}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 92.2% |
|---|---|
| Target | 91.6% |
| Herbie | 91.7% |
if z < 2.69999999999999988e-174Initial program 94.4%
if 2.69999999999999988e-174 < z Initial program 87.0%
Simplified94.6%
[Start]87.0 | \[ \frac{x \cdot y}{z}
\] |
|---|---|
associate-*l/ [<=]94.6 | \[ \color{blue}{\frac{x}{z} \cdot y}
\] |
Final simplification94.5%
| Alternative 1 | |
|---|---|
| Accuracy | 92.3% |
| Cost | 320 |
| Alternative 2 | |
|---|---|
| Accuracy | 91.7% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Accuracy | 91.8% |
| Cost | 320 |
herbie shell --seed 2023161
(FPCore (x y z)
:name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, A"
:precision binary64
:herbie-target
(if (< z -4.262230790519429e-138) (/ (* x y) z) (if (< z 1.7042130660650472e-164) (/ x (/ z y)) (* (/ x z) y)))
(/ (* x y) z))