Average Error: 3.9 → 1.3
Time: 15.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}\;\left(y \cdot 9\right) \cdot z \leq -2.076476446964344 \cdot 10^{+256}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(t \cdot \left(9 \cdot z\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \leq 3.0974314158590182 \cdot 10^{+34}:\\ \;\;\;\;x \cdot 2 - \left(\left(9 \cdot t\right) \cdot \left(y \cdot z\right) - a \cdot \left(27 \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - z \cdot \left(\left(y \cdot 9\right) \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}\;\left(y \cdot 9\right) \cdot z \leq -2.076476446964344 \cdot 10^{+256}:\\
\;\;\;\;\left(x \cdot 2 - y \cdot \left(t \cdot \left(9 \cdot z\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\

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

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

\end{array}
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (* (* y 9.0) z) -2.076476446964344e+256)
   (+ (- (* x 2.0) (* y (* t (* 9.0 z)))) (* a (* 27.0 b)))
   (if (<= (* (* y 9.0) z) 3.0974314158590182e+34)
     (- (* x 2.0) (- (* (* 9.0 t) (* y z)) (* a (* 27.0 b))))
     (+ (* x 2.0) (- (* a (* 27.0 b)) (* z (* (* y 9.0) t)))))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((y * 9.0) * z) <= -2.076476446964344e+256) {
		tmp = ((x * 2.0) - (y * (t * (9.0 * z)))) + (a * (27.0 * b));
	} else if (((y * 9.0) * z) <= 3.0974314158590182e+34) {
		tmp = (x * 2.0) - (((9.0 * t) * (y * z)) - (a * (27.0 * b)));
	} else {
		tmp = (x * 2.0) + ((a * (27.0 * b)) - (z * ((y * 9.0) * t)));
	}
	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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.9
Target2.7
Herbie1.3
\[\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 (*.f64 (*.f64 y 9) z) < -2.0764764469643441e256

    1. Initial program 40.6

      \[\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}{\left(x \cdot 2 - y \cdot \left(t \cdot \left(9 \cdot z\right)\right)\right) + a \cdot \left(27 \cdot b\right)}\]

    if -2.0764764469643441e256 < (*.f64 (*.f64 y 9) z) < 3.09743141585901823e34

    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. Simplified3.5

      \[\leadsto \color{blue}{x \cdot 2 - \left(z \cdot \left(\left(y \cdot 9\right) \cdot t\right) - a \cdot \left(27 \cdot b\right)\right)}\]
    3. Taylor expanded around 0 0.5

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

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

    if 3.09743141585901823e34 < (*.f64 (*.f64 y 9) z)

    1. Initial program 10.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \leq -2.076476446964344 \cdot 10^{+256}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(t \cdot \left(9 \cdot z\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \leq 3.0974314158590182 \cdot 10^{+34}:\\ \;\;\;\;x \cdot 2 - \left(\left(9 \cdot t\right) \cdot \left(y \cdot z\right) - a \cdot \left(27 \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + \left(a \cdot \left(27 \cdot b\right) - z \cdot \left(\left(y \cdot 9\right) \cdot t\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2021176 
(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)))