(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ y (/ z x))))
(if (<= (/ y z) -3.367633030424483e+163)
t_1
(if (<= (/ y z) -4.160115403043379e-41)
(* (/ y z) x)
(if (<= (/ y z) 5.651467744425165e-254)
(* y (/ x z))
(if (<= (/ y z) 9.366731369076651e+178) (/ 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 / (z / x);
double tmp;
if ((y / z) <= -3.367633030424483e+163) {
tmp = t_1;
} else if ((y / z) <= -4.160115403043379e-41) {
tmp = (y / z) * x;
} else if ((y / z) <= 5.651467744425165e-254) {
tmp = y * (x / z);
} else if ((y / z) <= 9.366731369076651e+178) {
tmp = x / (z / y);
} else {
tmp = t_1;
}
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) :: tmp
t_1 = y / (z / x)
if ((y / z) <= (-3.367633030424483d+163)) then
tmp = t_1
else if ((y / z) <= (-4.160115403043379d-41)) then
tmp = (y / z) * x
else if ((y / z) <= 5.651467744425165d-254) then
tmp = y * (x / z)
else if ((y / z) <= 9.366731369076651d+178) then
tmp = x / (z / y)
else
tmp = t_1
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 = y / (z / x);
double tmp;
if ((y / z) <= -3.367633030424483e+163) {
tmp = t_1;
} else if ((y / z) <= -4.160115403043379e-41) {
tmp = (y / z) * x;
} else if ((y / z) <= 5.651467744425165e-254) {
tmp = y * (x / z);
} else if ((y / z) <= 9.366731369076651e+178) {
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 / (z / x) tmp = 0 if (y / z) <= -3.367633030424483e+163: tmp = t_1 elif (y / z) <= -4.160115403043379e-41: tmp = (y / z) * x elif (y / z) <= 5.651467744425165e-254: tmp = y * (x / z) elif (y / z) <= 9.366731369076651e+178: 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(z / x)) tmp = 0.0 if (Float64(y / z) <= -3.367633030424483e+163) tmp = t_1; elseif (Float64(y / z) <= -4.160115403043379e-41) tmp = Float64(Float64(y / z) * x); elseif (Float64(y / z) <= 5.651467744425165e-254) tmp = Float64(y * Float64(x / z)); elseif (Float64(y / z) <= 9.366731369076651e+178) 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 / (z / x); tmp = 0.0; if ((y / z) <= -3.367633030424483e+163) tmp = t_1; elseif ((y / z) <= -4.160115403043379e-41) tmp = (y / z) * x; elseif ((y / z) <= 5.651467744425165e-254) tmp = y * (x / z); elseif ((y / z) <= 9.366731369076651e+178) 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[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], -3.367633030424483e+163], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], -4.160115403043379e-41], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 5.651467744425165e-254], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 9.366731369076651e+178], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;\frac{y}{z} \leq -3.367633030424483 \cdot 10^{+163}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq -4.160115403043379 \cdot 10^{-41}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\mathbf{elif}\;\frac{y}{z} \leq 5.651467744425165 \cdot 10^{-254}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;\frac{y}{z} \leq 9.366731369076651 \cdot 10^{+178}:\\
\;\;\;\;\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 | 15.1 |
|---|---|
| Target | 1.7 |
| Herbie | 1.4 |
if (/.f64 y z) < -3.3676330304244828e163 or 9.36673136907665148e178 < (/.f64 y z) Initial program 37.8
Simplified21.1
Taylor expanded in x around 0 1.7
Applied egg-rr2.0
Applied egg-rr1.8
if -3.3676330304244828e163 < (/.f64 y z) < -4.1601154030433789e-41Initial program 6.6
Simplified0.2
if -4.1601154030433789e-41 < (/.f64 y z) < 5.6514677444251647e-254Initial program 14.7
Simplified8.0
Taylor expanded in x around 0 2.9
Applied egg-rr2.8
Taylor expanded in x around 0 2.8
if 5.6514677444251647e-254 < (/.f64 y z) < 9.36673136907665148e178Initial program 9.0
Simplified0.2
Applied egg-rr0.2
Final simplification1.4
herbie shell --seed 2022134
(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)))