Average Error: 3.6 → 0.9
Time: 3.6s
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 -8.45453806233432274 \cdot 10^{101} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 4.2688792136598173 \cdot 10^{119}\right):\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + \left(\sqrt{27} \cdot \left(\sqrt{27} \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\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 \le -8.45453806233432274 \cdot 10^{101} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 4.2688792136598173 \cdot 10^{119}\right):\\
\;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + a \cdot \left(27 \cdot b\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r900089 = x;
        double r900090 = 2.0;
        double r900091 = r900089 * r900090;
        double r900092 = y;
        double r900093 = 9.0;
        double r900094 = r900092 * r900093;
        double r900095 = z;
        double r900096 = r900094 * r900095;
        double r900097 = t;
        double r900098 = r900096 * r900097;
        double r900099 = r900091 - r900098;
        double r900100 = a;
        double r900101 = 27.0;
        double r900102 = r900100 * r900101;
        double r900103 = b;
        double r900104 = r900102 * r900103;
        double r900105 = r900099 + r900104;
        return r900105;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r900106 = y;
        double r900107 = 9.0;
        double r900108 = r900106 * r900107;
        double r900109 = z;
        double r900110 = r900108 * r900109;
        double r900111 = -8.454538062334323e+101;
        bool r900112 = r900110 <= r900111;
        double r900113 = 4.268879213659817e+119;
        bool r900114 = r900110 <= r900113;
        double r900115 = !r900114;
        bool r900116 = r900112 || r900115;
        double r900117 = x;
        double r900118 = 2.0;
        double r900119 = r900117 * r900118;
        double r900120 = t;
        double r900121 = r900109 * r900120;
        double r900122 = r900108 * r900121;
        double r900123 = r900119 - r900122;
        double r900124 = a;
        double r900125 = 27.0;
        double r900126 = b;
        double r900127 = r900125 * r900126;
        double r900128 = r900124 * r900127;
        double r900129 = r900123 + r900128;
        double r900130 = sqrt(r900125);
        double r900131 = r900124 * r900126;
        double r900132 = r900130 * r900131;
        double r900133 = r900130 * r900132;
        double r900134 = r900109 * r900106;
        double r900135 = r900120 * r900134;
        double r900136 = r900107 * r900135;
        double r900137 = r900133 - r900136;
        double r900138 = r900119 + r900137;
        double r900139 = r900116 ? r900129 : r900138;
        return r900139;
}

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.5
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;y \lt 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 2 regimes
  2. if (* (* y 9.0) z) < -8.454538062334323e+101 or 4.268879213659817e+119 < (* (* y 9.0) z)

    1. Initial program 14.9

      \[\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*14.7

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

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

    if -8.454538062334323e+101 < (* (* y 9.0) z) < 4.268879213659817e+119

    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.4

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

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

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

      \[\leadsto x \cdot 2 + \color{blue}{\left(27 \cdot \left(a \cdot b\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    8. Taylor expanded around inf 0.4

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

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

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

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

Reproduce

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