Average Error: 5.9 → 1.5
Time: 28.1s
Precision: 64
\[\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k\]
\[\begin{array}{l} \mathbf{if}\;z \le -18589615164.687671661376953125:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot t\right) \cdot y\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \mathbf{elif}\;z \le 2.168478244128475081119441153156288006138 \cdot 10^{-38}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) \cdot 18 - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), k \cdot \left(27 \cdot j\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, z \cdot \left(18 \cdot \left(t \cdot \left(y \cdot x\right)\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \end{array}\]
\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k
\begin{array}{l}
\mathbf{if}\;z \le -18589615164.687671661376953125:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot t\right) \cdot y\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\

\mathbf{elif}\;z \le 2.168478244128475081119441153156288006138 \cdot 10^{-38}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) \cdot 18 - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), k \cdot \left(27 \cdot j\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, c, z \cdot \left(18 \cdot \left(t \cdot \left(y \cdot x\right)\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\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 r32124738 = x;
        double r32124739 = 18.0;
        double r32124740 = r32124738 * r32124739;
        double r32124741 = y;
        double r32124742 = r32124740 * r32124741;
        double r32124743 = z;
        double r32124744 = r32124742 * r32124743;
        double r32124745 = t;
        double r32124746 = r32124744 * r32124745;
        double r32124747 = a;
        double r32124748 = 4.0;
        double r32124749 = r32124747 * r32124748;
        double r32124750 = r32124749 * r32124745;
        double r32124751 = r32124746 - r32124750;
        double r32124752 = b;
        double r32124753 = c;
        double r32124754 = r32124752 * r32124753;
        double r32124755 = r32124751 + r32124754;
        double r32124756 = r32124738 * r32124748;
        double r32124757 = i;
        double r32124758 = r32124756 * r32124757;
        double r32124759 = r32124755 - r32124758;
        double r32124760 = j;
        double r32124761 = 27.0;
        double r32124762 = r32124760 * r32124761;
        double r32124763 = k;
        double r32124764 = r32124762 * r32124763;
        double r32124765 = r32124759 - r32124764;
        return r32124765;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r32124766 = z;
        double r32124767 = -18589615164.68767;
        bool r32124768 = r32124766 <= r32124767;
        double r32124769 = b;
        double r32124770 = c;
        double r32124771 = 18.0;
        double r32124772 = x;
        double r32124773 = r32124771 * r32124772;
        double r32124774 = t;
        double r32124775 = r32124773 * r32124774;
        double r32124776 = y;
        double r32124777 = r32124775 * r32124776;
        double r32124778 = r32124777 * r32124766;
        double r32124779 = 4.0;
        double r32124780 = a;
        double r32124781 = i;
        double r32124782 = r32124781 * r32124772;
        double r32124783 = fma(r32124774, r32124780, r32124782);
        double r32124784 = 27.0;
        double r32124785 = j;
        double r32124786 = k;
        double r32124787 = r32124785 * r32124786;
        double r32124788 = r32124784 * r32124787;
        double r32124789 = fma(r32124779, r32124783, r32124788);
        double r32124790 = r32124778 - r32124789;
        double r32124791 = fma(r32124769, r32124770, r32124790);
        double r32124792 = 2.168478244128475e-38;
        bool r32124793 = r32124766 <= r32124792;
        double r32124794 = r32124766 * r32124776;
        double r32124795 = r32124794 * r32124772;
        double r32124796 = r32124774 * r32124795;
        double r32124797 = r32124796 * r32124771;
        double r32124798 = r32124784 * r32124785;
        double r32124799 = r32124786 * r32124798;
        double r32124800 = fma(r32124779, r32124783, r32124799);
        double r32124801 = r32124797 - r32124800;
        double r32124802 = fma(r32124769, r32124770, r32124801);
        double r32124803 = r32124776 * r32124772;
        double r32124804 = r32124774 * r32124803;
        double r32124805 = r32124771 * r32124804;
        double r32124806 = r32124766 * r32124805;
        double r32124807 = r32124806 - r32124789;
        double r32124808 = fma(r32124769, r32124770, r32124807);
        double r32124809 = r32124793 ? r32124802 : r32124808;
        double r32124810 = r32124768 ? r32124791 : r32124809;
        return r32124810;
}

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

Original5.9
Target1.7
Herbie1.5
\[\begin{array}{l} \mathbf{if}\;t \lt -1.62108153975413982700795070153457058168 \cdot 10^{-69}:\\ \;\;\;\;\left(\left(18 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4\right) - \left(\left(k \cdot j\right) \cdot 27 - c \cdot b\right)\\ \mathbf{elif}\;t \lt 165.6802794380522243500308832153677940369:\\ \;\;\;\;\left(\left(18 \cdot y\right) \cdot \left(x \cdot \left(z \cdot t\right)\right) - \left(a \cdot t + i \cdot x\right) \cdot 4\right) + \left(c \cdot b - 27 \cdot \left(k \cdot j\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(18 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4\right) - \left(\left(k \cdot j\right) \cdot 27 - c \cdot b\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -18589615164.68767

    1. Initial program 7.2

      \[\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k\]
    2. Simplified7.2

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

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

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(\left(t \cdot \left(x \cdot 18\right)\right) \cdot y\right)} \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)\]
    7. Using strategy rm
    8. Applied associate-*l*1.8

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

    if -18589615164.68767 < z < 2.168478244128475e-38

    1. Initial program 5.2

      \[\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k\]
    2. Simplified5.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, c, t \cdot \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)}\]
    3. Taylor expanded around inf 1.4

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

    if 2.168478244128475e-38 < z

    1. Initial program 6.2

      \[\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k\]
    2. Simplified6.2

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

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

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(\left(t \cdot \left(x \cdot 18\right)\right) \cdot y\right)} \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)\]
    7. Using strategy rm
    8. Applied associate-*l*1.9

      \[\leadsto \mathsf{fma}\left(b, c, \left(\left(t \cdot \left(x \cdot 18\right)\right) \cdot y\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \color{blue}{27 \cdot \left(j \cdot k\right)}\right)\right)\]
    9. Taylor expanded around inf 1.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -18589615164.687671661376953125:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot t\right) \cdot y\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \mathbf{elif}\;z \le 2.168478244128475081119441153156288006138 \cdot 10^{-38}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) \cdot 18 - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), k \cdot \left(27 \cdot j\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, z \cdot \left(18 \cdot \left(t \cdot \left(y \cdot x\right)\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \end{array}\]

Reproduce

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