| Alternative 1 | |
|---|---|
| Accuracy | 94.3% |
| Cost | 580 |
\[\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 5 \cdot 10^{+206}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\]

(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z) :precision binary64 (if (<= (* x y) 5e+206) (/ (* 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 ((x * y) <= 5e+206) {
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 ((x * y) <= 5d+206) 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 ((x * y) <= 5e+206) {
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 (x * y) <= 5e+206: 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 (Float64(x * y) <= 5e+206) 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 ((x * y) <= 5e+206) 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[N[(x * y), $MachinePrecision], 5e+206], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\frac{x \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 5 \cdot 10^{+206}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 92.4% |
|---|---|
| Target | 92.0% |
| Herbie | 94.3% |
if (*.f64 x y) < 5.0000000000000002e206Initial program 97.8%
if 5.0000000000000002e206 < (*.f64 x y) Initial program 78.1%
Simplified96.7%
[Start]78.1% | \[ \frac{x \cdot y}{z}
\] |
|---|---|
associate-*l/ [<=]96.7% | \[ \color{blue}{\frac{x}{z} \cdot y}
\] |
Final simplification97.7%
| Alternative 1 | |
|---|---|
| Accuracy | 94.3% |
| Cost | 580 |
| Alternative 2 | |
|---|---|
| Accuracy | 92.2% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Accuracy | 91.8% |
| Cost | 320 |
herbie shell --seed 2023271
(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))