Average Error: 20.3 → 7.1
Time: 6.2s
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(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{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 -6.88404519285831616 \cdot 10^{-192}:\\ \;\;\;\;\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{\frac{1}{z}}{\frac{c}{\mathsf{fma}\left(x, 9 \cdot y, b\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 2.33791557198394563 \cdot 10^{294}:\\ \;\;\;\;\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(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{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(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{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 -6.88404519285831616 \cdot 10^{-192}:\\
\;\;\;\;\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{\frac{1}{z}}{\frac{c}{\mathsf{fma}\left(x, 9 \cdot y, b\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 2.33791557198394563 \cdot 10^{294}:\\
\;\;\;\;\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(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r711085 = x;
        double r711086 = 9.0;
        double r711087 = r711085 * r711086;
        double r711088 = y;
        double r711089 = r711087 * r711088;
        double r711090 = z;
        double r711091 = 4.0;
        double r711092 = r711090 * r711091;
        double r711093 = t;
        double r711094 = r711092 * r711093;
        double r711095 = a;
        double r711096 = r711094 * r711095;
        double r711097 = r711089 - r711096;
        double r711098 = b;
        double r711099 = r711097 + r711098;
        double r711100 = c;
        double r711101 = r711090 * r711100;
        double r711102 = r711099 / r711101;
        return r711102;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r711103 = x;
        double r711104 = 9.0;
        double r711105 = r711103 * r711104;
        double r711106 = y;
        double r711107 = r711105 * r711106;
        double r711108 = z;
        double r711109 = 4.0;
        double r711110 = r711108 * r711109;
        double r711111 = t;
        double r711112 = r711110 * r711111;
        double r711113 = a;
        double r711114 = r711112 * r711113;
        double r711115 = r711107 - r711114;
        double r711116 = b;
        double r711117 = r711115 + r711116;
        double r711118 = c;
        double r711119 = r711108 * r711118;
        double r711120 = r711117 / r711119;
        double r711121 = -inf.0;
        bool r711122 = r711120 <= r711121;
        double r711123 = -r711109;
        double r711124 = r711111 * r711113;
        double r711125 = r711124 / r711118;
        double r711126 = r711104 * r711103;
        double r711127 = fma(r711126, r711106, r711116);
        double r711128 = r711127 / r711108;
        double r711129 = r711128 / r711118;
        double r711130 = fma(r711123, r711125, r711129);
        double r711131 = -6.884045192858316e-192;
        bool r711132 = r711120 <= r711131;
        double r711133 = -0.0;
        bool r711134 = r711120 <= r711133;
        double r711135 = 1.0;
        double r711136 = r711135 / r711108;
        double r711137 = r711104 * r711106;
        double r711138 = fma(r711103, r711137, r711116);
        double r711139 = r711118 / r711138;
        double r711140 = r711136 / r711139;
        double r711141 = fma(r711123, r711125, r711140);
        double r711142 = 2.3379155719839456e+294;
        bool r711143 = r711120 <= r711142;
        double r711144 = r711143 ? r711120 : r711130;
        double r711145 = r711134 ? r711141 : r711144;
        double r711146 = r711132 ? r711120 : r711145;
        double r711147 = r711122 ? r711130 : r711146;
        return r711147;
}

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.7
Herbie7.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 3 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -inf.0 or 2.3379155719839456e+294 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 62.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. Simplified28.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 associate-/r*24.9

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -6.884045192858316e-192 or -0.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 2.3379155719839456e+294

    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 -6.884045192858316e-192 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -0.0

    1. Initial program 34.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. Simplified21.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. Using strategy rm
    4. Applied clear-num21.3

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

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

      \[\leadsto \mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{1}{\color{blue}{\frac{z}{1} \cdot \frac{c}{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}}\right)\]
    8. Applied associate-/r*2.3

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

      \[\leadsto \mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\color{blue}{\frac{1}{z}}}{\frac{c}{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{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 -6.88404519285831616 \cdot 10^{-192}:\\ \;\;\;\;\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{\frac{1}{z}}{\frac{c}{\mathsf{fma}\left(x, 9 \cdot y, b\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 2.33791557198394563 \cdot 10^{294}:\\ \;\;\;\;\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(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \end{array}\]

Reproduce

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