Average Error: 3.8 → 3.8
Time: 1.4m
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\]
\[\left(2 \cdot x - \left(9 \cdot t\right) \cdot \left(z \cdot y\right)\right) + a \cdot \left(27 \cdot b\right)\]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\left(2 \cdot x - \left(9 \cdot t\right) \cdot \left(z \cdot y\right)\right) + a \cdot \left(27 \cdot b\right)
double f(double x, double y, double z, double t, double a, double b) {
        double r564872 = x;
        double r564873 = 2.0;
        double r564874 = r564872 * r564873;
        double r564875 = y;
        double r564876 = 9.0;
        double r564877 = r564875 * r564876;
        double r564878 = z;
        double r564879 = r564877 * r564878;
        double r564880 = t;
        double r564881 = r564879 * r564880;
        double r564882 = r564874 - r564881;
        double r564883 = a;
        double r564884 = 27.0;
        double r564885 = r564883 * r564884;
        double r564886 = b;
        double r564887 = r564885 * r564886;
        double r564888 = r564882 + r564887;
        return r564888;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r564889 = 2.0;
        double r564890 = x;
        double r564891 = r564889 * r564890;
        double r564892 = 9.0;
        double r564893 = t;
        double r564894 = r564892 * r564893;
        double r564895 = z;
        double r564896 = y;
        double r564897 = r564895 * r564896;
        double r564898 = r564894 * r564897;
        double r564899 = r564891 - r564898;
        double r564900 = a;
        double r564901 = 27.0;
        double r564902 = b;
        double r564903 = r564901 * r564902;
        double r564904 = r564900 * r564903;
        double r564905 = r564899 + r564904;
        return r564905;
}

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.8
Target2.7
Herbie3.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 3 regimes
  2. if (* y 9.0) < -1.8790357115632566e+19

    1. Initial program 8.6

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Taylor expanded around inf 8.5

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

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

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

    if -1.8790357115632566e+19 < (* y 9.0) < 3.0661988671115835e-72

    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. Taylor expanded around inf 0.5

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

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

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

    if 3.0661988671115835e-72 < (* y 9.0)

    1. Initial program 6.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. Taylor expanded around inf 6.7

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

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

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

Reproduce

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