Average Error: 9.1 → 8.0
Time: 19.4s
Precision: binary64
\[[b, c] = \mathsf{sort}([b, c]) \[j, k] = \mathsf{sort}([j, k]) \\]
\[\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}\;c \leq -1.4189869398597547 \cdot 10^{-103}:\\ \;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(k \cdot j\right) \cdot -27\right)\right)\\ \mathbf{elif}\;c \leq 1.0221135886669087 \cdot 10^{-218}:\\ \;\;\;\;\left(\left(\left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right)\right) - t \cdot \left(a \cdot 4\right)\right) + c \cdot b\right) - i \cdot \left(x \cdot 4\right)\right) - k \cdot \left(j \cdot 27\right)\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \mathsf{fma}\left(x, \mathsf{fma}\left(18, y \cdot \left(t \cdot z\right), -4 \cdot i\right), \mathsf{fma}\left(a, -4 \cdot t, \mathsf{fma}\left(-27, k \cdot j, c \cdot b\right)\right)\right)\\ \mathbf{if}\;c \leq 1.133576917693191 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := -4 \cdot \left(x \cdot i\right)\\ \mathbf{if}\;c \leq 3.0740571289202475 \cdot 10^{+231}:\\ \;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(t, \mathsf{fma}\left(y, 18 \cdot \left(x \cdot z\right), -4 \cdot a\right), \mathsf{fma}\left(k \cdot j, -27, t_2\right)\right)\right)\\ \mathbf{elif}\;c \leq 5.4509450614732235 \cdot 10^{+258}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, \mathsf{fma}\left(18, y \cdot \left(x \cdot z\right), -4 \cdot a\right), \mathsf{fma}\left(c, b, t_2\right)\right)\\ \end{array}\\ \end{array}\\ \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}\;c \leq -1.4189869398597547 \cdot 10^{-103}:\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(k \cdot j\right) \cdot -27\right)\right)\\

\mathbf{elif}\;c \leq 1.0221135886669087 \cdot 10^{-218}:\\
\;\;\;\;\left(\left(\left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right)\right) - t \cdot \left(a \cdot 4\right)\right) + c \cdot b\right) - i \cdot \left(x \cdot 4\right)\right) - k \cdot \left(j \cdot 27\right)\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \mathsf{fma}\left(x, \mathsf{fma}\left(18, y \cdot \left(t \cdot z\right), -4 \cdot i\right), \mathsf{fma}\left(a, -4 \cdot t, \mathsf{fma}\left(-27, k \cdot j, c \cdot b\right)\right)\right)\\
\mathbf{if}\;c \leq 1.133576917693191 \cdot 10^{+145}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := -4 \cdot \left(x \cdot i\right)\\
\mathbf{if}\;c \leq 3.0740571289202475 \cdot 10^{+231}:\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(t, \mathsf{fma}\left(y, 18 \cdot \left(x \cdot z\right), -4 \cdot a\right), \mathsf{fma}\left(k \cdot j, -27, t_2\right)\right)\right)\\

\mathbf{elif}\;c \leq 5.4509450614732235 \cdot 10^{+258}:\\
\;\;\;\;t_1\\

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


\end{array}\\


\end{array}\\


\end{array}
(FPCore (x y z t a b c i j k)
 :precision binary64
 (-
  (-
   (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c))
   (* (* x 4.0) i))
  (* (* j 27.0) k)))
(FPCore (x y z t a b c i j k)
 :precision binary64
 (if (<= c -1.4189869398597547e-103)
   (fma c b (fma -4.0 (fma t a (* x i)) (* (* k j) -27.0)))
   (if (<= c 1.0221135886669087e-218)
     (-
      (-
       (+ (- (* t (* (* x 18.0) (* y z))) (* t (* a 4.0))) (* c b))
       (* i (* x 4.0)))
      (* k (* j 27.0)))
     (let* ((t_1
             (fma
              x
              (fma 18.0 (* y (* t z)) (* -4.0 i))
              (fma a (* -4.0 t) (fma -27.0 (* k j) (* c b))))))
       (if (<= c 1.133576917693191e+145)
         t_1
         (let* ((t_2 (* -4.0 (* x i))))
           (if (<= c 3.0740571289202475e+231)
             (fma
              c
              b
              (fma
               t
               (fma y (* 18.0 (* x z)) (* -4.0 a))
               (fma (* k j) -27.0 t_2)))
             (if (<= c 5.4509450614732235e+258)
               t_1
               (fma
                t
                (fma 18.0 (* y (* x z)) (* -4.0 a))
                (fma c b t_2))))))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
	return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
}
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
	double tmp;
	if (c <= -1.4189869398597547e-103) {
		tmp = fma(c, b, fma(-4.0, fma(t, a, (x * i)), ((k * j) * -27.0)));
	} else if (c <= 1.0221135886669087e-218) {
		tmp = ((((t * ((x * 18.0) * (y * z))) - (t * (a * 4.0))) + (c * b)) - (i * (x * 4.0))) - (k * (j * 27.0));
	} else {
		double t_1 = fma(x, fma(18.0, (y * (t * z)), (-4.0 * i)), fma(a, (-4.0 * t), fma(-27.0, (k * j), (c * b))));
		double tmp_1;
		if (c <= 1.133576917693191e+145) {
			tmp_1 = t_1;
		} else {
			double t_2 = -4.0 * (x * i);
			double tmp_2;
			if (c <= 3.0740571289202475e+231) {
				tmp_2 = fma(c, b, fma(t, fma(y, (18.0 * (x * z)), (-4.0 * a)), fma((k * j), -27.0, t_2)));
			} else if (c <= 5.4509450614732235e+258) {
				tmp_2 = t_1;
			} else {
				tmp_2 = fma(t, fma(18.0, (y * (x * z)), (-4.0 * a)), fma(c, b, t_2));
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	return tmp;
}

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

Original9.1
Target6.6
Herbie8.0
\[\begin{array}{l} \mathbf{if}\;t < -1.6210815397541398 \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 < 165.68027943805222:\\ \;\;\;\;\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 5 regimes
  2. if c < -1.4189869398597547e-103

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

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

      \[\leadsto \color{blue}{c \cdot b - \left(4 \cdot \left(i \cdot x\right) + \left(4 \cdot \left(a \cdot t\right) + 27 \cdot \left(k \cdot j\right)\right)\right)} \]
    4. Simplified12.0

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

    if -1.4189869398597547e-103 < c < 1.02211358866690874e-218

    1. Initial program 7.8

      \[\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. Applied associate-*l*_binary648.2

      \[\leadsto \left(\left(\left(\color{blue}{\left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right)\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 \]

    if 1.02211358866690874e-218 < c < 1.13357691769319104e145 or 3.0740571289202475e231 < c < 5.4509450614732235e258

    1. Initial program 8.6

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

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

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

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

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

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

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

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

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

    if 1.13357691769319104e145 < c < 3.0740571289202475e231

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

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

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

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

    if 5.4509450614732235e258 < c

    1. Initial program 13.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. Taylor expanded in j around 0 16.4

      \[\leadsto \color{blue}{\left(c \cdot b + 18 \cdot \left(y \cdot \left(t \cdot \left(z \cdot x\right)\right)\right)\right) - \left(4 \cdot \left(i \cdot x\right) + 4 \cdot \left(a \cdot t\right)\right)} \]
    3. Simplified13.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.4189869398597547 \cdot 10^{-103}:\\ \;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(k \cdot j\right) \cdot -27\right)\right)\\ \mathbf{elif}\;c \leq 1.0221135886669087 \cdot 10^{-218}:\\ \;\;\;\;\left(\left(\left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right)\right) - t \cdot \left(a \cdot 4\right)\right) + c \cdot b\right) - i \cdot \left(x \cdot 4\right)\right) - k \cdot \left(j \cdot 27\right)\\ \mathbf{elif}\;c \leq 1.133576917693191 \cdot 10^{+145}:\\ \;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(18, y \cdot \left(t \cdot z\right), -4 \cdot i\right), \mathsf{fma}\left(a, -4 \cdot t, \mathsf{fma}\left(-27, k \cdot j, c \cdot b\right)\right)\right)\\ \mathbf{elif}\;c \leq 3.0740571289202475 \cdot 10^{+231}:\\ \;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(t, \mathsf{fma}\left(y, 18 \cdot \left(x \cdot z\right), -4 \cdot a\right), \mathsf{fma}\left(k \cdot j, -27, -4 \cdot \left(x \cdot i\right)\right)\right)\right)\\ \mathbf{elif}\;c \leq 5.4509450614732235 \cdot 10^{+258}:\\ \;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(18, y \cdot \left(t \cdot z\right), -4 \cdot i\right), \mathsf{fma}\left(a, -4 \cdot t, \mathsf{fma}\left(-27, k \cdot j, c \cdot b\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, \mathsf{fma}\left(18, y \cdot \left(x \cdot z\right), -4 \cdot a\right), \mathsf{fma}\left(c, b, -4 \cdot \left(x \cdot i\right)\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022068 
(FPCore (x y z t a b c i j k)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, E"
  :precision binary64

  :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)))