Average Error: 3.6 → 0.7
Time: 4.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 -1.509627698880911586338015526628233224088 \cdot 10^{129} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 2.414314480791499273783363683236492721004 \cdot 10^{188}\right):\\ \;\;\;\;x \cdot 2 + \left(27 \cdot \left(a \cdot b\right) - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \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 -1.509627698880911586338015526628233224088 \cdot 10^{129} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 2.414314480791499273783363683236492721004 \cdot 10^{188}\right):\\
\;\;\;\;x \cdot 2 + \left(27 \cdot \left(a \cdot b\right) - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r819623 = x;
        double r819624 = 2.0;
        double r819625 = r819623 * r819624;
        double r819626 = y;
        double r819627 = 9.0;
        double r819628 = r819626 * r819627;
        double r819629 = z;
        double r819630 = r819628 * r819629;
        double r819631 = t;
        double r819632 = r819630 * r819631;
        double r819633 = r819625 - r819632;
        double r819634 = a;
        double r819635 = 27.0;
        double r819636 = r819634 * r819635;
        double r819637 = b;
        double r819638 = r819636 * r819637;
        double r819639 = r819633 + r819638;
        return r819639;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r819640 = y;
        double r819641 = 9.0;
        double r819642 = r819640 * r819641;
        double r819643 = z;
        double r819644 = r819642 * r819643;
        double r819645 = -1.5096276988809116e+129;
        bool r819646 = r819644 <= r819645;
        double r819647 = 2.4143144807914993e+188;
        bool r819648 = r819644 <= r819647;
        double r819649 = !r819648;
        bool r819650 = r819646 || r819649;
        double r819651 = x;
        double r819652 = 2.0;
        double r819653 = r819651 * r819652;
        double r819654 = 27.0;
        double r819655 = a;
        double r819656 = b;
        double r819657 = r819655 * r819656;
        double r819658 = r819654 * r819657;
        double r819659 = r819641 * r819643;
        double r819660 = t;
        double r819661 = r819659 * r819660;
        double r819662 = r819640 * r819661;
        double r819663 = r819658 - r819662;
        double r819664 = r819653 + r819663;
        double r819665 = r819640 * r819659;
        double r819666 = r819665 * r819660;
        double r819667 = r819653 - r819666;
        double r819668 = r819655 * r819654;
        double r819669 = r819668 * r819656;
        double r819670 = r819667 + r819669;
        double r819671 = r819650 ? r819664 : r819670;
        return r819671;
}

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.6
Target2.6
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811188954625810696587370427881 \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) < -1.5096276988809116e+129 or 2.4143144807914993e+188 < (* (* y 9.0) z)

    1. Initial program 19.0

      \[\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*2.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. Using strategy rm
    5. Applied associate-*l*1.8

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

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

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

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

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

    if -1.5096276988809116e+129 < (* (* y 9.0) z) < 2.4143144807914993e+188

    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 associate-*l*0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -1.509627698880911586338015526628233224088 \cdot 10^{129} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 2.414314480791499273783363683236492721004 \cdot 10^{188}\right):\\ \;\;\;\;x \cdot 2 + \left(27 \cdot \left(a \cdot b\right) - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]

Reproduce

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