Average Error: 3.7 → 0.6
Time: 4.8s
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.9800446771093483 \cdot 10^{217} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 7.947264576269877 \cdot 10^{204}\right):\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + 27 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot x - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\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 -8.9800446771093483 \cdot 10^{217} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 7.947264576269877 \cdot 10^{204}\right):\\
\;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + 27 \cdot \left(a \cdot b\right)\\

\mathbf{else}:\\
\;\;\;\;\left(2 \cdot x - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\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 r714581 = x;
        double r714582 = 2.0;
        double r714583 = r714581 * r714582;
        double r714584 = y;
        double r714585 = 9.0;
        double r714586 = r714584 * r714585;
        double r714587 = z;
        double r714588 = r714586 * r714587;
        double r714589 = t;
        double r714590 = r714588 * r714589;
        double r714591 = r714583 - r714590;
        double r714592 = a;
        double r714593 = 27.0;
        double r714594 = r714592 * r714593;
        double r714595 = b;
        double r714596 = r714594 * r714595;
        double r714597 = r714591 + r714596;
        return r714597;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r714598 = y;
        double r714599 = 9.0;
        double r714600 = r714598 * r714599;
        double r714601 = z;
        double r714602 = r714600 * r714601;
        double r714603 = -8.980044677109348e+217;
        bool r714604 = r714602 <= r714603;
        double r714605 = 7.947264576269877e+204;
        bool r714606 = r714602 <= r714605;
        double r714607 = !r714606;
        bool r714608 = r714604 || r714607;
        double r714609 = x;
        double r714610 = 2.0;
        double r714611 = r714609 * r714610;
        double r714612 = t;
        double r714613 = r714601 * r714612;
        double r714614 = r714600 * r714613;
        double r714615 = r714611 - r714614;
        double r714616 = 27.0;
        double r714617 = a;
        double r714618 = b;
        double r714619 = r714617 * r714618;
        double r714620 = r714616 * r714619;
        double r714621 = r714615 + r714620;
        double r714622 = r714610 * r714609;
        double r714623 = r714601 * r714598;
        double r714624 = r714612 * r714623;
        double r714625 = r714599 * r714624;
        double r714626 = r714622 - r714625;
        double r714627 = r714617 * r714616;
        double r714628 = r714627 * r714618;
        double r714629 = r714626 + r714628;
        double r714630 = r714608 ? r714621 : r714629;
        return r714630;
}

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.7
Target2.7
Herbie0.6
\[\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.980044677109348e+217 or 7.947264576269877e+204 < (* (* y 9.0) z)

    1. Initial program 28.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*1.1

      \[\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. Taylor expanded around 0 1.0

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

    if -8.980044677109348e+217 < (* (* y 9.0) z) < 7.947264576269877e+204

    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\]
    4. Taylor expanded around inf 0.5

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

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

Reproduce

herbie shell --seed 2020036 +o rules:numerics
(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)))