Average Error: 20.2 → 6.0
Time: 30.4s
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 -8569260933999674729203836689113474400256:\\ \;\;\;\;\left(\frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}} \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}}\right) \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}} - \frac{t}{\sqrt[3]{c}} \cdot \frac{4 \cdot a}{\sqrt[3]{c} \cdot \sqrt[3]{c}}\\ \mathbf{elif}\;c \le 4.431880420665139971603088320955600738026 \cdot 10^{-16}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{\frac{z}{y}}, 9, \frac{b}{z} - \left(4 \cdot a\right) \cdot t\right)}{c}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}} \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}}\right) \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}} - \frac{t}{\sqrt[3]{c}} \cdot \frac{4 \cdot a}{\sqrt[3]{c} \cdot \sqrt[3]{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}\;c \le -8569260933999674729203836689113474400256:\\
\;\;\;\;\left(\frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}} \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}}\right) \cdot \frac{\frac{\sqrt[3]{\mathsf{fma}\left(x \cdot 9, y, b\right)}}{\sqrt[3]{z}}}{\sqrt[3]{c}} - \frac{t}{\sqrt[3]{c}} \cdot \frac{4 \cdot a}{\sqrt[3]{c} \cdot \sqrt[3]{c}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c) {
        double r33620091 = x;
        double r33620092 = 9.0;
        double r33620093 = r33620091 * r33620092;
        double r33620094 = y;
        double r33620095 = r33620093 * r33620094;
        double r33620096 = z;
        double r33620097 = 4.0;
        double r33620098 = r33620096 * r33620097;
        double r33620099 = t;
        double r33620100 = r33620098 * r33620099;
        double r33620101 = a;
        double r33620102 = r33620100 * r33620101;
        double r33620103 = r33620095 - r33620102;
        double r33620104 = b;
        double r33620105 = r33620103 + r33620104;
        double r33620106 = c;
        double r33620107 = r33620096 * r33620106;
        double r33620108 = r33620105 / r33620107;
        return r33620108;
}

double f(double x, double y, double z, double t, double a, double b, double c) {
        double r33620109 = c;
        double r33620110 = -8.569260933999675e+39;
        bool r33620111 = r33620109 <= r33620110;
        double r33620112 = x;
        double r33620113 = 9.0;
        double r33620114 = r33620112 * r33620113;
        double r33620115 = y;
        double r33620116 = b;
        double r33620117 = fma(r33620114, r33620115, r33620116);
        double r33620118 = cbrt(r33620117);
        double r33620119 = z;
        double r33620120 = cbrt(r33620119);
        double r33620121 = r33620118 / r33620120;
        double r33620122 = cbrt(r33620109);
        double r33620123 = r33620121 / r33620122;
        double r33620124 = r33620123 * r33620123;
        double r33620125 = r33620124 * r33620123;
        double r33620126 = t;
        double r33620127 = r33620126 / r33620122;
        double r33620128 = 4.0;
        double r33620129 = a;
        double r33620130 = r33620128 * r33620129;
        double r33620131 = r33620122 * r33620122;
        double r33620132 = r33620130 / r33620131;
        double r33620133 = r33620127 * r33620132;
        double r33620134 = r33620125 - r33620133;
        double r33620135 = 4.43188042066514e-16;
        bool r33620136 = r33620109 <= r33620135;
        double r33620137 = r33620119 / r33620115;
        double r33620138 = r33620112 / r33620137;
        double r33620139 = r33620116 / r33620119;
        double r33620140 = r33620130 * r33620126;
        double r33620141 = r33620139 - r33620140;
        double r33620142 = fma(r33620138, r33620113, r33620141);
        double r33620143 = r33620142 / r33620109;
        double r33620144 = r33620136 ? r33620143 : r33620134;
        double r33620145 = r33620111 ? r33620134 : r33620144;
        return r33620145;
}

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.2
Target14.7
Herbie6.0
\[\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 2 regimes
  2. if c < -8.569260933999675e+39 or 4.43188042066514e-16 < c

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.569260933999675e+39 < c < 4.43188042066514e-16

    1. Initial program 14.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. Simplified3.1

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

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

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

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

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

Reproduce

herbie shell --seed 2019192 +o rules:numerics
(FPCore (x y z t a b c)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, J"

  :herbie-target
  (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -1.100156740804105e-171) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -0.0) (/ (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.1708877911747488e-53) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 2.876823679546137e+130) (- (+ (* (* 9.0 (/ y c)) (/ x z)) (/ b (* c z))) (* 4.0 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.3838515042456319e+158) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (- (+ (* 9.0 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4.0 (/ (* a t) c))))))))

  (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))