|
If I understand this right, you're providing the 2 as a precision argument to (rational->xreal 2), the 4 to (rational->xreal 3), and the 10 to the result returned by add_xreal. That's definitely the wrong thing to do.
should be a function taking one rational argument and returning a ratintvl. You've made it into a function taking two rational arguments, producing a function taking one rational argument, and returning a ratintvl. So
should return a ratintvl of width at most 10 containing 5. (2 8) (representing the interval [2,8]) is an OK result. So is (0 10). But the most sensible result to get in this case is (5 5). The easiest way to implement rational->xreal is to return perfect precision no matter what the argument to the xreal asks for. You're always allowed to provide better precision than what was requested.
The general form of
The arguments for xr1 and xr2 can be computed very simply from the argument prec to (add_xreal xr1 xr2).
I suspect that the trivial nature of Mike O'D. |
Thanks by Rich Lusk, 2002, Nov 12
to: