Average Error: 3.7 → 1.1
Time: 6.5s
Precision: binary64
\[\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}\;y \cdot 9 \leq -1.4421017111437187 \cdot 10^{-143}:\\ \;\;\;\;x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - y \cdot \left(\sqrt{9} \cdot \left(z \cdot \left(\sqrt{9} \cdot t\right)\right)\right)\right)\\ \mathbf{elif}\;y \cdot 9 \leq 5.104445911874034 \cdot 10^{-48}:\\ \;\;\;\;\left(x \cdot 2 - t \cdot \left(\left(y \cdot 9\right) \cdot z\right)\right) + b \cdot \left(a \cdot 27\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - \left(y \cdot 9\right) \cdot \left(z \cdot t\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}\;y \cdot 9 \leq -1.4421017111437187 \cdot 10^{-143}:\\
\;\;\;\;x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - y \cdot \left(\sqrt{9} \cdot \left(z \cdot \left(\sqrt{9} \cdot t\right)\right)\right)\right)\\

\mathbf{elif}\;y \cdot 9 \leq 5.104445911874034 \cdot 10^{-48}:\\
\;\;\;\;\left(x \cdot 2 - t \cdot \left(\left(y \cdot 9\right) \cdot z\right)\right) + b \cdot \left(a \cdot 27\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - \left(y \cdot 9\right) \cdot \left(z \cdot t\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) (y * 9.0)) <= -1.4421017111437187e-143)) {
		VAR = ((double) (((double) (x * 2.0)) + ((double) (((double) (a * ((double) (27.0 * b)))) - ((double) (y * ((double) (((double) sqrt(9.0)) * ((double) (z * ((double) (((double) sqrt(9.0)) * t))))))))))));
	} else {
		double VAR_1;
		if ((((double) (y * 9.0)) <= 5.104445911874034e-48)) {
			VAR_1 = ((double) (((double) (((double) (x * 2.0)) - ((double) (t * ((double) (((double) (y * 9.0)) * z)))))) + ((double) (b * ((double) (a * 27.0))))));
		} else {
			VAR_1 = ((double) (((double) (x * 2.0)) + ((double) (((double) (a * ((double) (27.0 * b)))) - ((double) (((double) (y * 9.0)) * ((double) (z * t))))))));
		}
		VAR = VAR_1;
	}
	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.7
Target2.8
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;y < 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 3 regimes
  2. if (* y 9.0) < -1.44210171114371868e-143

    1. Initial program Error: 5.4 bits

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. SimplifiedError: 1.8 bits

      \[\leadsto \color{blue}{x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right)}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrtError: 1.8 bits

      \[\leadsto x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - y \cdot \left(\color{blue}{\left(\sqrt{9} \cdot \sqrt{9}\right)} \cdot \left(z \cdot t\right)\right)\right)\]
    5. Applied associate-*l*Error: 1.9 bits

      \[\leadsto x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - y \cdot \color{blue}{\left(\sqrt{9} \cdot \left(\sqrt{9} \cdot \left(z \cdot t\right)\right)\right)}\right)\]
    6. SimplifiedError: 1.9 bits

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

    if -1.44210171114371868e-143 < (* y 9.0) < 5.1044459118740339e-48

    1. Initial program Error: 0.6 bits

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

    if 5.1044459118740339e-48 < (* y 9.0)

    1. Initial program Error: 6.3 bits

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. SimplifiedError: 0.8 bits

      \[\leadsto \color{blue}{x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right)}\]
    3. Using strategy rm
    4. Applied associate-*r*Error: 0.8 bits

      \[\leadsto x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplificationError: 1.1 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 9 \leq -1.4421017111437187 \cdot 10^{-143}:\\ \;\;\;\;x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - y \cdot \left(\sqrt{9} \cdot \left(z \cdot \left(\sqrt{9} \cdot t\right)\right)\right)\right)\\ \mathbf{elif}\;y \cdot 9 \leq 5.104445911874034 \cdot 10^{-48}:\\ \;\;\;\;\left(x \cdot 2 - t \cdot \left(\left(y \cdot 9\right) \cdot z\right)\right) + b \cdot \left(a \cdot 27\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020200 
(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.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))

  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))