Average Error: 4.9 → 1.8
Time: 30.0s
Precision: 64
\[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.338863715081203 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(t \cdot x\right) \cdot y\right) \cdot 18.0\right) \cdot z - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), 27.0 \cdot \left(k \cdot j\right)\right)\right)\\ \mathbf{elif}\;z \le 8.320283028555687 \cdot 10^{+114}:\\ \;\;\;\;\mathsf{fma}\left(b, c, 18.0 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), j \cdot \left(27.0 \cdot k\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(t \cdot x\right) \cdot y\right) \cdot 18.0\right) \cdot z - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), 27.0 \cdot \left(k \cdot j\right)\right)\right)\\ \end{array}\]
\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k
\begin{array}{l}
\mathbf{if}\;z \le -6.338863715081203 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(t \cdot x\right) \cdot y\right) \cdot 18.0\right) \cdot z - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), 27.0 \cdot \left(k \cdot j\right)\right)\right)\\

\mathbf{elif}\;z \le 8.320283028555687 \cdot 10^{+114}:\\
\;\;\;\;\mathsf{fma}\left(b, c, 18.0 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), j \cdot \left(27.0 \cdot k\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r35770738 = x;
        double r35770739 = 18.0;
        double r35770740 = r35770738 * r35770739;
        double r35770741 = y;
        double r35770742 = r35770740 * r35770741;
        double r35770743 = z;
        double r35770744 = r35770742 * r35770743;
        double r35770745 = t;
        double r35770746 = r35770744 * r35770745;
        double r35770747 = a;
        double r35770748 = 4.0;
        double r35770749 = r35770747 * r35770748;
        double r35770750 = r35770749 * r35770745;
        double r35770751 = r35770746 - r35770750;
        double r35770752 = b;
        double r35770753 = c;
        double r35770754 = r35770752 * r35770753;
        double r35770755 = r35770751 + r35770754;
        double r35770756 = r35770738 * r35770748;
        double r35770757 = i;
        double r35770758 = r35770756 * r35770757;
        double r35770759 = r35770755 - r35770758;
        double r35770760 = j;
        double r35770761 = 27.0;
        double r35770762 = r35770760 * r35770761;
        double r35770763 = k;
        double r35770764 = r35770762 * r35770763;
        double r35770765 = r35770759 - r35770764;
        return r35770765;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r35770766 = z;
        double r35770767 = -6.338863715081203e-20;
        bool r35770768 = r35770766 <= r35770767;
        double r35770769 = b;
        double r35770770 = c;
        double r35770771 = t;
        double r35770772 = x;
        double r35770773 = r35770771 * r35770772;
        double r35770774 = y;
        double r35770775 = r35770773 * r35770774;
        double r35770776 = 18.0;
        double r35770777 = r35770775 * r35770776;
        double r35770778 = r35770777 * r35770766;
        double r35770779 = 4.0;
        double r35770780 = a;
        double r35770781 = i;
        double r35770782 = r35770781 * r35770772;
        double r35770783 = fma(r35770771, r35770780, r35770782);
        double r35770784 = 27.0;
        double r35770785 = k;
        double r35770786 = j;
        double r35770787 = r35770785 * r35770786;
        double r35770788 = r35770784 * r35770787;
        double r35770789 = fma(r35770779, r35770783, r35770788);
        double r35770790 = r35770778 - r35770789;
        double r35770791 = fma(r35770769, r35770770, r35770790);
        double r35770792 = 8.320283028555687e+114;
        bool r35770793 = r35770766 <= r35770792;
        double r35770794 = r35770766 * r35770774;
        double r35770795 = r35770794 * r35770772;
        double r35770796 = r35770771 * r35770795;
        double r35770797 = r35770776 * r35770796;
        double r35770798 = r35770784 * r35770785;
        double r35770799 = r35770786 * r35770798;
        double r35770800 = fma(r35770779, r35770783, r35770799);
        double r35770801 = r35770797 - r35770800;
        double r35770802 = fma(r35770769, r35770770, r35770801);
        double r35770803 = r35770793 ? r35770802 : r35770791;
        double r35770804 = r35770768 ? r35770791 : r35770803;
        return r35770804;
}

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

Bits error versus j

Bits error versus k

Target

Original4.9
Target1.5
Herbie1.8
\[\begin{array}{l} \mathbf{if}\;t \lt -1.6210815397541398 \cdot 10^{-69}:\\ \;\;\;\;\left(\left(18.0 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) - \left(\left(k \cdot j\right) \cdot 27.0 - c \cdot b\right)\\ \mathbf{elif}\;t \lt 165.68027943805222:\\ \;\;\;\;\left(\left(18.0 \cdot y\right) \cdot \left(x \cdot \left(z \cdot t\right)\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) + \left(c \cdot b - 27.0 \cdot \left(k \cdot j\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(18.0 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) - \left(\left(k \cdot j\right) \cdot 27.0 - c \cdot b\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -6.338863715081203e-20 or 8.320283028555687e+114 < z

    1. Initial program 6.5

      \[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
    2. Simplified2.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, c, z \cdot \left(\left(t \cdot x\right) \cdot \left(y \cdot 18.0\right)\right) - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, x \cdot i\right), 27.0 \cdot \left(k \cdot j\right)\right)\right)}\]
    3. Using strategy rm
    4. Applied associate-*r*2.1

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

    if -6.338863715081203e-20 < z < 8.320283028555687e+114

    1. Initial program 4.1

      \[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
    2. Simplified5.3

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

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

      \[\leadsto \mathsf{fma}\left(b, c, \left(z \cdot \left(t \cdot x\right)\right) \cdot \left(y \cdot 18.0\right) - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, x \cdot i\right), \color{blue}{\left(27.0 \cdot k\right) \cdot j}\right)\right)\]
    7. Taylor expanded around inf 1.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.338863715081203 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(t \cdot x\right) \cdot y\right) \cdot 18.0\right) \cdot z - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), 27.0 \cdot \left(k \cdot j\right)\right)\right)\\ \mathbf{elif}\;z \le 8.320283028555687 \cdot 10^{+114}:\\ \;\;\;\;\mathsf{fma}\left(b, c, 18.0 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), j \cdot \left(27.0 \cdot k\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(t \cdot x\right) \cdot y\right) \cdot 18.0\right) \cdot z - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), 27.0 \cdot \left(k \cdot j\right)\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (x y z t a b c i j k)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, E"

  :herbie-target
  (if (< t -1.6210815397541398e-69) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b))) (if (< t 165.68027943805222) (+ (- (* (* 18.0 y) (* x (* z t))) (* (+ (* a t) (* i x)) 4.0)) (- (* c b) (* 27.0 (* k j)))) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b)))))

  (- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))