Average Error: 3.5 → 0.5
Time: 16.4s
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}\;\left(y \cdot 9.0\right) \cdot z = -\infty:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(t \cdot z\right) \cdot \left(y \cdot 9.0\right)\right)\\ \mathbf{elif}\;\left(y \cdot 9.0\right) \cdot z \le 1.2701086409972831 \cdot 10^{+256}:\\ \;\;\;\;a \cdot \left(27.0 \cdot b\right) + \left(x \cdot 2.0 - \left(z \cdot y\right) \cdot \left(t \cdot 9.0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(27.0 \cdot b\right) + \left(x \cdot 2.0 - \left(y \cdot \left(t \cdot z\right)\right) \cdot 9.0\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}\;\left(y \cdot 9.0\right) \cdot z = -\infty:\\
\;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(t \cdot z\right) \cdot \left(y \cdot 9.0\right)\right)\\

\mathbf{elif}\;\left(y \cdot 9.0\right) \cdot z \le 1.2701086409972831 \cdot 10^{+256}:\\
\;\;\;\;a \cdot \left(27.0 \cdot b\right) + \left(x \cdot 2.0 - \left(z \cdot y\right) \cdot \left(t \cdot 9.0\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r39393922 = x;
        double r39393923 = 2.0;
        double r39393924 = r39393922 * r39393923;
        double r39393925 = y;
        double r39393926 = 9.0;
        double r39393927 = r39393925 * r39393926;
        double r39393928 = z;
        double r39393929 = r39393927 * r39393928;
        double r39393930 = t;
        double r39393931 = r39393929 * r39393930;
        double r39393932 = r39393924 - r39393931;
        double r39393933 = a;
        double r39393934 = 27.0;
        double r39393935 = r39393933 * r39393934;
        double r39393936 = b;
        double r39393937 = r39393935 * r39393936;
        double r39393938 = r39393932 + r39393937;
        return r39393938;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r39393939 = y;
        double r39393940 = 9.0;
        double r39393941 = r39393939 * r39393940;
        double r39393942 = z;
        double r39393943 = r39393941 * r39393942;
        double r39393944 = -inf.0;
        bool r39393945 = r39393943 <= r39393944;
        double r39393946 = 27.0;
        double r39393947 = a;
        double r39393948 = r39393946 * r39393947;
        double r39393949 = b;
        double r39393950 = r39393948 * r39393949;
        double r39393951 = x;
        double r39393952 = 2.0;
        double r39393953 = r39393951 * r39393952;
        double r39393954 = t;
        double r39393955 = r39393954 * r39393942;
        double r39393956 = r39393955 * r39393941;
        double r39393957 = r39393953 - r39393956;
        double r39393958 = r39393950 + r39393957;
        double r39393959 = 1.2701086409972831e+256;
        bool r39393960 = r39393943 <= r39393959;
        double r39393961 = r39393946 * r39393949;
        double r39393962 = r39393947 * r39393961;
        double r39393963 = r39393942 * r39393939;
        double r39393964 = r39393954 * r39393940;
        double r39393965 = r39393963 * r39393964;
        double r39393966 = r39393953 - r39393965;
        double r39393967 = r39393962 + r39393966;
        double r39393968 = r39393939 * r39393955;
        double r39393969 = r39393968 * r39393940;
        double r39393970 = r39393953 - r39393969;
        double r39393971 = r39393962 + r39393970;
        double r39393972 = r39393960 ? r39393967 : r39393971;
        double r39393973 = r39393945 ? r39393958 : r39393972;
        return r39393973;
}

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.5
\[\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 3 regimes
  2. if (* (* y 9.0) z) < -inf.0

    1. Initial program 60.4

      \[\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*1.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\]

    if -inf.0 < (* (* y 9.0) z) < 1.2701086409972831e+256

    1. Initial program 0.4

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

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

      \[\leadsto \left(x \cdot 2.0 - \left(9.0 \cdot \left(z \cdot y\right)\right) \cdot t\right) + \color{blue}{a \cdot \left(27.0 \cdot b\right)}\]
    5. Taylor expanded around inf 0.4

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

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

    if 1.2701086409972831e+256 < (* (* y 9.0) z)

    1. Initial program 37.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. Taylor expanded around 0 36.8

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

      \[\leadsto \left(x \cdot 2.0 - \left(9.0 \cdot \left(z \cdot y\right)\right) \cdot t\right) + \color{blue}{a \cdot \left(27.0 \cdot b\right)}\]
    5. Taylor expanded around inf 36.9

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

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

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

Reproduce

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