Average Error: 31.2 → 0.3
Time: 4.4s
Precision: 64
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0311990908630558443:\\ \;\;\;\;\frac{\sqrt{\frac{\sqrt{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}} \cdot \sqrt{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \mathbf{elif}\;x \le 0.0311785731008621426:\\ \;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \end{array}\]
\frac{1 - \cos x}{x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \le -0.0311990908630558443:\\
\;\;\;\;\frac{\sqrt{\frac{\sqrt{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}} \cdot \sqrt{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\

\mathbf{elif}\;x \le 0.0311785731008621426:\\
\;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\

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

\end{array}
double f(double x) {
        double r22412 = 1.0;
        double r22413 = x;
        double r22414 = cos(r22413);
        double r22415 = r22412 - r22414;
        double r22416 = r22413 * r22413;
        double r22417 = r22415 / r22416;
        return r22417;
}

double f(double x) {
        double r22418 = x;
        double r22419 = -0.031199090863055844;
        bool r22420 = r22418 <= r22419;
        double r22421 = 1.0;
        double r22422 = 3.0;
        double r22423 = pow(r22421, r22422);
        double r22424 = cos(r22418);
        double r22425 = pow(r22424, r22422);
        double r22426 = pow(r22425, r22422);
        double r22427 = cbrt(r22426);
        double r22428 = r22423 - r22427;
        double r22429 = sqrt(r22428);
        double r22430 = r22429 * r22429;
        double r22431 = r22424 + r22421;
        double r22432 = r22424 * r22431;
        double r22433 = r22421 * r22421;
        double r22434 = r22432 + r22433;
        double r22435 = r22430 / r22434;
        double r22436 = sqrt(r22435);
        double r22437 = r22436 / r22418;
        double r22438 = r22421 - r22424;
        double r22439 = sqrt(r22438);
        double r22440 = r22439 / r22418;
        double r22441 = r22437 * r22440;
        double r22442 = 0.031178573100862143;
        bool r22443 = r22418 <= r22442;
        double r22444 = 0.001388888888888889;
        double r22445 = 4.0;
        double r22446 = pow(r22418, r22445);
        double r22447 = r22444 * r22446;
        double r22448 = 0.5;
        double r22449 = r22447 + r22448;
        double r22450 = 0.041666666666666664;
        double r22451 = 2.0;
        double r22452 = pow(r22418, r22451);
        double r22453 = r22450 * r22452;
        double r22454 = r22449 - r22453;
        double r22455 = r22428 / r22434;
        double r22456 = sqrt(r22455);
        double r22457 = r22456 / r22418;
        double r22458 = r22457 * r22440;
        double r22459 = r22443 ? r22454 : r22458;
        double r22460 = r22420 ? r22441 : r22459;
        return r22460;
}

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.031199090863055844

    1. Initial program 0.8

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.9

      \[\leadsto \frac{\color{blue}{\sqrt{1 - \cos x} \cdot \sqrt{1 - \cos x}}}{x \cdot x}\]
    4. Applied times-frac0.5

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

      \[\leadsto \frac{\sqrt{\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} \cdot \frac{\sqrt{1 - \cos x}}{x}\]
    7. Simplified0.5

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

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

      \[\leadsto \frac{\sqrt{\frac{{1}^{3} - \sqrt[3]{\color{blue}{{\left({\left(\cos x\right)}^{3}\right)}^{3}}}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\]
    11. Using strategy rm
    12. Applied add-sqr-sqrt0.5

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

    if -0.031199090863055844 < x < 0.031178573100862143

    1. Initial program 62.3

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}}\]

    if 0.031178573100862143 < x

    1. Initial program 1.0

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt1.1

      \[\leadsto \frac{\color{blue}{\sqrt{1 - \cos x} \cdot \sqrt{1 - \cos x}}}{x \cdot x}\]
    4. Applied times-frac0.6

      \[\leadsto \color{blue}{\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}}\]
    5. Using strategy rm
    6. Applied flip3--0.6

      \[\leadsto \frac{\sqrt{\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} \cdot \frac{\sqrt{1 - \cos x}}{x}\]
    7. Simplified0.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.0311990908630558443:\\ \;\;\;\;\frac{\sqrt{\frac{\sqrt{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}} \cdot \sqrt{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \mathbf{elif}\;x \le 0.0311785731008621426:\\ \;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \end{array}\]

Reproduce

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