Average Error: 30.7 → 0.3
Time: 4.2s
Precision: 64
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.03116229552204852:\\ \;\;\;\;\frac{\frac{\log \left(e^{{1}^{3} - {\left(\cos x\right)}^{3}}\right)}{\left(\cos x \cdot \left(\left(\sqrt[3]{\cos x + 1} \cdot \sqrt[3]{\cos x + 1}\right) \cdot \sqrt[3]{\cos x + 1}\right) + 1 \cdot 1\right) \cdot x}}{x}\\ \mathbf{elif}\;x \le 0.032272014734577137:\\ \;\;\;\;\frac{\left(0.5 \cdot x + 0.00138888888888887 \cdot {x}^{5}\right) - 0.041666666666666685 \cdot {x}^{3}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{1}^{3} \cdot {1}^{3} - {\left(\cos x\right)}^{3} \cdot {\left(\cos x\right)}^{3}}{\left(\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x\right) \cdot \left({1}^{3} + {\left(\cos x\right)}^{3}\right)}}{x}\\ \end{array}\]
\frac{1 - \cos x}{x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \le -0.03116229552204852:\\
\;\;\;\;\frac{\frac{\log \left(e^{{1}^{3} - {\left(\cos x\right)}^{3}}\right)}{\left(\cos x \cdot \left(\left(\sqrt[3]{\cos x + 1} \cdot \sqrt[3]{\cos x + 1}\right) \cdot \sqrt[3]{\cos x + 1}\right) + 1 \cdot 1\right) \cdot x}}{x}\\

\mathbf{elif}\;x \le 0.032272014734577137:\\
\;\;\;\;\frac{\left(0.5 \cdot x + 0.00138888888888887 \cdot {x}^{5}\right) - 0.041666666666666685 \cdot {x}^{3}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{{1}^{3} \cdot {1}^{3} - {\left(\cos x\right)}^{3} \cdot {\left(\cos x\right)}^{3}}{\left(\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x\right) \cdot \left({1}^{3} + {\left(\cos x\right)}^{3}\right)}}{x}\\

\end{array}
double f(double x) {
        double r25276 = 1.0;
        double r25277 = x;
        double r25278 = cos(r25277);
        double r25279 = r25276 - r25278;
        double r25280 = r25277 * r25277;
        double r25281 = r25279 / r25280;
        return r25281;
}

double f(double x) {
        double r25282 = x;
        double r25283 = -0.031162295522048522;
        bool r25284 = r25282 <= r25283;
        double r25285 = 1.0;
        double r25286 = 3.0;
        double r25287 = pow(r25285, r25286);
        double r25288 = cos(r25282);
        double r25289 = pow(r25288, r25286);
        double r25290 = r25287 - r25289;
        double r25291 = exp(r25290);
        double r25292 = log(r25291);
        double r25293 = r25288 + r25285;
        double r25294 = cbrt(r25293);
        double r25295 = r25294 * r25294;
        double r25296 = r25295 * r25294;
        double r25297 = r25288 * r25296;
        double r25298 = r25285 * r25285;
        double r25299 = r25297 + r25298;
        double r25300 = r25299 * r25282;
        double r25301 = r25292 / r25300;
        double r25302 = r25301 / r25282;
        double r25303 = 0.03227201473457714;
        bool r25304 = r25282 <= r25303;
        double r25305 = 0.5;
        double r25306 = r25305 * r25282;
        double r25307 = 0.00138888888888887;
        double r25308 = 5.0;
        double r25309 = pow(r25282, r25308);
        double r25310 = r25307 * r25309;
        double r25311 = r25306 + r25310;
        double r25312 = 0.041666666666666685;
        double r25313 = pow(r25282, r25286);
        double r25314 = r25312 * r25313;
        double r25315 = r25311 - r25314;
        double r25316 = r25315 / r25282;
        double r25317 = r25287 * r25287;
        double r25318 = r25289 * r25289;
        double r25319 = r25317 - r25318;
        double r25320 = r25288 * r25293;
        double r25321 = r25320 + r25298;
        double r25322 = r25321 * r25282;
        double r25323 = r25287 + r25289;
        double r25324 = r25322 * r25323;
        double r25325 = r25319 / r25324;
        double r25326 = r25325 / r25282;
        double r25327 = r25304 ? r25316 : r25326;
        double r25328 = r25284 ? r25302 : r25327;
        return r25328;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -0.031162295522048522

    1. Initial program 1.1

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied associate-/r*0.4

      \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}}\]
    4. Using strategy rm
    5. Applied flip3--0.5

      \[\leadsto \frac{\frac{\color{blue}{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}}}{x}}{x}\]
    6. Applied associate-/l/0.5

      \[\leadsto \frac{\color{blue}{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x \cdot \left(1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)\right)}}}{x}\]
    7. Simplified0.5

      \[\leadsto \frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\color{blue}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x}}}{x}\]
    8. Using strategy rm
    9. Applied add-log-exp0.5

      \[\leadsto \frac{\frac{{1}^{3} - \color{blue}{\log \left(e^{{\left(\cos x\right)}^{3}}\right)}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x}}{x}\]
    10. Applied add-log-exp0.5

      \[\leadsto \frac{\frac{\color{blue}{\log \left(e^{{1}^{3}}\right)} - \log \left(e^{{\left(\cos x\right)}^{3}}\right)}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x}}{x}\]
    11. Applied diff-log0.6

      \[\leadsto \frac{\frac{\color{blue}{\log \left(\frac{e^{{1}^{3}}}{e^{{\left(\cos x\right)}^{3}}}\right)}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x}}{x}\]
    12. Simplified0.5

      \[\leadsto \frac{\frac{\log \color{blue}{\left(e^{{1}^{3} - {\left(\cos x\right)}^{3}}\right)}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x}}{x}\]
    13. Using strategy rm
    14. Applied add-cube-cbrt0.6

      \[\leadsto \frac{\frac{\log \left(e^{{1}^{3} - {\left(\cos x\right)}^{3}}\right)}{\left(\cos x \cdot \color{blue}{\left(\left(\sqrt[3]{\cos x + 1} \cdot \sqrt[3]{\cos x + 1}\right) \cdot \sqrt[3]{\cos x + 1}\right)} + 1 \cdot 1\right) \cdot x}}{x}\]

    if -0.031162295522048522 < x < 0.03227201473457714

    1. Initial program 62.2

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied associate-/r*61.3

      \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}}\]
    4. Using strategy rm
    5. Applied flip3--61.3

      \[\leadsto \frac{\frac{\color{blue}{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}}}{x}}{x}\]
    6. Applied associate-/l/61.3

      \[\leadsto \frac{\color{blue}{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x \cdot \left(1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)\right)}}}{x}\]
    7. Simplified61.3

      \[\leadsto \frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\color{blue}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x}}}{x}\]
    8. Taylor expanded around 0 0.0

      \[\leadsto \frac{\color{blue}{\left(0.5 \cdot x + 0.00138888888888887 \cdot {x}^{5}\right) - 0.041666666666666685 \cdot {x}^{3}}}{x}\]

    if 0.03227201473457714 < x

    1. Initial program 1.3

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied associate-/r*0.5

      \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}}\]
    4. Using strategy rm
    5. Applied flip3--0.5

      \[\leadsto \frac{\frac{\color{blue}{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}}}{x}}{x}\]
    6. Applied associate-/l/0.5

      \[\leadsto \frac{\color{blue}{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x \cdot \left(1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)\right)}}}{x}\]
    7. Simplified0.5

      \[\leadsto \frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\color{blue}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x}}}{x}\]
    8. Using strategy rm
    9. Applied flip--0.6

      \[\leadsto \frac{\frac{\color{blue}{\frac{{1}^{3} \cdot {1}^{3} - {\left(\cos x\right)}^{3} \cdot {\left(\cos x\right)}^{3}}{{1}^{3} + {\left(\cos x\right)}^{3}}}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x}}{x}\]
    10. Applied associate-/l/0.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.03116229552204852:\\ \;\;\;\;\frac{\frac{\log \left(e^{{1}^{3} - {\left(\cos x\right)}^{3}}\right)}{\left(\cos x \cdot \left(\left(\sqrt[3]{\cos x + 1} \cdot \sqrt[3]{\cos x + 1}\right) \cdot \sqrt[3]{\cos x + 1}\right) + 1 \cdot 1\right) \cdot x}}{x}\\ \mathbf{elif}\;x \le 0.032272014734577137:\\ \;\;\;\;\frac{\left(0.5 \cdot x + 0.00138888888888887 \cdot {x}^{5}\right) - 0.041666666666666685 \cdot {x}^{3}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{1}^{3} \cdot {1}^{3} - {\left(\cos x\right)}^{3} \cdot {\left(\cos x\right)}^{3}}{\left(\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot x\right) \cdot \left({1}^{3} + {\left(\cos x\right)}^{3}\right)}}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2020025 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  :precision binary64
  (/ (- 1 (cos x)) (* x x)))