(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ x (/ z y))) (t_2 (/ y (/ z x))))
(if (<= (/ y z) -1.1302820992287937e+282)
t_2
(if (<= (/ y z) -3.3661765824879353e-113)
t_1
(if (<= (/ y z) 6.72368e-318)
t_2
(if (<= (/ y z) 1.3164353627601914e+143) t_1 (/ (* y x) z)))))))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 = x / (z / y);
double t_2 = y / (z / x);
double tmp;
if ((y / z) <= -1.1302820992287937e+282) {
tmp = t_2;
} else if ((y / z) <= -3.3661765824879353e-113) {
tmp = t_1;
} else if ((y / z) <= 6.72368e-318) {
tmp = t_2;
} else if ((y / z) <= 1.3164353627601914e+143) {
tmp = t_1;
} else {
tmp = (y * x) / z;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x / (z / y)
t_2 = y / (z / x)
if ((y / z) <= (-1.1302820992287937d+282)) then
tmp = t_2
else if ((y / z) <= (-3.3661765824879353d-113)) then
tmp = t_1
else if ((y / z) <= 6.72368d-318) then
tmp = t_2
else if ((y / z) <= 1.3164353627601914d+143) then
tmp = t_1
else
tmp = (y * x) / z
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 t_1 = x / (z / y);
double t_2 = y / (z / x);
double tmp;
if ((y / z) <= -1.1302820992287937e+282) {
tmp = t_2;
} else if ((y / z) <= -3.3661765824879353e-113) {
tmp = t_1;
} else if ((y / z) <= 6.72368e-318) {
tmp = t_2;
} else if ((y / z) <= 1.3164353627601914e+143) {
tmp = t_1;
} else {
tmp = (y * x) / z;
}
return tmp;
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
def code(x, y, z, t): t_1 = x / (z / y) t_2 = y / (z / x) tmp = 0 if (y / z) <= -1.1302820992287937e+282: tmp = t_2 elif (y / z) <= -3.3661765824879353e-113: tmp = t_1 elif (y / z) <= 6.72368e-318: tmp = t_2 elif (y / z) <= 1.3164353627601914e+143: tmp = t_1 else: tmp = (y * x) / z 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(x / Float64(z / y)) t_2 = Float64(y / Float64(z / x)) tmp = 0.0 if (Float64(y / z) <= -1.1302820992287937e+282) tmp = t_2; elseif (Float64(y / z) <= -3.3661765824879353e-113) tmp = t_1; elseif (Float64(y / z) <= 6.72368e-318) tmp = t_2; elseif (Float64(y / z) <= 1.3164353627601914e+143) tmp = t_1; else tmp = Float64(Float64(y * x) / z); 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 = x / (z / y); t_2 = y / (z / x); tmp = 0.0; if ((y / z) <= -1.1302820992287937e+282) tmp = t_2; elseif ((y / z) <= -3.3661765824879353e-113) tmp = t_1; elseif ((y / z) <= 6.72368e-318) tmp = t_2; elseif ((y / z) <= 1.3164353627601914e+143) tmp = t_1; else tmp = (y * x) / z; 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[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], -1.1302820992287937e+282], t$95$2, If[LessEqual[N[(y / z), $MachinePrecision], -3.3661765824879353e-113], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], 6.72368e-318], t$95$2, If[LessEqual[N[(y / z), $MachinePrecision], 1.3164353627601914e+143], t$95$1, N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]]]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := \frac{x}{\frac{z}{y}}\\
t_2 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;\frac{y}{z} \leq -1.1302820992287937 \cdot 10^{+282}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{y}{z} \leq -3.3661765824879353 \cdot 10^{-113}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq 6.72368 \cdot 10^{-318}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{y}{z} \leq 1.3164353627601914 \cdot 10^{+143}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 15.0 |
|---|---|
| Target | 1.5 |
| Herbie | 1.0 |
if (/.f64 y z) < -1.1302820992287937e282 or -3.36617658248793534e-113 < (/.f64 y z) < 6.7236801e-318Initial program 21.0
Simplified14.4
Taylor expanded in x around 0 1.5
Simplified1.6
Applied egg-rr1.7
if -1.1302820992287937e282 < (/.f64 y z) < -3.36617658248793534e-113 or 6.7236801e-318 < (/.f64 y z) < 1.3164353627601914e143Initial program 9.0
Simplified0.5
if 1.3164353627601914e143 < (/.f64 y z) Initial program 34.2
Simplified16.2
Taylor expanded in x around 0 2.3
Final simplification1.0
herbie shell --seed 2022153
(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)))