Average Error: 19.9 → 5.2
Time: 19.4s
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.355593586848966217550676178447366828849 \cdot 10^{-244}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x \cdot y}{z \cdot c}, 9, \frac{\sqrt[3]{b} \cdot \sqrt[3]{b}}{\frac{z \cdot c}{\sqrt[3]{b}}}\right) - 4 \cdot \left(t \cdot \frac{a}{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.885128341702259182801358415930166931496 \cdot 10^{-153}:\\ \;\;\;\;\frac{\sqrt[3]{\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t} \cdot \sqrt[3]{\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t}}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\sqrt[3]{\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t}}{\sqrt[3]{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 1.893118102310617680117230001054255080538 \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}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z} \cdot \frac{y}{c}, 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 -1.355593586848966217550676178447366828849 \cdot 10^{-244}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x \cdot y}{z \cdot c}, 9, \frac{\sqrt[3]{b} \cdot \sqrt[3]{b}}{\frac{z \cdot c}{\sqrt[3]{b}}}\right) - 4 \cdot \left(t \cdot \frac{a}{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.885128341702259182801358415930166931496 \cdot 10^{-153}:\\
\;\;\;\;\frac{\sqrt[3]{\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t} \cdot \sqrt[3]{\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t}}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{\sqrt[3]{\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t}}{\sqrt[3]{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 1.893118102310617680117230001054255080538 \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}{z \cdot c}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z} \cdot \frac{y}{c}, 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 r432322 = x;
        double r432323 = 9.0;
        double r432324 = r432322 * r432323;
        double r432325 = y;
        double r432326 = r432324 * r432325;
        double r432327 = z;
        double r432328 = 4.0;
        double r432329 = r432327 * r432328;
        double r432330 = t;
        double r432331 = r432329 * r432330;
        double r432332 = a;
        double r432333 = r432331 * r432332;
        double r432334 = r432326 - r432333;
        double r432335 = b;
        double r432336 = r432334 + r432335;
        double r432337 = c;
        double r432338 = r432327 * r432337;
        double r432339 = r432336 / r432338;
        return r432339;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r432340 = x;
        double r432341 = 9.0;
        double r432342 = r432340 * r432341;
        double r432343 = y;
        double r432344 = r432342 * r432343;
        double r432345 = z;
        double r432346 = 4.0;
        double r432347 = r432345 * r432346;
        double r432348 = t;
        double r432349 = r432347 * r432348;
        double r432350 = a;
        double r432351 = r432349 * r432350;
        double r432352 = r432344 - r432351;
        double r432353 = b;
        double r432354 = r432352 + r432353;
        double r432355 = c;
        double r432356 = r432345 * r432355;
        double r432357 = r432354 / r432356;
        double r432358 = -1.3555935868489662e-244;
        bool r432359 = r432357 <= r432358;
        double r432360 = r432340 * r432343;
        double r432361 = r432360 / r432356;
        double r432362 = cbrt(r432353);
        double r432363 = r432362 * r432362;
        double r432364 = r432356 / r432362;
        double r432365 = r432363 / r432364;
        double r432366 = fma(r432361, r432341, r432365);
        double r432367 = r432350 / r432355;
        double r432368 = r432348 * r432367;
        double r432369 = r432346 * r432368;
        double r432370 = r432366 - r432369;
        double r432371 = 6.885128341702259e-153;
        bool r432372 = r432357 <= r432371;
        double r432373 = fma(r432343, r432342, r432353);
        double r432374 = r432373 / r432345;
        double r432375 = r432350 * r432346;
        double r432376 = r432375 * r432348;
        double r432377 = r432374 - r432376;
        double r432378 = cbrt(r432377);
        double r432379 = r432378 * r432378;
        double r432380 = cbrt(r432355);
        double r432381 = r432380 * r432380;
        double r432382 = r432379 / r432381;
        double r432383 = r432378 / r432380;
        double r432384 = r432382 * r432383;
        double r432385 = 1.8931181023106177e+306;
        bool r432386 = r432357 <= r432385;
        double r432387 = r432340 / r432345;
        double r432388 = r432343 / r432355;
        double r432389 = r432387 * r432388;
        double r432390 = r432353 / r432356;
        double r432391 = fma(r432389, r432341, r432390);
        double r432392 = r432391 - r432369;
        double r432393 = r432386 ? r432357 : r432392;
        double r432394 = r432372 ? r432384 : r432393;
        double r432395 = r432359 ? r432370 : r432394;
        return r432395;
}

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

Original19.9
Target13.8
Herbie5.2
\[\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 4 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -1.3555935868489662e-244

    1. Initial program 11.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. Simplified13.0

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

      \[\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. Simplified7.6

      \[\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 *-un-lft-identity7.6

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

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

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

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

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

    if -1.3555935868489662e-244 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 6.885128341702259e-153

    1. Initial program 27.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. Simplified0.9

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

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

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

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

    if 6.885128341702259e-153 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 1.8931181023106177e+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}\]

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

    1. Initial program 63.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}\]
    2. Simplified27.8

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t}{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 *-un-lft-identity30.3

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

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

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

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

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

Reproduce

herbie shell --seed 2019208 +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.1001567408041049e-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.17088779117474882e-53) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 2.8768236795461372e130) (- (+ (* (* 9 (/ y c)) (/ x z)) (/ b (* c z))) (* 4 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 1.3838515042456319e158) (/ (+ (- (* (* 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)))