Average Error: 20.8 → 8.5
Time: 7.5s
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}\;z \le -1.543905335657327018667500024760689729908 \cdot 10^{-60} \lor \neg \left(z \le 1.922500653134763196019662841029122258793 \cdot 10^{-48}\right):\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}, \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{\frac{z \cdot c}{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\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}\;z \le -1.543905335657327018667500024760689729908 \cdot 10^{-60} \lor \neg \left(z \le 1.922500653134763196019662841029122258793 \cdot 10^{-48}\right):\\
\;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r618825 = x;
        double r618826 = 9.0;
        double r618827 = r618825 * r618826;
        double r618828 = y;
        double r618829 = r618827 * r618828;
        double r618830 = z;
        double r618831 = 4.0;
        double r618832 = r618830 * r618831;
        double r618833 = t;
        double r618834 = r618832 * r618833;
        double r618835 = a;
        double r618836 = r618834 * r618835;
        double r618837 = r618829 - r618836;
        double r618838 = b;
        double r618839 = r618837 + r618838;
        double r618840 = c;
        double r618841 = r618830 * r618840;
        double r618842 = r618839 / r618841;
        return r618842;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r618843 = z;
        double r618844 = -1.543905335657327e-60;
        bool r618845 = r618843 <= r618844;
        double r618846 = 1.9225006531347632e-48;
        bool r618847 = r618843 <= r618846;
        double r618848 = !r618847;
        bool r618849 = r618845 || r618848;
        double r618850 = 4.0;
        double r618851 = -r618850;
        double r618852 = t;
        double r618853 = a;
        double r618854 = r618852 * r618853;
        double r618855 = c;
        double r618856 = r618854 / r618855;
        double r618857 = 9.0;
        double r618858 = x;
        double r618859 = r618857 * r618858;
        double r618860 = y;
        double r618861 = b;
        double r618862 = fma(r618859, r618860, r618861);
        double r618863 = r618862 / r618843;
        double r618864 = r618863 / r618855;
        double r618865 = fma(r618851, r618856, r618864);
        double r618866 = cbrt(r618855);
        double r618867 = r618866 * r618866;
        double r618868 = r618852 / r618867;
        double r618869 = r618853 / r618866;
        double r618870 = r618868 * r618869;
        double r618871 = r618857 * r618860;
        double r618872 = fma(r618858, r618871, r618861);
        double r618873 = cbrt(r618872);
        double r618874 = r618873 * r618873;
        double r618875 = r618843 * r618855;
        double r618876 = r618875 / r618873;
        double r618877 = r618874 / r618876;
        double r618878 = fma(r618851, r618870, r618877);
        double r618879 = r618849 ? r618865 : r618878;
        return r618879;
}

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.4
Herbie8.5
\[\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 2 regimes
  2. if z < -1.543905335657327e-60 or 1.9225006531347632e-48 < z

    1. Initial program 27.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. Simplified12.8

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

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

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

    if -1.543905335657327e-60 < z < 1.9225006531347632e-48

    1. Initial program 6.3

      \[\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. Simplified9.4

      \[\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 add-cube-cbrt9.6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.543905335657327018667500024760689729908 \cdot 10^{-60} \lor \neg \left(z \le 1.922500653134763196019662841029122258793 \cdot 10^{-48}\right):\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t \cdot a}{c}, \frac{\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z}}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-4, \frac{t}{\sqrt[3]{c} \cdot \sqrt[3]{c}} \cdot \frac{a}{\sqrt[3]{c}}, \frac{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}{\frac{z \cdot c}{\sqrt[3]{\mathsf{fma}\left(x, 9 \cdot y, b\right)}}}\right)\\ \end{array}\]

Reproduce

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