Average Error: 20.5 → 6.0
Time: 43.3s
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{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le -2.28298144243635429750975635929884797855 \cdot 10^{112}:\\ \;\;\;\;\left(\frac{1}{\frac{c \cdot z}{b}} + 9 \cdot \frac{x}{\frac{c \cdot z}{y}}\right) - \left(\frac{a}{c} \cdot t\right) \cdot 4\\ \mathbf{elif}\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le 4.09973230378698016031405356379068580905 \cdot 10^{-73}:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z} - \left(a \cdot 4\right) \cdot t}}\\ \mathbf{elif}\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le 1.676513492778132650506503414162823386727 \cdot 10^{303}:\\ \;\;\;\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{\frac{c \cdot z}{b}} + 9 \cdot \frac{x}{\frac{c \cdot z}{y}}\right) - \left(\frac{a}{c} \cdot t\right) \cdot 4\\ \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{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le -2.28298144243635429750975635929884797855 \cdot 10^{112}:\\
\;\;\;\;\left(\frac{1}{\frac{c \cdot z}{b}} + 9 \cdot \frac{x}{\frac{c \cdot z}{y}}\right) - \left(\frac{a}{c} \cdot t\right) \cdot 4\\

\mathbf{elif}\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le 4.09973230378698016031405356379068580905 \cdot 10^{-73}:\\
\;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z} - \left(a \cdot 4\right) \cdot t}}\\

\mathbf{elif}\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le 1.676513492778132650506503414162823386727 \cdot 10^{303}:\\
\;\;\;\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{\frac{c \cdot z}{b}} + 9 \cdot \frac{x}{\frac{c \cdot z}{y}}\right) - \left(\frac{a}{c} \cdot t\right) \cdot 4\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r34476366 = x;
        double r34476367 = 9.0;
        double r34476368 = r34476366 * r34476367;
        double r34476369 = y;
        double r34476370 = r34476368 * r34476369;
        double r34476371 = z;
        double r34476372 = 4.0;
        double r34476373 = r34476371 * r34476372;
        double r34476374 = t;
        double r34476375 = r34476373 * r34476374;
        double r34476376 = a;
        double r34476377 = r34476375 * r34476376;
        double r34476378 = r34476370 - r34476377;
        double r34476379 = b;
        double r34476380 = r34476378 + r34476379;
        double r34476381 = c;
        double r34476382 = r34476371 * r34476381;
        double r34476383 = r34476380 / r34476382;
        return r34476383;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r34476384 = b;
        double r34476385 = 9.0;
        double r34476386 = x;
        double r34476387 = r34476385 * r34476386;
        double r34476388 = y;
        double r34476389 = r34476387 * r34476388;
        double r34476390 = t;
        double r34476391 = z;
        double r34476392 = 4.0;
        double r34476393 = r34476391 * r34476392;
        double r34476394 = r34476390 * r34476393;
        double r34476395 = a;
        double r34476396 = r34476394 * r34476395;
        double r34476397 = r34476389 - r34476396;
        double r34476398 = r34476384 + r34476397;
        double r34476399 = c;
        double r34476400 = r34476399 * r34476391;
        double r34476401 = r34476398 / r34476400;
        double r34476402 = -2.2829814424363543e+112;
        bool r34476403 = r34476401 <= r34476402;
        double r34476404 = 1.0;
        double r34476405 = r34476400 / r34476384;
        double r34476406 = r34476404 / r34476405;
        double r34476407 = r34476400 / r34476388;
        double r34476408 = r34476386 / r34476407;
        double r34476409 = r34476385 * r34476408;
        double r34476410 = r34476406 + r34476409;
        double r34476411 = r34476395 / r34476399;
        double r34476412 = r34476411 * r34476390;
        double r34476413 = r34476412 * r34476392;
        double r34476414 = r34476410 - r34476413;
        double r34476415 = 4.09973230378698e-73;
        bool r34476416 = r34476401 <= r34476415;
        double r34476417 = fma(r34476387, r34476388, r34476384);
        double r34476418 = r34476417 / r34476391;
        double r34476419 = r34476395 * r34476392;
        double r34476420 = r34476419 * r34476390;
        double r34476421 = r34476418 - r34476420;
        double r34476422 = r34476399 / r34476421;
        double r34476423 = r34476404 / r34476422;
        double r34476424 = 1.6765134927781327e+303;
        bool r34476425 = r34476401 <= r34476424;
        double r34476426 = r34476425 ? r34476401 : r34476414;
        double r34476427 = r34476416 ? r34476423 : r34476426;
        double r34476428 = r34476403 ? r34476414 : r34476427;
        return r34476428;
}

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.5
Target14.2
Herbie6.0
\[\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 3 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -2.2829814424363543e+112 or 1.6765134927781327e+303 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 41.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.3

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

      \[\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. Using strategy rm
    5. Applied associate-/l*15.7

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

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

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

      \[\leadsto \left(\frac{b}{z \cdot c} + 9 \cdot \frac{x}{\frac{z \cdot c}{y}}\right) - 4 \cdot \left(\color{blue}{t} \cdot \frac{a}{c}\right)\]
    10. Using strategy rm
    11. Applied clear-num12.2

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

    if -2.2829814424363543e+112 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 4.09973230378698e-73

    1. Initial program 12.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. Simplified2.3

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

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

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

    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}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification6.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le -2.28298144243635429750975635929884797855 \cdot 10^{112}:\\ \;\;\;\;\left(\frac{1}{\frac{c \cdot z}{b}} + 9 \cdot \frac{x}{\frac{c \cdot z}{y}}\right) - \left(\frac{a}{c} \cdot t\right) \cdot 4\\ \mathbf{elif}\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le 4.09973230378698016031405356379068580905 \cdot 10^{-73}:\\ \;\;\;\;\frac{1}{\frac{c}{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z} - \left(a \cdot 4\right) \cdot t}}\\ \mathbf{elif}\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z} \le 1.676513492778132650506503414162823386727 \cdot 10^{303}:\\ \;\;\;\;\frac{b + \left(\left(9 \cdot x\right) \cdot y - \left(t \cdot \left(z \cdot 4\right)\right) \cdot a\right)}{c \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{\frac{c \cdot z}{b}} + 9 \cdot \frac{x}{\frac{c \cdot z}{y}}\right) - \left(\frac{a}{c} \cdot t\right) \cdot 4\\ \end{array}\]

Reproduce

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