Average Error: 6.5 → 1.8
Time: 24.4s
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}\;i \le -7.472033446684188899599491262791955462412 \cdot 10^{-59}:\\ \;\;\;\;2 \cdot \left(\left(t \cdot z - \left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot i\right) + y \cdot x\right)\\ \mathbf{elif}\;i \le 1.502007598359967449068109020258153999519 \cdot 10^{-55}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(t \cdot z - \left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot i\right) + y \cdot x\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}\;i \le -7.472033446684188899599491262791955462412 \cdot 10^{-59}:\\
\;\;\;\;2 \cdot \left(\left(t \cdot z - \left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot i\right) + y \cdot x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r30143081 = 2.0;
        double r30143082 = x;
        double r30143083 = y;
        double r30143084 = r30143082 * r30143083;
        double r30143085 = z;
        double r30143086 = t;
        double r30143087 = r30143085 * r30143086;
        double r30143088 = r30143084 + r30143087;
        double r30143089 = a;
        double r30143090 = b;
        double r30143091 = c;
        double r30143092 = r30143090 * r30143091;
        double r30143093 = r30143089 + r30143092;
        double r30143094 = r30143093 * r30143091;
        double r30143095 = i;
        double r30143096 = r30143094 * r30143095;
        double r30143097 = r30143088 - r30143096;
        double r30143098 = r30143081 * r30143097;
        return r30143098;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r30143099 = i;
        double r30143100 = -7.472033446684189e-59;
        bool r30143101 = r30143099 <= r30143100;
        double r30143102 = 2.0;
        double r30143103 = t;
        double r30143104 = z;
        double r30143105 = r30143103 * r30143104;
        double r30143106 = c;
        double r30143107 = b;
        double r30143108 = a;
        double r30143109 = fma(r30143106, r30143107, r30143108);
        double r30143110 = r30143109 * r30143106;
        double r30143111 = r30143110 * r30143099;
        double r30143112 = r30143105 - r30143111;
        double r30143113 = y;
        double r30143114 = x;
        double r30143115 = r30143113 * r30143114;
        double r30143116 = r30143112 + r30143115;
        double r30143117 = r30143102 * r30143116;
        double r30143118 = 1.5020075983599674e-55;
        bool r30143119 = r30143099 <= r30143118;
        double r30143120 = fma(r30143103, r30143104, r30143115);
        double r30143121 = fma(r30143107, r30143106, r30143108);
        double r30143122 = r30143099 * r30143121;
        double r30143123 = r30143106 * r30143122;
        double r30143124 = r30143120 - r30143123;
        double r30143125 = r30143102 * r30143124;
        double r30143126 = r30143119 ? r30143125 : r30143117;
        double r30143127 = r30143101 ? r30143117 : r30143126;
        return r30143127;
}

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.5
Target2.1
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 i < -7.472033446684189e-59 or 1.5020075983599674e-55 < i

    1. Initial program 1.3

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

      \[\leadsto \color{blue}{2 \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 add-cube-cbrt1.7

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

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

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \left(\sqrt[3]{i} \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot \color{blue}{{c}^{1}}\right)\right)\right)\]
    8. Applied pow11.7

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \left(\sqrt[3]{i} \cdot \left(\color{blue}{{\left(\mathsf{fma}\left(b, c, a\right)\right)}^{1}} \cdot {c}^{1}\right)\right)\right)\]
    9. Applied pow-prod-down1.7

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \left(\sqrt[3]{i} \cdot \color{blue}{{\left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)}^{1}}\right)\right)\]
    10. Applied pow11.7

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \left(\color{blue}{{\left(\sqrt[3]{i}\right)}^{1}} \cdot {\left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)}^{1}\right)\right)\]
    11. Applied pow-prod-down1.7

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \color{blue}{{\left(\sqrt[3]{i} \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)}^{1}}\right)\]
    12. Applied pow11.7

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\sqrt[3]{i} \cdot \color{blue}{{\left(\sqrt[3]{i}\right)}^{1}}\right) \cdot {\left(\sqrt[3]{i} \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)}^{1}\right)\]
    13. Applied pow11.7

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\color{blue}{{\left(\sqrt[3]{i}\right)}^{1}} \cdot {\left(\sqrt[3]{i}\right)}^{1}\right) \cdot {\left(\sqrt[3]{i} \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)}^{1}\right)\]
    14. Applied pow-prod-down1.7

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \color{blue}{{\left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right)}^{1}} \cdot {\left(\sqrt[3]{i} \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right)\right)}^{1}\right)\]
    15. Applied pow-prod-down1.7

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

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - {\color{blue}{\left(\left(i \cdot c\right) \cdot \mathsf{fma}\left(b, c, a\right)\right)}}^{1}\right)\]
    17. Using strategy rm
    18. Applied *-un-lft-identity1.2

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \color{blue}{1 \cdot {\left(\left(i \cdot c\right) \cdot \mathsf{fma}\left(b, c, a\right)\right)}^{1}}\right)\]
    19. Applied *-un-lft-identity1.2

      \[\leadsto 2 \cdot \left(\color{blue}{1 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)} - 1 \cdot {\left(\left(i \cdot c\right) \cdot \mathsf{fma}\left(b, c, a\right)\right)}^{1}\right)\]
    20. Applied distribute-lft-out--1.2

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

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

      \[\leadsto 2 \cdot \left(1 \cdot \left(\color{blue}{\left(y \cdot x + z \cdot t\right)} - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\right)\]
    24. Applied associate--l+1.3

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

    if -7.472033446684189e-59 < i < 1.5020075983599674e-55

    1. Initial program 11.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. Simplified11.5

      \[\leadsto \color{blue}{2 \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*2.2

      \[\leadsto 2 \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)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.8

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

Reproduce

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