Average Error: 19.7 → 5.2
Time: 27.2s
Precision: 64
\[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} = -\infty:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, 9.0 \cdot \frac{y}{z}, \frac{b}{z} - a \cdot \left(4.0 \cdot t\right)\right)}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -2.3643960646068597 \cdot 10^{-183}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y \cdot 9.0, b\right)}{c \cdot z} - \frac{4.0 \cdot \left(t \cdot a\right)}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 3.006339460891949 \cdot 10^{-266}:\\ \;\;\;\;\frac{1}{c} \cdot \left(\frac{1}{z} \cdot \mathsf{fma}\left(x \cdot 9.0, y, b\right) - 4.0 \cdot \left(t \cdot a\right)\right)\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 5.262448632271994 \cdot 10^{+292}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, 9.0 \cdot \frac{y}{z}, \frac{b}{z} - a \cdot \left(4.0 \cdot t\right)\right)}{c}\\ \end{array}\]
\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\begin{array}{l}
\mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} = -\infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, 9.0 \cdot \frac{y}{z}, \frac{b}{z} - a \cdot \left(4.0 \cdot t\right)\right)}{c}\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -2.3643960646068597 \cdot 10^{-183}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y \cdot 9.0, b\right)}{c \cdot z} - \frac{4.0 \cdot \left(t \cdot a\right)}{c}\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 3.006339460891949 \cdot 10^{-266}:\\
\;\;\;\;\frac{1}{c} \cdot \left(\frac{1}{z} \cdot \mathsf{fma}\left(x \cdot 9.0, y, b\right) - 4.0 \cdot \left(t \cdot a\right)\right)\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 5.262448632271994 \cdot 10^{+292}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r30818407 = x;
        double r30818408 = 9.0;
        double r30818409 = r30818407 * r30818408;
        double r30818410 = y;
        double r30818411 = r30818409 * r30818410;
        double r30818412 = z;
        double r30818413 = 4.0;
        double r30818414 = r30818412 * r30818413;
        double r30818415 = t;
        double r30818416 = r30818414 * r30818415;
        double r30818417 = a;
        double r30818418 = r30818416 * r30818417;
        double r30818419 = r30818411 - r30818418;
        double r30818420 = b;
        double r30818421 = r30818419 + r30818420;
        double r30818422 = c;
        double r30818423 = r30818412 * r30818422;
        double r30818424 = r30818421 / r30818423;
        return r30818424;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r30818425 = x;
        double r30818426 = 9.0;
        double r30818427 = r30818425 * r30818426;
        double r30818428 = y;
        double r30818429 = r30818427 * r30818428;
        double r30818430 = z;
        double r30818431 = 4.0;
        double r30818432 = r30818430 * r30818431;
        double r30818433 = t;
        double r30818434 = r30818432 * r30818433;
        double r30818435 = a;
        double r30818436 = r30818434 * r30818435;
        double r30818437 = r30818429 - r30818436;
        double r30818438 = b;
        double r30818439 = r30818437 + r30818438;
        double r30818440 = c;
        double r30818441 = r30818440 * r30818430;
        double r30818442 = r30818439 / r30818441;
        double r30818443 = -inf.0;
        bool r30818444 = r30818442 <= r30818443;
        double r30818445 = r30818428 / r30818430;
        double r30818446 = r30818426 * r30818445;
        double r30818447 = r30818438 / r30818430;
        double r30818448 = r30818431 * r30818433;
        double r30818449 = r30818435 * r30818448;
        double r30818450 = r30818447 - r30818449;
        double r30818451 = fma(r30818425, r30818446, r30818450);
        double r30818452 = r30818451 / r30818440;
        double r30818453 = -2.3643960646068597e-183;
        bool r30818454 = r30818442 <= r30818453;
        double r30818455 = r30818428 * r30818426;
        double r30818456 = fma(r30818425, r30818455, r30818438);
        double r30818457 = r30818456 / r30818441;
        double r30818458 = r30818433 * r30818435;
        double r30818459 = r30818431 * r30818458;
        double r30818460 = r30818459 / r30818440;
        double r30818461 = r30818457 - r30818460;
        double r30818462 = 3.006339460891949e-266;
        bool r30818463 = r30818442 <= r30818462;
        double r30818464 = 1.0;
        double r30818465 = r30818464 / r30818440;
        double r30818466 = r30818464 / r30818430;
        double r30818467 = fma(r30818427, r30818428, r30818438);
        double r30818468 = r30818466 * r30818467;
        double r30818469 = r30818468 - r30818459;
        double r30818470 = r30818465 * r30818469;
        double r30818471 = 5.262448632271994e+292;
        bool r30818472 = r30818442 <= r30818471;
        double r30818473 = r30818472 ? r30818442 : r30818452;
        double r30818474 = r30818463 ? r30818470 : r30818473;
        double r30818475 = r30818454 ? r30818461 : r30818474;
        double r30818476 = r30818444 ? r30818452 : r30818475;
        return r30818476;
}

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

Bits error versus c

Target

Original19.7
Target13.8
Herbie5.2
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -1.100156740804105 \cdot 10^{-171}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -0.0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.1708877911747488 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 2.876823679546137 \cdot 10^{+130}:\\ \;\;\;\;\left(\left(9.0 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.3838515042456319 \cdot 10^{+158}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -inf.0 or 5.262448632271994e+292 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 58.5

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified24.7

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4.0}{c}}\]
    3. Using strategy rm
    4. Applied clear-num24.7

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{z}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    5. Using strategy rm
    6. Applied div-inv24.7

      \[\leadsto \frac{\frac{1}{\color{blue}{z \cdot \frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    7. Applied add-cube-cbrt24.7

      \[\leadsto \frac{\frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{z \cdot \frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    8. Applied times-frac24.7

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{z} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    9. Simplified24.7

      \[\leadsto \frac{\color{blue}{\frac{1}{z}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    10. Simplified24.7

      \[\leadsto \frac{\frac{1}{z} \cdot \color{blue}{\mathsf{fma}\left(9.0 \cdot x, y, b\right)} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    11. Taylor expanded around inf 24.5

      \[\leadsto \frac{\color{blue}{\left(9.0 \cdot \frac{x \cdot y}{z} + \frac{b}{z}\right) - 4.0 \cdot \left(t \cdot a\right)}}{c}\]
    12. Simplified15.5

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -2.3643960646068597e-183

    1. Initial program 0.8

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified9.4

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4.0}{c}}\]
    3. Using strategy rm
    4. Applied clear-num9.5

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{z}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    5. Using strategy rm
    6. Applied div-inv9.6

      \[\leadsto \frac{\frac{1}{\color{blue}{z \cdot \frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    7. Applied add-cube-cbrt9.6

      \[\leadsto \frac{\frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{z \cdot \frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    8. Applied times-frac9.5

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{z} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    9. Simplified9.5

      \[\leadsto \frac{\color{blue}{\frac{1}{z}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    10. Simplified9.4

      \[\leadsto \frac{\frac{1}{z} \cdot \color{blue}{\mathsf{fma}\left(9.0 \cdot x, y, b\right)} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    11. Using strategy rm
    12. Applied div-sub9.4

      \[\leadsto \color{blue}{\frac{\frac{1}{z} \cdot \mathsf{fma}\left(9.0 \cdot x, y, b\right)}{c} - \frac{\left(a \cdot t\right) \cdot 4.0}{c}}\]
    13. Simplified2.6

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

    if -2.3643960646068597e-183 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 3.006339460891949e-266

    1. Initial program 31.0

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified1.1

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4.0}{c}}\]
    3. Using strategy rm
    4. Applied clear-num1.1

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{z}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    5. Using strategy rm
    6. Applied div-inv1.1

      \[\leadsto \frac{\frac{1}{\color{blue}{z \cdot \frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    7. Applied add-cube-cbrt1.1

      \[\leadsto \frac{\frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{z \cdot \frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    8. Applied times-frac1.1

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{z} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    9. Simplified1.1

      \[\leadsto \frac{\color{blue}{\frac{1}{z}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    10. Simplified1.1

      \[\leadsto \frac{\frac{1}{z} \cdot \color{blue}{\mathsf{fma}\left(9.0 \cdot x, y, b\right)} - \left(a \cdot t\right) \cdot 4.0}{c}\]
    11. Using strategy rm
    12. Applied div-inv1.1

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

    if 3.006339460891949e-266 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 5.262448632271994e+292

    1. Initial program 0.7

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification5.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} = -\infty:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, 9.0 \cdot \frac{y}{z}, \frac{b}{z} - a \cdot \left(4.0 \cdot t\right)\right)}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -2.3643960646068597 \cdot 10^{-183}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y \cdot 9.0, b\right)}{c \cdot z} - \frac{4.0 \cdot \left(t \cdot a\right)}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 3.006339460891949 \cdot 10^{-266}:\\ \;\;\;\;\frac{1}{c} \cdot \left(\frac{1}{z} \cdot \mathsf{fma}\left(x \cdot 9.0, y, b\right) - 4.0 \cdot \left(t \cdot a\right)\right)\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 5.262448632271994 \cdot 10^{+292}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, 9.0 \cdot \frac{y}{z}, \frac{b}{z} - a \cdot \left(4.0 \cdot t\right)\right)}{c}\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (x y z t a b c)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, J"

  :herbie-target
  (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -1.100156740804105e-171) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -0.0) (/ (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.1708877911747488e-53) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 2.876823679546137e+130) (- (+ (* (* 9.0 (/ y c)) (/ x z)) (/ b (* c z))) (* 4.0 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.3838515042456319e+158) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (- (+ (* 9.0 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4.0 (/ (* a t) c))))))))

  (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))