Average Error: 3.6 → 0.7
Time: 14.2s
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}\;t \le -2.767371119342816049720828607804652324816 \cdot 10^{-31}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right) + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\ \mathbf{elif}\;t \le 525414192.578026354312896728515625:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(t \cdot z\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 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}\;t \le -2.767371119342816049720828607804652324816 \cdot 10^{-31}:\\
\;\;\;\;27 \cdot \left(a \cdot b\right) + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2 - 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 r585000 = x;
        double r585001 = 2.0;
        double r585002 = r585000 * r585001;
        double r585003 = y;
        double r585004 = 9.0;
        double r585005 = r585003 * r585004;
        double r585006 = z;
        double r585007 = r585005 * r585006;
        double r585008 = t;
        double r585009 = r585007 * r585008;
        double r585010 = r585002 - r585009;
        double r585011 = a;
        double r585012 = 27.0;
        double r585013 = r585011 * r585012;
        double r585014 = b;
        double r585015 = r585013 * r585014;
        double r585016 = r585010 + r585015;
        return r585016;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r585017 = t;
        double r585018 = -2.767371119342816e-31;
        bool r585019 = r585017 <= r585018;
        double r585020 = 27.0;
        double r585021 = a;
        double r585022 = b;
        double r585023 = r585021 * r585022;
        double r585024 = r585020 * r585023;
        double r585025 = x;
        double r585026 = 2.0;
        double r585027 = r585025 * r585026;
        double r585028 = y;
        double r585029 = 9.0;
        double r585030 = r585028 * r585029;
        double r585031 = z;
        double r585032 = r585030 * r585031;
        double r585033 = r585032 * r585017;
        double r585034 = r585027 - r585033;
        double r585035 = r585024 + r585034;
        double r585036 = 525414192.57802635;
        bool r585037 = r585017 <= r585036;
        double r585038 = r585017 * r585031;
        double r585039 = r585030 * r585038;
        double r585040 = r585027 - r585039;
        double r585041 = r585020 * r585022;
        double r585042 = r585021 * r585041;
        double r585043 = r585040 + r585042;
        double r585044 = r585031 * r585028;
        double r585045 = r585017 * r585044;
        double r585046 = r585029 * r585045;
        double r585047 = r585027 - r585046;
        double r585048 = r585021 * r585020;
        double r585049 = r585048 * r585022;
        double r585050 = r585047 + r585049;
        double r585051 = r585037 ? r585043 : r585050;
        double r585052 = r585019 ? r585035 : r585051;
        return r585052;
}

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 3 regimes
  2. if t < -2.767371119342816e-31

    1. Initial program 0.8

      \[\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.8

      \[\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 *-un-lft-identity0.8

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

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

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

    if -2.767371119342816e-31 < t < 525414192.57802635

    1. Initial program 6.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*6.0

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

      \[\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)\]
    6. Simplified0.7

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

    if 525414192.57802635 < t

    1. Initial program 0.7

      \[\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.9

      \[\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. Taylor expanded around inf 0.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -2.767371119342816049720828607804652324816 \cdot 10^{-31}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right) + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\ \mathbf{elif}\;t \le 525414192.578026354312896728515625:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(t \cdot z\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 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 2019347 +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)))