Average Error: 20.3 → 4.9
Time: 5.7s
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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c} - 4 \cdot \left(\left(a \cdot t\right) \cdot \frac{1}{c}\right)\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 -5.1710270467639258 \cdot 10^{-300}:\\ \;\;\;\;\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{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 -0.0:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{z} \cdot \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{c}\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 7.02888390748903483 \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(9, \frac{x}{z \cdot \frac{c}{y}}, \frac{b}{z \cdot c} - 4 \cdot \frac{a \cdot t}{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} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c} - 4 \cdot \left(\left(a \cdot t\right) \cdot \frac{1}{c}\right)\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 -5.1710270467639258 \cdot 10^{-300}:\\
\;\;\;\;\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{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 -0.0:\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{z} \cdot \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{c}\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 7.02888390748903483 \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(9, \frac{x}{z \cdot \frac{c}{y}}, \frac{b}{z \cdot c} - 4 \cdot \frac{a \cdot t}{c}\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r736558 = x;
        double r736559 = 9.0;
        double r736560 = r736558 * r736559;
        double r736561 = y;
        double r736562 = r736560 * r736561;
        double r736563 = z;
        double r736564 = 4.0;
        double r736565 = r736563 * r736564;
        double r736566 = t;
        double r736567 = r736565 * r736566;
        double r736568 = a;
        double r736569 = r736567 * r736568;
        double r736570 = r736562 - r736569;
        double r736571 = b;
        double r736572 = r736570 + r736571;
        double r736573 = c;
        double r736574 = r736563 * r736573;
        double r736575 = r736572 / r736574;
        return r736575;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r736576 = x;
        double r736577 = 9.0;
        double r736578 = r736576 * r736577;
        double r736579 = y;
        double r736580 = r736578 * r736579;
        double r736581 = z;
        double r736582 = 4.0;
        double r736583 = r736581 * r736582;
        double r736584 = t;
        double r736585 = r736583 * r736584;
        double r736586 = a;
        double r736587 = r736585 * r736586;
        double r736588 = r736580 - r736587;
        double r736589 = b;
        double r736590 = r736588 + r736589;
        double r736591 = c;
        double r736592 = r736581 * r736591;
        double r736593 = r736590 / r736592;
        double r736594 = -inf.0;
        bool r736595 = r736593 <= r736594;
        double r736596 = r736592 / r736579;
        double r736597 = r736576 / r736596;
        double r736598 = r736589 / r736592;
        double r736599 = r736586 * r736584;
        double r736600 = 1.0;
        double r736601 = r736600 / r736591;
        double r736602 = r736599 * r736601;
        double r736603 = r736582 * r736602;
        double r736604 = r736598 - r736603;
        double r736605 = fma(r736577, r736597, r736604);
        double r736606 = -5.171027046763926e-300;
        bool r736607 = r736593 <= r736606;
        double r736608 = -0.0;
        bool r736609 = r736593 <= r736608;
        double r736610 = -r736582;
        double r736611 = r736584 * r736586;
        double r736612 = r736611 / r736591;
        double r736613 = r736577 * r736579;
        double r736614 = fma(r736576, r736613, r736589);
        double r736615 = cbrt(r736614);
        double r736616 = r736615 * r736615;
        double r736617 = r736616 / r736581;
        double r736618 = r736615 / r736591;
        double r736619 = r736617 * r736618;
        double r736620 = fma(r736610, r736612, r736619);
        double r736621 = 7.028883907489035e+303;
        bool r736622 = r736593 <= r736621;
        double r736623 = r736591 / r736579;
        double r736624 = r736581 * r736623;
        double r736625 = r736576 / r736624;
        double r736626 = r736599 / r736591;
        double r736627 = r736582 * r736626;
        double r736628 = r736598 - r736627;
        double r736629 = fma(r736577, r736625, r736628);
        double r736630 = r736622 ? r736593 : r736629;
        double r736631 = r736609 ? r736620 : r736630;
        double r736632 = r736607 ? r736593 : r736631;
        double r736633 = r736595 ? r736605 : r736632;
        return r736633;
}

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.3
Target14.4
Herbie4.9
\[\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 4 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -inf.0

    1. Initial program 64.0

      \[\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. Simplified29.2

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

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

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

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -5.171027046763926e-300 or -0.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 7.028883907489035e+303

    1. Initial program 0.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}\]

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

    1. Initial program 39.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. Simplified23.9

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

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

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

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

    1. Initial program 63.0

      \[\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. Simplified29.8

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

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

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

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

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

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

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

    \[\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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{b}{z \cdot c} - 4 \cdot \left(\left(a \cdot t\right) \cdot \frac{1}{c}\right)\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 -5.1710270467639258 \cdot 10^{-300}:\\ \;\;\;\;\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{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 -0.0:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{z} \cdot \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{c}\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 7.02888390748903483 \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(9, \frac{x}{z \cdot \frac{c}{y}}, \frac{b}{z \cdot c} - 4 \cdot \frac{a \cdot t}{c}\right)\\ \end{array}\]

Reproduce

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