| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 20096 |
\[0.16666666666666666 \cdot {x}^{2} + \left(-0.0007275132275132275 \cdot {x}^{6} + -0.06388888888888888 \cdot {x}^{4}\right)
\]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x)
:precision binary64
(+
(* -0.06388888888888888 (pow x 4.0))
(+
(+
(* 0.16666666666666666 (pow x 2.0))
(* -0.0007275132275132275 (pow x 6.0)))
(* -0.00023644179894179894 (pow x 8.0)))))double code(double x) {
return (x - sin(x)) / tan(x);
}
double code(double x) {
return (-0.06388888888888888 * pow(x, 4.0)) + (((0.16666666666666666 * pow(x, 2.0)) + (-0.0007275132275132275 * pow(x, 6.0))) + (-0.00023644179894179894 * pow(x, 8.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 = ((-0.06388888888888888d0) * (x ** 4.0d0)) + (((0.16666666666666666d0 * (x ** 2.0d0)) + ((-0.0007275132275132275d0) * (x ** 6.0d0))) + ((-0.00023644179894179894d0) * (x ** 8.0d0)))
end function
public static double code(double x) {
return (x - Math.sin(x)) / Math.tan(x);
}
public static double code(double x) {
return (-0.06388888888888888 * Math.pow(x, 4.0)) + (((0.16666666666666666 * Math.pow(x, 2.0)) + (-0.0007275132275132275 * Math.pow(x, 6.0))) + (-0.00023644179894179894 * Math.pow(x, 8.0)));
}
def code(x): return (x - math.sin(x)) / math.tan(x)
def code(x): return (-0.06388888888888888 * math.pow(x, 4.0)) + (((0.16666666666666666 * math.pow(x, 2.0)) + (-0.0007275132275132275 * math.pow(x, 6.0))) + (-0.00023644179894179894 * math.pow(x, 8.0)))
function code(x) return Float64(Float64(x - sin(x)) / tan(x)) end
function code(x) return Float64(Float64(-0.06388888888888888 * (x ^ 4.0)) + Float64(Float64(Float64(0.16666666666666666 * (x ^ 2.0)) + Float64(-0.0007275132275132275 * (x ^ 6.0))) + Float64(-0.00023644179894179894 * (x ^ 8.0)))) end
function tmp = code(x) tmp = (x - sin(x)) / tan(x); end
function tmp = code(x) tmp = (-0.06388888888888888 * (x ^ 4.0)) + (((0.16666666666666666 * (x ^ 2.0)) + (-0.0007275132275132275 * (x ^ 6.0))) + (-0.00023644179894179894 * (x ^ 8.0))); end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(-0.06388888888888888 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.16666666666666666 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0007275132275132275 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.00023644179894179894 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
-0.06388888888888888 \cdot {x}^{4} + \left(\left(0.16666666666666666 \cdot {x}^{2} + -0.0007275132275132275 \cdot {x}^{6}\right) + -0.00023644179894179894 \cdot {x}^{8}\right)
Results
| Original | 29.8 |
|---|---|
| Target | 0.8 |
| Herbie | 0.3 |
Initial program 29.8
Taylor expanded in x around 0 0.3
Simplified0.3
[Start]0.3 | \[ 0.16666666666666666 \cdot {x}^{2} + \left(-0.00023644179894179894 \cdot {x}^{8} + \left(-0.0007275132275132275 \cdot {x}^{6} + -0.06388888888888888 \cdot {x}^{4}\right)\right)
\] |
|---|---|
rational.json-simplify-41 [=>]0.3 | \[ \color{blue}{-0.00023644179894179894 \cdot {x}^{8} + \left(\left(-0.0007275132275132275 \cdot {x}^{6} + -0.06388888888888888 \cdot {x}^{4}\right) + 0.16666666666666666 \cdot {x}^{2}\right)}
\] |
rational.json-simplify-1 [<=]0.3 | \[ -0.00023644179894179894 \cdot {x}^{8} + \color{blue}{\left(0.16666666666666666 \cdot {x}^{2} + \left(-0.0007275132275132275 \cdot {x}^{6} + -0.06388888888888888 \cdot {x}^{4}\right)\right)}
\] |
rational.json-simplify-1 [=>]0.3 | \[ -0.00023644179894179894 \cdot {x}^{8} + \left(0.16666666666666666 \cdot {x}^{2} + \color{blue}{\left(-0.06388888888888888 \cdot {x}^{4} + -0.0007275132275132275 \cdot {x}^{6}\right)}\right)
\] |
rational.json-simplify-41 [=>]0.3 | \[ -0.00023644179894179894 \cdot {x}^{8} + \color{blue}{\left(-0.06388888888888888 \cdot {x}^{4} + \left(-0.0007275132275132275 \cdot {x}^{6} + 0.16666666666666666 \cdot {x}^{2}\right)\right)}
\] |
rational.json-simplify-41 [=>]0.3 | \[ \color{blue}{-0.06388888888888888 \cdot {x}^{4} + \left(\left(-0.0007275132275132275 \cdot {x}^{6} + 0.16666666666666666 \cdot {x}^{2}\right) + -0.00023644179894179894 \cdot {x}^{8}\right)}
\] |
rational.json-simplify-1 [=>]0.3 | \[ -0.06388888888888888 \cdot {x}^{4} + \left(\color{blue}{\left(0.16666666666666666 \cdot {x}^{2} + -0.0007275132275132275 \cdot {x}^{6}\right)} + -0.00023644179894179894 \cdot {x}^{8}\right)
\] |
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 20096 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 13376 |
| Alternative 3 | |
|---|---|
| Error | 0.8 |
| Cost | 6656 |
| Alternative 4 | |
|---|---|
| Error | 61.3 |
| Cost | 6592 |
| Alternative 5 | |
|---|---|
| Error | 61.3 |
| Cost | 64 |
herbie shell --seed 2023074
(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)))