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

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

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

\end{array}
double f(double x) {
        double r28628 = 1.0;
        double r28629 = x;
        double r28630 = cos(r28629);
        double r28631 = r28628 - r28630;
        double r28632 = r28629 * r28629;
        double r28633 = r28631 / r28632;
        return r28633;
}

double f(double x) {
        double r28634 = x;
        double r28635 = -0.0295890883960637;
        bool r28636 = r28634 <= r28635;
        double r28637 = 1.0;
        double r28638 = 3.0;
        double r28639 = pow(r28637, r28638);
        double r28640 = cos(r28634);
        double r28641 = cbrt(r28640);
        double r28642 = pow(r28641, r28638);
        double r28643 = 2.0;
        double r28644 = pow(r28640, r28643);
        double r28645 = r28642 * r28644;
        double r28646 = r28639 - r28645;
        double r28647 = sqrt(r28646);
        double r28648 = r28637 * r28637;
        double r28649 = r28640 * r28640;
        double r28650 = r28637 * r28640;
        double r28651 = r28649 + r28650;
        double r28652 = r28648 + r28651;
        double r28653 = sqrt(r28652);
        double r28654 = r28634 * r28653;
        double r28655 = r28647 / r28654;
        double r28656 = r28637 - r28640;
        double r28657 = sqrt(r28656);
        double r28658 = r28657 / r28634;
        double r28659 = r28655 * r28658;
        double r28660 = 0.022874134562334194;
        bool r28661 = r28634 <= r28660;
        double r28662 = 0.001388888888888889;
        double r28663 = 4.0;
        double r28664 = pow(r28634, r28663);
        double r28665 = r28662 * r28664;
        double r28666 = 0.5;
        double r28667 = r28665 + r28666;
        double r28668 = 0.041666666666666664;
        double r28669 = pow(r28634, r28643);
        double r28670 = r28668 * r28669;
        double r28671 = r28667 - r28670;
        double r28672 = 6.0;
        double r28673 = pow(r28637, r28672);
        double r28674 = pow(r28640, r28672);
        double r28675 = r28673 - r28674;
        double r28676 = pow(r28640, r28638);
        double r28677 = r28676 + r28639;
        double r28678 = r28675 / r28677;
        double r28679 = sqrt(r28678);
        double r28680 = r28679 / r28654;
        double r28681 = r28680 * r28658;
        double r28682 = r28661 ? r28671 : r28681;
        double r28683 = r28636 ? r28659 : r28682;
        return r28683;
}

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

    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. Applied sqrt-div0.6

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

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

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

      \[\leadsto \frac{\sqrt{{1}^{3} - \log \left(e^{{\color{blue}{\left(\left(\sqrt[3]{\cos x} \cdot \sqrt[3]{\cos x}\right) \cdot \sqrt[3]{\cos x}\right)}}^{3}}\right)}}{x \cdot \sqrt{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}} \cdot \frac{\sqrt{1 - \cos x}}{x}\]
    13. Applied unpow-prod-down0.8

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

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

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

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

    if -0.0295890883960637 < x < 0.022874134562334194

    1. Initial program 62.4

      \[\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.022874134562334194 < x

    1. Initial program 1.1

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

      \[\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.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. Applied sqrt-div0.5

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

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

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

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

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

      \[\leadsto \frac{\sqrt{\frac{{1}^{6} - {\left(\cos x\right)}^{6}}{\color{blue}{{\left(\cos x\right)}^{3} + {1}^{3}}}}}{x \cdot \sqrt{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}} \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.02958908839606369869934532346178457373753:\\ \;\;\;\;\frac{\sqrt{{1}^{3} - {\left(\sqrt[3]{\cos x}\right)}^{3} \cdot {\left(\cos x\right)}^{2}}}{x \cdot \sqrt{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \mathbf{elif}\;x \le 0.02287413456233419392638062106470897560939:\\ \;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{{1}^{6} - {\left(\cos x\right)}^{6}}{{\left(\cos x\right)}^{3} + {1}^{3}}}}{x \cdot \sqrt{1 \cdot 1 + \left(\cos x \cdot \cos x + 1 \cdot \cos x\right)}} \cdot \frac{\sqrt{1 - \cos x}}{x}\\ \end{array}\]

Reproduce

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