Average Error: 31.8 → 0.4
Time: 5.4s
Precision: binary64
\[\frac{1 - \cos x}{x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -0.03368084982938704:\\ \;\;\;\;\frac{1}{x} \cdot \frac{\frac{\frac{{\left({1}^{3}\right)}^{3} - {\left({\left(\cos x\right)}^{3}\right)}^{3}}{{1}^{6} + \left({\left(\cos x\right)}^{6} + {1}^{3} \cdot {\left(\cos x\right)}^{3}\right)}}{1 \cdot 1 + \cos x \cdot \left(1 + \cos x\right)}}{x}\\ \mathbf{elif}\;x \leq 0.03609453174808888:\\ \;\;\;\;{x}^{4} \cdot 0.001388888888888889 + \left(0.5 + x \cdot \left(x \cdot -0.041666666666666664\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x \cdot \left(x \cdot \left(1 \cdot 1 + \cos x \cdot \left(1 + \cos x\right)\right)\right)}\\ \end{array}\]
\frac{1 - \cos x}{x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \leq -0.03368084982938704:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\frac{\frac{{\left({1}^{3}\right)}^{3} - {\left({\left(\cos x\right)}^{3}\right)}^{3}}{{1}^{6} + \left({\left(\cos x\right)}^{6} + {1}^{3} \cdot {\left(\cos x\right)}^{3}\right)}}{1 \cdot 1 + \cos x \cdot \left(1 + \cos x\right)}}{x}\\

\mathbf{elif}\;x \leq 0.03609453174808888:\\
\;\;\;\;{x}^{4} \cdot 0.001388888888888889 + \left(0.5 + x \cdot \left(x \cdot -0.041666666666666664\right)\right)\\

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

\end{array}
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x)
 :precision binary64
 (if (<= x -0.03368084982938704)
   (*
    (/ 1.0 x)
    (/
     (/
      (/
       (- (pow (pow 1.0 3.0) 3.0) (pow (pow (cos x) 3.0) 3.0))
       (+
        (pow 1.0 6.0)
        (+ (pow (cos x) 6.0) (* (pow 1.0 3.0) (pow (cos x) 3.0)))))
      (+ (* 1.0 1.0) (* (cos x) (+ 1.0 (cos x)))))
     x))
   (if (<= x 0.03609453174808888)
     (+
      (* (pow x 4.0) 0.001388888888888889)
      (+ 0.5 (* x (* x -0.041666666666666664))))
     (/
      (- (pow 1.0 3.0) (pow (cos x) 3.0))
      (* x (* x (+ (* 1.0 1.0) (* (cos x) (+ 1.0 (cos x))))))))))
double code(double x) {
	return (((double) (1.0 - ((double) cos(x)))) / ((double) (x * x)));
}
double code(double x) {
	double tmp;
	if ((x <= -0.03368084982938704)) {
		tmp = ((double) ((1.0 / x) * (((((double) (((double) pow(((double) pow(1.0, 3.0)), 3.0)) - ((double) pow(((double) pow(((double) cos(x)), 3.0)), 3.0)))) / ((double) (((double) pow(1.0, 6.0)) + ((double) (((double) pow(((double) cos(x)), 6.0)) + ((double) (((double) pow(1.0, 3.0)) * ((double) pow(((double) cos(x)), 3.0))))))))) / ((double) (((double) (1.0 * 1.0)) + ((double) (((double) cos(x)) * ((double) (1.0 + ((double) cos(x))))))))) / x)));
	} else {
		double tmp_1;
		if ((x <= 0.03609453174808888)) {
			tmp_1 = ((double) (((double) (((double) pow(x, 4.0)) * 0.001388888888888889)) + ((double) (0.5 + ((double) (x * ((double) (x * -0.041666666666666664))))))));
		} else {
			tmp_1 = (((double) (((double) pow(1.0, 3.0)) - ((double) pow(((double) cos(x)), 3.0)))) / ((double) (x * ((double) (x * ((double) (((double) (1.0 * 1.0)) + ((double) (((double) cos(x)) * ((double) (1.0 + ((double) cos(x)))))))))))));
		}
		tmp = tmp_1;
	}
	return tmp;
}

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

    1. Initial program Error: 1.2 bits

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Using strategy rm
    3. Applied *-un-lft-identityError: 1.2 bits

      \[\leadsto \frac{\color{blue}{1 \cdot \left(1 - \cos x\right)}}{x \cdot x}\]
    4. Applied times-fracError: 0.5 bits

      \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1 - \cos x}{x}}\]
    5. Using strategy rm
    6. Applied flip3--Error: 0.5 bits

      \[\leadsto \frac{1}{x} \cdot \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}\]
    7. SimplifiedError: 0.5 bits

      \[\leadsto \frac{1}{x} \cdot \frac{\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\color{blue}{1 \cdot 1 + \cos x \cdot \left(1 + \cos x\right)}}}{x}\]
    8. Using strategy rm
    9. Applied flip3--Error: 0.6 bits

      \[\leadsto \frac{1}{x} \cdot \frac{\frac{\color{blue}{\frac{{\left({1}^{3}\right)}^{3} - {\left({\left(\cos x\right)}^{3}\right)}^{3}}{{1}^{3} \cdot {1}^{3} + \left({\left(\cos x\right)}^{3} \cdot {\left(\cos x\right)}^{3} + {1}^{3} \cdot {\left(\cos x\right)}^{3}\right)}}}{1 \cdot 1 + \cos x \cdot \left(1 + \cos x\right)}}{x}\]
    10. SimplifiedError: 0.6 bits

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

    if -0.033680849829387037 < x < 0.036094531748088882

    1. Initial program Error: 62.3 bits

      \[\frac{1 - \cos x}{x \cdot x}\]
    2. Taylor expanded around 0 Error: 0.0 bits

      \[\leadsto \color{blue}{\left(0.001388888888888889 \cdot {x}^{4} + 0.5\right) - 0.041666666666666664 \cdot {x}^{2}}\]
    3. SimplifiedError: 0.0 bits

      \[\leadsto \color{blue}{{x}^{4} \cdot 0.001388888888888889 + \left(0.5 + x \cdot \left(x \cdot -0.041666666666666664\right)\right)}\]

    if 0.036094531748088882 < x

    1. Initial program Error: 1.0 bits

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

      \[\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/Error: 1.2 bits

      \[\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. SimplifiedError: 1.2 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.03368084982938704:\\ \;\;\;\;\frac{1}{x} \cdot \frac{\frac{\frac{{\left({1}^{3}\right)}^{3} - {\left({\left(\cos x\right)}^{3}\right)}^{3}}{{1}^{6} + \left({\left(\cos x\right)}^{6} + {1}^{3} \cdot {\left(\cos x\right)}^{3}\right)}}{1 \cdot 1 + \cos x \cdot \left(1 + \cos x\right)}}{x}\\ \mathbf{elif}\;x \leq 0.03609453174808888:\\ \;\;\;\;{x}^{4} \cdot 0.001388888888888889 + \left(0.5 + x \cdot \left(x \cdot -0.041666666666666664\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x \cdot \left(x \cdot \left(1 \cdot 1 + \cos x \cdot \left(1 + \cos x\right)\right)\right)}\\ \end{array}\]

Reproduce

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