(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* c (+ a (* b c)))))
(if (<= t_1 5e-173)
(* 2.0 (fma z t (fma (fma b c a) (* c (- i)) (* x y))))
(if (<= t_1 1e+204)
(* 2.0 (fma z t (- (* x y) (* i (+ (* a c) (* b (pow c 2.0)))))))
(* 2.0 (fma z t (fma x y (- (fma c (* a i) (* c (* b (* c i))))))))))))double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = c * (a + (b * c));
double tmp;
if (t_1 <= 5e-173) {
tmp = 2.0 * fma(z, t, fma(fma(b, c, a), (c * -i), (x * y)));
} else if (t_1 <= 1e+204) {
tmp = 2.0 * fma(z, t, ((x * y) - (i * ((a * c) + (b * pow(c, 2.0))))));
} else {
tmp = 2.0 * fma(z, t, fma(x, y, -fma(c, (a * i), (c * (b * (c * i))))));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function code(x, y, z, t, a, b, c, i) t_1 = Float64(c * Float64(a + Float64(b * c))) tmp = 0.0 if (t_1 <= 5e-173) tmp = Float64(2.0 * fma(z, t, fma(fma(b, c, a), Float64(c * Float64(-i)), Float64(x * y)))); elseif (t_1 <= 1e+204) tmp = Float64(2.0 * fma(z, t, Float64(Float64(x * y) - Float64(i * Float64(Float64(a * c) + Float64(b * (c ^ 2.0))))))); else tmp = Float64(2.0 * fma(z, t, fma(x, y, Float64(-fma(c, Float64(a * i), Float64(c * Float64(b * Float64(c * i)))))))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(c * N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-173], N[(2.0 * N[(z * t + N[(N[(b * c + a), $MachinePrecision] * N[(c * (-i)), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+204], N[(2.0 * N[(z * t + N[(N[(x * y), $MachinePrecision] - N[(i * N[(N[(a * c), $MachinePrecision] + N[(b * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * t + N[(x * y + (-N[(c * N[(a * i), $MachinePrecision] + N[(c * N[(b * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\begin{array}{l}
t_1 := c \cdot \left(a + b \cdot c\right)\\
\mathbf{if}\;t_1 \leq 5 \cdot 10^{-173}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), c \cdot \left(-i\right), x \cdot y\right)\right)\\
\mathbf{elif}\;t_1 \leq 10^{+204}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, x \cdot y - i \cdot \left(a \cdot c + b \cdot {c}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, -\mathsf{fma}\left(c, a \cdot i, c \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)\right)\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a




Bits error versus b




Bits error versus c




Bits error versus i
| Original | 6.5 |
|---|---|
| Target | 2.0 |
| Herbie | 1.6 |
if (*.f64 (+.f64 a (*.f64 b c)) c) < 5.0000000000000002e-173Initial program 5.3
Simplified1.7
if 5.0000000000000002e-173 < (*.f64 (+.f64 a (*.f64 b c)) c) < 9.99999999999999989e203Initial program 0.1
Simplified1.6
Taylor expanded in b around 0 11.8
Taylor expanded in i around inf 2.0
if 9.99999999999999989e203 < (*.f64 (+.f64 a (*.f64 b c)) c) Initial program 31.4
Simplified5.0
Taylor expanded in b around 0 27.4
Applied egg-rr10.5
Applied egg-rr0.4
Final simplification1.6
herbie shell --seed 2022166
(FPCore (x y z t a b c i)
:name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
:precision binary64
:herbie-target
(* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))
(* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))