Average Error: 6.8 → 1.5
Time: 33.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}\;c \le -6.753357285253370739227878007540049072435 \cdot 10^{60}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(a \cdot i + \left(i \cdot b\right) \cdot c\right)\right)\\ \mathbf{elif}\;c \le 120250148987918560:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, -i \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(a \cdot i + \left(i \cdot b\right) \cdot c\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}\;c \le -6.753357285253370739227878007540049072435 \cdot 10^{60}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(a \cdot i + \left(i \cdot b\right) \cdot c\right)\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r80689468 = 2.0;
        double r80689469 = x;
        double r80689470 = y;
        double r80689471 = r80689469 * r80689470;
        double r80689472 = z;
        double r80689473 = t;
        double r80689474 = r80689472 * r80689473;
        double r80689475 = r80689471 + r80689474;
        double r80689476 = a;
        double r80689477 = b;
        double r80689478 = c;
        double r80689479 = r80689477 * r80689478;
        double r80689480 = r80689476 + r80689479;
        double r80689481 = r80689480 * r80689478;
        double r80689482 = i;
        double r80689483 = r80689481 * r80689482;
        double r80689484 = r80689475 - r80689483;
        double r80689485 = r80689468 * r80689484;
        return r80689485;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r80689486 = c;
        double r80689487 = -6.753357285253371e+60;
        bool r80689488 = r80689486 <= r80689487;
        double r80689489 = 2.0;
        double r80689490 = y;
        double r80689491 = x;
        double r80689492 = z;
        double r80689493 = t;
        double r80689494 = r80689492 * r80689493;
        double r80689495 = a;
        double r80689496 = i;
        double r80689497 = r80689495 * r80689496;
        double r80689498 = b;
        double r80689499 = r80689496 * r80689498;
        double r80689500 = r80689499 * r80689486;
        double r80689501 = r80689497 + r80689500;
        double r80689502 = r80689486 * r80689501;
        double r80689503 = r80689494 - r80689502;
        double r80689504 = fma(r80689490, r80689491, r80689503);
        double r80689505 = r80689489 * r80689504;
        double r80689506 = 1.2025014898791856e+17;
        bool r80689507 = r80689486 <= r80689506;
        double r80689508 = fma(r80689498, r80689486, r80689495);
        double r80689509 = r80689508 * r80689486;
        double r80689510 = r80689496 * r80689509;
        double r80689511 = -r80689510;
        double r80689512 = fma(r80689492, r80689493, r80689511);
        double r80689513 = fma(r80689490, r80689491, r80689512);
        double r80689514 = r80689489 * r80689513;
        double r80689515 = r80689507 ? r80689514 : r80689505;
        double r80689516 = r80689488 ? r80689505 : r80689515;
        return r80689516;
}

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.8
Target1.8
Herbie1.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 c < -6.753357285253371e+60 or 1.2025014898791856e+17 < c

    1. Initial program 23.8

      \[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. Simplified23.8

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \color{blue}{\left(i \cdot \mathsf{fma}\left(b, c, a\right)\right) \cdot c}\right)\]
    5. Taylor expanded around inf 31.4

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

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

    if -6.753357285253371e+60 < c < 1.2025014898791856e+17

    1. Initial program 0.9

      \[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.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \le -6.753357285253370739227878007540049072435 \cdot 10^{60}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(a \cdot i + \left(i \cdot b\right) \cdot c\right)\right)\\ \mathbf{elif}\;c \le 120250148987918560:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, -i \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(a \cdot i + \left(i \cdot b\right) \cdot c\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019173 +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"

  :herbie-target
  (* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))

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