| Alternative 1 | |
|---|---|
| Error | 0.2% |
| 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 (/ (/ (- (sin x)) (/ x (tan (* x 0.5)))) (- x)))
double code(double x) {
return (1.0 - cos(x)) / (x * x);
}
double code(double x) {
return (-sin(x) / (x / tan((x * 0.5)))) / -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 = (-sin(x) / (x / tan((x * 0.5d0)))) / -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.sin(x) / (x / Math.tan((x * 0.5)))) / -x;
}
def code(x): return (1.0 - math.cos(x)) / (x * x)
def code(x): return (-math.sin(x) / (x / math.tan((x * 0.5)))) / -x
function code(x) return Float64(Float64(1.0 - cos(x)) / Float64(x * x)) end
function code(x) return Float64(Float64(Float64(-sin(x)) / Float64(x / tan(Float64(x * 0.5)))) / Float64(-x)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / (x * x); end
function tmp = code(x) tmp = (-sin(x) / (x / tan((x * 0.5)))) / -x; 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]) / N[(x / N[Tan[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision]
\frac{1 - \cos x}{x \cdot x}
\frac{\frac{-\sin x}{\frac{x}{\tan \left(x \cdot 0.5\right)}}}{-x}
Results
Initial program 48.81
Applied egg-rr25.09
Simplified24.8
[Start]25.09 | \[ \frac{\left(\sin x \cdot \sin x\right) \cdot \frac{1}{1 + \cos x}}{x \cdot x}
\] |
|---|---|
associate-*l* [=>]25.09 | \[ \frac{\color{blue}{\sin x \cdot \left(\sin x \cdot \frac{1}{1 + \cos x}\right)}}{x \cdot x}
\] |
associate-*r/ [=>]25.07 | \[ \frac{\sin x \cdot \color{blue}{\frac{\sin x \cdot 1}{1 + \cos x}}}{x \cdot x}
\] |
*-rgt-identity [=>]25.07 | \[ \frac{\sin x \cdot \frac{\color{blue}{\sin x}}{1 + \cos x}}{x \cdot x}
\] |
hang-0p-tan [=>]24.8 | \[ \frac{\sin x \cdot \color{blue}{\tan \left(\frac{x}{2}\right)}}{x \cdot x}
\] |
Applied egg-rr0.2
Applied egg-rr0.19
Final simplification0.19
| Alternative 1 | |
|---|---|
| Error | 0.2% |
| Cost | 13376 |
| Alternative 2 | |
|---|---|
| Error | 0.58% |
| Cost | 7240 |
| Alternative 3 | |
|---|---|
| Error | 0.59% |
| Cost | 7240 |
| Alternative 4 | |
|---|---|
| Error | 1% |
| Cost | 7113 |
| Alternative 5 | |
|---|---|
| Error | 0.55% |
| Cost | 7113 |
| Alternative 6 | |
|---|---|
| Error | 0.56% |
| Cost | 7112 |
| Alternative 7 | |
|---|---|
| Error | 21.66% |
| Cost | 969 |
| Alternative 8 | |
|---|---|
| Error | 21.66% |
| Cost | 968 |
| Alternative 9 | |
|---|---|
| Error | 21.66% |
| Cost | 713 |
| Alternative 10 | |
|---|---|
| Error | 21.95% |
| Cost | 585 |
| Alternative 11 | |
|---|---|
| Error | 48.72% |
| Cost | 64 |
herbie shell --seed 2023089
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))