Average Error: 5.8 → 1.5
Time: 15.2s
Precision: 64
\[2.0 \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 -1.7711710378706902 \cdot 10^{+51}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\ \mathbf{elif}\;c \le 6.218371822021183 \cdot 10^{-30}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(1, \mathsf{fma}\left(t, z, x \cdot y\right), \left(-i\right) \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right) + \mathsf{fma}\left(-\mathsf{fma}\left(b, c, a\right) \cdot c, i, i \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\ \end{array}\]
2.0 \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 -1.7711710378706902 \cdot 10^{+51}:\\
\;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\

\mathbf{elif}\;c \le 6.218371822021183 \cdot 10^{-30}:\\
\;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(1, \mathsf{fma}\left(t, z, x \cdot y\right), \left(-i\right) \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right) + \mathsf{fma}\left(-\mathsf{fma}\left(b, c, a\right) \cdot c, i, i \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r13096655 = 2.0;
        double r13096656 = x;
        double r13096657 = y;
        double r13096658 = r13096656 * r13096657;
        double r13096659 = z;
        double r13096660 = t;
        double r13096661 = r13096659 * r13096660;
        double r13096662 = r13096658 + r13096661;
        double r13096663 = a;
        double r13096664 = b;
        double r13096665 = c;
        double r13096666 = r13096664 * r13096665;
        double r13096667 = r13096663 + r13096666;
        double r13096668 = r13096667 * r13096665;
        double r13096669 = i;
        double r13096670 = r13096668 * r13096669;
        double r13096671 = r13096662 - r13096670;
        double r13096672 = r13096655 * r13096671;
        return r13096672;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r13096673 = c;
        double r13096674 = -1.7711710378706902e+51;
        bool r13096675 = r13096673 <= r13096674;
        double r13096676 = 2.0;
        double r13096677 = t;
        double r13096678 = z;
        double r13096679 = x;
        double r13096680 = y;
        double r13096681 = r13096679 * r13096680;
        double r13096682 = fma(r13096677, r13096678, r13096681);
        double r13096683 = i;
        double r13096684 = b;
        double r13096685 = a;
        double r13096686 = fma(r13096684, r13096673, r13096685);
        double r13096687 = r13096683 * r13096686;
        double r13096688 = r13096673 * r13096687;
        double r13096689 = r13096682 - r13096688;
        double r13096690 = r13096676 * r13096689;
        double r13096691 = 6.218371822021183e-30;
        bool r13096692 = r13096673 <= r13096691;
        double r13096693 = 1.0;
        double r13096694 = -r13096683;
        double r13096695 = r13096686 * r13096673;
        double r13096696 = r13096694 * r13096695;
        double r13096697 = fma(r13096693, r13096682, r13096696);
        double r13096698 = -r13096695;
        double r13096699 = r13096683 * r13096695;
        double r13096700 = fma(r13096698, r13096683, r13096699);
        double r13096701 = r13096697 + r13096700;
        double r13096702 = r13096676 * r13096701;
        double r13096703 = r13096692 ? r13096702 : r13096690;
        double r13096704 = r13096675 ? r13096690 : r13096703;
        return r13096704;
}

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

Original5.8
Target1.8
Herbie1.5
\[2.0 \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 < -1.7711710378706902e+51 or 6.218371822021183e-30 < c

    1. Initial program 17.9

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

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

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

    if -1.7711710378706902e+51 < c < 6.218371822021183e-30

    1. Initial program 0.7

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

      \[\leadsto \color{blue}{2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - i \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity0.7

      \[\leadsto 2.0 \cdot \left(\color{blue}{1 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)} - i \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)\]
    5. Applied prod-diff0.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \le -1.7711710378706902 \cdot 10^{+51}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\ \mathbf{elif}\;c \le 6.218371822021183 \cdot 10^{-30}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(1, \mathsf{fma}\left(t, z, x \cdot y\right), \left(-i\right) \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right) + \mathsf{fma}\left(-\mathsf{fma}\left(b, c, a\right) \cdot c, i, i \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\ \end{array}\]

Reproduce

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