Average Error: 6.4 → 1.4
Time: 55.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}\;c \le -3.780226141482327129579157526221877803227 \cdot 10^{-17}:\\ \;\;\;\;\left(\mathsf{fma}\left(t, z, x \cdot y\right) - \left(i \cdot \mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot 2\\ \mathbf{elif}\;c \le 2.405310837335638562254649692762064198741 \cdot 10^{-63}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(y, x, z \cdot t\right) - \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right) \cdot i\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(t, z, x \cdot y\right) - \left(i \cdot \mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot 2\\ \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}\;c \le -3.780226141482327129579157526221877803227 \cdot 10^{-17}:\\
\;\;\;\;\left(\mathsf{fma}\left(t, z, x \cdot y\right) - \left(i \cdot \mathsf{fma}\left(c, b, a\right)\right) \cdot c\right) \cdot 2\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r30428795 = 2.0;
        double r30428796 = x;
        double r30428797 = y;
        double r30428798 = r30428796 * r30428797;
        double r30428799 = z;
        double r30428800 = t;
        double r30428801 = r30428799 * r30428800;
        double r30428802 = r30428798 + r30428801;
        double r30428803 = a;
        double r30428804 = b;
        double r30428805 = c;
        double r30428806 = r30428804 * r30428805;
        double r30428807 = r30428803 + r30428806;
        double r30428808 = r30428807 * r30428805;
        double r30428809 = i;
        double r30428810 = r30428808 * r30428809;
        double r30428811 = r30428802 - r30428810;
        double r30428812 = r30428795 * r30428811;
        return r30428812;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r30428813 = c;
        double r30428814 = -3.780226141482327e-17;
        bool r30428815 = r30428813 <= r30428814;
        double r30428816 = t;
        double r30428817 = z;
        double r30428818 = x;
        double r30428819 = y;
        double r30428820 = r30428818 * r30428819;
        double r30428821 = fma(r30428816, r30428817, r30428820);
        double r30428822 = i;
        double r30428823 = b;
        double r30428824 = a;
        double r30428825 = fma(r30428813, r30428823, r30428824);
        double r30428826 = r30428822 * r30428825;
        double r30428827 = r30428826 * r30428813;
        double r30428828 = r30428821 - r30428827;
        double r30428829 = 2.0;
        double r30428830 = r30428828 * r30428829;
        double r30428831 = 2.4053108373356386e-63;
        bool r30428832 = r30428813 <= r30428831;
        double r30428833 = r30428817 * r30428816;
        double r30428834 = fma(r30428819, r30428818, r30428833);
        double r30428835 = r30428813 * r30428825;
        double r30428836 = r30428835 * r30428822;
        double r30428837 = r30428834 - r30428836;
        double r30428838 = r30428829 * r30428837;
        double r30428839 = r30428832 ? r30428838 : r30428830;
        double r30428840 = r30428815 ? r30428830 : r30428839;
        return r30428840;
}

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.4
Target1.6
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 c < -3.780226141482327e-17 or 2.4053108373356386e-63 < c

    1. Initial program 15.8

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

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

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

    if -3.780226141482327e-17 < c < 2.4053108373356386e-63

    1. Initial program 0.4

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

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

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

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

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

Reproduce

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