Average Error: 3.5 → 0.8
Time: 15.4s
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 r412973 = x;
        double r412974 = 2.0;
        double r412975 = r412973 * r412974;
        double r412976 = y;
        double r412977 = 9.0;
        double r412978 = r412976 * r412977;
        double r412979 = z;
        double r412980 = r412978 * r412979;
        double r412981 = t;
        double r412982 = r412980 * r412981;
        double r412983 = r412975 - r412982;
        double r412984 = a;
        double r412985 = 27.0;
        double r412986 = r412984 * r412985;
        double r412987 = b;
        double r412988 = r412986 * r412987;
        double r412989 = r412983 + r412988;
        return r412989;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r412990 = y;
        double r412991 = 9.0;
        double r412992 = r412990 * r412991;
        double r412993 = -0.02104244598094788;
        bool r412994 = r412992 <= r412993;
        double r412995 = 3.778805294297183e-109;
        bool r412996 = r412992 <= r412995;
        double r412997 = !r412996;
        bool r412998 = r412994 || r412997;
        double r412999 = x;
        double r413000 = 2.0;
        double r413001 = r412999 * r413000;
        double r413002 = 27.0;
        double r413003 = a;
        double r413004 = b;
        double r413005 = r413003 * r413004;
        double r413006 = r413002 * r413005;
        double r413007 = t;
        double r413008 = z;
        double r413009 = r413007 * r413008;
        double r413010 = r413009 * r412990;
        double r413011 = r412991 * r413010;
        double r413012 = r413006 - r413011;
        double r413013 = r413001 + r413012;
        double r413014 = r412991 * r413007;
        double r413015 = r413008 * r412990;
        double r413016 = r413014 * r413015;
        double r413017 = r413006 - r413016;
        double r413018 = r413001 + r413017;
        double r413019 = r412998 ? r413013 : r413018;
        return r413019;
}

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 +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)))