Average Error: 6.0 → 1.8
Time: 9.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 -4.130648500261893 \cdot 10^{-18}:\\ \;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(t, z, x \cdot y\right), 2 \cdot \left(\left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(t, z, x \cdot y\right), 2 \cdot \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\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 -4.130648500261893 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(t, z, x \cdot y\right), 2 \cdot \left(\left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot i\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r715023 = 2.0;
        double r715024 = x;
        double r715025 = y;
        double r715026 = r715024 * r715025;
        double r715027 = z;
        double r715028 = t;
        double r715029 = r715027 * r715028;
        double r715030 = r715026 + r715029;
        double r715031 = a;
        double r715032 = b;
        double r715033 = c;
        double r715034 = r715032 * r715033;
        double r715035 = r715031 + r715034;
        double r715036 = r715035 * r715033;
        double r715037 = i;
        double r715038 = r715036 * r715037;
        double r715039 = r715030 - r715038;
        double r715040 = r715023 * r715039;
        return r715040;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r715041 = i;
        double r715042 = -4.130648500261893e-18;
        bool r715043 = r715041 <= r715042;
        double r715044 = 2.0;
        double r715045 = t;
        double r715046 = z;
        double r715047 = x;
        double r715048 = y;
        double r715049 = r715047 * r715048;
        double r715050 = fma(r715045, r715046, r715049);
        double r715051 = c;
        double r715052 = b;
        double r715053 = a;
        double r715054 = fma(r715051, r715052, r715053);
        double r715055 = -r715054;
        double r715056 = r715055 * r715051;
        double r715057 = r715056 * r715041;
        double r715058 = r715044 * r715057;
        double r715059 = fma(r715044, r715050, r715058);
        double r715060 = r715051 * r715041;
        double r715061 = r715055 * r715060;
        double r715062 = r715044 * r715061;
        double r715063 = fma(r715044, r715050, r715062);
        double r715064 = r715043 ? r715059 : r715063;
        return r715064;
}

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.0
Target1.9
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 < -4.130648500261893e-18

    1. Initial program 0.6

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

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

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

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

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

    if -4.130648500261893e-18 < i

    1. Initial program 7.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. Simplified2.1

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

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

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

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

Reproduce

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