(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x) :precision binary64 (* (/ (sin x) x) (/ (tan (* x 0.5)) x)))
double code(double x) {
return (1.0 - cos(x)) / (x * x);
}
double code(double x) {
return (sin(x) / x) * (tan((x * 0.5)) / 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) / x) * (tan((x * 0.5d0)) / 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) / x) * (Math.tan((x * 0.5)) / x);
}
def code(x): return (1.0 - math.cos(x)) / (x * x)
def code(x): return (math.sin(x) / x) * (math.tan((x * 0.5)) / x)
function code(x) return Float64(Float64(1.0 - cos(x)) / Float64(x * x)) end
function code(x) return Float64(Float64(sin(x) / x) * Float64(tan(Float64(x * 0.5)) / x)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / (x * x); end
function tmp = code(x) tmp = (sin(x) / x) * (tan((x * 0.5)) / 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] / x), $MachinePrecision] * N[(N[Tan[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\frac{1 - \cos x}{x \cdot x}
\frac{\sin x}{x} \cdot \frac{\tan \left(x \cdot 0.5\right)}{x}



Bits error versus x
Results
Initial program 31.7
Applied egg-rr16.1
Applied egg-rr16.1
Taylor expanded in x around inf 16.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2022150
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))