Average Error: 20.8 → 4.3
Time: 14.0s
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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z \cdot c} \cdot y, 9, \frac{b}{z \cdot c}\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 -2.448849724241717662651180909470129832597 \cdot 10^{-172}:\\ \;\;\;\;\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{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 9.946124472836577314236323586150611923427 \cdot 10^{-283}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{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 7.600895977698465868869796601584418022319 \cdot 10^{300}:\\ \;\;\;\;\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(x \cdot \frac{\frac{y}{c}}{z}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \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} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z \cdot c} \cdot y, 9, \frac{b}{z \cdot c}\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 -2.448849724241717662651180909470129832597 \cdot 10^{-172}:\\
\;\;\;\;\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{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 9.946124472836577314236323586150611923427 \cdot 10^{-283}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{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 7.600895977698465868869796601584418022319 \cdot 10^{300}:\\
\;\;\;\;\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(x \cdot \frac{\frac{y}{c}}{z}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r950931 = x;
        double r950932 = 9.0;
        double r950933 = r950931 * r950932;
        double r950934 = y;
        double r950935 = r950933 * r950934;
        double r950936 = z;
        double r950937 = 4.0;
        double r950938 = r950936 * r950937;
        double r950939 = t;
        double r950940 = r950938 * r950939;
        double r950941 = a;
        double r950942 = r950940 * r950941;
        double r950943 = r950935 - r950942;
        double r950944 = b;
        double r950945 = r950943 + r950944;
        double r950946 = c;
        double r950947 = r950936 * r950946;
        double r950948 = r950945 / r950947;
        return r950948;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r950949 = x;
        double r950950 = 9.0;
        double r950951 = r950949 * r950950;
        double r950952 = y;
        double r950953 = r950951 * r950952;
        double r950954 = z;
        double r950955 = 4.0;
        double r950956 = r950954 * r950955;
        double r950957 = t;
        double r950958 = r950956 * r950957;
        double r950959 = a;
        double r950960 = r950958 * r950959;
        double r950961 = r950953 - r950960;
        double r950962 = b;
        double r950963 = r950961 + r950962;
        double r950964 = c;
        double r950965 = r950954 * r950964;
        double r950966 = r950963 / r950965;
        double r950967 = -inf.0;
        bool r950968 = r950966 <= r950967;
        double r950969 = r950949 / r950965;
        double r950970 = r950969 * r950952;
        double r950971 = r950962 / r950965;
        double r950972 = fma(r950970, r950950, r950971);
        double r950973 = r950959 / r950964;
        double r950974 = r950957 * r950973;
        double r950975 = r950955 * r950974;
        double r950976 = r950972 - r950975;
        double r950977 = -2.4488497242417177e-172;
        bool r950978 = r950966 <= r950977;
        double r950979 = 9.946124472836577e-283;
        bool r950980 = r950966 <= r950979;
        double r950981 = fma(r950952, r950951, r950962);
        double r950982 = r950981 / r950954;
        double r950983 = r950959 * r950955;
        double r950984 = r950983 * r950957;
        double r950985 = r950982 - r950984;
        double r950986 = 1.0;
        double r950987 = r950986 / r950964;
        double r950988 = r950985 * r950987;
        double r950989 = 7.600895977698466e+300;
        bool r950990 = r950966 <= r950989;
        double r950991 = r950952 / r950964;
        double r950992 = r950991 / r950954;
        double r950993 = r950949 * r950992;
        double r950994 = fma(r950993, r950950, r950971);
        double r950995 = r950957 * r950959;
        double r950996 = r950995 / r950964;
        double r950997 = r950955 * r950996;
        double r950998 = r950994 - r950997;
        double r950999 = r950990 ? r950966 : r950998;
        double r951000 = r950980 ? r950988 : r950999;
        double r951001 = r950978 ? r950966 : r951000;
        double r951002 = r950968 ? r950976 : r951001;
        return r951002;
}

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.8
Target14.7
Herbie4.3
\[\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.100156740804105117061698089246936481893 \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)) < -inf.0

    1. Initial program 64.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. Simplified26.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 31.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. Simplified31.2

      \[\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 associate-/l*16.0

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

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

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

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -2.4488497242417177e-172 or 9.946124472836577e-283 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 7.600895977698466e+300

    1. Initial program 0.7

      \[\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 -2.4488497242417177e-172 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 9.946124472836577e-283

    1. Initial program 32.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. Simplified0.5

      \[\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 div-inv0.5

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

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

    1. Initial program 62.7

      \[\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. Simplified26.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. Taylor expanded around 0 30.1

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

      \[\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 associate-/l*20.9

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

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

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

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

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

    \[\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} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z \cdot c} \cdot y, 9, \frac{b}{z \cdot c}\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 -2.448849724241717662651180909470129832597 \cdot 10^{-172}:\\ \;\;\;\;\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{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 9.946124472836577314236323586150611923427 \cdot 10^{-283}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(y, x \cdot 9, b\right)}{z} - \left(a \cdot 4\right) \cdot t\right) \cdot \frac{1}{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 7.600895977698465868869796601584418022319 \cdot 10^{300}:\\ \;\;\;\;\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(x \cdot \frac{\frac{y}{c}}{z}, 9, \frac{b}{z \cdot c}\right) - 4 \cdot \frac{t \cdot a}{c}\\ \end{array}\]

Reproduce

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