Average Error: 20.4 → 7.2
Time: 19.1s
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} \le -3.112336060241917007874486736181561242188 \cdot 10^{169}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - \frac{a}{c} \cdot \left(4 \cdot t\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 8.968020731522558612674702070183059050191 \cdot 10^{-133}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - \left(a \cdot 4\right) \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} \le 2.937767246768031145961339930985040677734 \cdot 10^{206}:\\ \;\;\;\;\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}{\frac{z \cdot c}{y}}, 9, \frac{1}{z} \cdot \frac{b}{c}\right) - \frac{a \cdot 4}{\frac{c}{t}}\\ \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} \le -3.112336060241917007874486736181561242188 \cdot 10^{169}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - \frac{a}{c} \cdot \left(4 \cdot t\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 8.968020731522558612674702070183059050191 \cdot 10^{-133}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - \left(a \cdot 4\right) \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} \le 2.937767246768031145961339930985040677734 \cdot 10^{206}:\\
\;\;\;\;\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}{\frac{z \cdot c}{y}}, 9, \frac{1}{z} \cdot \frac{b}{c}\right) - \frac{a \cdot 4}{\frac{c}{t}}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r62842 = x;
        double r62843 = 9.0;
        double r62844 = r62842 * r62843;
        double r62845 = y;
        double r62846 = r62844 * r62845;
        double r62847 = z;
        double r62848 = 4.0;
        double r62849 = r62847 * r62848;
        double r62850 = t;
        double r62851 = r62849 * r62850;
        double r62852 = a;
        double r62853 = r62851 * r62852;
        double r62854 = r62846 - r62853;
        double r62855 = b;
        double r62856 = r62854 + r62855;
        double r62857 = c;
        double r62858 = r62847 * r62857;
        double r62859 = r62856 / r62858;
        return r62859;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r62860 = x;
        double r62861 = 9.0;
        double r62862 = r62860 * r62861;
        double r62863 = y;
        double r62864 = r62862 * r62863;
        double r62865 = z;
        double r62866 = 4.0;
        double r62867 = r62865 * r62866;
        double r62868 = t;
        double r62869 = r62867 * r62868;
        double r62870 = a;
        double r62871 = r62869 * r62870;
        double r62872 = r62864 - r62871;
        double r62873 = b;
        double r62874 = r62872 + r62873;
        double r62875 = c;
        double r62876 = r62865 * r62875;
        double r62877 = r62874 / r62876;
        double r62878 = -3.112336060241917e+169;
        bool r62879 = r62877 <= r62878;
        double r62880 = r62876 / r62863;
        double r62881 = r62860 / r62880;
        double r62882 = r62873 / r62876;
        double r62883 = fma(r62881, r62861, r62882);
        double r62884 = r62870 / r62875;
        double r62885 = r62866 * r62868;
        double r62886 = r62884 * r62885;
        double r62887 = r62883 - r62886;
        double r62888 = 8.968020731522559e-133;
        bool r62889 = r62877 <= r62888;
        double r62890 = r62863 * r62861;
        double r62891 = fma(r62890, r62860, r62873);
        double r62892 = r62891 / r62865;
        double r62893 = r62870 * r62866;
        double r62894 = r62893 * r62868;
        double r62895 = r62892 - r62894;
        double r62896 = r62895 / r62875;
        double r62897 = 2.937767246768031e+206;
        bool r62898 = r62877 <= r62897;
        double r62899 = 1.0;
        double r62900 = r62899 / r62865;
        double r62901 = r62873 / r62875;
        double r62902 = r62900 * r62901;
        double r62903 = fma(r62881, r62861, r62902);
        double r62904 = r62875 / r62868;
        double r62905 = r62893 / r62904;
        double r62906 = r62903 - r62905;
        double r62907 = r62898 ? r62877 : r62906;
        double r62908 = r62889 ? r62896 : r62907;
        double r62909 = r62879 ? r62887 : r62908;
        return r62909;
}

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.4
Target14.4
Herbie7.2
\[\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 4 regimes
  2. if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -3.112336060241917e+169

    1. Initial program 27.4

      \[\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. Simplified21.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 14.4

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

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

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

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

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

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

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

    if -3.112336060241917e+169 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 8.968020731522559e-133

    1. Initial program 11.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. Simplified3.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. Using strategy rm
    4. Applied *-un-lft-identity3.9

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

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

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

    if 8.968020731522559e-133 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 2.937767246768031e+206

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

    1. Initial program 46.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. 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 24.7

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

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

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

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

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

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

    \[\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} \le -3.112336060241917007874486736181561242188 \cdot 10^{169}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{\frac{z \cdot c}{y}}, 9, \frac{b}{z \cdot c}\right) - \frac{a}{c} \cdot \left(4 \cdot t\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 8.968020731522558612674702070183059050191 \cdot 10^{-133}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(y \cdot 9, x, b\right)}{z} - \left(a \cdot 4\right) \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} \le 2.937767246768031145961339930985040677734 \cdot 10^{206}:\\ \;\;\;\;\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}{\frac{z \cdot c}{y}}, 9, \frac{1}{z} \cdot \frac{b}{c}\right) - \frac{a \cdot 4}{\frac{c}{t}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019310 +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.1001567408041049e-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.17088779117474882e-53) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 2.8768236795461372e130) (- (+ (* (* 9 (/ y c)) (/ x z)) (/ b (* c z))) (* 4 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 1.3838515042456319e158) (/ (+ (- (* (* 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)))