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

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r33466801 = x;
        double r33466802 = 2.0;
        double r33466803 = r33466801 * r33466802;
        double r33466804 = y;
        double r33466805 = 9.0;
        double r33466806 = r33466804 * r33466805;
        double r33466807 = z;
        double r33466808 = r33466806 * r33466807;
        double r33466809 = t;
        double r33466810 = r33466808 * r33466809;
        double r33466811 = r33466803 - r33466810;
        double r33466812 = a;
        double r33466813 = 27.0;
        double r33466814 = r33466812 * r33466813;
        double r33466815 = b;
        double r33466816 = r33466814 * r33466815;
        double r33466817 = r33466811 + r33466816;
        return r33466817;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r33466818 = y;
        double r33466819 = 9.0;
        double r33466820 = r33466818 * r33466819;
        double r33466821 = z;
        double r33466822 = r33466820 * r33466821;
        double r33466823 = -inf.0;
        bool r33466824 = r33466822 <= r33466823;
        double r33466825 = x;
        double r33466826 = 2.0;
        double r33466827 = r33466825 * r33466826;
        double r33466828 = r33466821 * r33466819;
        double r33466829 = t;
        double r33466830 = r33466828 * r33466829;
        double r33466831 = r33466830 * r33466818;
        double r33466832 = r33466827 - r33466831;
        double r33466833 = 27.0;
        double r33466834 = b;
        double r33466835 = r33466833 * r33466834;
        double r33466836 = a;
        double r33466837 = r33466835 * r33466836;
        double r33466838 = r33466832 + r33466837;
        double r33466839 = 5.9361705210496e-36;
        bool r33466840 = r33466822 <= r33466839;
        double r33466841 = r33466836 * r33466834;
        double r33466842 = r33466841 * r33466833;
        double r33466843 = r33466827 + r33466842;
        double r33466844 = r33466821 * r33466818;
        double r33466845 = r33466844 * r33466829;
        double r33466846 = r33466819 * r33466845;
        double r33466847 = r33466843 - r33466846;
        double r33466848 = r33466821 * r33466829;
        double r33466849 = r33466820 * r33466848;
        double r33466850 = r33466827 - r33466849;
        double r33466851 = r33466850 + r33466837;
        double r33466852 = r33466840 ? r33466847 : r33466851;
        double r33466853 = r33466824 ? r33466838 : r33466852;
        return r33466853;
}

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.4
Herbie1.3
\[\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*2.6

      \[\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.8

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

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

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

    if -inf.0 < (* (* y 9.0) z) < 5.9361705210496e-36

    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. Using strategy rm
    3. Applied associate-*l*3.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. Taylor expanded around inf 0.3

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

    if 5.9361705210496e-36 < (* (* y 9.0) z)

    1. Initial program 6.7

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

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

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

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

Reproduce

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