Average Error: 3.8 → 0.9
Time: 17.7s
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 \le -2.136194850984398706225356968041167578331 \cdot 10^{-80}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(z \cdot \left(t \cdot 9\right)\right)\right) + \left(27 \cdot a\right) \cdot b\\ \mathbf{elif}\;y \le 3.301017605632561513674871396351394935966 \cdot 10^{-76}:\\ \;\;\;\;\left(x \cdot 2 + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(\left(z \cdot y\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(z \cdot \left(t \cdot 9\right)\right)\right) + \left(27 \cdot a\right) \cdot b\\ \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 \le -2.136194850984398706225356968041167578331 \cdot 10^{-80}:\\
\;\;\;\;\left(x \cdot 2 - y \cdot \left(z \cdot \left(t \cdot 9\right)\right)\right) + \left(27 \cdot a\right) \cdot b\\

\mathbf{elif}\;y \le 3.301017605632561513674871396351394935966 \cdot 10^{-76}:\\
\;\;\;\;\left(x \cdot 2 + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(\left(z \cdot y\right) \cdot t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r34457780 = x;
        double r34457781 = 2.0;
        double r34457782 = r34457780 * r34457781;
        double r34457783 = y;
        double r34457784 = 9.0;
        double r34457785 = r34457783 * r34457784;
        double r34457786 = z;
        double r34457787 = r34457785 * r34457786;
        double r34457788 = t;
        double r34457789 = r34457787 * r34457788;
        double r34457790 = r34457782 - r34457789;
        double r34457791 = a;
        double r34457792 = 27.0;
        double r34457793 = r34457791 * r34457792;
        double r34457794 = b;
        double r34457795 = r34457793 * r34457794;
        double r34457796 = r34457790 + r34457795;
        return r34457796;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r34457797 = y;
        double r34457798 = -2.1361948509843987e-80;
        bool r34457799 = r34457797 <= r34457798;
        double r34457800 = x;
        double r34457801 = 2.0;
        double r34457802 = r34457800 * r34457801;
        double r34457803 = z;
        double r34457804 = t;
        double r34457805 = 9.0;
        double r34457806 = r34457804 * r34457805;
        double r34457807 = r34457803 * r34457806;
        double r34457808 = r34457797 * r34457807;
        double r34457809 = r34457802 - r34457808;
        double r34457810 = 27.0;
        double r34457811 = a;
        double r34457812 = r34457810 * r34457811;
        double r34457813 = b;
        double r34457814 = r34457812 * r34457813;
        double r34457815 = r34457809 + r34457814;
        double r34457816 = 3.3010176056325615e-76;
        bool r34457817 = r34457797 <= r34457816;
        double r34457818 = r34457811 * r34457813;
        double r34457819 = r34457810 * r34457818;
        double r34457820 = r34457802 + r34457819;
        double r34457821 = r34457803 * r34457797;
        double r34457822 = r34457821 * r34457804;
        double r34457823 = r34457805 * r34457822;
        double r34457824 = r34457820 - r34457823;
        double r34457825 = r34457817 ? r34457824 : r34457815;
        double r34457826 = r34457799 ? r34457815 : r34457825;
        return r34457826;
}

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
Herbie0.9
\[\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 < -2.1361948509843987e-80 or 3.3010176056325615e-76 < y

    1. Initial program 6.2

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

      \[\leadsto \left(x \cdot 2 - \color{blue}{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*6.1

      \[\leadsto \left(x \cdot 2 - \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*1.2

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

    if -2.1361948509843987e-80 < y < 3.3010176056325615e-76

    1. Initial program 0.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 0.6

      \[\leadsto \left(x \cdot 2 - \color{blue}{9 \cdot \left(t \cdot \left(z \cdot y\right)\right)}\right) + \left(a \cdot 27\right) \cdot b\]
    3. Taylor expanded around inf 0.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 simplification0.9

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

Reproduce

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