(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (/ x z))))
(if (<= (/ y z) (- INFINITY))
t_1
(if (<= (/ y z) -2e-236)
(* (/ y z) x)
(if (<= (/ y z) 5e-57)
(/ (* y (- x)) (- z))
(if (<= (/ y z) 5e+160) (/ x (/ z y)) t_1))))))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 t_1 = y * (x / z);
double tmp;
if ((y / z) <= -((double) INFINITY)) {
tmp = t_1;
} else if ((y / z) <= -2e-236) {
tmp = (y / z) * x;
} else if ((y / z) <= 5e-57) {
tmp = (y * -x) / -z;
} else if ((y / z) <= 5e+160) {
tmp = x / (z / y);
} else {
tmp = t_1;
}
return tmp;
}
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 t_1 = y * (x / z);
double tmp;
if ((y / z) <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if ((y / z) <= -2e-236) {
tmp = (y / z) * x;
} else if ((y / z) <= 5e-57) {
tmp = (y * -x) / -z;
} else if ((y / z) <= 5e+160) {
tmp = x / (z / y);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
def code(x, y, z, t): t_1 = y * (x / z) tmp = 0 if (y / z) <= -math.inf: tmp = t_1 elif (y / z) <= -2e-236: tmp = (y / z) * x elif (y / z) <= 5e-57: tmp = (y * -x) / -z elif (y / z) <= 5e+160: tmp = x / (z / y) else: tmp = t_1 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) t_1 = Float64(y * Float64(x / z)) tmp = 0.0 if (Float64(y / z) <= Float64(-Inf)) tmp = t_1; elseif (Float64(y / z) <= -2e-236) tmp = Float64(Float64(y / z) * x); elseif (Float64(y / z) <= 5e-57) tmp = Float64(Float64(y * Float64(-x)) / Float64(-z)); elseif (Float64(y / z) <= 5e+160) tmp = Float64(x / Float64(z / y)); else tmp = t_1; 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) t_1 = y * (x / z); tmp = 0.0; if ((y / z) <= -Inf) tmp = t_1; elseif ((y / z) <= -2e-236) tmp = (y / z) * x; elseif ((y / z) <= 5e-57) tmp = (y * -x) / -z; elseif ((y / z) <= 5e+160) tmp = x / (z / y); else tmp = t_1; 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_] := Block[{t$95$1 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], (-Infinity)], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], -2e-236], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 5e-57], N[(N[(y * (-x)), $MachinePrecision] / (-z)), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 5e+160], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := y \cdot \frac{x}{z}\\
\mathbf{if}\;\frac{y}{z} \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-236}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{-57}:\\
\;\;\;\;\frac{y \cdot \left(-x\right)}{-z}\\
\mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{+160}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 14.8 |
|---|---|
| Target | 1.6 |
| Herbie | 1.2 |
if (/.f64 y z) < -inf.0 or 5.0000000000000002e160 < (/.f64 y z) Initial program 42.7
Simplified26.4
Taylor expanded in x around 0 2.0
Simplified1.8
if -inf.0 < (/.f64 y z) < -2.0000000000000001e-236Initial program 10.9
Simplified0.2
Applied egg-rr0.2
if -2.0000000000000001e-236 < (/.f64 y z) < 5.0000000000000002e-57Initial program 14.9
Simplified8.2
Taylor expanded in x around 0 2.5
Simplified2.4
Applied egg-rr2.5
if 5.0000000000000002e-57 < (/.f64 y z) < 5.0000000000000002e160Initial program 6.5
Simplified0.3
Final simplification1.2
herbie shell --seed 2022162
(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)))