(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (+ y z)) z)))
(if (<= t_0 -1.6809885121048745e+104)
(+ x (/ y (/ z x)))
(if (<= t_0 1.208491790712971e-65)
(fma x (/ y z) x)
(if (<= t_0 3.712242571148193e+294)
(+ x (/ 1.0 (/ z (* x y))))
(+ x (* y (/ x z))))))))double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
double t_0 = (x * (y + z)) / z;
double tmp;
if (t_0 <= -1.6809885121048745e+104) {
tmp = x + (y / (z / x));
} else if (t_0 <= 1.208491790712971e-65) {
tmp = fma(x, (y / z), x);
} else if (t_0 <= 3.712242571148193e+294) {
tmp = x + (1.0 / (z / (x * y)));
} else {
tmp = x + (y * (x / z));
}
return tmp;
}
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y + z)) / z) tmp = 0.0 if (t_0 <= -1.6809885121048745e+104) tmp = Float64(x + Float64(y / Float64(z / x))); elseif (t_0 <= 1.208491790712971e-65) tmp = fma(x, Float64(y / z), x); elseif (t_0 <= 3.712242571148193e+294) tmp = Float64(x + Float64(1.0 / Float64(z / Float64(x * y)))); else tmp = Float64(x + Float64(y * Float64(x / z))); end return tmp end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, -1.6809885121048745e+104], N[(x + N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.208491790712971e-65], N[(x * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 3.712242571148193e+294], N[(x + N[(1.0 / N[(z / N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y + z\right)}{z}\\
\mathbf{if}\;t_0 \leq -1.6809885121048745 \cdot 10^{+104}:\\
\;\;\;\;x + \frac{y}{\frac{z}{x}}\\
\mathbf{elif}\;t_0 \leq 1.208491790712971 \cdot 10^{-65}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{z}, x\right)\\
\mathbf{elif}\;t_0 \leq 3.712242571148193 \cdot 10^{+294}:\\
\;\;\;\;x + \frac{1}{\frac{z}{x \cdot y}}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{x}{z}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 12.2 |
|---|---|
| Target | 3.1 |
| Herbie | 1.7 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < -1.6809885121048745e104Initial program 22.6
Simplified7.1
Taylor expanded in y around 0 7.8
Applied associate-/l*_binary646.1
if -1.6809885121048745e104 < (/.f64 (*.f64 x (+.f64 y z)) z) < 1.208491790712971e-65Initial program 6.1
Simplified0.6
Taylor expanded in y around 0 3.3
Applied *-un-lft-identity_binary643.3
Applied *-un-lft-identity_binary643.3
Applied distribute-lft-out_binary643.3
Simplified0.6
if 1.208491790712971e-65 < (/.f64 (*.f64 x (+.f64 y z)) z) < 3.7122425711481931e294Initial program 0.3
Simplified5.9
Taylor expanded in y around 0 0.2
Applied clear-num_binary640.3
if 3.7122425711481931e294 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 59.7
Simplified1.0
Taylor expanded in y around 0 21.2
Applied *-un-lft-identity_binary6421.2
Applied times-frac_binary642.1
Simplified2.1
Final simplification1.7
herbie shell --seed 2022129
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))