Average Error: 31.4 → 0.1
Time: 6.8s
Precision: binary64
\[\frac{1 - \cos x}{x \cdot x} \]
\[\frac{\sin x \cdot \frac{\tan \left(\frac{x}{2}\right)}{x}}{x} \]
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x) :precision binary64 (/ (* (sin x) (/ (tan (/ x 2.0)) x)) x))
double code(double x) {
	return (1.0 - cos(x)) / (x * x);
}
double code(double x) {
	return (sin(x) * (tan((x / 2.0)) / 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 = (sin(x) * (tan((x / 2.0d0)) / 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.sin(x) * (Math.tan((x / 2.0)) / x)) / x;
}
def code(x):
	return (1.0 - math.cos(x)) / (x * x)
def code(x):
	return (math.sin(x) * (math.tan((x / 2.0)) / x)) / x
function code(x)
	return Float64(Float64(1.0 - cos(x)) / Float64(x * x))
end
function code(x)
	return Float64(Float64(sin(x) * Float64(tan(Float64(x / 2.0)) / x)) / x)
end
function tmp = code(x)
	tmp = (1.0 - cos(x)) / (x * x);
end
function tmp = code(x)
	tmp = (sin(x) * (tan((x / 2.0)) / x)) / x;
end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[Sin[x], $MachinePrecision] * N[(N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\frac{1 - \cos x}{x \cdot x}
\frac{\sin x \cdot \frac{\tan \left(\frac{x}{2}\right)}{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.4

    \[\frac{1 - \cos x}{x \cdot x} \]
  2. Applied flip--_binary6431.5

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}}{x \cdot x} \]
  3. Simplified16.1

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

    \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{\left(1 + \cos x\right) \cdot {x}^{2}}} \]
  5. Simplified0.1

    \[\leadsto \color{blue}{\frac{\sin x}{x} \cdot \frac{\tan \left(\frac{x}{2}\right)}{x}} \]
  6. Applied associate-*l/_binary640.1

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

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

Reproduce

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