Average Error: 32.0 → 0.4
Time: 4.7s
Precision: 64
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.03585382449127275800160319363385497126728 \lor \neg \left(x \le 0.0450725634015326365178211176498734857887\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x}, \frac{\sqrt[3]{1}}{x}, -\frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right) + \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)\\ \end{array}\]
\frac{1 - \cos x}{x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \le -0.03585382449127275800160319363385497126728 \lor \neg \left(x \le 0.0450725634015326365178211176498734857887\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x}, \frac{\sqrt[3]{1}}{x}, -\frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right) + \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)\\

\end{array}
double f(double x) {
        double r30285 = 1.0;
        double r30286 = x;
        double r30287 = cos(r30286);
        double r30288 = r30285 - r30287;
        double r30289 = r30286 * r30286;
        double r30290 = r30288 / r30289;
        return r30290;
}

double f(double x) {
        double r30291 = x;
        double r30292 = -0.03585382449127276;
        bool r30293 = r30291 <= r30292;
        double r30294 = 0.045072563401532637;
        bool r30295 = r30291 <= r30294;
        double r30296 = !r30295;
        bool r30297 = r30293 || r30296;
        double r30298 = 1.0;
        double r30299 = cbrt(r30298);
        double r30300 = r30299 * r30299;
        double r30301 = r30300 / r30291;
        double r30302 = r30299 / r30291;
        double r30303 = cos(r30291);
        double r30304 = cbrt(r30303);
        double r30305 = r30304 / r30291;
        double r30306 = r30304 * r30304;
        double r30307 = r30306 / r30291;
        double r30308 = r30305 * r30307;
        double r30309 = -r30308;
        double r30310 = fma(r30301, r30302, r30309);
        double r30311 = -r30305;
        double r30312 = r30311 + r30305;
        double r30313 = r30307 * r30312;
        double r30314 = r30310 + r30313;
        double r30315 = 4.0;
        double r30316 = pow(r30291, r30315);
        double r30317 = 0.001388888888888889;
        double r30318 = 0.5;
        double r30319 = 0.041666666666666664;
        double r30320 = 2.0;
        double r30321 = pow(r30291, r30320);
        double r30322 = r30319 * r30321;
        double r30323 = r30318 - r30322;
        double r30324 = fma(r30316, r30317, r30323);
        double r30325 = r30324 + r30313;
        double r30326 = r30297 ? r30314 : r30325;
        return r30326;
}

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.03585382449127276 or 0.045072563401532637 < x

    1. Initial program 1.0

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied div-sub1.1

      \[\leadsto \color{blue}{\frac{1}{x \cdot x} - \frac{\cos x}{x \cdot x}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt1.4

      \[\leadsto \frac{1}{x \cdot x} - \frac{\color{blue}{\left(\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}\right) \cdot \sqrt[3]{\cos x}}}{x \cdot x}\]
    6. Applied times-frac1.5

      \[\leadsto \frac{1}{x \cdot x} - \color{blue}{\frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x}}{x}}\]
    7. Applied add-cube-cbrt1.5

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{x \cdot x} - \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x}}{x}\]
    8. Applied times-frac0.9

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x} \cdot \frac{\sqrt[3]{1}}{x}} - \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x}}{x}\]
    9. Applied prod-diff0.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x}, \frac{\sqrt[3]{1}}{x}, -\frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right) + \mathsf{fma}\left(-\frac{\sqrt[3]{\cos x}}{x}, \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}, \frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right)}\]
    10. Simplified0.9

      \[\leadsto \mathsf{fma}\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x}, \frac{\sqrt[3]{1}}{x}, -\frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right) + \color{blue}{\frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)}\]

    if -0.03585382449127276 < x < 0.045072563401532637

    1. Initial program 62.3

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied div-sub62.1

      \[\leadsto \color{blue}{\frac{1}{x \cdot x} - \frac{\cos x}{x \cdot x}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt62.4

      \[\leadsto \frac{1}{x \cdot x} - \frac{\color{blue}{\left(\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}\right) \cdot \sqrt[3]{\cos x}}}{x \cdot x}\]
    6. Applied times-frac62.3

      \[\leadsto \frac{1}{x \cdot x} - \color{blue}{\frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x}}{x}}\]
    7. Applied add-cube-cbrt62.3

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{x \cdot x} - \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x}}{x}\]
    8. Applied times-frac62.3

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x} \cdot \frac{\sqrt[3]{1}}{x}} - \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x}}{x}\]
    9. Applied prod-diff62.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x}, \frac{\sqrt[3]{1}}{x}, -\frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right) + \mathsf{fma}\left(-\frac{\sqrt[3]{\cos x}}{x}, \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}, \frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right)}\]
    10. Simplified62.3

      \[\leadsto \mathsf{fma}\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x}, \frac{\sqrt[3]{1}}{x}, -\frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right) + \color{blue}{\frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)}\]
    11. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\left(\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\right)} + \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)\]
    12. Simplified0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)} + \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.03585382449127275800160319363385497126728 \lor \neg \left(x \le 0.0450725634015326365178211176498734857887\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{x}, \frac{\sqrt[3]{1}}{x}, -\frac{\sqrt[3]{\cos x}}{x} \cdot \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right) + \frac{\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}}{x} \cdot \left(\left(-\frac{\sqrt[3]{\cos x}}{x}\right) + \frac{\sqrt[3]{\cos x}}{x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019346 +o rules:numerics
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  :precision binary64
  (/ (- 1 (cos x)) (* x x)))