| Alternative 1 | |
|---|---|
| Error | 1.36% |
| Cost | 320 |
\[0.16666666666666666 \cdot \left(x \cdot x\right)
\]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x) :precision binary64 (+ (* x (* 0.16666666666666666 x)) (* -0.06388888888888888 (pow x 4.0))))
double code(double x) {
return (x - sin(x)) / tan(x);
}
double code(double x) {
return (x * (0.16666666666666666 * x)) + (-0.06388888888888888 * pow(x, 4.0));
}
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 * (0.16666666666666666d0 * x)) + ((-0.06388888888888888d0) * (x ** 4.0d0))
end function
public static double code(double x) {
return (x - Math.sin(x)) / Math.tan(x);
}
public static double code(double x) {
return (x * (0.16666666666666666 * x)) + (-0.06388888888888888 * Math.pow(x, 4.0));
}
def code(x): return (x - math.sin(x)) / math.tan(x)
def code(x): return (x * (0.16666666666666666 * x)) + (-0.06388888888888888 * math.pow(x, 4.0))
function code(x) return Float64(Float64(x - sin(x)) / tan(x)) end
function code(x) return Float64(Float64(x * Float64(0.16666666666666666 * x)) + Float64(-0.06388888888888888 * (x ^ 4.0))) end
function tmp = code(x) tmp = (x - sin(x)) / tan(x); end
function tmp = code(x) tmp = (x * (0.16666666666666666 * x)) + (-0.06388888888888888 * (x ^ 4.0)); end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * N[(0.16666666666666666 * x), $MachinePrecision]), $MachinePrecision] + N[(-0.06388888888888888 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
x \cdot \left(0.16666666666666666 \cdot x\right) + -0.06388888888888888 \cdot {x}^{4}
Results
| Original | 46.24% |
|---|---|
| Target | 1.36% |
| Herbie | 0.68% |
Initial program 46.24
Taylor expanded in x around 0 0.7
Simplified0.7
[Start]0.7 | \[ 0.16666666666666666 \cdot {x}^{2} + -0.06388888888888888 \cdot {x}^{4}
\] |
|---|---|
unpow2 [=>]0.7 | \[ 0.16666666666666666 \cdot \color{blue}{\left(x \cdot x\right)} + -0.06388888888888888 \cdot {x}^{4}
\] |
fma-def [=>]0.7 | \[ \color{blue}{\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.06388888888888888 \cdot {x}^{4}\right)}
\] |
Applied egg-rr0.68
Final simplification0.68
| Alternative 1 | |
|---|---|
| Error | 1.36% |
| Cost | 320 |
| Alternative 2 | |
|---|---|
| Error | 1.34% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Error | 1.27% |
| Cost | 320 |
herbie shell --seed 2023121
(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)))