Average Error: 3.0 → 0.7
Time: 9.1s
Precision: binary64
\[[y, z, t]=\mathsf{sort}([y, z, t])\]
\[[a, b]=\mathsf{sort}([a, b])\]
\[\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(\left(y \cdot 9\right) \cdot z\right) \cdot t \leq -2.9625710411553207 \cdot 10^{+307}:\\ \;\;\;\;\left(x \cdot 2 - z \cdot \left(9 \cdot \left(y \cdot t\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{elif}\;\left(\left(y \cdot 9\right) \cdot z\right) \cdot t \leq 1.010787557651193 \cdot 10^{+286}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + b \cdot \left(a \cdot 27\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(a \cdot 27\right) + \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\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(\left(y \cdot 9\right) \cdot z\right) \cdot t \leq -2.9625710411553207 \cdot 10^{+307}:\\
\;\;\;\;\left(x \cdot 2 - z \cdot \left(9 \cdot \left(y \cdot t\right)\right)\right) + a \cdot \left(27 \cdot b\right)\\

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

\mathbf{else}:\\
\;\;\;\;b \cdot \left(a \cdot 27\right) + \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\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) t) -2.9625710411553207e+307)
   (+ (- (* x 2.0) (* z (* 9.0 (* y t)))) (* a (* 27.0 b)))
   (if (<= (* (* (* y 9.0) z) t) 1.010787557651193e+286)
     (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* b (* a 27.0)))
     (+ (* b (* a 27.0)) (- (* x 2.0) (* y (* 9.0 (* z 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) * t) <= -2.9625710411553207e+307) {
		tmp = ((x * 2.0) - (z * (9.0 * (y * t)))) + (a * (27.0 * b));
	} else if ((((y * 9.0) * z) * t) <= 1.010787557651193e+286) {
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (b * (a * 27.0));
	} else {
		tmp = (b * (a * 27.0)) + ((x * 2.0) - (y * (9.0 * (z * 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.0
Target3.4
Herbie0.7
\[\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 (*.f64 y 9) z) t) < -2.9625710411553207e307

    1. Initial program 62.7

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*_binary644.3

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

      \[\leadsto \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \color{blue}{\left(t \cdot z\right)}\right) + \left(a \cdot 27\right) \cdot b\]
    5. Using strategy rm
    6. Applied associate-*r*_binary643.5

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

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(t \cdot \left(9 \cdot y\right)\right)} \cdot z\right) + \left(a \cdot 27\right) \cdot b\]
    8. Using strategy rm
    9. Applied pow1_binary643.5

      \[\leadsto \left(x \cdot 2 - \left(t \cdot \left(9 \cdot \color{blue}{{y}^{1}}\right)\right) \cdot z\right) + \left(a \cdot 27\right) \cdot b\]
    10. Applied pow1_binary643.5

      \[\leadsto \left(x \cdot 2 - \left(t \cdot \left(\color{blue}{{9}^{1}} \cdot {y}^{1}\right)\right) \cdot z\right) + \left(a \cdot 27\right) \cdot b\]
    11. Applied pow-prod-down_binary643.5

      \[\leadsto \left(x \cdot 2 - \left(t \cdot \color{blue}{{\left(9 \cdot y\right)}^{1}}\right) \cdot z\right) + \left(a \cdot 27\right) \cdot b\]
    12. Applied pow1_binary643.5

      \[\leadsto \left(x \cdot 2 - \left(\color{blue}{{t}^{1}} \cdot {\left(9 \cdot y\right)}^{1}\right) \cdot z\right) + \left(a \cdot 27\right) \cdot b\]
    13. Applied pow-prod-down_binary643.5

      \[\leadsto \left(x \cdot 2 - \color{blue}{{\left(t \cdot \left(9 \cdot y\right)\right)}^{1}} \cdot z\right) + \left(a \cdot 27\right) \cdot b\]
    14. Simplified1.6

      \[\leadsto \left(x \cdot 2 - {\color{blue}{\left(9 \cdot \left(t \cdot y\right)\right)}}^{1} \cdot z\right) + \left(a \cdot 27\right) \cdot b\]
    15. Using strategy rm
    16. Applied associate-*l*_binary641.6

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

    if -2.9625710411553207e307 < (*.f64 (*.f64 (*.f64 y 9) z) t) < 1.01078755765119304e286

    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. Using strategy rm
    3. Applied *-un-lft-identity_binary640.5

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

    if 1.01078755765119304e286 < (*.f64 (*.f64 (*.f64 y 9) z) t)

    1. Initial program 41.3

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*_binary645.4

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

      \[\leadsto \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \color{blue}{\left(t \cdot z\right)}\right) + \left(a \cdot 27\right) \cdot b\]
    5. Using strategy rm
    6. Applied associate-*l*_binary644.5

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

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

Alternatives

Reproduce

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