Average Error: 31.4 → 0.2
Time: 4.6s
Precision: binary64
\[\]
\[\]
double code(double x) {
	return ((double) (((double) (1.0 - ((double) cos(x)))) / ((double) (x * x))));
}
double code(double x) {
	double VAR;
	if (((x <= -0.02996085913414137) || !(x <= 0.03290940923071691))) {
		VAR = ((double) (((double) (1.0 / ((double) (x / ((double) (1.0 - ((double) cos(x)))))))) / x));
	} else {
		VAR = ((double) (((double) (((double) pow(x, 4.0)) * 0.001388888888888889)) + ((double) (0.5 - ((double) (x * ((double) (x * 0.041666666666666664))))))));
	}
	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 2 regimes
  2. if x < -0.02996085913414137 or 0.0329094092307169114 < x

    1. Initial program 1.0

      \[\]
    2. Using strategy rm
    3. Applied associate-/r*0.5

      \[\leadsto \]
    4. Using strategy rm
    5. Applied clear-num0.5

      \[\leadsto \]

    if -0.02996085913414137 < x < 0.0329094092307169114

    1. Initial program 62.3

      \[\]
    2. Taylor expanded around 0 0.0

      \[\leadsto \]
    3. Simplified0.0

      \[\leadsto \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \]

Reproduce

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