Average Error: 31.5 → 0.4
Time: 5.3s
Precision: 64
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.029466469328828359:\\ \;\;\;\;\frac{\frac{{1}^{3} - \cos x \cdot {\left(\cos x\right)}^{2}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}{x \cdot x}\\ \mathbf{elif}\;x \le 0.03447109155992608:\\ \;\;\;\;\left(0.00138888888888887 \cdot {x}^{4} + 0.5\right) - 0.041666666666666685 \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x}}{{\left(\cos x\right)}^{2} \cdot \left(\left(\cos x + 1\right) \cdot \left(\cos x + 1\right)\right) + \left(-{1}^{3} \cdot 1\right)} \cdot \frac{\cos x \cdot \frac{{\left(\cos x\right)}^{2} - 1 \cdot 1}{\cos x - 1} - 1 \cdot 1}{x}\\ \end{array}\]
\frac{1 - \cos x}{x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \le -0.029466469328828359:\\
\;\;\;\;\frac{\frac{{1}^{3} - \cos x \cdot {\left(\cos x\right)}^{2}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}{x \cdot x}\\

\mathbf{elif}\;x \le 0.03447109155992608:\\
\;\;\;\;\left(0.00138888888888887 \cdot {x}^{4} + 0.5\right) - 0.041666666666666685 \cdot {x}^{2}\\

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

\end{array}
double f(double x) {
        double r23521 = 1.0;
        double r23522 = x;
        double r23523 = cos(r23522);
        double r23524 = r23521 - r23523;
        double r23525 = r23522 * r23522;
        double r23526 = r23524 / r23525;
        return r23526;
}

double f(double x) {
        double r23527 = x;
        double r23528 = -0.02946646932882836;
        bool r23529 = r23527 <= r23528;
        double r23530 = 1.0;
        double r23531 = 3.0;
        double r23532 = pow(r23530, r23531);
        double r23533 = cos(r23527);
        double r23534 = 2.0;
        double r23535 = pow(r23533, r23534);
        double r23536 = r23533 * r23535;
        double r23537 = r23532 - r23536;
        double r23538 = r23533 + r23530;
        double r23539 = r23533 * r23538;
        double r23540 = r23530 * r23530;
        double r23541 = r23539 + r23540;
        double r23542 = r23537 / r23541;
        double r23543 = r23527 * r23527;
        double r23544 = r23542 / r23543;
        double r23545 = 0.03447109155992608;
        bool r23546 = r23527 <= r23545;
        double r23547 = 0.00138888888888887;
        double r23548 = 4.0;
        double r23549 = pow(r23527, r23548);
        double r23550 = r23547 * r23549;
        double r23551 = 0.5;
        double r23552 = r23550 + r23551;
        double r23553 = 0.041666666666666685;
        double r23554 = pow(r23527, r23534);
        double r23555 = r23553 * r23554;
        double r23556 = r23552 - r23555;
        double r23557 = pow(r23533, r23531);
        double r23558 = r23532 - r23557;
        double r23559 = r23558 / r23527;
        double r23560 = r23538 * r23538;
        double r23561 = r23535 * r23560;
        double r23562 = r23532 * r23530;
        double r23563 = -r23562;
        double r23564 = r23561 + r23563;
        double r23565 = r23559 / r23564;
        double r23566 = r23535 - r23540;
        double r23567 = r23533 - r23530;
        double r23568 = r23566 / r23567;
        double r23569 = r23533 * r23568;
        double r23570 = r23569 - r23540;
        double r23571 = r23570 / r23527;
        double r23572 = r23565 * r23571;
        double r23573 = r23546 ? r23556 : r23572;
        double r23574 = r23529 ? r23544 : r23573;
        return r23574;
}

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

    1. Initial program 1.0

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

      \[\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. Simplified1.0

      \[\leadsto \frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\color{blue}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}}{x \cdot x}\]
    5. Using strategy rm
    6. Applied cube-mult1.0

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

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

    if -0.02946646932882836 < x < 0.03447109155992608

    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. Simplified62.3

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

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

    if 0.03447109155992608 < x

    1. Initial program 1.2

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

      \[\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. Simplified1.2

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x}}{{\left(\cos x\right)}^{2} \cdot \left(\left(\cos x + 1\right) \cdot \left(\cos x + 1\right)\right) + \left(-{1}^{3} \cdot 1\right)}} \cdot \frac{\cos x \cdot \left(\cos x + 1\right) - 1 \cdot 1}{x}\]
    10. Using strategy rm
    11. Applied flip-+0.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.029466469328828359:\\ \;\;\;\;\frac{\frac{{1}^{3} - \cos x \cdot {\left(\cos x\right)}^{2}}{\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1}}{x \cdot x}\\ \mathbf{elif}\;x \le 0.03447109155992608:\\ \;\;\;\;\left(0.00138888888888887 \cdot {x}^{4} + 0.5\right) - 0.041666666666666685 \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x}}{{\left(\cos x\right)}^{2} \cdot \left(\left(\cos x + 1\right) \cdot \left(\cos x + 1\right)\right) + \left(-{1}^{3} \cdot 1\right)} \cdot \frac{\cos x \cdot \frac{{\left(\cos x\right)}^{2} - 1 \cdot 1}{\cos x - 1} - 1 \cdot 1}{x}\\ \end{array}\]

Reproduce

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