?

Average Error: 31.6 → 0.1
Time: 12.5s
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.6

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

    \[\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. 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
Error0.4
Cost13508
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0004:\\ \;\;\;\;\tan \left(\frac{x}{2}\right) \cdot \frac{\sin x}{x \cdot x}\\ \mathbf{elif}\;x \leq 0.0052:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} + \cos x \cdot \frac{-1}{x}}{x}\\ \end{array} \]
Alternative 2
Error0.1
Cost13376
\[\frac{\sin x}{x} \cdot \frac{\tan \left(\frac{x}{2}\right)}{x} \]
Alternative 3
Error0.4
Cost7368
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0055:\\ \;\;\;\;\frac{-1}{\frac{x \cdot x}{\cos x + -1}}\\ \mathbf{elif}\;x \leq 0.0052:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} + \cos x \cdot \frac{-1}{x}}{x}\\ \end{array} \]
Alternative 4
Error0.4
Cost7240
\[\begin{array}{l} t_0 := 1 - \cos x\\ \mathbf{if}\;x \leq -0.0055:\\ \;\;\;\;\frac{t_0}{x \cdot x}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{t_0}{x}\\ \end{array} \]
Alternative 5
Error0.4
Cost7240
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0055:\\ \;\;\;\;\frac{-1}{\frac{x \cdot x}{\cos x + -1}}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\ \end{array} \]
Alternative 6
Error0.5
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0055 \lor \neg \left(x \leq 0.0055\right):\\ \;\;\;\;\frac{1 - \cos x}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \end{array} \]
Alternative 7
Error0.4
Cost7112
\[\begin{array}{l} t_0 := 1 - \cos x\\ \mathbf{if}\;x \leq -0.0055:\\ \;\;\;\;\frac{t_0}{x \cdot x}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{x}\\ \end{array} \]
Alternative 8
Error13.3
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2:\\ \;\;\;\;\frac{6}{x \cdot x}\\ \mathbf{elif}\;x \leq 2.1:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{0.16666666666666666 + \frac{2}{x \cdot x}}}{x \cdot x}\\ \end{array} \]
Alternative 9
Error13.3
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \lor \neg \left(x \leq 3.25\right):\\ \;\;\;\;\frac{6}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \end{array} \]
Alternative 10
Error13.5
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -3.5 \lor \neg \left(x \leq 3.5\right):\\ \;\;\;\;\frac{6}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 11
Error14.9
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{+77}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+77}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 12
Error46.0
Cost64
\[0 \]

Error

Reproduce?

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