Average Error: 3.8 → 1.4
Time: 37.1s
Precision: binary64
Cost: 1986
\[\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 -1.2640897934873165 \cdot 10^{+189}:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \leq 5.768366724569417 \cdot 10^{+26}:\\ \;\;\;\;\left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot 27\right) \cdot b + \left(x \cdot 2 + y \cdot \left(t \cdot \left(z \cdot -9\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 \leq -1.2640897934873165 \cdot 10^{+189}:\\
\;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\

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

\mathbf{else}:\\
\;\;\;\;\left(a \cdot 27\right) \cdot b + \left(x \cdot 2 + y \cdot \left(t \cdot \left(z \cdot -9\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) -1.2640897934873165e+189)
   (+ (- (* x 2.0) (* (* y 9.0) (* z t))) (* (* a 27.0) b))
   (if (<= (* (* y 9.0) z) 5.768366724569417e+26)
     (+ (* (* a 27.0) b) (- (* x 2.0) (* (* (* y 9.0) z) t)))
     (+ (* (* a 27.0) b) (+ (* x 2.0) (* y (* t (* z -9.0))))))))
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) <= -1.2640897934873165e+189) {
		tmp = ((x * 2.0) - ((y * 9.0) * (z * t))) + ((a * 27.0) * b);
	} else if (((y * 9.0) * z) <= 5.768366724569417e+26) {
		tmp = ((a * 27.0) * b) + ((x * 2.0) - (((y * 9.0) * z) * t));
	} else {
		tmp = ((a * 27.0) * b) + ((x * 2.0) + (y * (t * (z * -9.0))));
	}
	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.8
Target2.7
Herbie1.4
\[\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}\]

Alternatives

Alternative 1
Accuracy0.9
Cost1924
\[\begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \leq -1.2640897934873165 \cdot 10^{+189} \lor \neg \left(\left(y \cdot 9\right) \cdot z \leq 4.901120821551416 \cdot 10^{+103}\right):\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\ \end{array}\]
Alternative 2
Accuracy3.8
Cost1088
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 y 9) z) < -1.26408979348731648e189

    1. Initial program 24.2

      \[\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*_binary64_249121.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\]

    if -1.26408979348731648e189 < (*.f64 (*.f64 y 9) z) < 5.7683667245694172e26

    1. Initial program 0.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. Using strategy rm
    3. Applied *-un-lft-identity_binary64_249710.6

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

      \[\leadsto \color{blue}{{\left(x \cdot 2 - \left(1 \cdot \left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t\right)}^{1}} + \left(a \cdot 27\right) \cdot b\]
    6. Using strategy rm
    7. Applied *-un-lft-identity_binary64_249710.6

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

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

    if 5.7683667245694172e26 < (*.f64 (*.f64 y 9) z)

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

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

      \[\leadsto \color{blue}{{\left(x \cdot 2 - \left(1 \cdot \left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t\right)}^{1}} + \left(a \cdot 27\right) \cdot b\]
    6. Using strategy rm
    7. Applied sub-neg_binary64_249649.5

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

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

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

Reproduce

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