Average Error: 31.5 → 0.5
Time: 4.5s
Precision: 64
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0327046735404788111:\\ \;\;\;\;\frac{{\left({\left(\log \left(e^{1 - \cos x}\right)\right)}^{\left(\sqrt{\frac{2}{3}}\right)}\right)}^{\left(\sqrt{\frac{2}{3}}\right)}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\\ \mathbf{elif}\;x \le 0.0291181343132320171:\\ \;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot {x}^{2}}\\ \end{array}\]
\frac{1 - \cos x}{x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \le -0.0327046735404788111:\\
\;\;\;\;\frac{{\left({\left(\log \left(e^{1 - \cos x}\right)\right)}^{\left(\sqrt{\frac{2}{3}}\right)}\right)}^{\left(\sqrt{\frac{2}{3}}\right)}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\\

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

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

\end{array}
double code(double x) {
	return ((double) (((double) (1.0 - ((double) cos(x)))) / ((double) (x * x))));
}
double code(double x) {
	double VAR;
	if ((x <= -0.03270467354047881)) {
		VAR = ((double) (((double) (((double) pow(((double) pow(((double) log(((double) exp(((double) (1.0 - ((double) cos(x)))))))), ((double) sqrt(0.6666666666666666)))), ((double) sqrt(0.6666666666666666)))) / x)) * ((double) (((double) cbrt(((double) (1.0 - ((double) cos(x)))))) / x))));
	} else {
		double VAR_1;
		if ((x <= 0.029118134313232017)) {
			VAR_1 = ((double) (((double) (((double) (0.001388888888888889 * ((double) pow(x, 4.0)))) + 0.5)) - ((double) (0.041666666666666664 * ((double) pow(x, 2.0))))));
		} else {
			VAR_1 = ((double) (((double) (((double) pow(1.0, 3.0)) - ((double) pow(((double) cos(x)), 3.0)))) / ((double) (((double) (((double) (((double) cos(x)) * ((double) (((double) cos(x)) + 1.0)))) + ((double) (1.0 * 1.0)))) * ((double) pow(x, 2.0))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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

    1. Initial program 1.2

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt1.6

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1 - \cos x} \cdot \sqrt[3]{1 - \cos x}\right) \cdot \sqrt[3]{1 - \cos x}}}{x \cdot x}\]
    4. Applied times-frac0.9

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1 - \cos x} \cdot \sqrt[3]{1 - \cos x}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}}\]
    5. Using strategy rm
    6. Applied pow1/30.8

      \[\leadsto \frac{\sqrt[3]{1 - \cos x} \cdot \color{blue}{{\left(1 - \cos x\right)}^{\frac{1}{3}}}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\]
    7. Applied pow1/30.7

      \[\leadsto \frac{\color{blue}{{\left(1 - \cos x\right)}^{\frac{1}{3}}} \cdot {\left(1 - \cos x\right)}^{\frac{1}{3}}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\]
    8. Applied pow-prod-up0.6

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

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

      \[\leadsto \frac{{\left(1 - \color{blue}{\log \left(e^{\cos x}\right)}\right)}^{\frac{2}{3}}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\]
    12. Applied add-log-exp0.7

      \[\leadsto \frac{{\left(\color{blue}{\log \left(e^{1}\right)} - \log \left(e^{\cos x}\right)\right)}^{\frac{2}{3}}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\]
    13. Applied diff-log0.7

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

      \[\leadsto \frac{{\left(\log \color{blue}{\left(e^{1 - \cos x}\right)}\right)}^{\frac{2}{3}}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\]
    15. Using strategy rm
    16. Applied add-sqr-sqrt0.7

      \[\leadsto \frac{{\left(\log \left(e^{1 - \cos x}\right)\right)}^{\color{blue}{\left(\sqrt{\frac{2}{3}} \cdot \sqrt{\frac{2}{3}}\right)}}}{x} \cdot \frac{\sqrt[3]{1 - \cos x}}{x}\]
    17. Applied pow-unpow0.7

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

    if -0.03270467354047881 < x < 0.029118134313232017

    1. Initial program 62.2

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

    1. Initial program 1.1

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

      \[\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/1.1

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

      \[\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}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.5

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

Reproduce

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