Average Error: 19.9 → 6.4
Time: 11.6s
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:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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 -4.5747116168721846 \cdot 10^{107}:\\ \;\;\;\;\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 1.557205577643591 \cdot 10^{-75}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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 4.569674877906646 \cdot 10^{241}:\\ \;\;\;\;\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(\frac{x}{z} \cdot \frac{y}{c}, 9, \frac{1}{z} \cdot \frac{b}{c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{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:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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 -4.5747116168721846 \cdot 10^{107}:\\
\;\;\;\;\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 1.557205577643591 \cdot 10^{-75}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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 4.569674877906646 \cdot 10^{241}:\\
\;\;\;\;\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(\frac{x}{z} \cdot \frac{y}{c}, 9, \frac{1}{z} \cdot \frac{b}{c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{c}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r747881 = x;
        double r747882 = 9.0;
        double r747883 = r747881 * r747882;
        double r747884 = y;
        double r747885 = r747883 * r747884;
        double r747886 = z;
        double r747887 = 4.0;
        double r747888 = r747886 * r747887;
        double r747889 = t;
        double r747890 = r747888 * r747889;
        double r747891 = a;
        double r747892 = r747890 * r747891;
        double r747893 = r747885 - r747892;
        double r747894 = b;
        double r747895 = r747893 + r747894;
        double r747896 = c;
        double r747897 = r747886 * r747896;
        double r747898 = r747895 / r747897;
        return r747898;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r747899 = x;
        double r747900 = 9.0;
        double r747901 = r747899 * r747900;
        double r747902 = y;
        double r747903 = r747901 * r747902;
        double r747904 = z;
        double r747905 = 4.0;
        double r747906 = r747904 * r747905;
        double r747907 = t;
        double r747908 = r747906 * r747907;
        double r747909 = a;
        double r747910 = r747908 * r747909;
        double r747911 = r747903 - r747910;
        double r747912 = b;
        double r747913 = r747911 + r747912;
        double r747914 = c;
        double r747915 = r747904 * r747914;
        double r747916 = r747913 / r747915;
        double r747917 = -inf.0;
        bool r747918 = r747916 <= r747917;
        double r747919 = r747900 * r747902;
        double r747920 = fma(r747899, r747919, r747912);
        double r747921 = r747920 / r747904;
        double r747922 = r747907 * r747909;
        double r747923 = r747922 * r747905;
        double r747924 = r747921 - r747923;
        double r747925 = 1.0;
        double r747926 = r747925 / r747914;
        double r747927 = r747924 * r747926;
        double r747928 = -4.5747116168721846e+107;
        bool r747929 = r747916 <= r747928;
        double r747930 = 1.557205577643591e-75;
        bool r747931 = r747916 <= r747930;
        double r747932 = 4.569674877906646e+241;
        bool r747933 = r747916 <= r747932;
        double r747934 = r747899 / r747904;
        double r747935 = r747902 / r747914;
        double r747936 = r747934 * r747935;
        double r747937 = r747925 / r747904;
        double r747938 = r747912 / r747914;
        double r747939 = r747937 * r747938;
        double r747940 = fma(r747936, r747900, r747939);
        double r747941 = r747923 / r747914;
        double r747942 = r747940 - r747941;
        double r747943 = r747933 ? r747916 : r747942;
        double r747944 = r747931 ? r747927 : r747943;
        double r747945 = r747929 ? r747916 : r747944;
        double r747946 = r747918 ? r747927 : r747945;
        return r747946;
}

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

Original19.9
Target14.4
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 3 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -inf.0 or -4.5747116168721846e+107 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 1.557205577643591e-75

    1. Initial program 21.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. Simplified6.2

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

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

    if -inf.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -4.5747116168721846e+107 or 1.557205577643591e-75 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 4.569674877906646e+241

    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 4.569674877906646e+241 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))

    1. Initial program 50.2

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{x}{z} \cdot \frac{y}{c}, 9, \color{blue}{\frac{1}{z} \cdot \frac{b}{c}}\right) - \frac{\left(t \cdot a\right) \cdot 4}{c}\]
  3. Recombined 3 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:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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 -4.5747116168721846 \cdot 10^{107}:\\ \;\;\;\;\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 1.557205577643591 \cdot 10^{-75}:\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(x, 9 \cdot y, b\right)}{z} - \left(t \cdot a\right) \cdot 4\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 4.569674877906646 \cdot 10^{241}:\\ \;\;\;\;\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(\frac{x}{z} \cdot \frac{y}{c}, 9, \frac{1}{z} \cdot \frac{b}{c}\right) - \frac{\left(t \cdot a\right) \cdot 4}{c}\\ \end{array}\]

Reproduce

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