Average Error: 21.0 → 3.3
Time: 55.5s
Precision: 64
\[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -1.2458730547416133 \cdot 10^{+293}:\\ \;\;\;\;\left(\frac{b}{c \cdot z} + \frac{x}{\frac{c \cdot z}{y}} \cdot 9.0\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -3.822718760911502 \cdot 10^{-179}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 2.893585920773858 \cdot 10^{+33}:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - 4.0 \cdot \left(t \cdot a\right)}}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 1.0275879372618488 \cdot 10^{+308}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) + \frac{b}{c \cdot z}\right) - 4.0 \cdot \left(\frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}\right)\\ \end{array}\]
\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\begin{array}{l}
\mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -1.2458730547416133 \cdot 10^{+293}:\\
\;\;\;\;\left(\frac{b}{c \cdot z} + \frac{x}{\frac{c \cdot z}{y}} \cdot 9.0\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -3.822718760911502 \cdot 10^{-179}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 2.893585920773858 \cdot 10^{+33}:\\
\;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - 4.0 \cdot \left(t \cdot a\right)}}\\

\mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 1.0275879372618488 \cdot 10^{+308}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\left(9.0 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) + \frac{b}{c \cdot z}\right) - 4.0 \cdot \left(\frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r30292300 = x;
        double r30292301 = 9.0;
        double r30292302 = r30292300 * r30292301;
        double r30292303 = y;
        double r30292304 = r30292302 * r30292303;
        double r30292305 = z;
        double r30292306 = 4.0;
        double r30292307 = r30292305 * r30292306;
        double r30292308 = t;
        double r30292309 = r30292307 * r30292308;
        double r30292310 = a;
        double r30292311 = r30292309 * r30292310;
        double r30292312 = r30292304 - r30292311;
        double r30292313 = b;
        double r30292314 = r30292312 + r30292313;
        double r30292315 = c;
        double r30292316 = r30292305 * r30292315;
        double r30292317 = r30292314 / r30292316;
        return r30292317;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r30292318 = x;
        double r30292319 = 9.0;
        double r30292320 = r30292318 * r30292319;
        double r30292321 = y;
        double r30292322 = r30292320 * r30292321;
        double r30292323 = z;
        double r30292324 = 4.0;
        double r30292325 = r30292323 * r30292324;
        double r30292326 = t;
        double r30292327 = r30292325 * r30292326;
        double r30292328 = a;
        double r30292329 = r30292327 * r30292328;
        double r30292330 = r30292322 - r30292329;
        double r30292331 = b;
        double r30292332 = r30292330 + r30292331;
        double r30292333 = c;
        double r30292334 = r30292333 * r30292323;
        double r30292335 = r30292332 / r30292334;
        double r30292336 = -1.2458730547416133e+293;
        bool r30292337 = r30292335 <= r30292336;
        double r30292338 = r30292331 / r30292334;
        double r30292339 = r30292334 / r30292321;
        double r30292340 = r30292318 / r30292339;
        double r30292341 = r30292340 * r30292319;
        double r30292342 = r30292338 + r30292341;
        double r30292343 = r30292328 / r30292333;
        double r30292344 = r30292326 * r30292343;
        double r30292345 = r30292324 * r30292344;
        double r30292346 = r30292342 - r30292345;
        double r30292347 = -3.822718760911502e-179;
        bool r30292348 = r30292335 <= r30292347;
        double r30292349 = 2.893585920773858e+33;
        bool r30292350 = r30292335 <= r30292349;
        double r30292351 = 1.0;
        double r30292352 = r30292321 * r30292319;
        double r30292353 = fma(r30292352, r30292318, r30292331);
        double r30292354 = r30292353 / r30292323;
        double r30292355 = r30292326 * r30292328;
        double r30292356 = r30292324 * r30292355;
        double r30292357 = r30292354 - r30292356;
        double r30292358 = r30292333 / r30292357;
        double r30292359 = r30292351 / r30292358;
        double r30292360 = 1.0275879372618488e+308;
        bool r30292361 = r30292335 <= r30292360;
        double r30292362 = r30292321 / r30292333;
        double r30292363 = r30292318 / r30292323;
        double r30292364 = r30292362 * r30292363;
        double r30292365 = r30292319 * r30292364;
        double r30292366 = r30292365 + r30292338;
        double r30292367 = cbrt(r30292333);
        double r30292368 = r30292367 * r30292367;
        double r30292369 = r30292326 / r30292368;
        double r30292370 = r30292328 / r30292367;
        double r30292371 = r30292369 * r30292370;
        double r30292372 = r30292324 * r30292371;
        double r30292373 = r30292366 - r30292372;
        double r30292374 = r30292361 ? r30292335 : r30292373;
        double r30292375 = r30292350 ? r30292359 : r30292374;
        double r30292376 = r30292348 ? r30292335 : r30292375;
        double r30292377 = r30292337 ? r30292346 : r30292376;
        return r30292377;
}

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

Original21.0
Target15.0
Herbie3.3
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -1.100156740804105 \cdot 10^{-171}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -0.0:\\ \;\;\;\;\frac{\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.1708877911747488 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 2.876823679546137 \cdot 10^{+130}:\\ \;\;\;\;\left(\left(9.0 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.3838515042456319 \cdot 10^{+158}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4.0 \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.2458730547416133e+293

    1. Initial program 57.6

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified26.0

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

      \[\leadsto \color{blue}{\left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{c}}\]
    4. Using strategy rm
    5. Applied associate-/l*15.4

      \[\leadsto \left(9.0 \cdot \color{blue}{\frac{x}{\frac{z \cdot c}{y}}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{c}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity15.4

      \[\leadsto \left(9.0 \cdot \frac{x}{\frac{z \cdot c}{y}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{\color{blue}{1 \cdot c}}\]
    8. Applied times-frac9.6

      \[\leadsto \left(9.0 \cdot \frac{x}{\frac{z \cdot c}{y}} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \color{blue}{\left(\frac{t}{1} \cdot \frac{a}{c}\right)}\]
    9. Simplified9.6

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

    if -1.2458730547416133e+293 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -3.822718760911502e-179 or 2.893585920773858e+33 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 1.0275879372618488e+308

    1. Initial program 0.7

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]

    if -3.822718760911502e-179 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 2.893585920773858e+33

    1. Initial program 17.4

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified0.9

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

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

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

    1. Initial program 64.0

      \[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
    2. Simplified28.8

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

      \[\leadsto \color{blue}{\left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{c}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt33.4

      \[\leadsto \left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \frac{t \cdot a}{\color{blue}{\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}}}\]
    6. Applied times-frac27.0

      \[\leadsto \left(9.0 \cdot \frac{x \cdot y}{z \cdot c} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \color{blue}{\left(\frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}\right)}\]
    7. Using strategy rm
    8. Applied times-frac9.8

      \[\leadsto \left(9.0 \cdot \color{blue}{\left(\frac{x}{z} \cdot \frac{y}{c}\right)} + \frac{b}{z \cdot c}\right) - 4.0 \cdot \left(\frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}\right)\]
  3. Recombined 4 regimes into one program.
  4. Final simplification3.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -1.2458730547416133 \cdot 10^{+293}:\\ \;\;\;\;\left(\frac{b}{c \cdot z} + \frac{x}{\frac{c \cdot z}{y}} \cdot 9.0\right) - 4.0 \cdot \left(t \cdot \frac{a}{c}\right)\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le -3.822718760911502 \cdot 10^{-179}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 2.893585920773858 \cdot 10^{+33}:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(y \cdot 9.0, x, b\right)}{z} - 4.0 \cdot \left(t \cdot a\right)}}\\ \mathbf{elif}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z} \le 1.0275879372618488 \cdot 10^{+308}:\\ \;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(9.0 \cdot \left(\frac{y}{c} \cdot \frac{x}{z}\right) + \frac{b}{c \cdot z}\right) - 4.0 \cdot \left(\frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}\right)\\ \end{array}\]

Reproduce

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

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

  (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))