Average Error: 3.5 → 0.8
Time: 13.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}\;y \cdot 9 \le -0.02104244598094787838116204170546552632004 \lor \neg \left(y \cdot 9 \le 3.77880529429718286420427754234597037636 \cdot 10^{-109}\right):\\ \;\;\;\;x \cdot 2 + \left(27 \cdot \left(a \cdot b\right) - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + \left(27 \cdot \left(a \cdot b\right) - \left(9 \cdot t\right) \cdot \left(z \cdot y\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}\;y \cdot 9 \le -0.02104244598094787838116204170546552632004 \lor \neg \left(y \cdot 9 \le 3.77880529429718286420427754234597037636 \cdot 10^{-109}\right):\\
\;\;\;\;x \cdot 2 + \left(27 \cdot \left(a \cdot b\right) - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r465706 = x;
        double r465707 = 2.0;
        double r465708 = r465706 * r465707;
        double r465709 = y;
        double r465710 = 9.0;
        double r465711 = r465709 * r465710;
        double r465712 = z;
        double r465713 = r465711 * r465712;
        double r465714 = t;
        double r465715 = r465713 * r465714;
        double r465716 = r465708 - r465715;
        double r465717 = a;
        double r465718 = 27.0;
        double r465719 = r465717 * r465718;
        double r465720 = b;
        double r465721 = r465719 * r465720;
        double r465722 = r465716 + r465721;
        return r465722;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r465723 = y;
        double r465724 = 9.0;
        double r465725 = r465723 * r465724;
        double r465726 = -0.02104244598094788;
        bool r465727 = r465725 <= r465726;
        double r465728 = 3.778805294297183e-109;
        bool r465729 = r465725 <= r465728;
        double r465730 = !r465729;
        bool r465731 = r465727 || r465730;
        double r465732 = x;
        double r465733 = 2.0;
        double r465734 = r465732 * r465733;
        double r465735 = 27.0;
        double r465736 = a;
        double r465737 = b;
        double r465738 = r465736 * r465737;
        double r465739 = r465735 * r465738;
        double r465740 = t;
        double r465741 = z;
        double r465742 = r465740 * r465741;
        double r465743 = r465742 * r465723;
        double r465744 = r465724 * r465743;
        double r465745 = r465739 - r465744;
        double r465746 = r465734 + r465745;
        double r465747 = r465724 * r465740;
        double r465748 = r465741 * r465723;
        double r465749 = r465747 * r465748;
        double r465750 = r465739 - r465749;
        double r465751 = r465734 + r465750;
        double r465752 = r465731 ? r465746 : r465751;
        return r465752;
}

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.5
Target2.5
Herbie0.8
\[\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) < -0.02104244598094788 or 3.778805294297183e-109 < (* y 9.0)

    1. Initial program 6.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 sub-neg6.3

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

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

      \[\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)}\]
    6. Using strategy rm
    7. Applied associate-*r*1.0

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

    if -0.02104244598094788 < (* y 9.0) < 3.778805294297183e-109

    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 sub-neg0.5

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

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

      \[\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)}\]
    6. Using strategy rm
    7. Applied associate-*r*0.6

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

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

Reproduce

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