Average Error: 20.2 → 6.8
Time: 27.3s
Precision: 64
\[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -1.374803283974334360156558763689253638838 \cdot 10^{90}:\\ \;\;\;\;\left(\frac{b}{c \cdot z} + \frac{y \cdot x}{c \cdot z} \cdot 9\right) - 4 \cdot \frac{t \cdot a}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 0.0:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{\frac{z}{y}}, 9, \frac{b}{z}\right) - \left(t \cdot a\right) \cdot 4}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 2.620700023232696087217511908822360317664 \cdot 10^{306}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{\frac{z}{y}}, 9, \frac{b}{z}\right) - \left(t \cdot a\right) \cdot 4}{c}\\ \end{array}\]
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\begin{array}{l}
\mathbf{if}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -1.374803283974334360156558763689253638838 \cdot 10^{90}:\\
\;\;\;\;\left(\frac{b}{c \cdot z} + \frac{y \cdot x}{c \cdot z} \cdot 9\right) - 4 \cdot \frac{t \cdot a}{c}\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 0.0:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{\frac{z}{y}}, 9, \frac{b}{z}\right) - \left(t \cdot a\right) \cdot 4}{c}\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 2.620700023232696087217511908822360317664 \cdot 10^{306}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r30333530 = x;
        double r30333531 = 9.0;
        double r30333532 = r30333530 * r30333531;
        double r30333533 = y;
        double r30333534 = r30333532 * r30333533;
        double r30333535 = z;
        double r30333536 = 4.0;
        double r30333537 = r30333535 * r30333536;
        double r30333538 = t;
        double r30333539 = r30333537 * r30333538;
        double r30333540 = a;
        double r30333541 = r30333539 * r30333540;
        double r30333542 = r30333534 - r30333541;
        double r30333543 = b;
        double r30333544 = r30333542 + r30333543;
        double r30333545 = c;
        double r30333546 = r30333535 * r30333545;
        double r30333547 = r30333544 / r30333546;
        return r30333547;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r30333548 = x;
        double r30333549 = 9.0;
        double r30333550 = r30333548 * r30333549;
        double r30333551 = y;
        double r30333552 = r30333550 * r30333551;
        double r30333553 = z;
        double r30333554 = 4.0;
        double r30333555 = r30333553 * r30333554;
        double r30333556 = t;
        double r30333557 = r30333555 * r30333556;
        double r30333558 = a;
        double r30333559 = r30333557 * r30333558;
        double r30333560 = r30333552 - r30333559;
        double r30333561 = b;
        double r30333562 = r30333560 + r30333561;
        double r30333563 = c;
        double r30333564 = r30333563 * r30333553;
        double r30333565 = r30333562 / r30333564;
        double r30333566 = -1.3748032839743344e+90;
        bool r30333567 = r30333565 <= r30333566;
        double r30333568 = r30333561 / r30333564;
        double r30333569 = r30333551 * r30333548;
        double r30333570 = r30333569 / r30333564;
        double r30333571 = r30333570 * r30333549;
        double r30333572 = r30333568 + r30333571;
        double r30333573 = r30333556 * r30333558;
        double r30333574 = r30333573 / r30333563;
        double r30333575 = r30333554 * r30333574;
        double r30333576 = r30333572 - r30333575;
        double r30333577 = 0.0;
        bool r30333578 = r30333565 <= r30333577;
        double r30333579 = r30333553 / r30333551;
        double r30333580 = r30333548 / r30333579;
        double r30333581 = r30333561 / r30333553;
        double r30333582 = fma(r30333580, r30333549, r30333581);
        double r30333583 = r30333573 * r30333554;
        double r30333584 = r30333582 - r30333583;
        double r30333585 = r30333584 / r30333563;
        double r30333586 = 2.620700023232696e+306;
        bool r30333587 = r30333565 <= r30333586;
        double r30333588 = r30333587 ? r30333565 : r30333585;
        double r30333589 = r30333578 ? r30333585 : r30333588;
        double r30333590 = r30333567 ? r30333576 : r30333589;
        return r30333590;
}

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

Original20.2
Target14.2
Herbie6.8
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -1.100156740804104887233830094663413900721 \cdot 10^{-171}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -0.0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.170887791174748819600820354912645756062 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 2.876823679546137226963937101710277849382 \cdot 10^{130}:\\ \;\;\;\;\left(\left(9 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.383851504245631860711731716196098366993 \cdot 10^{158}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(9 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4 \cdot \frac{a \cdot t}{c}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -1.3748032839743344e+90

    1. Initial program 20.1

      \[\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified18.1

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4}{c}}\]
    3. Taylor expanded around 0 11.2

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

    if -1.3748032839743344e+90 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 0.0 or 2.620700023232696e+306 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 34.8

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

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

      \[\leadsto \color{blue}{\left(\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - \left(a \cdot t\right) \cdot 4\right) \cdot \frac{1}{c}}\]
    5. Taylor expanded around 0 12.2

      \[\leadsto \left(\color{blue}{\left(9 \cdot \frac{x \cdot y}{z} + \frac{b}{z}\right)} - \left(a \cdot t\right) \cdot 4\right) \cdot \frac{1}{c}\]
    6. Simplified9.1

      \[\leadsto \left(\color{blue}{\mathsf{fma}\left(\frac{x}{\frac{z}{y}}, 9, \frac{b}{z}\right)} - \left(a \cdot t\right) \cdot 4\right) \cdot \frac{1}{c}\]
    7. Using strategy rm
    8. Applied un-div-inv9.0

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

    if 0.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 2.620700023232696e+306

    1. Initial program 0.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -1.374803283974334360156558763689253638838 \cdot 10^{90}:\\ \;\;\;\;\left(\frac{b}{c \cdot z} + \frac{y \cdot x}{c \cdot z} \cdot 9\right) - 4 \cdot \frac{t \cdot a}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 0.0:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{\frac{z}{y}}, 9, \frac{b}{z}\right) - \left(t \cdot a\right) \cdot 4}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 2.620700023232696087217511908822360317664 \cdot 10^{306}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{\frac{z}{y}}, 9, \frac{b}{z}\right) - \left(t \cdot a\right) \cdot 4}{c}\\ \end{array}\]

Reproduce

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