?

Average Error: 31.7 → 0.1
Time: 11.3s
Precision: binary64
Cost: 13376

?

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

Error?

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-rr15.9

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

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

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

Alternatives

Alternative 1
Error0.3
Cost7304
\[\begin{array}{l} t_0 := \frac{x}{1 - \cos x}\\ \mathbf{if}\;x \leq -0.0056:\\ \;\;\;\;\frac{\frac{1}{x}}{t_0}\\ \mathbf{elif}\;x \leq 0.0051:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{t_0}}{-x}\\ \end{array} \]
Alternative 2
Error0.5
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0056 \lor \neg \left(x \leq 0.0051\right):\\ \;\;\;\;\frac{1 - \cos x}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \end{array} \]
Alternative 3
Error0.3
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0056 \lor \neg \left(x \leq 0.0051\right):\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \end{array} \]
Alternative 4
Error0.3
Cost7112
\[\begin{array}{l} t_0 := \frac{1 - \cos x}{x}\\ \mathbf{if}\;x \leq -0.0056:\\ \;\;\;\;\frac{1}{x} \cdot t_0\\ \mathbf{elif}\;x \leq 0.0051:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{x}\\ \end{array} \]
Alternative 5
Error0.3
Cost7112
\[\begin{array}{l} t_0 := 1 - \cos x\\ \mathbf{if}\;x \leq -0.0056:\\ \;\;\;\;\frac{\frac{1}{x}}{\frac{x}{t_0}}\\ \mathbf{elif}\;x \leq 0.0051:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{x}\\ \end{array} \]
Alternative 6
Error15.2
Cost905
\[\begin{array}{l} \mathbf{if}\;x \leq -3.45 \lor \neg \left(x \leq 3.5\right):\\ \;\;\;\;\frac{x - x}{x \cdot \left(x \cdot \left(-x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \end{array} \]
Alternative 7
Error13.6
Cost832
\[\frac{\frac{1}{x}}{x \cdot 0.16666666666666666 + 2 \cdot \frac{1}{x}} \]
Alternative 8
Error30.7
Cost64
\[0.5 \]

Error

Reproduce?

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