Average Error: 3.7 → 0.8
Time: 18.4s
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}\;t \le -8.1134783959941927 \cdot 10^{-26}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{elif}\;t \le 1.18144855083657069 \cdot 10^{54}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, x, \sqrt{27} \cdot \left(\sqrt{27} \cdot \left(a \cdot b\right)\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\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}\;t \le -8.1134783959941927 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r533484 = x;
        double r533485 = 2.0;
        double r533486 = r533484 * r533485;
        double r533487 = y;
        double r533488 = 9.0;
        double r533489 = r533487 * r533488;
        double r533490 = z;
        double r533491 = r533489 * r533490;
        double r533492 = t;
        double r533493 = r533491 * r533492;
        double r533494 = r533486 - r533493;
        double r533495 = a;
        double r533496 = 27.0;
        double r533497 = r533495 * r533496;
        double r533498 = b;
        double r533499 = r533497 * r533498;
        double r533500 = r533494 + r533499;
        return r533500;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r533501 = t;
        double r533502 = -8.113478395994193e-26;
        bool r533503 = r533501 <= r533502;
        double r533504 = 2.0;
        double r533505 = x;
        double r533506 = 27.0;
        double r533507 = a;
        double r533508 = b;
        double r533509 = r533507 * r533508;
        double r533510 = r533506 * r533509;
        double r533511 = fma(r533504, r533505, r533510);
        double r533512 = 9.0;
        double r533513 = cbrt(r533512);
        double r533514 = r533513 * r533513;
        double r533515 = z;
        double r533516 = y;
        double r533517 = r533515 * r533516;
        double r533518 = r533501 * r533517;
        double r533519 = r533513 * r533518;
        double r533520 = r533514 * r533519;
        double r533521 = r533511 - r533520;
        double r533522 = 1.1814485508365707e+54;
        bool r533523 = r533501 <= r533522;
        double r533524 = r533505 * r533504;
        double r533525 = r533501 * r533515;
        double r533526 = r533525 * r533516;
        double r533527 = r533512 * r533526;
        double r533528 = r533524 - r533527;
        double r533529 = r533506 * r533508;
        double r533530 = r533507 * r533529;
        double r533531 = r533528 + r533530;
        double r533532 = sqrt(r533506);
        double r533533 = r533532 * r533509;
        double r533534 = r533532 * r533533;
        double r533535 = fma(r533504, r533505, r533534);
        double r533536 = r533512 * r533518;
        double r533537 = r533535 - r533536;
        double r533538 = r533523 ? r533531 : r533537;
        double r533539 = r533503 ? r533521 : r533538;
        return r533539;
}

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.7
Herbie0.8
\[\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 t < -8.113478395994193e-26

    1. Initial program 0.7

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

      \[\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. 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) + a \cdot \left(27 \cdot b\right)\]
    5. Taylor expanded around inf 0.6

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt0.6

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) - \color{blue}{\left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \sqrt[3]{9}\right)} \cdot \left(t \cdot \left(z \cdot y\right)\right)\]
    9. Applied associate-*l*0.6

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) - \color{blue}{\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)}\]

    if -8.113478395994193e-26 < t < 1.1814485508365707e+54

    1. Initial program 5.7

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

      \[\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. Taylor expanded around inf 5.6

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

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

    if 1.1814485508365707e+54 < t

    1. Initial program 0.9

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

      \[\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. Taylor expanded around inf 0.9

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt0.8

      \[\leadsto \mathsf{fma}\left(2, x, \color{blue}{\left(\sqrt{27} \cdot \sqrt{27}\right)} \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\]
    9. Applied associate-*l*0.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -8.1134783959941927 \cdot 10^{-26}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{elif}\;t \le 1.18144855083657069 \cdot 10^{54}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, x, \sqrt{27} \cdot \left(\sqrt{27} \cdot \left(a \cdot b\right)\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019198 +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)))