Average Error: 3.7 → 1.0
Time: 46.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}\;t \le -1.63797584648016 \cdot 10^{+90}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot b, 27.0, x \cdot 2.0\right) - \left(z \cdot y\right) \cdot \left(t \cdot 9.0\right)\\ \mathbf{elif}\;t \le 2.728698628306364 \cdot 10^{-128}:\\ \;\;\;\;\mathsf{fma}\left(a, 27.0 \cdot b, x \cdot 2.0 - \left(\left(t \cdot 9.0\right) \cdot y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot b, 27.0, x \cdot 2.0\right) - \left(z \cdot y\right) \cdot \left(t \cdot 9.0\right)\\ \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}\;t \le -1.63797584648016 \cdot 10^{+90}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot b, 27.0, x \cdot 2.0\right) - \left(z \cdot y\right) \cdot \left(t \cdot 9.0\right)\\

\mathbf{elif}\;t \le 2.728698628306364 \cdot 10^{-128}:\\
\;\;\;\;\mathsf{fma}\left(a, 27.0 \cdot b, x \cdot 2.0 - \left(\left(t \cdot 9.0\right) \cdot y\right) \cdot z\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r31354637 = x;
        double r31354638 = 2.0;
        double r31354639 = r31354637 * r31354638;
        double r31354640 = y;
        double r31354641 = 9.0;
        double r31354642 = r31354640 * r31354641;
        double r31354643 = z;
        double r31354644 = r31354642 * r31354643;
        double r31354645 = t;
        double r31354646 = r31354644 * r31354645;
        double r31354647 = r31354639 - r31354646;
        double r31354648 = a;
        double r31354649 = 27.0;
        double r31354650 = r31354648 * r31354649;
        double r31354651 = b;
        double r31354652 = r31354650 * r31354651;
        double r31354653 = r31354647 + r31354652;
        return r31354653;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r31354654 = t;
        double r31354655 = -1.63797584648016e+90;
        bool r31354656 = r31354654 <= r31354655;
        double r31354657 = a;
        double r31354658 = b;
        double r31354659 = r31354657 * r31354658;
        double r31354660 = 27.0;
        double r31354661 = x;
        double r31354662 = 2.0;
        double r31354663 = r31354661 * r31354662;
        double r31354664 = fma(r31354659, r31354660, r31354663);
        double r31354665 = z;
        double r31354666 = y;
        double r31354667 = r31354665 * r31354666;
        double r31354668 = 9.0;
        double r31354669 = r31354654 * r31354668;
        double r31354670 = r31354667 * r31354669;
        double r31354671 = r31354664 - r31354670;
        double r31354672 = 2.728698628306364e-128;
        bool r31354673 = r31354654 <= r31354672;
        double r31354674 = r31354660 * r31354658;
        double r31354675 = r31354669 * r31354666;
        double r31354676 = r31354675 * r31354665;
        double r31354677 = r31354663 - r31354676;
        double r31354678 = fma(r31354657, r31354674, r31354677);
        double r31354679 = r31354673 ? r31354678 : r31354671;
        double r31354680 = r31354656 ? r31354671 : r31354679;
        return r31354680;
}

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

Target

Original3.7
Target2.5
Herbie1.0
\[\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 2 regimes
  2. if t < -1.63797584648016e+90 or 2.728698628306364e-128 < t

    1. Initial program 1.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(27.0 \cdot a, b, x \cdot 2.0\right) - z \cdot \left(\left(t \cdot y\right) \cdot 9.0\right)}\]
    3. Using strategy rm
    4. Applied associate-*l*7.0

      \[\leadsto \mathsf{fma}\left(27.0 \cdot a, b, x \cdot 2.0\right) - z \cdot \color{blue}{\left(t \cdot \left(y \cdot 9.0\right)\right)}\]
    5. Taylor expanded around inf 1.1

      \[\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)}\]
    6. Simplified7.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(b \cdot 27.0, a, 2.0 \cdot x\right) - z \cdot \left(y \cdot \left(9.0 \cdot t\right)\right)}\]
    7. Taylor expanded around 0 7.0

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

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

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

    if -1.63797584648016e+90 < t < 2.728698628306364e-128

    1. Initial program 5.8

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

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

      \[\leadsto \mathsf{fma}\left(27.0 \cdot a, b, x \cdot 2.0\right) - z \cdot \color{blue}{\left(t \cdot \left(y \cdot 9.0\right)\right)}\]
    5. Taylor expanded around inf 5.7

      \[\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)}\]
    6. Simplified0.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(b \cdot 27.0, a, 2.0 \cdot x\right) - z \cdot \left(y \cdot \left(9.0 \cdot t\right)\right)}\]
    7. Taylor expanded around inf 5.7

      \[\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)}\]
    8. Simplified0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.63797584648016 \cdot 10^{+90}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot b, 27.0, x \cdot 2.0\right) - \left(z \cdot y\right) \cdot \left(t \cdot 9.0\right)\\ \mathbf{elif}\;t \le 2.728698628306364 \cdot 10^{-128}:\\ \;\;\;\;\mathsf{fma}\left(a, 27.0 \cdot b, x \cdot 2.0 - \left(\left(t \cdot 9.0\right) \cdot y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot b, 27.0, x \cdot 2.0\right) - \left(z \cdot y\right) \cdot \left(t \cdot 9.0\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019165 +o rules:numerics
(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)))