Average Error: 6.7 → 1.8
Time: 21.7s
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}\;c \le -9.836913490220496580499301553870379295751 \cdot 10^{-80} \lor \neg \left(c \le 3.128354228323495917583504820869116081353 \cdot 10^{-78}\right):\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right) \cdot i\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}\;c \le -9.836913490220496580499301553870379295751 \cdot 10^{-80} \lor \neg \left(c \le 3.128354228323495917583504820869116081353 \cdot 10^{-78}\right):\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r415479 = 2.0;
        double r415480 = x;
        double r415481 = y;
        double r415482 = r415480 * r415481;
        double r415483 = z;
        double r415484 = t;
        double r415485 = r415483 * r415484;
        double r415486 = r415482 + r415485;
        double r415487 = a;
        double r415488 = b;
        double r415489 = c;
        double r415490 = r415488 * r415489;
        double r415491 = r415487 + r415490;
        double r415492 = r415491 * r415489;
        double r415493 = i;
        double r415494 = r415492 * r415493;
        double r415495 = r415486 - r415494;
        double r415496 = r415479 * r415495;
        return r415496;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r415497 = c;
        double r415498 = -9.836913490220497e-80;
        bool r415499 = r415497 <= r415498;
        double r415500 = 3.128354228323496e-78;
        bool r415501 = r415497 <= r415500;
        double r415502 = !r415501;
        bool r415503 = r415499 || r415502;
        double r415504 = 2.0;
        double r415505 = y;
        double r415506 = x;
        double r415507 = z;
        double r415508 = t;
        double r415509 = r415507 * r415508;
        double r415510 = b;
        double r415511 = a;
        double r415512 = fma(r415497, r415510, r415511);
        double r415513 = i;
        double r415514 = r415512 * r415513;
        double r415515 = r415497 * r415514;
        double r415516 = r415509 - r415515;
        double r415517 = fma(r415505, r415506, r415516);
        double r415518 = r415504 * r415517;
        double r415519 = r415497 * r415512;
        double r415520 = r415519 * r415513;
        double r415521 = r415509 - r415520;
        double r415522 = fma(r415505, r415506, r415521);
        double r415523 = r415504 * r415522;
        double r415524 = r415503 ? r415518 : r415523;
        return r415524;
}

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.7
Target2.0
Herbie1.8
\[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 c < -9.836913490220497e-80 or 3.128354228323496e-78 < c

    1. Initial program 13.2

      \[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. Simplified13.2

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

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

    if -9.836913490220497e-80 < c < 3.128354228323496e-78

    1. Initial program 0.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. Simplified0.4

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

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

Reproduce

herbie shell --seed 2019208 +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))))