| Alternative 1 | |
|---|---|
| Accuracy | 92.6% |
| Cost | 452 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-283}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\]

(FPCore (x y z) :precision binary64 (/ (* x y) z))
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= x -7.5e-283) (/ x (/ z y)) (* y (/ x z))))
double code(double x, double y, double z) {
return (x * y) / z;
}
assert(x < y);
double code(double x, double y, double z) {
double tmp;
if (x <= -7.5e-283) {
tmp = x / (z / y);
} 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
NOTE: x and y should be sorted in increasing order before calling this 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 <= (-7.5d-283)) then
tmp = x / (z / y)
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;
}
assert x < y;
public static double code(double x, double y, double z) {
double tmp;
if (x <= -7.5e-283) {
tmp = x / (z / y);
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): return (x * y) / z
[x, y] = sort([x, y]) def code(x, y, z): tmp = 0 if x <= -7.5e-283: tmp = x / (z / y) else: tmp = y * (x / z) return tmp
function code(x, y, z) return Float64(Float64(x * y) / z) end
x, y = sort([x, y]) function code(x, y, z) tmp = 0.0 if (x <= -7.5e-283) tmp = Float64(x / Float64(z / y)); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp = code(x, y, z) tmp = (x * y) / z; end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (x <= -7.5e-283)
tmp = x / (z / y);
else
tmp = y * (x / z);
end
tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[x, -7.5e-283], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\frac{x \cdot y}{z}
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-283}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 92.2% |
|---|---|
| Target | 92.0% |
| Herbie | 92.6% |
if x < -7.5000000000000001e-283Initial program 88.7%
Simplified98.3%
[Start]88.7% | \[ \frac{x \cdot y}{z}
\] |
|---|---|
associate-/l* [=>]98.3% | \[ \color{blue}{\frac{x}{\frac{z}{y}}}
\] |
if -7.5000000000000001e-283 < x Initial program 91.5%
Simplified93.4%
[Start]91.5% | \[ \frac{x \cdot y}{z}
\] |
|---|---|
associate-*l/ [<=]93.4% | \[ \color{blue}{\frac{x}{z} \cdot y}
\] |
Final simplification95.8%
| Alternative 1 | |
|---|---|
| Accuracy | 92.6% |
| Cost | 452 |
| Alternative 2 | |
|---|---|
| Accuracy | 92.8% |
| Cost | 452 |
| Alternative 3 | |
|---|---|
| Accuracy | 92.1% |
| Cost | 320 |
herbie shell --seed 2023167
(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))