?

Average Accuracy: 50.6% → 99.8%
Time: 11.5s
Precision: binary64
Cost: 13376

?

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

    \[\frac{1 - \cos x}{x \cdot x} \]
  2. Applied egg-rr75.0%

    \[\leadsto \frac{\color{blue}{\left(\sin x \cdot \sin x\right) \cdot \frac{1}{1 + \cos x}}}{x \cdot x} \]
  3. Simplified75.3%

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

    [Start]75.0

    \[ \frac{\left(\sin x \cdot \sin x\right) \cdot \frac{1}{1 + \cos x}}{x \cdot x} \]

    associate-*l* [=>]75.0

    \[ \frac{\color{blue}{\sin x \cdot \left(\sin x \cdot \frac{1}{1 + \cos x}\right)}}{x \cdot x} \]

    associate-*r/ [=>]75.0

    \[ \frac{\sin x \cdot \color{blue}{\frac{\sin x \cdot 1}{1 + \cos x}}}{x \cdot x} \]

    *-rgt-identity [=>]75.0

    \[ \frac{\sin x \cdot \frac{\color{blue}{\sin x}}{1 + \cos x}}{x \cdot x} \]

    hang-0p-tan [=>]75.3

    \[ \frac{\sin x \cdot \color{blue}{\tan \left(\frac{x}{2}\right)}}{x \cdot x} \]
  4. Applied egg-rr99.8%

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

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

Alternatives

Alternative 1
Accuracy99.6%
Cost13448
\[\begin{array}{l} t_0 := 1 - \cos x\\ \mathbf{if}\;x \leq -0.0051:\\ \;\;\;\;\frac{\frac{1}{x} \cdot t_0}{x}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot {x}^{-2}\\ \end{array} \]
Alternative 2
Accuracy99.0%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0051 \lor \neg \left(x \leq 0.0055\right):\\ \;\;\;\;\frac{1 - \cos x}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \end{array} \]
Alternative 3
Accuracy99.6%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0051 \lor \neg \left(x \leq 0.0055\right):\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \end{array} \]
Alternative 4
Accuracy99.6%
Cost7112
\[\begin{array}{l} t_0 := 1 - \cos x\\ \mathbf{if}\;x \leq -0.0051:\\ \;\;\;\;\frac{\frac{1}{x} \cdot t_0}{x}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{x}\\ \end{array} \]
Alternative 5
Accuracy75.9%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -3.5:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 3.4:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 6
Accuracy76.0%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+77}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+77}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 7
Accuracy27.6%
Cost64
\[0 \]

Error

Reproduce?

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