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 r612853 = x;
        double r612854 = 9.0;
        double r612855 = r612853 * r612854;
        double r612856 = y;
        double r612857 = r612855 * r612856;
        double r612858 = z;
        double r612859 = 4.0;
        double r612860 = r612858 * r612859;
        double r612861 = t;
        double r612862 = r612860 * r612861;
        double r612863 = a;
        double r612864 = r612862 * r612863;
        double r612865 = r612857 - r612864;
        double r612866 = b;
        double r612867 = r612865 + r612866;
        double r612868 = c;
        double r612869 = r612858 * r612868;
        double r612870 = r612867 / r612869;
        return r612870;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r612871 = z;
        double r612872 = -1.543905335657327e-60;
        bool r612873 = r612871 <= r612872;
        double r612874 = 1.9225006531347632e-48;
        bool r612875 = r612871 <= r612874;
        double r612876 = !r612875;
        bool r612877 = r612873 || r612876;
        double r612878 = 4.0;
        double r612879 = -r612878;
        double r612880 = t;
        double r612881 = a;
        double r612882 = r612880 * r612881;
        double r612883 = c;
        double r612884 = r612882 / r612883;
        double r612885 = 9.0;
        double r612886 = x;
        double r612887 = r612885 * r612886;
        double r612888 = y;
        double r612889 = b;
        double r612890 = fma(r612887, r612888, r612889);
        double r612891 = r612890 / r612871;
        double r612892 = r612891 / r612883;
        double r612893 = fma(r612879, r612884, r612892);
        double r612894 = cbrt(r612883);
        double r612895 = r612894 * r612894;
        double r612896 = r612880 / r612895;
        double r612897 = r612881 / r612894;
        double r612898 = r612896 * r612897;
        double r612899 = r612885 * r612888;
        double r612900 = fma(r612886, r612899, r612889);
        double r612901 = cbrt(r612900);
        double r612902 = r612901 * r612901;
        double r612903 = r612871 * r612883;
        double r612904 = r612903 / r612901;
        double r612905 = r612902 / r612904;
        double r612906 = fma(r612879, r612898, r612905);
        double r612907 = r612877 ? r612893 : r612906;
        return r612907;
}

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)))