Average Error: 6.5 → 1.1
Time: 24.9s
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 -9.21843154920237693526132449719605190821 \cdot 10^{-50}:\\ \;\;\;\;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{elif}\;i \le 416884.9095603732275776565074920654296875:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, -c \cdot \left(a \cdot i + \left(i \cdot b\right) \cdot c\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;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)\\ \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 -9.21843154920237693526132449719605190821 \cdot 10^{-50}:\\
\;\;\;\;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{elif}\;i \le 416884.9095603732275776565074920654296875:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, -c \cdot \left(a \cdot i + \left(i \cdot b\right) \cdot c\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;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)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r44693850 = 2.0;
        double r44693851 = x;
        double r44693852 = y;
        double r44693853 = r44693851 * r44693852;
        double r44693854 = z;
        double r44693855 = t;
        double r44693856 = r44693854 * r44693855;
        double r44693857 = r44693853 + r44693856;
        double r44693858 = a;
        double r44693859 = b;
        double r44693860 = c;
        double r44693861 = r44693859 * r44693860;
        double r44693862 = r44693858 + r44693861;
        double r44693863 = r44693862 * r44693860;
        double r44693864 = i;
        double r44693865 = r44693863 * r44693864;
        double r44693866 = r44693857 - r44693865;
        double r44693867 = r44693850 * r44693866;
        return r44693867;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r44693868 = i;
        double r44693869 = -9.218431549202377e-50;
        bool r44693870 = r44693868 <= r44693869;
        double r44693871 = 2.0;
        double r44693872 = y;
        double r44693873 = x;
        double r44693874 = z;
        double r44693875 = t;
        double r44693876 = b;
        double r44693877 = c;
        double r44693878 = a;
        double r44693879 = fma(r44693876, r44693877, r44693878);
        double r44693880 = r44693879 * r44693877;
        double r44693881 = r44693868 * r44693880;
        double r44693882 = -r44693881;
        double r44693883 = fma(r44693874, r44693875, r44693882);
        double r44693884 = fma(r44693872, r44693873, r44693883);
        double r44693885 = r44693871 * r44693884;
        double r44693886 = 416884.9095603732;
        bool r44693887 = r44693868 <= r44693886;
        double r44693888 = r44693878 * r44693868;
        double r44693889 = r44693868 * r44693876;
        double r44693890 = r44693889 * r44693877;
        double r44693891 = r44693888 + r44693890;
        double r44693892 = r44693877 * r44693891;
        double r44693893 = -r44693892;
        double r44693894 = fma(r44693874, r44693875, r44693893);
        double r44693895 = fma(r44693872, r44693873, r44693894);
        double r44693896 = r44693871 * r44693895;
        double r44693897 = r44693887 ? r44693896 : r44693885;
        double r44693898 = r44693870 ? r44693885 : r44693897;
        return r44693898;
}

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.1
\[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 < -9.218431549202377e-50 or 416884.9095603732 < i

    1. Initial program 1.0

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

      \[\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)\]

    if -9.218431549202377e-50 < i < 416884.9095603732

    1. Initial program 10.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. Simplified10.6

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

      \[\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)\]
    5. Using strategy rm
    6. Applied add-cube-cbrt10.7

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, -\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)\right)\]
    7. Applied associate-*l*10.7

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, -\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)\right)\]
    8. Using strategy rm
    9. Applied add-cube-cbrt10.7

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

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

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

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

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