Average Error: 31.7 → 0.1
Time: 9.1s
Precision: binary64
Cost: 13376
\[\frac{1 - \cos x}{x \cdot x} \]
\[\frac{\frac{\tan \left(x \cdot 0.5\right)}{x} \cdot \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(Float64(tan(Float64(x * 0.5)) / x) * 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[(N[Tan[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] * N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\frac{1 - \cos x}{x \cdot x}
\frac{\frac{\tan \left(x \cdot 0.5\right)}{x} \cdot \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-rr16.0

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

    \[\leadsto \frac{\color{blue}{\tan \left(\frac{x}{2}\right) \cdot \sin x}}{x \cdot x} \]
  4. Applied egg-rr16.0

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

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

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

Alternatives

Alternative 1
Error1.1
Cost7816
\[\begin{array}{l} t_0 := 1 - \cos x\\ \mathbf{if}\;x \leq -44255415973652.86:\\ \;\;\;\;\frac{\frac{1}{x}}{\frac{x}{t_0}}\\ \mathbf{elif}\;x \leq 0.004969832777992591:\\ \;\;\;\;\frac{1}{x \cdot \left(0.008333333333333333 \cdot {x}^{3} + \left(x \cdot 0.16666666666666666 + \frac{1}{x} \cdot 2\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{x}\\ \end{array} \]
Alternative 2
Error1.1
Cost7112
\[\begin{array}{l} t_0 := \frac{\frac{1 - \cos x}{x}}{x}\\ \mathbf{if}\;x \leq -44255415973652.86:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.004969832777992591:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.1
Cost7112
\[\begin{array}{l} t_0 := 1 - \cos x\\ \mathbf{if}\;x \leq -44255415973652.86:\\ \;\;\;\;\frac{\frac{1}{x}}{\frac{x}{t_0}}\\ \mathbf{elif}\;x \leq 0.004969832777992591:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{x}\\ \end{array} \]
Alternative 4
Error15.7
Cost968
\[\begin{array}{l} t_0 := \frac{1}{\frac{\frac{x \cdot x}{x \cdot 0.5}}{x}}\\ \mathbf{if}\;x \leq -44255415973652.86:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.004969832777992591:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error13.9
Cost832
\[\frac{1}{x \cdot \left(x \cdot 0.16666666666666666 + \frac{1}{x} \cdot 2\right)} \]
Alternative 6
Error30.7
Cost64
\[0.5 \]

Error

Reproduce

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