Average Error: 5.9 → 3.9
Time: 34.5s
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}\;t \le -2.358815224477369630616150140951158939988 \cdot 10^{82}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(18 \cdot \left(x \cdot y\right)\right) \cdot z\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \sqrt{27} \cdot \left(\sqrt{27} \cdot \left(k \cdot j\right)\right)\right)\right)\\ \mathbf{elif}\;t \le 7.467946257651942711329108872973994392395 \cdot 10^{-123}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(18 \cdot \left(x \cdot y\right)\right) \cdot \left(z \cdot t\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), 27 \cdot \left(k \cdot j\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\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\\ \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}\;t \le -2.358815224477369630616150140951158939988 \cdot 10^{82}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(18 \cdot \left(x \cdot y\right)\right) \cdot z\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \sqrt{27} \cdot \left(\sqrt{27} \cdot \left(k \cdot j\right)\right)\right)\right)\\

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

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

\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 r46288770 = x;
        double r46288771 = 18.0;
        double r46288772 = r46288770 * r46288771;
        double r46288773 = y;
        double r46288774 = r46288772 * r46288773;
        double r46288775 = z;
        double r46288776 = r46288774 * r46288775;
        double r46288777 = t;
        double r46288778 = r46288776 * r46288777;
        double r46288779 = a;
        double r46288780 = 4.0;
        double r46288781 = r46288779 * r46288780;
        double r46288782 = r46288781 * r46288777;
        double r46288783 = r46288778 - r46288782;
        double r46288784 = b;
        double r46288785 = c;
        double r46288786 = r46288784 * r46288785;
        double r46288787 = r46288783 + r46288786;
        double r46288788 = r46288770 * r46288780;
        double r46288789 = i;
        double r46288790 = r46288788 * r46288789;
        double r46288791 = r46288787 - r46288790;
        double r46288792 = j;
        double r46288793 = 27.0;
        double r46288794 = r46288792 * r46288793;
        double r46288795 = k;
        double r46288796 = r46288794 * r46288795;
        double r46288797 = r46288791 - r46288796;
        return r46288797;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r46288798 = t;
        double r46288799 = -2.3588152244773696e+82;
        bool r46288800 = r46288798 <= r46288799;
        double r46288801 = b;
        double r46288802 = c;
        double r46288803 = 18.0;
        double r46288804 = x;
        double r46288805 = y;
        double r46288806 = r46288804 * r46288805;
        double r46288807 = r46288803 * r46288806;
        double r46288808 = z;
        double r46288809 = r46288807 * r46288808;
        double r46288810 = r46288809 * r46288798;
        double r46288811 = 4.0;
        double r46288812 = a;
        double r46288813 = i;
        double r46288814 = r46288804 * r46288813;
        double r46288815 = fma(r46288798, r46288812, r46288814);
        double r46288816 = 27.0;
        double r46288817 = sqrt(r46288816);
        double r46288818 = k;
        double r46288819 = j;
        double r46288820 = r46288818 * r46288819;
        double r46288821 = r46288817 * r46288820;
        double r46288822 = r46288817 * r46288821;
        double r46288823 = fma(r46288811, r46288815, r46288822);
        double r46288824 = r46288810 - r46288823;
        double r46288825 = fma(r46288801, r46288802, r46288824);
        double r46288826 = 7.467946257651943e-123;
        bool r46288827 = r46288798 <= r46288826;
        double r46288828 = r46288808 * r46288798;
        double r46288829 = r46288807 * r46288828;
        double r46288830 = r46288816 * r46288820;
        double r46288831 = fma(r46288811, r46288815, r46288830);
        double r46288832 = r46288829 - r46288831;
        double r46288833 = fma(r46288801, r46288802, r46288832);
        double r46288834 = r46288804 * r46288803;
        double r46288835 = r46288834 * r46288805;
        double r46288836 = r46288835 * r46288808;
        double r46288837 = r46288836 * r46288798;
        double r46288838 = r46288812 * r46288811;
        double r46288839 = r46288838 * r46288798;
        double r46288840 = r46288837 - r46288839;
        double r46288841 = r46288801 * r46288802;
        double r46288842 = r46288840 + r46288841;
        double r46288843 = r46288804 * r46288811;
        double r46288844 = r46288843 * r46288813;
        double r46288845 = r46288842 - r46288844;
        double r46288846 = r46288819 * r46288816;
        double r46288847 = r46288846 * r46288818;
        double r46288848 = r46288845 - r46288847;
        double r46288849 = r46288827 ? r46288833 : r46288848;
        double r46288850 = r46288800 ? r46288825 : r46288849;
        return r46288850;
}

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.6
Herbie3.9
\[\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 t < -2.3588152244773696e+82

    1. Initial program 1.5

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(b, c, \left(\color{blue}{\left(18 \cdot \left(x \cdot y\right)\right)} \cdot z\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), 27 \cdot \left(k \cdot j\right)\right)\right)\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt1.4

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

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

    if -2.3588152244773696e+82 < t < 7.467946257651943e-123

    1. Initial program 8.1

      \[\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. Simplified8.1

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

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

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

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

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

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

    if 7.467946257651943e-123 < t

    1. Initial program 3.4

      \[\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\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -2.358815224477369630616150140951158939988 \cdot 10^{82}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(18 \cdot \left(x \cdot y\right)\right) \cdot z\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \sqrt{27} \cdot \left(\sqrt{27} \cdot \left(k \cdot j\right)\right)\right)\right)\\ \mathbf{elif}\;t \le 7.467946257651942711329108872973994392395 \cdot 10^{-123}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(18 \cdot \left(x \cdot y\right)\right) \cdot \left(z \cdot t\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), 27 \cdot \left(k \cdot j\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\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\\ \end{array}\]

Reproduce

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