Average Error: 6.2 → 2.5
Time: 21.3s
Precision: 64
\[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}\;b \le -1.9198517509076077 \cdot 10^{-162} \lor \neg \left(b \le 3.1223938727283748 \cdot 10^{-276}\right):\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot i\right)\right)\\ \end{array}\]
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}\;b \le -1.9198517509076077 \cdot 10^{-162} \lor \neg \left(b \le 3.1223938727283748 \cdot 10^{-276}\right):\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot i\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r783167 = 2.0;
        double r783168 = x;
        double r783169 = y;
        double r783170 = r783168 * r783169;
        double r783171 = z;
        double r783172 = t;
        double r783173 = r783171 * r783172;
        double r783174 = r783170 + r783173;
        double r783175 = a;
        double r783176 = b;
        double r783177 = c;
        double r783178 = r783176 * r783177;
        double r783179 = r783175 + r783178;
        double r783180 = r783179 * r783177;
        double r783181 = i;
        double r783182 = r783180 * r783181;
        double r783183 = r783174 - r783182;
        double r783184 = r783167 * r783183;
        return r783184;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r783185 = b;
        double r783186 = -1.9198517509076077e-162;
        bool r783187 = r783185 <= r783186;
        double r783188 = 3.1223938727283748e-276;
        bool r783189 = r783185 <= r783188;
        double r783190 = !r783189;
        bool r783191 = r783187 || r783190;
        double r783192 = 2.0;
        double r783193 = y;
        double r783194 = x;
        double r783195 = t;
        double r783196 = z;
        double r783197 = c;
        double r783198 = a;
        double r783199 = fma(r783197, r783185, r783198);
        double r783200 = -r783199;
        double r783201 = i;
        double r783202 = r783197 * r783201;
        double r783203 = r783200 * r783202;
        double r783204 = fma(r783195, r783196, r783203);
        double r783205 = fma(r783193, r783194, r783204);
        double r783206 = r783192 * r783205;
        double r783207 = r783200 * r783197;
        double r783208 = r783207 * r783201;
        double r783209 = fma(r783195, r783196, r783208);
        double r783210 = fma(r783193, r783194, r783209);
        double r783211 = r783192 * r783210;
        double r783212 = r783191 ? r783206 : r783211;
        return r783212;
}

Error

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

Target

Original6.2
Target2.0
Herbie2.5
\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)\]

Derivation

  1. Split input into 2 regimes
  2. if b < -1.9198517509076077e-162 or 3.1223938727283748e-276 < b

    1. Initial program 6.5

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
    2. Simplified2.0

      \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)}\]

    if -1.9198517509076077e-162 < b < 3.1223938727283748e-276

    1. Initial program 4.4

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
    2. Simplified1.7

      \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)}\]
    3. Using strategy rm
    4. Applied associate-*r*4.4

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \color{blue}{\left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot i}\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.9198517509076077 \cdot 10^{-162} \lor \neg \left(b \le 3.1223938727283748 \cdot 10^{-276}\right):\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot i\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(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 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))

  (* 2 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))