Average Error: 3.5 → 2.2
Time: 12.6s
Precision: 64
\[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;t \le -2.6559016943190243 \cdot 10^{+76}:\\ \;\;\;\;\left(x \cdot 2.0 - t \cdot \left(\left(9.0 \cdot z\right) \cdot y\right)\right) + \left(27.0 \cdot a\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - y \cdot \left(\left(t \cdot z\right) \cdot 9.0\right)\right)\\ \end{array}\]
\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b
\begin{array}{l}
\mathbf{if}\;t \le -2.6559016943190243 \cdot 10^{+76}:\\
\;\;\;\;\left(x \cdot 2.0 - t \cdot \left(\left(9.0 \cdot z\right) \cdot y\right)\right) + \left(27.0 \cdot a\right) \cdot b\\

\mathbf{else}:\\
\;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - y \cdot \left(\left(t \cdot z\right) \cdot 9.0\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r15358006 = x;
        double r15358007 = 2.0;
        double r15358008 = r15358006 * r15358007;
        double r15358009 = y;
        double r15358010 = 9.0;
        double r15358011 = r15358009 * r15358010;
        double r15358012 = z;
        double r15358013 = r15358011 * r15358012;
        double r15358014 = t;
        double r15358015 = r15358013 * r15358014;
        double r15358016 = r15358008 - r15358015;
        double r15358017 = a;
        double r15358018 = 27.0;
        double r15358019 = r15358017 * r15358018;
        double r15358020 = b;
        double r15358021 = r15358019 * r15358020;
        double r15358022 = r15358016 + r15358021;
        return r15358022;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r15358023 = t;
        double r15358024 = -2.6559016943190243e+76;
        bool r15358025 = r15358023 <= r15358024;
        double r15358026 = x;
        double r15358027 = 2.0;
        double r15358028 = r15358026 * r15358027;
        double r15358029 = 9.0;
        double r15358030 = z;
        double r15358031 = r15358029 * r15358030;
        double r15358032 = y;
        double r15358033 = r15358031 * r15358032;
        double r15358034 = r15358023 * r15358033;
        double r15358035 = r15358028 - r15358034;
        double r15358036 = 27.0;
        double r15358037 = a;
        double r15358038 = r15358036 * r15358037;
        double r15358039 = b;
        double r15358040 = r15358038 * r15358039;
        double r15358041 = r15358035 + r15358040;
        double r15358042 = r15358023 * r15358030;
        double r15358043 = r15358042 * r15358029;
        double r15358044 = r15358032 * r15358043;
        double r15358045 = r15358028 - r15358044;
        double r15358046 = r15358040 + r15358045;
        double r15358047 = r15358025 ? r15358041 : r15358046;
        return r15358047;
}

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
Herbie2.2
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + a \cdot \left(27.0 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27.0\right) \cdot b\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -2.6559016943190243e+76

    1. Initial program 0.8

      \[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*0.9

      \[\leadsto \left(x \cdot 2.0 - \color{blue}{\left(y \cdot \left(9.0 \cdot z\right)\right)} \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]

    if -2.6559016943190243e+76 < t

    1. Initial program 4.0

      \[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*2.4

      \[\leadsto \left(x \cdot 2.0 - \color{blue}{\left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27.0\right) \cdot b\]
    4. Using strategy rm
    5. Applied associate-*l*2.4

      \[\leadsto \left(x \cdot 2.0 - \color{blue}{y \cdot \left(9.0 \cdot \left(z \cdot t\right)\right)}\right) + \left(a \cdot 27.0\right) \cdot b\]
    6. Using strategy rm
    7. Applied +-commutative2.4

      \[\leadsto \color{blue}{\left(a \cdot 27.0\right) \cdot b + \left(x \cdot 2.0 - y \cdot \left(9.0 \cdot \left(z \cdot t\right)\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -2.6559016943190243 \cdot 10^{+76}:\\ \;\;\;\;\left(x \cdot 2.0 - t \cdot \left(\left(9.0 \cdot z\right) \cdot y\right)\right) + \left(27.0 \cdot a\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - y \cdot \left(\left(t \cdot z\right) \cdot 9.0\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019156 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))

  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))