| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13376 |
\[\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) (/ 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}}
Results
Initial program 31.6
Applied egg-rr16.1
Simplified16.0
Applied egg-rr0.1
Applied egg-rr0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13376 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 7240 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 7113 |
| Alternative 4 | |
|---|---|
| Error | 0.4 |
| Cost | 7112 |
| Alternative 5 | |
|---|---|
| Error | 15.3 |
| Cost | 328 |
| Alternative 6 | |
|---|---|
| Error | 46.3 |
| Cost | 64 |
herbie shell --seed 2022340
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))