| Alternative 1 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 320 |
\[0.16666666666666666 \cdot \left(x \cdot x\right)
\]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x) :precision binary64 (/ x (/ (* (/ (tan x) x) 6.0) x)))
double code(double x) {
return (x - sin(x)) / tan(x);
}
double code(double x) {
return x / (((tan(x) / x) * 6.0) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x - sin(x)) / tan(x)
end function
real(8) function code(x)
real(8), intent (in) :: x
code = x / (((tan(x) / x) * 6.0d0) / x)
end function
public static double code(double x) {
return (x - Math.sin(x)) / Math.tan(x);
}
public static double code(double x) {
return x / (((Math.tan(x) / x) * 6.0) / x);
}
def code(x): return (x - math.sin(x)) / math.tan(x)
def code(x): return x / (((math.tan(x) / x) * 6.0) / x)
function code(x) return Float64(Float64(x - sin(x)) / tan(x)) end
function code(x) return Float64(x / Float64(Float64(Float64(tan(x) / x) * 6.0) / x)) end
function tmp = code(x) tmp = (x - sin(x)) / tan(x); end
function tmp = code(x) tmp = x / (((tan(x) / x) * 6.0) / x); end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x / N[(N[(N[(N[Tan[x], $MachinePrecision] / x), $MachinePrecision] * 6.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
\frac{x}{\frac{\frac{\tan x}{x} \cdot 6}{x}}
Results
| Original | 52.5% |
|---|---|
| Target | 98.8% |
| Herbie | 99.0% |
Initial program 52.5%
Taylor expanded in x around 0 83.2%
Applied egg-rr98.9%
[Start]83.2 | \[ \frac{0.16666666666666666 \cdot {x}^{3}}{\tan x}
\] |
|---|---|
associate-/l* [=>]83.2 | \[ \color{blue}{\frac{0.16666666666666666}{\frac{\tan x}{{x}^{3}}}}
\] |
cube-mult [=>]83.2 | \[ \frac{0.16666666666666666}{\frac{\tan x}{\color{blue}{x \cdot \left(x \cdot x\right)}}}
\] |
associate-/r* [=>]97.9 | \[ \frac{0.16666666666666666}{\color{blue}{\frac{\frac{\tan x}{x}}{x \cdot x}}}
\] |
associate-/r/ [=>]98.9 | \[ \color{blue}{\frac{0.16666666666666666}{\frac{\tan x}{x}} \cdot \left(x \cdot x\right)}
\] |
Applied egg-rr99.0%
[Start]98.9 | \[ \frac{0.16666666666666666}{\frac{\tan x}{x}} \cdot \left(x \cdot x\right)
\] |
|---|---|
associate-*l/ [=>]98.9 | \[ \color{blue}{\frac{0.16666666666666666 \cdot \left(x \cdot x\right)}{\frac{\tan x}{x}}}
\] |
*-commutative [=>]98.9 | \[ \frac{\color{blue}{\left(x \cdot x\right) \cdot 0.16666666666666666}}{\frac{\tan x}{x}}
\] |
associate-/l* [=>]99.0 | \[ \color{blue}{\frac{x \cdot x}{\frac{\frac{\tan x}{x}}{0.16666666666666666}}}
\] |
associate-/l* [=>]99.0 | \[ \color{blue}{\frac{x}{\frac{\frac{\frac{\tan x}{x}}{0.16666666666666666}}{x}}}
\] |
div-inv [=>]99.0 | \[ \frac{x}{\frac{\color{blue}{\frac{\tan x}{x} \cdot \frac{1}{0.16666666666666666}}}{x}}
\] |
metadata-eval [=>]99.0 | \[ \frac{x}{\frac{\frac{\tan x}{x} \cdot \color{blue}{6}}{x}}
\] |
Final simplification99.0%
| Alternative 1 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 320 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 320 |
herbie shell --seed 2023133
(FPCore (x)
:name "ENA, Section 1.4, Exercise 4a"
:precision binary64
:pre (and (<= -1.0 x) (<= x 1.0))
:herbie-target
(* 0.16666666666666666 (* x x))
(/ (- x (sin x)) (tan x)))