(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
(if (<= i -3.5147571057147903e-28)
(* 2.0 (fma z t (fma i (* c (- (fma c b a))) (* y x))))
(if (<= i 4.85756880567276e-284)
(* 2.0 (- (fma t z (* y x)) (* c (* i (fma c b a)))))
(* 2.0 (fma z t (fma (fma b c a) (* i (- c)) (* y x)))))))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 tmp;
if (i <= -3.5147571057147903e-28) {
tmp = 2.0 * fma(z, t, fma(i, (c * -fma(c, b, a)), (y * x)));
} else if (i <= 4.85756880567276e-284) {
tmp = 2.0 * (fma(t, z, (y * x)) - (c * (i * fma(c, b, a))));
} else {
tmp = 2.0 * fma(z, t, fma(fma(b, c, a), (i * -c), (y * x)));
}
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) tmp = 0.0 if (i <= -3.5147571057147903e-28) tmp = Float64(2.0 * fma(z, t, fma(i, Float64(c * Float64(-fma(c, b, a))), Float64(y * x)))); elseif (i <= 4.85756880567276e-284) tmp = Float64(2.0 * Float64(fma(t, z, Float64(y * x)) - Float64(c * Float64(i * fma(c, b, a))))); else tmp = Float64(2.0 * fma(z, t, fma(fma(b, c, a), Float64(i * Float64(-c)), Float64(y * x)))); 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_] := If[LessEqual[i, -3.5147571057147903e-28], N[(2.0 * N[(z * t + N[(i * N[(c * (-N[(c * b + a), $MachinePrecision])), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 4.85756880567276e-284], N[(2.0 * N[(N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision] - N[(c * N[(i * N[(c * b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * t + N[(N[(b * c + a), $MachinePrecision] * N[(i * (-c)), $MachinePrecision] + N[(y * x), $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}
\mathbf{if}\;i \leq -3.5147571057147903 \cdot 10^{-28}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(i, c \cdot \left(-\mathsf{fma}\left(c, b, a\right)\right), y \cdot x\right)\right)\\
\mathbf{elif}\;i \leq 4.85756880567276 \cdot 10^{-284}:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - c \cdot \left(i \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), i \cdot \left(-c\right), y \cdot x\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.3 |
|---|---|
| Target | 1.8 |
| Herbie | 1.5 |
if i < -3.5147571057147903e-28Initial program 1.0
Simplified1.6
Taylor expanded in b around 0 18.4
Simplified1.0
Taylor expanded in a around 0 1.0
Simplified1.0
if -3.5147571057147903e-28 < i < 4.85756880567276e-284Initial program 10.6
Simplified2.3
Taylor expanded in z around 0 9.2
Simplified1.7
Taylor expanded in c around 0 9.1
Simplified1.7
if 4.85756880567276e-284 < i Initial program 6.0
Simplified1.5
Final simplification1.5
herbie shell --seed 2022152
(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))))