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

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2.0 - \left(\left(t \cdot z\right) \cdot y\right) \cdot 9.0\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 r30459200 = x;
        double r30459201 = 2.0;
        double r30459202 = r30459200 * r30459201;
        double r30459203 = y;
        double r30459204 = 9.0;
        double r30459205 = r30459203 * r30459204;
        double r30459206 = z;
        double r30459207 = r30459205 * r30459206;
        double r30459208 = t;
        double r30459209 = r30459207 * r30459208;
        double r30459210 = r30459202 - r30459209;
        double r30459211 = a;
        double r30459212 = 27.0;
        double r30459213 = r30459211 * r30459212;
        double r30459214 = b;
        double r30459215 = r30459213 * r30459214;
        double r30459216 = r30459210 + r30459215;
        return r30459216;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r30459217 = y;
        double r30459218 = 9.0;
        double r30459219 = r30459217 * r30459218;
        double r30459220 = z;
        double r30459221 = r30459219 * r30459220;
        double r30459222 = -inf.0;
        bool r30459223 = r30459221 <= r30459222;
        double r30459224 = 27.0;
        double r30459225 = a;
        double r30459226 = r30459224 * r30459225;
        double r30459227 = b;
        double r30459228 = x;
        double r30459229 = 2.0;
        double r30459230 = r30459228 * r30459229;
        double r30459231 = fma(r30459226, r30459227, r30459230);
        double r30459232 = t;
        double r30459233 = r30459232 * r30459217;
        double r30459234 = r30459233 * r30459218;
        double r30459235 = r30459220 * r30459234;
        double r30459236 = r30459231 - r30459235;
        double r30459237 = 1.2701086409972831e+256;
        bool r30459238 = r30459221 <= r30459237;
        double r30459239 = r30459220 * r30459217;
        double r30459240 = r30459232 * r30459218;
        double r30459241 = r30459239 * r30459240;
        double r30459242 = r30459230 - r30459241;
        double r30459243 = r30459224 * r30459227;
        double r30459244 = r30459243 * r30459225;
        double r30459245 = r30459242 + r30459244;
        double r30459246 = r30459232 * r30459220;
        double r30459247 = r30459246 * r30459217;
        double r30459248 = r30459247 * r30459218;
        double r30459249 = r30459230 - r30459248;
        double r30459250 = r30459249 + r30459244;
        double r30459251 = r30459238 ? r30459245 : r30459250;
        double r30459252 = r30459223 ? r30459236 : r30459251;
        return r30459252;
}

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.5
Target2.5
Herbie0.4
\[\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. Simplified0.6

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

    if -inf.0 < (* (* y 9.0) z) < 1.2701086409972831e+256

    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. Taylor expanded around 0 0.4

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

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

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

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

    if 1.2701086409972831e+256 < (* (* y 9.0) z)

    1. Initial program 37.0

      \[\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. Taylor expanded around 0 36.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9.0\right) \cdot z = -\infty:\\ \;\;\;\;\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)\\ \mathbf{elif}\;\left(y \cdot 9.0\right) \cdot z \le 1.2701086409972831 \cdot 10^{+256}:\\ \;\;\;\;\left(x \cdot 2.0 - \left(z \cdot y\right) \cdot \left(t \cdot 9.0\right)\right) + \left(27.0 \cdot b\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2.0 - \left(\left(t \cdot z\right) \cdot y\right) \cdot 9.0\right) + \left(27.0 \cdot b\right) \cdot a\\ \end{array}\]

Reproduce

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