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

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

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

\end{array}
double f(double x) {
        double r735943 = 1.0;
        double r735944 = x;
        double r735945 = cos(r735944);
        double r735946 = r735943 - r735945;
        double r735947 = r735944 * r735944;
        double r735948 = r735946 / r735947;
        return r735948;
}

double f(double x) {
        double r735949 = x;
        double r735950 = -0.031614486696612494;
        bool r735951 = r735949 <= r735950;
        double r735952 = 1.0;
        double r735953 = r735952 * r735952;
        double r735954 = r735952 * r735953;
        double r735955 = 2.0;
        double r735956 = r735955 * r735949;
        double r735957 = cos(r735956);
        double r735958 = 0.5;
        double r735959 = r735957 * r735958;
        double r735960 = r735959 + r735958;
        double r735961 = cos(r735949);
        double r735962 = r735960 * r735961;
        double r735963 = r735954 - r735962;
        double r735964 = exp(r735963);
        double r735965 = log(r735964);
        double r735966 = r735952 + r735961;
        double r735967 = r735961 * r735966;
        double r735968 = r735953 + r735967;
        double r735969 = r735949 * r735968;
        double r735970 = r735965 / r735969;
        double r735971 = r735970 / r735949;
        double r735972 = 0.029235651627996857;
        bool r735973 = r735949 <= r735972;
        double r735974 = r735949 * r735949;
        double r735975 = 0.001388888888888889;
        double r735976 = r735974 * r735975;
        double r735977 = 0.041666666666666664;
        double r735978 = r735976 - r735977;
        double r735979 = r735974 * r735978;
        double r735980 = r735979 + r735958;
        double r735981 = 3.0;
        double r735982 = pow(r735952, r735981);
        double r735983 = pow(r735961, r735981);
        double r735984 = r735982 - r735983;
        double r735985 = r735967 * r735967;
        double r735986 = r735967 * r735985;
        double r735987 = cbrt(r735986);
        double r735988 = r735987 + r735953;
        double r735989 = r735949 * r735988;
        double r735990 = r735984 / r735989;
        double r735991 = r735990 / r735949;
        double r735992 = r735973 ? r735980 : r735991;
        double r735993 = r735951 ? r735971 : r735992;
        return r735993;
}

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

    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}{x \cdot \left(\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1\right)}}}{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)}}{x \cdot \left(\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1\right)}}{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)}{x \cdot \left(\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1\right)}}{x}\]
    11. Applied diff-log0.5

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

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

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

    if -0.031614486696612494 < x < 0.029235651627996857

    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}}\]
    3. Simplified0.0

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

    if 0.029235651627996857 < x

    1. Initial program 1.1

      \[\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}{x \cdot \left(\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1\right)}}}{x}\]
    8. Using strategy rm
    9. Applied add-cbrt-cube0.5

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

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

Reproduce

herbie shell --seed 2019170 
(FPCore (x)
  :name "cos2 (problem 3.4.1)"
  (/ (- 1.0 (cos x)) (* x x)))