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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 31.3

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

    \[\leadsto \frac{\color{blue}{\left(\sin x \cdot \sin x\right) \cdot \frac{1}{1 + \cos x}}}{x \cdot x} \]
  3. Applied egg-rr0.1

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

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

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

Alternatives

Alternative 1
Error1.4
Cost7112
\[\begin{array}{l} t_0 := \frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{if}\;x \leq -23225632.774201367:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.836132281765733 \cdot 10^{-16}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error14.0
Cost712
\[\begin{array}{l} t_0 := \frac{6}{x \cdot x}\\ \mathbf{if}\;x \leq -23225632.774201367:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.04590316606432221:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error14.1
Cost584
\[\begin{array}{l} t_0 := \frac{6}{x \cdot x}\\ \mathbf{if}\;x \leq -23225632.774201367:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.04590316606432221:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error13.9
Cost576
\[\frac{1}{0.16666666666666666 \cdot \left(x \cdot x\right) + 2} \]
Alternative 5
Error15.5
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.46328190275453 \cdot 10^{+85}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.861791091587785 \cdot 10^{+72}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 6
Error46.3
Cost64
\[0 \]

Error

Reproduce

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