Average Error: 20.5 → 6.0
Time: 42.7s
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 r26904274 = x;
        double r26904275 = 9.0;
        double r26904276 = r26904274 * r26904275;
        double r26904277 = y;
        double r26904278 = r26904276 * r26904277;
        double r26904279 = z;
        double r26904280 = 4.0;
        double r26904281 = r26904279 * r26904280;
        double r26904282 = t;
        double r26904283 = r26904281 * r26904282;
        double r26904284 = a;
        double r26904285 = r26904283 * r26904284;
        double r26904286 = r26904278 - r26904285;
        double r26904287 = b;
        double r26904288 = r26904286 + r26904287;
        double r26904289 = c;
        double r26904290 = r26904279 * r26904289;
        double r26904291 = r26904288 / r26904290;
        return r26904291;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r26904292 = b;
        double r26904293 = 9.0;
        double r26904294 = x;
        double r26904295 = r26904293 * r26904294;
        double r26904296 = y;
        double r26904297 = r26904295 * r26904296;
        double r26904298 = t;
        double r26904299 = z;
        double r26904300 = 4.0;
        double r26904301 = r26904299 * r26904300;
        double r26904302 = r26904298 * r26904301;
        double r26904303 = a;
        double r26904304 = r26904302 * r26904303;
        double r26904305 = r26904297 - r26904304;
        double r26904306 = r26904292 + r26904305;
        double r26904307 = c;
        double r26904308 = r26904307 * r26904299;
        double r26904309 = r26904306 / r26904308;
        double r26904310 = -2.2829814424363543e+112;
        bool r26904311 = r26904309 <= r26904310;
        double r26904312 = 1.0;
        double r26904313 = r26904308 / r26904292;
        double r26904314 = r26904312 / r26904313;
        double r26904315 = r26904308 / r26904296;
        double r26904316 = r26904294 / r26904315;
        double r26904317 = r26904293 * r26904316;
        double r26904318 = r26904314 + r26904317;
        double r26904319 = r26904303 / r26904307;
        double r26904320 = r26904319 * r26904298;
        double r26904321 = r26904320 * r26904300;
        double r26904322 = r26904318 - r26904321;
        double r26904323 = 4.09973230378698e-73;
        bool r26904324 = r26904309 <= r26904323;
        double r26904325 = fma(r26904295, r26904296, r26904292);
        double r26904326 = r26904325 / r26904299;
        double r26904327 = r26904303 * r26904300;
        double r26904328 = r26904327 * r26904298;
        double r26904329 = r26904326 - r26904328;
        double r26904330 = r26904307 / r26904329;
        double r26904331 = r26904312 / r26904330;
        double r26904332 = 1.6765134927781327e+303;
        bool r26904333 = r26904309 <= r26904332;
        double r26904334 = r26904333 ? r26904309 : r26904322;
        double r26904335 = r26904324 ? r26904331 : r26904334;
        double r26904336 = r26904311 ? r26904322 : r26904335;
        return r26904336;
}

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)))