Average Error: 20.7 → 6.4
Time: 13.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}\;\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:\\ \;\;\;\;\frac{1}{\frac{c}{\mathsf{fma}\left(4, -t \cdot a, \frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z}\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 -1.2924559506748985 \cdot 10^{48}:\\ \;\;\;\;\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 5.1699103539817533 \cdot 10^{-16}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - 4 \cdot \left(t \cdot a\right)\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 2.03198024949057577 \cdot 10^{301}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{\mathsf{fma}\left(9, x \cdot \frac{y}{z}, -4 \cdot \left(t \cdot a\right)\right)}{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:\\
\;\;\;\;\frac{1}{\frac{c}{\mathsf{fma}\left(4, -t \cdot a, \frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z}\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 -1.2924559506748985 \cdot 10^{48}:\\
\;\;\;\;\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 5.1699103539817533 \cdot 10^{-16}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - 4 \cdot \left(t \cdot a\right)\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 2.03198024949057577 \cdot 10^{301}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{\mathsf{fma}\left(9, x \cdot \frac{y}{z}, -4 \cdot \left(t \cdot a\right)\right)}{c}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r792844 = x;
        double r792845 = 9.0;
        double r792846 = r792844 * r792845;
        double r792847 = y;
        double r792848 = r792846 * r792847;
        double r792849 = z;
        double r792850 = 4.0;
        double r792851 = r792849 * r792850;
        double r792852 = t;
        double r792853 = r792851 * r792852;
        double r792854 = a;
        double r792855 = r792853 * r792854;
        double r792856 = r792848 - r792855;
        double r792857 = b;
        double r792858 = r792856 + r792857;
        double r792859 = c;
        double r792860 = r792849 * r792859;
        double r792861 = r792858 / r792860;
        return r792861;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r792862 = x;
        double r792863 = 9.0;
        double r792864 = r792862 * r792863;
        double r792865 = y;
        double r792866 = r792864 * r792865;
        double r792867 = z;
        double r792868 = 4.0;
        double r792869 = r792867 * r792868;
        double r792870 = t;
        double r792871 = r792869 * r792870;
        double r792872 = a;
        double r792873 = r792871 * r792872;
        double r792874 = r792866 - r792873;
        double r792875 = b;
        double r792876 = r792874 + r792875;
        double r792877 = c;
        double r792878 = r792867 * r792877;
        double r792879 = r792876 / r792878;
        double r792880 = -inf.0;
        bool r792881 = r792879 <= r792880;
        double r792882 = 1.0;
        double r792883 = r792870 * r792872;
        double r792884 = -r792883;
        double r792885 = fma(r792864, r792865, r792875);
        double r792886 = r792885 / r792867;
        double r792887 = fma(r792868, r792884, r792886);
        double r792888 = r792877 / r792887;
        double r792889 = r792882 / r792888;
        double r792890 = -1.2924559506748985e+48;
        bool r792891 = r792879 <= r792890;
        double r792892 = 5.169910353981753e-16;
        bool r792893 = r792879 <= r792892;
        double r792894 = r792868 * r792883;
        double r792895 = r792886 - r792894;
        double r792896 = r792882 / r792877;
        double r792897 = r792895 * r792896;
        double r792898 = 2.0319802494905758e+301;
        bool r792899 = r792879 <= r792898;
        double r792900 = r792865 / r792867;
        double r792901 = r792862 * r792900;
        double r792902 = -r792894;
        double r792903 = fma(r792863, r792901, r792902);
        double r792904 = r792903 / r792877;
        double r792905 = r792899 ? r792879 : r792904;
        double r792906 = r792893 ? r792897 : r792905;
        double r792907 = r792891 ? r792879 : r792906;
        double r792908 = r792881 ? r792889 : r792907;
        return r792908;
}

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.7
Target15.2
Herbie6.4
\[\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 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. Simplified25.0

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

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

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

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

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -1.2924559506748985e+48 or 5.169910353981753e-16 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 2.0319802494905758e+301

    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}\]

    if -1.2924559506748985e+48 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 5.169910353981753e-16

    1. Initial program 13.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. Simplified1.0

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

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

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

    1. Initial program 62.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}\]
    2. Simplified28.6

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

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

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

      \[\leadsto \frac{\color{blue}{9 \cdot \frac{x \cdot y}{z} - 4 \cdot \left(a \cdot t\right)}}{c}\]
    7. Simplified21.5

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

    \[\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:\\ \;\;\;\;\frac{1}{\frac{c}{\mathsf{fma}\left(4, -t \cdot a, \frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z}\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 -1.2924559506748985 \cdot 10^{48}:\\ \;\;\;\;\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 5.1699103539817533 \cdot 10^{-16}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(x \cdot 9, y, b\right)}{z} - 4 \cdot \left(t \cdot a\right)\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 2.03198024949057577 \cdot 10^{301}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{\mathsf{fma}\left(9, x \cdot \frac{y}{z}, -4 \cdot \left(t \cdot a\right)\right)}{c}\\ \end{array}\]

Reproduce

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