Average Error: 4.0 → 2.1
Time: 3.9s
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 -1.0621960484068377 \cdot 10^{-5}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(t \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 -1.0621960484068377 \cdot 10^{-5}:\\
\;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r758896 = x;
        double r758897 = 2.0;
        double r758898 = r758896 * r758897;
        double r758899 = y;
        double r758900 = 9.0;
        double r758901 = r758899 * r758900;
        double r758902 = z;
        double r758903 = r758901 * r758902;
        double r758904 = t;
        double r758905 = r758903 * r758904;
        double r758906 = r758898 - r758905;
        double r758907 = a;
        double r758908 = 27.0;
        double r758909 = r758907 * r758908;
        double r758910 = b;
        double r758911 = r758909 * r758910;
        double r758912 = r758906 + r758911;
        return r758912;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r758913 = y;
        double r758914 = 9.0;
        double r758915 = r758913 * r758914;
        double r758916 = -1.0621960484068377e-05;
        bool r758917 = r758915 <= r758916;
        double r758918 = x;
        double r758919 = 2.0;
        double r758920 = r758918 * r758919;
        double r758921 = z;
        double r758922 = r758914 * r758921;
        double r758923 = t;
        double r758924 = r758922 * r758923;
        double r758925 = r758913 * r758924;
        double r758926 = r758920 - r758925;
        double r758927 = a;
        double r758928 = 27.0;
        double r758929 = r758927 * r758928;
        double r758930 = b;
        double r758931 = r758929 * r758930;
        double r758932 = r758926 + r758931;
        double r758933 = r758919 * r758918;
        double r758934 = r758927 * r758930;
        double r758935 = r758928 * r758934;
        double r758936 = r758933 + r758935;
        double r758937 = r758921 * r758913;
        double r758938 = r758923 * r758937;
        double r758939 = r758914 * r758938;
        double r758940 = r758936 - r758939;
        double r758941 = r758917 ? r758932 : r758940;
        return r758941;
}

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

Original4.0
Target2.9
Herbie2.1
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811189 \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) < -1.0621960484068377e-05

    1. Initial program 8.4

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

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

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

    if -1.0621960484068377e-05 < (* y 9.0)

    1. Initial program 2.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*2.7

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot \left(9 \cdot z\right)\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    4. Using strategy rm
    5. Applied pow12.7

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

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

      \[\leadsto \left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \left(\color{blue}{{a}^{1}} \cdot {27}^{1}\right) \cdot {b}^{1}\]
    8. Applied pow-prod-down2.7

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

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

      \[\leadsto \left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + {\color{blue}{\left(27 \cdot \left(a \cdot b\right)\right)}}^{1}\]
    11. Taylor expanded around inf 2.5

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

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

Reproduce

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