Average Error: 20.9 → 7.5
Time: 6.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 1.2738200335784327 \cdot 10^{-213}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{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.9472373964360321 \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{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{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} \le 1.2738200335784327 \cdot 10^{-213}:\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{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.9472373964360321 \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{else}:\\
\;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{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 r661293 = x;
        double r661294 = 9.0;
        double r661295 = r661293 * r661294;
        double r661296 = y;
        double r661297 = r661295 * r661296;
        double r661298 = z;
        double r661299 = 4.0;
        double r661300 = r661298 * r661299;
        double r661301 = t;
        double r661302 = r661300 * r661301;
        double r661303 = a;
        double r661304 = r661302 * r661303;
        double r661305 = r661297 - r661304;
        double r661306 = b;
        double r661307 = r661305 + r661306;
        double r661308 = c;
        double r661309 = r661298 * r661308;
        double r661310 = r661307 / r661309;
        return r661310;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r661311 = x;
        double r661312 = 9.0;
        double r661313 = r661311 * r661312;
        double r661314 = y;
        double r661315 = r661313 * r661314;
        double r661316 = z;
        double r661317 = 4.0;
        double r661318 = r661316 * r661317;
        double r661319 = t;
        double r661320 = r661318 * r661319;
        double r661321 = a;
        double r661322 = r661320 * r661321;
        double r661323 = r661315 - r661322;
        double r661324 = b;
        double r661325 = r661323 + r661324;
        double r661326 = c;
        double r661327 = r661316 * r661326;
        double r661328 = r661325 / r661327;
        double r661329 = 1.2738200335784327e-213;
        bool r661330 = r661328 <= r661329;
        double r661331 = -r661317;
        double r661332 = r661319 * r661321;
        double r661333 = r661332 / r661326;
        double r661334 = r661312 * r661311;
        double r661335 = fma(r661334, r661314, r661324);
        double r661336 = cbrt(r661335);
        double r661337 = r661336 * r661336;
        double r661338 = cbrt(r661316);
        double r661339 = r661338 * r661338;
        double r661340 = r661337 / r661339;
        double r661341 = cbrt(r661326);
        double r661342 = r661341 * r661341;
        double r661343 = r661340 / r661342;
        double r661344 = r661336 / r661338;
        double r661345 = r661344 / r661341;
        double r661346 = r661343 * r661345;
        double r661347 = fma(r661331, r661333, r661346);
        double r661348 = 7.947237396436032e+300;
        bool r661349 = r661328 <= r661348;
        double r661350 = r661321 / r661326;
        double r661351 = r661319 * r661350;
        double r661352 = r661335 / r661316;
        double r661353 = r661352 / r661326;
        double r661354 = fma(r661331, r661351, r661353);
        double r661355 = r661349 ? r661328 : r661354;
        double r661356 = r661330 ? r661347 : r661355;
        return r661356;
}

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.9
Target14.2
Herbie7.5
\[\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)) < 1.2738200335784327e-213

    1. Initial program 17.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. Simplified10.7

      \[\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*9.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. Simplified9.9

      \[\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)\]
    6. Using strategy rm
    7. Applied add-cube-cbrt10.4

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

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

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

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

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

    if 1.2738200335784327e-213 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 7.947237396436032e+300

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

    1. Initial program 62.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. Simplified29.5

      \[\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*25.7

      \[\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. Simplified26.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)\]
    6. Using strategy rm
    7. Applied *-un-lft-identity26.0

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

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

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

    \[\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 1.2738200335784327 \cdot 10^{-213}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(9 \cdot x, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{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.9472373964360321 \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{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \end{array}\]

Reproduce

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