Average Error: 6.2 → 1.4
Time: 27.2s
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 -1.288224235181277607967963144964340784922 \cdot 10^{52}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\ \mathbf{elif}\;i \le 951568508819.6107177734375:\\ \;\;\;\;2 \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{else}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\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}\;i \le -1.288224235181277607967963144964340784922 \cdot 10^{52}:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\

\mathbf{elif}\;i \le 951568508819.6107177734375:\\
\;\;\;\;2 \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{else}:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, 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 r25245842 = 2.0;
        double r25245843 = x;
        double r25245844 = y;
        double r25245845 = r25245843 * r25245844;
        double r25245846 = z;
        double r25245847 = t;
        double r25245848 = r25245846 * r25245847;
        double r25245849 = r25245845 + r25245848;
        double r25245850 = a;
        double r25245851 = b;
        double r25245852 = c;
        double r25245853 = r25245851 * r25245852;
        double r25245854 = r25245850 + r25245853;
        double r25245855 = r25245854 * r25245852;
        double r25245856 = i;
        double r25245857 = r25245855 * r25245856;
        double r25245858 = r25245849 - r25245857;
        double r25245859 = r25245842 * r25245858;
        return r25245859;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r25245860 = i;
        double r25245861 = -1.2882242351812776e+52;
        bool r25245862 = r25245860 <= r25245861;
        double r25245863 = 2.0;
        double r25245864 = t;
        double r25245865 = z;
        double r25245866 = x;
        double r25245867 = y;
        double r25245868 = r25245866 * r25245867;
        double r25245869 = fma(r25245864, r25245865, r25245868);
        double r25245870 = c;
        double r25245871 = b;
        double r25245872 = a;
        double r25245873 = fma(r25245870, r25245871, r25245872);
        double r25245874 = r25245870 * r25245873;
        double r25245875 = r25245860 * r25245874;
        double r25245876 = r25245869 - r25245875;
        double r25245877 = r25245863 * r25245876;
        double r25245878 = 951568508819.6107;
        bool r25245879 = r25245860 <= r25245878;
        double r25245880 = fma(r25245871, r25245870, r25245872);
        double r25245881 = r25245860 * r25245880;
        double r25245882 = r25245870 * r25245881;
        double r25245883 = r25245869 - r25245882;
        double r25245884 = r25245863 * r25245883;
        double r25245885 = r25245879 ? r25245884 : r25245877;
        double r25245886 = r25245862 ? r25245877 : r25245885;
        return r25245886;
}

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
Herbie1.4
\[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 < -1.2882242351812776e+52 or 951568508819.6107 < i

    1. Initial program 0.7

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

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

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

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

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

    if -1.2882242351812776e+52 < i < 951568508819.6107

    1. Initial program 8.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. Simplified8.9

      \[\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*1.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \le -1.288224235181277607967963144964340784922 \cdot 10^{52}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\ \mathbf{elif}\;i \le 951568508819.6107177734375:\\ \;\;\;\;2 \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{else}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\ \end{array}\]

Reproduce

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