Average Error: 3.5 → 3.5
Time: 6.5s
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\]
\[x \cdot 2 + \left(27 \cdot \left(a \cdot b\right) - \left(9 \cdot t\right) \cdot \left(z \cdot y\right)\right)\]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
x \cdot 2 + \left(27 \cdot \left(a \cdot b\right) - \left(9 \cdot t\right) \cdot \left(z \cdot y\right)\right)
double f(double x, double y, double z, double t, double a, double b) {
        double r697041 = x;
        double r697042 = 2.0;
        double r697043 = r697041 * r697042;
        double r697044 = y;
        double r697045 = 9.0;
        double r697046 = r697044 * r697045;
        double r697047 = z;
        double r697048 = r697046 * r697047;
        double r697049 = t;
        double r697050 = r697048 * r697049;
        double r697051 = r697043 - r697050;
        double r697052 = a;
        double r697053 = 27.0;
        double r697054 = r697052 * r697053;
        double r697055 = b;
        double r697056 = r697054 * r697055;
        double r697057 = r697051 + r697056;
        return r697057;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r697058 = x;
        double r697059 = 2.0;
        double r697060 = r697058 * r697059;
        double r697061 = 27.0;
        double r697062 = a;
        double r697063 = b;
        double r697064 = r697062 * r697063;
        double r697065 = r697061 * r697064;
        double r697066 = 9.0;
        double r697067 = t;
        double r697068 = r697066 * r697067;
        double r697069 = z;
        double r697070 = y;
        double r697071 = r697069 * r697070;
        double r697072 = r697068 * r697071;
        double r697073 = r697065 - r697072;
        double r697074 = r697060 + r697073;
        return r697074;
}

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
Herbie3.5
\[\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 2 regimes
  2. if (* y 9.0) < -0.02104244598094788 or 3.778805294297183e-109 < (* y 9.0)

    1. Initial program 6.3

      \[\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 sub-neg6.3

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

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

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

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

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

    if -0.02104244598094788 < (* y 9.0) < 3.778805294297183e-109

    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. Using strategy rm
    3. Applied sub-neg0.5

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

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

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

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

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

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

Reproduce

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