Average Error: 20.4 → 5.1
Time: 12.5s
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}{z \cdot c} \le -6.79788688002701001 \cdot 10^{270}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{1}{z} \cdot \frac{b}{c}\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}{z \cdot c} \le -2.07074883831385532 \cdot 10^{-229}:\\ \;\;\;\;\left(9 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\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}{z \cdot c} \le 448174337903075008:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - a \cdot \left(4 \cdot t\right)}}\\ \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} \le 1.3732890460674824 \cdot 10^{303}:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\ \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}{z \cdot c} \le -6.79788688002701001 \cdot 10^{270}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{1}{z} \cdot \frac{b}{c}\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}{z \cdot c} \le -2.07074883831385532 \cdot 10^{-229}:\\
\;\;\;\;\left(9 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\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}{z \cdot c} \le 448174337903075008:\\
\;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - a \cdot \left(4 \cdot t\right)}}\\

\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} \le 1.3732890460674824 \cdot 10^{303}:\\
\;\;\;\;\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}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r787541 = x;
        double r787542 = 9.0;
        double r787543 = r787541 * r787542;
        double r787544 = y;
        double r787545 = r787543 * r787544;
        double r787546 = z;
        double r787547 = 4.0;
        double r787548 = r787546 * r787547;
        double r787549 = t;
        double r787550 = r787548 * r787549;
        double r787551 = a;
        double r787552 = r787550 * r787551;
        double r787553 = r787545 - r787552;
        double r787554 = b;
        double r787555 = r787553 + r787554;
        double r787556 = c;
        double r787557 = r787546 * r787556;
        double r787558 = r787555 / r787557;
        return r787558;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r787559 = x;
        double r787560 = 9.0;
        double r787561 = r787559 * r787560;
        double r787562 = y;
        double r787563 = r787561 * r787562;
        double r787564 = z;
        double r787565 = 4.0;
        double r787566 = r787564 * r787565;
        double r787567 = t;
        double r787568 = r787566 * r787567;
        double r787569 = a;
        double r787570 = r787568 * r787569;
        double r787571 = r787563 - r787570;
        double r787572 = b;
        double r787573 = r787571 + r787572;
        double r787574 = c;
        double r787575 = r787564 * r787574;
        double r787576 = r787573 / r787575;
        double r787577 = -6.79788688002701e+270;
        bool r787578 = r787576 <= r787577;
        double r787579 = r787564 / r787562;
        double r787580 = r787574 * r787579;
        double r787581 = r787559 / r787580;
        double r787582 = 1.0;
        double r787583 = r787582 / r787564;
        double r787584 = r787572 / r787574;
        double r787585 = r787583 * r787584;
        double r787586 = fma(r787581, r787560, r787585);
        double r787587 = r787567 * r787569;
        double r787588 = r787587 / r787574;
        double r787589 = r787565 * r787588;
        double r787590 = r787586 - r787589;
        double r787591 = -2.0707488383138553e-229;
        bool r787592 = r787576 <= r787591;
        double r787593 = r787559 * r787562;
        double r787594 = r787593 / r787575;
        double r787595 = r787560 * r787594;
        double r787596 = r787572 / r787575;
        double r787597 = r787595 + r787596;
        double r787598 = r787597 - r787589;
        double r787599 = 4.48174337903075e+17;
        bool r787600 = r787576 <= r787599;
        double r787601 = r787560 * r787562;
        double r787602 = fma(r787559, r787601, r787572);
        double r787603 = r787602 / r787564;
        double r787604 = r787565 * r787567;
        double r787605 = r787569 * r787604;
        double r787606 = r787603 - r787605;
        double r787607 = r787574 / r787606;
        double r787608 = r787582 / r787607;
        double r787609 = 1.3732890460674824e+303;
        bool r787610 = r787576 <= r787609;
        double r787611 = fma(r787581, r787560, r787596);
        double r787612 = r787569 / r787574;
        double r787613 = r787567 * r787612;
        double r787614 = r787565 * r787613;
        double r787615 = r787611 - r787614;
        double r787616 = r787610 ? r787576 : r787615;
        double r787617 = r787600 ? r787608 : r787616;
        double r787618 = r787592 ? r787598 : r787617;
        double r787619 = r787578 ? r787590 : r787618;
        return r787619;
}

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.4
Target14.5
Herbie5.1
\[\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.10015674080410512 \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.17088779117474882 \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.8768236795461372 \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.3838515042456319 \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 5 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -6.79788688002701e+270

    1. Initial program 48.7

      \[\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. Simplified25.4

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x \cdot y}{z \cdot c}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}}\]
    5. Using strategy rm
    6. Applied associate-/l*15.0

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

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

      \[\leadsto \mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{\color{blue}{1 \cdot b}}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\]
    10. Applied times-frac20.8

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

    if -6.79788688002701e+270 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -2.0707488383138553e-229

    1. Initial program 0.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. Simplified9.2

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

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

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

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

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

    if -2.0707488383138553e-229 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 4.48174337903075e+17

    1. Initial program 18.4

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

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

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

    if 4.48174337903075e+17 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 1.3732890460674824e+303

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

    if 1.3732890460674824e+303 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 62.9

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x \cdot y}{z \cdot c}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}}\]
    5. Using strategy rm
    6. Applied associate-/l*22.2

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

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

      \[\leadsto \mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{\color{blue}{1 \cdot c}}\]
    10. Applied times-frac10.6

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

      \[\leadsto \mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(\color{blue}{t} \cdot \frac{a}{c}\right)\]
  3. Recombined 5 regimes into one program.
  4. Final simplification5.1

    \[\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}{z \cdot c} \le -6.79788688002701001 \cdot 10^{270}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{1}{z} \cdot \frac{b}{c}\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}{z \cdot c} \le -2.07074883831385532 \cdot 10^{-229}:\\ \;\;\;\;\left(9 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\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}{z \cdot c} \le 448174337903075008:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - a \cdot \left(4 \cdot t\right)}}\\ \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} \le 1.3732890460674824 \cdot 10^{303}:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{c \cdot \frac{z}{y}}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \left(t \cdot \frac{a}{c}\right)\\ \end{array}\]

Reproduce

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

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

  (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)))