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

(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t) :precision binary64 (if (<= t -1.05e+102) (/ x (/ z y)) (/ y (/ z x))))
double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.05e+102) {
tmp = x / (z / y);
} else {
tmp = y / (z / x);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * (((y / z) * t) / t)
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-1.05d+102)) then
tmp = x / (z / y)
else
tmp = y / (z / x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.05e+102) {
tmp = x / (z / y);
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
def code(x, y, z, t): tmp = 0 if t <= -1.05e+102: tmp = x / (z / y) else: tmp = y / (z / x) return tmp
function code(x, y, z, t) return Float64(x * Float64(Float64(Float64(y / z) * t) / t)) end
function code(x, y, z, t) tmp = 0.0 if (t <= -1.05e+102) tmp = Float64(x / Float64(z / y)); else tmp = Float64(y / Float64(z / x)); end return tmp end
function tmp = code(x, y, z, t) tmp = x * (((y / z) * t) / t); end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.05e+102) tmp = x / (z / y); else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[t, -1.05e+102], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -1.05 \cdot 10^{+102}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 81.7% |
|---|---|
| Target | 98.1% |
| Herbie | 92.6% |
if t < -1.05000000000000001e102Initial program 68.3%
Simplified88.9%
[Start]68.3% | \[ x \cdot \frac{\frac{y}{z} \cdot t}{t}
\] |
|---|---|
associate-/l* [=>]88.9% | \[ x \cdot \color{blue}{\frac{\frac{y}{z}}{\frac{t}{t}}}
\] |
*-inverses [=>]88.9% | \[ x \cdot \frac{\frac{y}{z}}{\color{blue}{1}}
\] |
/-rgt-identity [=>]88.9% | \[ x \cdot \color{blue}{\frac{y}{z}}
\] |
Applied egg-rr89.5%
[Start]88.9% | \[ x \cdot \frac{y}{z}
\] |
|---|---|
clear-num [=>]87.3% | \[ x \cdot \color{blue}{\frac{1}{\frac{z}{y}}}
\] |
un-div-inv [=>]89.5% | \[ \color{blue}{\frac{x}{\frac{z}{y}}}
\] |
if -1.05000000000000001e102 < t Initial program 88.1%
Simplified96.8%
[Start]88.1% | \[ x \cdot \frac{\frac{y}{z} \cdot t}{t}
\] |
|---|---|
associate-/l* [=>]96.8% | \[ x \cdot \color{blue}{\frac{\frac{y}{z}}{\frac{t}{t}}}
\] |
*-inverses [=>]96.8% | \[ x \cdot \frac{\frac{y}{z}}{\color{blue}{1}}
\] |
/-rgt-identity [=>]96.8% | \[ x \cdot \color{blue}{\frac{y}{z}}
\] |
Applied egg-rr92.3%
[Start]96.8% | \[ x \cdot \frac{y}{z}
\] |
|---|---|
associate-*r/ [=>]88.2% | \[ \color{blue}{\frac{x \cdot y}{z}}
\] |
*-commutative [=>]88.2% | \[ \frac{\color{blue}{y \cdot x}}{z}
\] |
associate-/l* [=>]92.3% | \[ \color{blue}{\frac{y}{\frac{z}{x}}}
\] |
Final simplification91.8%
| Alternative 1 | |
|---|---|
| Accuracy | 92.6% |
| Cost | 452 |
| Alternative 2 | |
|---|---|
| Accuracy | 92.6% |
| Cost | 452 |
| Alternative 3 | |
|---|---|
| Accuracy | 92.4% |
| Cost | 320 |
| Alternative 4 | |
|---|---|
| Accuracy | 92.6% |
| Cost | 320 |
herbie shell --seed 2023271
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
:precision binary64
:herbie-target
(if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))
(* x (/ (* (/ y z) t) t)))