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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 31.5

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

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

    \[\leadsto \frac{\color{blue}{\sin x \cdot \tan \left(\frac{x}{2}\right)}}{x \cdot x} \]
    Proof
    (*.f64 (sin.f64 x) (tan.f64 (/.f64 x 2))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sin.f64 x) (Rewrite<= hang-0p-tan_binary64 (/.f64 (sin.f64 x) (+.f64 1 (cos.f64 x))))): 38 points increase in error, 19 points decrease in error
    (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (sin.f64 x) (sin.f64 x)) (+.f64 1 (cos.f64 x)))): 26 points increase in error, 27 points decrease in error
    (/.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 (*.f64 (sin.f64 x) (sin.f64 x)) 1)) (+.f64 1 (cos.f64 x))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-*r/_binary64 (*.f64 (*.f64 (sin.f64 x) (sin.f64 x)) (/.f64 1 (+.f64 1 (cos.f64 x))))): 16 points increase in error, 19 points decrease in error
  4. Applied egg-rr0.1

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

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

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

Alternatives

Alternative 1
Error15.9
Cost13376
\[\tan \left(x \cdot 0.5\right) \cdot \frac{\sin x}{x \cdot x} \]
Alternative 2
Error0.1
Cost13376
\[\frac{\tan \left(x \cdot 0.5\right)}{x} \cdot \frac{\sin x}{x} \]
Alternative 3
Error0.1
Cost13376
\[\frac{\tan \left(x \cdot 0.5\right) \cdot \frac{\sin x}{x}}{x} \]
Alternative 4
Error30.7
Cost7040
\[\frac{\frac{1}{x} \cdot \left(\cos x + -1\right)}{-x} \]
Alternative 5
Error31.5
Cost6848
\[\frac{1 - \cos x}{x \cdot x} \]
Alternative 6
Error30.7
Cost6848
\[\frac{\frac{1 - \cos x}{x}}{x} \]

Error

Reproduce

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