?

Average Error: 49.19% → 0.2%
Time: 11.7s
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 49.19

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

    \[\leadsto \frac{\color{blue}{\frac{\sin x \cdot \sin x}{1 + \cos x}}}{x \cdot x} \]
  3. Taylor expanded in x around inf 25.08

    \[\leadsto \color{blue}{\frac{{\sin x}^{2}}{\left(1 + \cos x\right) \cdot {x}^{2}}} \]
  4. Simplified25.45

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

    [Start]25.08

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

    associate-/r* [=>]25.39

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

    unpow2 [=>]25.4

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

    associate-*r/ [<=]25.4

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

    unpow2 [=>]25.4

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

    associate-*l/ [<=]25.69

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

    hang-0p-tan [=>]25.45

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

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

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

Alternatives

Alternative 1
Error0.7%
Cost13376
\[\frac{\sin x}{\frac{x}{\frac{\tan \left(x \cdot 0.5\right)}{x}}} \]
Alternative 2
Error0.39%
Cost7240
\[\begin{array}{l} t_0 := -1 + \cos x\\ \mathbf{if}\;x \leq -0.032:\\ \;\;\;\;\frac{t_0 \cdot \frac{-1}{x}}{x}\\ \mathbf{elif}\;x \leq 0.033:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{\frac{x}{t_0}}}{x}\\ \end{array} \]
Alternative 3
Error0.86%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -0.032 \lor \neg \left(x \leq 0.033\right):\\ \;\;\;\;\frac{1 - \cos x}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\ \end{array} \]
Alternative 4
Error0.37%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -0.032 \lor \neg \left(x \leq 0.033\right):\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\ \end{array} \]
Alternative 5
Error0.39%
Cost7112
\[\begin{array}{l} t_0 := \frac{1 - \cos x}{x}\\ \mathbf{if}\;x \leq -0.032:\\ \;\;\;\;t_0 \cdot \frac{1}{x}\\ \mathbf{elif}\;x \leq 0.033:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{x}\\ \end{array} \]
Alternative 6
Error0.38%
Cost7112
\[\begin{array}{l} \mathbf{if}\;x \leq -0.032:\\ \;\;\;\;\frac{\left(-1 + \cos x\right) \cdot \frac{-1}{x}}{x}\\ \mathbf{elif}\;x \leq 0.033:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \end{array} \]
Alternative 7
Error21.66%
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8:\\ \;\;\;\;\frac{6}{x \cdot x}\\ \mathbf{elif}\;x \leq 3.9:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{6 - \frac{72}{x \cdot x}}{x \cdot x}\\ \end{array} \]
Alternative 8
Error21.76%
Cost968
\[\begin{array}{l} \mathbf{if}\;x \leq -3.3:\\ \;\;\;\;\frac{6}{x \cdot x}\\ \mathbf{elif}\;x \leq 3.4:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{6 - \frac{72}{x \cdot x}}{x \cdot x}\\ \end{array} \]
Alternative 9
Error21.76%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -3.3 \lor \neg \left(x \leq 3.3\right):\\ \;\;\;\;\frac{6}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \end{array} \]
Alternative 10
Error22.05%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -3.5 \lor \neg \left(x \leq 3.4\right):\\ \;\;\;\;\frac{6}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 11
Error48.46%
Cost64
\[0.5 \]

Error

Reproduce?

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