Average Error: 3.8 → 0.6
Time: 7.5s
Precision: 64
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -7.32951410425208251 \cdot 10^{257} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 1.15727662613318563 \cdot 10^{249}\right):\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(\left(\sqrt{9} \cdot z\right) \cdot t\right) \cdot \left(y \cdot \sqrt{9}\right)\right) + \left(\left(\sqrt{9} \cdot z\right) \cdot t\right) \cdot \left(\left(-y \cdot \sqrt{9}\right) + y \cdot \sqrt{9}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \end{array}\]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
\mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -7.32951410425208251 \cdot 10^{257} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 1.15727662613318563 \cdot 10^{249}\right):\\
\;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(\left(\sqrt{9} \cdot z\right) \cdot t\right) \cdot \left(y \cdot \sqrt{9}\right)\right) + \left(\left(\sqrt{9} \cdot z\right) \cdot t\right) \cdot \left(\left(-y \cdot \sqrt{9}\right) + y \cdot \sqrt{9}\right)\right)\\

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

\end{array}
double code(double x, double y, double z, double t, double a, double b) {
	return ((double) (((double) (((double) (x * 2.0)) - ((double) (((double) (((double) (y * 9.0)) * z)) * t)))) + ((double) (((double) (a * 27.0)) * b))));
}
double code(double x, double y, double z, double t, double a, double b) {
	double VAR;
	if (((((double) (((double) (y * 9.0)) * z)) <= -7.329514104252083e+257) || !(((double) (((double) (y * 9.0)) * z)) <= 1.1572766261331856e+249))) {
		VAR = ((double) fma(a, ((double) (27.0 * b)), ((double) (((double) fma(x, 2.0, ((double) -(((double) (((double) (((double) (((double) sqrt(9.0)) * z)) * t)) * ((double) (y * ((double) sqrt(9.0)))))))))) + ((double) (((double) (((double) (((double) sqrt(9.0)) * z)) * t)) * ((double) (((double) -(((double) (y * ((double) sqrt(9.0)))))) + ((double) (y * ((double) sqrt(9.0))))))))))));
	} else {
		VAR = ((double) fma(a, ((double) (27.0 * b)), ((double) (((double) (x * 2.0)) - ((double) (9.0 * ((double) (t * ((double) (z * y))))))))));
	}
	return VAR;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.8
Target2.6
Herbie0.6
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (* (* y 9.0) z) < -7.329514104252083e+257 or 1.1572766261331856e+249 < (* (* y 9.0) z)

    1. Initial program 41.4

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified41.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt41.4

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot \color{blue}{\left(\sqrt{9} \cdot \sqrt{9}\right)}\right) \cdot z\right) \cdot t\right)\]
    5. Applied associate-*r*41.4

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\color{blue}{\left(\left(y \cdot \sqrt{9}\right) \cdot \sqrt{9}\right)} \cdot z\right) \cdot t\right)\]
    6. Applied associate-*l*41.2

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \color{blue}{\left(\left(y \cdot \sqrt{9}\right) \cdot \left(\sqrt{9} \cdot z\right)\right)} \cdot t\right)\]
    7. Applied associate-*l*1.5

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \color{blue}{\left(y \cdot \sqrt{9}\right) \cdot \left(\left(\sqrt{9} \cdot z\right) \cdot t\right)}\right)\]
    8. Applied prod-diff1.5

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(\sqrt{9} \cdot z\right) \cdot t\right) \cdot \left(y \cdot \sqrt{9}\right)\right) + \mathsf{fma}\left(-\left(\sqrt{9} \cdot z\right) \cdot t, y \cdot \sqrt{9}, \left(\left(\sqrt{9} \cdot z\right) \cdot t\right) \cdot \left(y \cdot \sqrt{9}\right)\right)}\right)\]
    9. Simplified1.5

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

    if -7.329514104252083e+257 < (* (* y 9.0) z) < 1.1572766261331856e+249

    1. Initial program 0.5

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified0.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    3. Using strategy rm
    4. Applied *-commutative0.5

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\color{blue}{\left(9 \cdot y\right)} \cdot z\right) \cdot t\right)\]
    5. Applied associate-*l*0.5

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \color{blue}{\left(9 \cdot \left(y \cdot z\right)\right)} \cdot t\right)\]
    6. Applied associate-*l*0.5

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \color{blue}{9 \cdot \left(\left(y \cdot z\right) \cdot t\right)}\right)\]
    7. Simplified0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -7.32951410425208251 \cdot 10^{257} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 1.15727662613318563 \cdot 10^{249}\right):\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(\left(\sqrt{9} \cdot z\right) \cdot t\right) \cdot \left(y \cdot \sqrt{9}\right)\right) + \left(\left(\sqrt{9} \cdot z\right) \cdot t\right) \cdot \left(\left(-y \cdot \sqrt{9}\right) + y \cdot \sqrt{9}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020114 +o rules:numerics
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2) (* (* (* y 9) z) t)) (* a (* 27 b))) (+ (- (* x 2) (* 9 (* y (* t z)))) (* (* a 27) b)))

  (+ (- (* x 2) (* (* (* y 9) z) t)) (* (* a 27) b)))