Average Error: 20.9 → 8.8
Time: 6.7s
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 -3906358862777155070:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\frac{c}{a}}, \mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{1}{z} \cdot \frac{b}{c}\right)\right)\\ \mathbf{elif}\;c \le 1.9776186768340695 \cdot 10^{70}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{c} \cdot a, \mathsf{fma}\left(9, \frac{x \cdot y}{z \cdot c}, \frac{b}{z \cdot c}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\frac{c}{a}}, \mathsf{fma}\left(9, \frac{x}{\frac{z}{\frac{y}{c}}}, \frac{b}{z \cdot c}\right)\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 -3906358862777155070:\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\frac{c}{a}}, \mathsf{fma}\left(9, \frac{x}{\frac{z \cdot c}{y}}, \frac{1}{z} \cdot \frac{b}{c}\right)\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r992884 = x;
        double r992885 = 9.0;
        double r992886 = r992884 * r992885;
        double r992887 = y;
        double r992888 = r992886 * r992887;
        double r992889 = z;
        double r992890 = 4.0;
        double r992891 = r992889 * r992890;
        double r992892 = t;
        double r992893 = r992891 * r992892;
        double r992894 = a;
        double r992895 = r992893 * r992894;
        double r992896 = r992888 - r992895;
        double r992897 = b;
        double r992898 = r992896 + r992897;
        double r992899 = c;
        double r992900 = r992889 * r992899;
        double r992901 = r992898 / r992900;
        return r992901;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r992902 = c;
        double r992903 = -3.906358862777155e+18;
        bool r992904 = r992902 <= r992903;
        double r992905 = 4.0;
        double r992906 = -r992905;
        double r992907 = t;
        double r992908 = a;
        double r992909 = r992902 / r992908;
        double r992910 = r992907 / r992909;
        double r992911 = 9.0;
        double r992912 = x;
        double r992913 = z;
        double r992914 = r992913 * r992902;
        double r992915 = y;
        double r992916 = r992914 / r992915;
        double r992917 = r992912 / r992916;
        double r992918 = 1.0;
        double r992919 = r992918 / r992913;
        double r992920 = b;
        double r992921 = r992920 / r992902;
        double r992922 = r992919 * r992921;
        double r992923 = fma(r992911, r992917, r992922);
        double r992924 = fma(r992906, r992910, r992923);
        double r992925 = 1.9776186768340695e+70;
        bool r992926 = r992902 <= r992925;
        double r992927 = r992907 / r992902;
        double r992928 = r992927 * r992908;
        double r992929 = r992912 * r992915;
        double r992930 = r992929 / r992914;
        double r992931 = r992920 / r992914;
        double r992932 = fma(r992911, r992930, r992931);
        double r992933 = fma(r992906, r992928, r992932);
        double r992934 = r992915 / r992902;
        double r992935 = r992913 / r992934;
        double r992936 = r992912 / r992935;
        double r992937 = fma(r992911, r992936, r992931);
        double r992938 = fma(r992906, r992910, r992937);
        double r992939 = r992926 ? r992933 : r992938;
        double r992940 = r992904 ? r992924 : r992939;
        return r992940;
}

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.9
Target14.9
Herbie8.8
\[\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 < -3.906358862777155e+18

    1. Initial program 23.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. Simplified14.9

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

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

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

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

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

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

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

    if -3.906358862777155e+18 < c < 1.9776186768340695e+70

    1. Initial program 15.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. Simplified5.7

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

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

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

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

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

    if 1.9776186768340695e+70 < c

    1. Initial program 25.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. Simplified17.7

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

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

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

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

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

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

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

Reproduce

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