Average Error: 3.7 → 1.4
Time: 3.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\]
\[\begin{array}{l} \mathbf{if}\;y \cdot 9 \le -8.63828739859890366 \cdot 10^{64}:\\ \;\;\;\;\left(2 \cdot x - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{elif}\;y \cdot 9 \le 4.26640526336584695 \cdot 10^{171}:\\ \;\;\;\;\left(2 \cdot x - \left(9 \cdot t\right) \cdot \left(z \cdot y\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + a \cdot \left(27 \cdot b\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 -8.63828739859890366 \cdot 10^{64}:\\
\;\;\;\;\left(2 \cdot x - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right) + \left(a \cdot 27\right) \cdot b\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r876645 = x;
        double r876646 = 2.0;
        double r876647 = r876645 * r876646;
        double r876648 = y;
        double r876649 = 9.0;
        double r876650 = r876648 * r876649;
        double r876651 = z;
        double r876652 = r876650 * r876651;
        double r876653 = t;
        double r876654 = r876652 * r876653;
        double r876655 = r876647 - r876654;
        double r876656 = a;
        double r876657 = 27.0;
        double r876658 = r876656 * r876657;
        double r876659 = b;
        double r876660 = r876658 * r876659;
        double r876661 = r876655 + r876660;
        return r876661;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r876662 = y;
        double r876663 = 9.0;
        double r876664 = r876662 * r876663;
        double r876665 = -8.638287398598904e+64;
        bool r876666 = r876664 <= r876665;
        double r876667 = 2.0;
        double r876668 = x;
        double r876669 = r876667 * r876668;
        double r876670 = t;
        double r876671 = z;
        double r876672 = r876670 * r876671;
        double r876673 = r876672 * r876662;
        double r876674 = r876663 * r876673;
        double r876675 = r876669 - r876674;
        double r876676 = a;
        double r876677 = 27.0;
        double r876678 = r876676 * r876677;
        double r876679 = b;
        double r876680 = r876678 * r876679;
        double r876681 = r876675 + r876680;
        double r876682 = 4.266405263365847e+171;
        bool r876683 = r876664 <= r876682;
        double r876684 = r876663 * r876670;
        double r876685 = r876671 * r876662;
        double r876686 = r876684 * r876685;
        double r876687 = r876669 - r876686;
        double r876688 = r876687 + r876680;
        double r876689 = r876668 * r876667;
        double r876690 = r876671 * r876670;
        double r876691 = r876664 * r876690;
        double r876692 = r876689 - r876691;
        double r876693 = r876677 * r876679;
        double r876694 = r876676 * r876693;
        double r876695 = r876692 + r876694;
        double r876696 = r876683 ? r876688 : r876695;
        double r876697 = r876666 ? r876681 : r876696;
        return r876697;
}

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.7
Target2.6
Herbie1.4
\[\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 3 regimes
  2. if (* y 9.0) < -8.638287398598904e+64

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

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

      \[\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\]

    if -8.638287398598904e+64 < (* y 9.0) < 4.266405263365847e+171

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

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

    if 4.266405263365847e+171 < (* y 9.0)

    1. Initial program 13.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. Using strategy rm
    3. Applied associate-*l*13.5

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

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

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

Reproduce

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