Average Error: 20.6 → 9.0
Time: 6.2s
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}\;c \le -1.9994054055991995 \cdot 10^{44}:\\ \;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)\\ \mathbf{elif}\;c \le 5.37240412345229966 \cdot 10^{57}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\sqrt{c}} \cdot \frac{a}{\sqrt{c}}, \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z \cdot 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}\;c \le -1.9994054055991995 \cdot 10^{44}:\\
\;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\sqrt{c}} \cdot \frac{a}{\sqrt{c}}, \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z \cdot c}\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r670269 = x;
        double r670270 = 9.0;
        double r670271 = r670269 * r670270;
        double r670272 = y;
        double r670273 = r670271 * r670272;
        double r670274 = z;
        double r670275 = 4.0;
        double r670276 = r670274 * r670275;
        double r670277 = t;
        double r670278 = r670276 * r670277;
        double r670279 = a;
        double r670280 = r670278 * r670279;
        double r670281 = r670273 - r670280;
        double r670282 = b;
        double r670283 = r670281 + r670282;
        double r670284 = c;
        double r670285 = r670274 * r670284;
        double r670286 = r670283 / r670285;
        return r670286;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r670287 = c;
        double r670288 = -1.9994054055991995e+44;
        bool r670289 = r670287 <= r670288;
        double r670290 = 4.0;
        double r670291 = -r670290;
        double r670292 = t;
        double r670293 = a;
        double r670294 = r670293 / r670287;
        double r670295 = r670292 * r670294;
        double r670296 = 9.0;
        double r670297 = x;
        double r670298 = y;
        double r670299 = r670297 * r670298;
        double r670300 = z;
        double r670301 = r670300 * r670287;
        double r670302 = r670299 / r670301;
        double r670303 = b;
        double r670304 = r670303 / r670301;
        double r670305 = fma(r670296, r670302, r670304);
        double r670306 = fma(r670291, r670295, r670305);
        double r670307 = 5.3724041234523e+57;
        bool r670308 = r670287 <= r670307;
        double r670309 = r670292 * r670293;
        double r670310 = r670309 / r670287;
        double r670311 = r670296 * r670297;
        double r670312 = fma(r670311, r670298, r670303);
        double r670313 = r670312 / r670300;
        double r670314 = r670313 / r670287;
        double r670315 = fma(r670291, r670310, r670314);
        double r670316 = sqrt(r670287);
        double r670317 = r670292 / r670316;
        double r670318 = r670293 / r670316;
        double r670319 = r670317 * r670318;
        double r670320 = r670312 / r670301;
        double r670321 = fma(r670291, r670319, r670320);
        double r670322 = r670308 ? r670315 : r670321;
        double r670323 = r670289 ? r670306 : r670322;
        return r670323;
}

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.6
Target14.9
Herbie9.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.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 c < -1.9994054055991995e+44

    1. Initial program 24.5

      \[\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. Simplified16.4

      \[\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 *-un-lft-identity16.4

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

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

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

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

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

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

    if -1.9994054055991995e+44 < c < 5.3724041234523e+57

    1. Initial program 15.3

      \[\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. Simplified5.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*4.1

      \[\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. Simplified4.1

      \[\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)\]

    if 5.3724041234523e+57 < c

    1. Initial program 24.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. Simplified17.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 *-un-lft-identity17.5

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(-4, t \cdot \frac{a}{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}, \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z \cdot c}\right)\]
    11. Applied *-un-lft-identity12.7

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

      \[\leadsto \mathsf{fma}\left(-4, t \cdot \color{blue}{\left(\frac{1}{\sqrt{c}} \cdot \frac{a}{\sqrt{c}}\right)}, \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z \cdot c}\right)\]
    13. Applied associate-*r*12.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \le -1.9994054055991995 \cdot 10^{44}:\\ \;\;\;\;\mathsf{fma}\left(-4, t \cdot \frac{a}{c}, \mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)\\ \mathbf{elif}\;c \le 5.37240412345229966 \cdot 10^{57}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\sqrt{c}} \cdot \frac{a}{\sqrt{c}}, \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z \cdot c}\right)\\ \end{array}\]

Reproduce

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