Average Error: 31.7 → 0.1
Time: 5.0s
Precision: binary64
\[\frac{1 - \cos x}{x \cdot x} \]
\[\frac{\tan \left(x \cdot 0.5\right) \cdot \frac{\sin x}{x}}{x} \]
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x) :precision binary64 (/ (* (tan (* x 0.5)) (/ (sin x) x)) x))
double code(double x) {
	return (1.0 - cos(x)) / (x * x);
}
double code(double x) {
	return (tan((x * 0.5)) * (sin(x) / x)) / x;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 - cos(x)) / (x * x)
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = (tan((x * 0.5d0)) * (sin(x) / x)) / x
end function
public static double code(double x) {
	return (1.0 - Math.cos(x)) / (x * x);
}
public static double code(double x) {
	return (Math.tan((x * 0.5)) * (Math.sin(x) / x)) / x;
}
def code(x):
	return (1.0 - math.cos(x)) / (x * x)
def code(x):
	return (math.tan((x * 0.5)) * (math.sin(x) / x)) / x
function code(x)
	return Float64(Float64(1.0 - cos(x)) / Float64(x * x))
end
function code(x)
	return Float64(Float64(tan(Float64(x * 0.5)) * Float64(sin(x) / x)) / x)
end
function tmp = code(x)
	tmp = (1.0 - cos(x)) / (x * x);
end
function tmp = code(x)
	tmp = (tan((x * 0.5)) * (sin(x) / x)) / x;
end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[Tan[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\frac{1 - \cos x}{x \cdot x}
\frac{\tan \left(x \cdot 0.5\right) \cdot \frac{\sin x}{x}}{x}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 31.7

    \[\frac{1 - \cos x}{x \cdot x} \]
  2. Applied egg-rr16.2

    \[\leadsto \frac{\color{blue}{\frac{\sin x \cdot \sin x}{1 + \cos x}}}{x \cdot x} \]
  3. Taylor expanded in x around inf 16.0

    \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{\left(1 + \cos x\right) \cdot {x}^{2}}} \]
  4. Applied egg-rr16.2

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right) \cdot \frac{\sin x}{x \cdot x}} \]
  5. Applied egg-rr0.1

    \[\leadsto \color{blue}{\frac{\tan \left(x \cdot 0.5\right) \cdot \frac{\sin x}{x}}{x}} \]
  6. Final simplification0.1

    \[\leadsto \frac{\tan \left(x \cdot 0.5\right) \cdot \frac{\sin x}{x}}{x} \]

Reproduce

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