Average Error: 32.0 → 0.3
Time: 4.6s
Precision: 64
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02893782525956919982057513607287546619773 \lor \neg \left(x \le 0.02887089759792521928560837807253847131506\right):\\ \;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(0.001388888888888870076776527184847509488463 \cdot {x}^{4} + 0.5\right) - 0.04166666666666668517038374375260900706053 \cdot {x}^{2}\\ \end{array}\]
\frac{1 - \cos x}{x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \le -0.02893782525956919982057513607287546619773 \lor \neg \left(x \le 0.02887089759792521928560837807253847131506\right):\\
\;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\

\mathbf{else}:\\
\;\;\;\;\left(0.001388888888888870076776527184847509488463 \cdot {x}^{4} + 0.5\right) - 0.04166666666666668517038374375260900706053 \cdot {x}^{2}\\

\end{array}
double f(double x) {
        double r22989 = 1.0;
        double r22990 = x;
        double r22991 = cos(r22990);
        double r22992 = r22989 - r22991;
        double r22993 = r22990 * r22990;
        double r22994 = r22992 / r22993;
        return r22994;
}

double f(double x) {
        double r22995 = x;
        double r22996 = -0.0289378252595692;
        bool r22997 = r22995 <= r22996;
        double r22998 = 0.02887089759792522;
        bool r22999 = r22995 <= r22998;
        double r23000 = !r22999;
        bool r23001 = r22997 || r23000;
        double r23002 = 1.0;
        double r23003 = cos(r22995);
        double r23004 = r23002 - r23003;
        double r23005 = sqrt(r23004);
        double r23006 = r23005 / r22995;
        double r23007 = r23006 * r23006;
        double r23008 = 0.00138888888888887;
        double r23009 = 4.0;
        double r23010 = pow(r22995, r23009);
        double r23011 = r23008 * r23010;
        double r23012 = 0.5;
        double r23013 = r23011 + r23012;
        double r23014 = 0.041666666666666685;
        double r23015 = 2.0;
        double r23016 = pow(r22995, r23015);
        double r23017 = r23014 * r23016;
        double r23018 = r23013 - r23017;
        double r23019 = r23001 ? r23007 : r23018;
        return r23019;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -0.0289378252595692 or 0.02887089759792522 < 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.5

      \[\leadsto \color{blue}{\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}}\]

    if -0.0289378252595692 < x < 0.02887089759792522

    1. Initial program 62.3

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

      \[\leadsto \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 \cdot x}\]
    4. Applied associate-/l/62.3

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

      \[\leadsto \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}^{2}}}\]
    6. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\left(0.001388888888888870076776527184847509488463 \cdot {x}^{4} + 0.5\right) - 0.04166666666666668517038374375260900706053 \cdot {x}^{2}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.02893782525956919982057513607287546619773 \lor \neg \left(x \le 0.02887089759792521928560837807253847131506\right):\\ \;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(0.001388888888888870076776527184847509488463 \cdot {x}^{4} + 0.5\right) - 0.04166666666666668517038374375260900706053 \cdot {x}^{2}\\ \end{array}\]

Reproduce

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