?

Average Error: 50.5% → 99.8%
Time: 14.5s
Precision: binary64
Cost: 13376.00

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 50.5

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

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

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

    [Start]75.1

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

    *-commutative [<=]75.1

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

    associate-*l/ [=>]75.1

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

    *-lft-identity [=>]75.1

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

    associate-*l/ [<=]75.1

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

    *-commutative [=>]75.1

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

    hang-0p-tan [=>]75.4

    \[ \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. Applied egg-rr99.8

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

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

Alternatives

Alternative 1
Error99.2%
Cost13640.00
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0068:\\ \;\;\;\;{x}^{-2} - \frac{\cos x}{x \cdot x}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-6}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\sin x \cdot \frac{\tan \left(x \cdot 0.5\right)}{x \cdot x}\\ \end{array} \]
Alternative 2
Error99.4%
Cost13640.00
\[\begin{array}{l} t_0 := \tan \left(x \cdot 0.5\right)\\ \mathbf{if}\;x \leq -0.0002:\\ \;\;\;\;t_0 \cdot \frac{\sin x}{x \cdot x}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-6}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\sin x \cdot \frac{t_0}{x \cdot x}\\ \end{array} \]
Alternative 3
Error99.3%
Cost13444.00
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0068:\\ \;\;\;\;{x}^{-2} - \frac{\cos x}{x \cdot x}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{x} \cdot \left(1 - \cos x\right)\\ \end{array} \]
Alternative 4
Error99.8%
Cost13376.00
\[\frac{\sin x}{x} \cdot \frac{\tan \left(x \cdot 0.5\right)}{x} \]
Alternative 5
Error99.6%
Cost7241.00
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0042 \lor \neg \left(x \leq 0.0055\right):\\ \;\;\;\;\frac{\frac{1}{x}}{x} \cdot \left(1 - \cos x\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \end{array} \]
Alternative 6
Error99.4%
Cost7240.00
\[\begin{array}{l} t_0 := 1 - \cos x\\ \mathbf{if}\;x \leq -0.0042:\\ \;\;\;\;\frac{1}{x \cdot \frac{x}{t_0}}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{x} \cdot t_0\\ \end{array} \]
Alternative 7
Error99.3%
Cost7240.00
\[\begin{array}{l} t_0 := \frac{\frac{1}{x}}{x}\\ \mathbf{if}\;x \leq -0.006:\\ \;\;\;\;t_0 - \frac{\cos x}{x \cdot x}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(1 - \cos x\right)\\ \end{array} \]
Alternative 8
Error99.5%
Cost7240.00
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0055:\\ \;\;\;\;\frac{\frac{1}{x} + \cos x \cdot \frac{-1}{x}}{x}\\ \mathbf{elif}\;x \leq 0.0055:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{x} \cdot \left(1 - \cos x\right)\\ \end{array} \]
Alternative 9
Error99.1%
Cost7113.00
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0042 \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 10
Error99.6%
Cost7113.00
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0042 \lor \neg \left(x \leq 0.0055\right):\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\ \end{array} \]
Alternative 11
Error78.0%
Cost1097.00
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0002 \lor \neg \left(x \leq 4 \cdot 10^{-39}\right):\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot \left(0.16666666666666666 + \frac{2}{x \cdot x}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \end{array} \]
Alternative 12
Error75.5%
Cost328.00
\[\begin{array}{l} \mathbf{if}\;x \leq -8.6 \cdot 10^{+76}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
Alternative 13
Error26.9%
Cost64.00
\[0 \]

Error

Reproduce?

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