Go to the first, previous, next, last section, table of contents.

Types Tutorial Exercise 8

The first answer is pretty simple: `1 / (0 .. 10) = (0.1 .. inf)'. Since a number in the interval `(0 .. 10)' can get arbitrarily close to zero, its reciprocal can get arbitrarily large, so the answer is an interval that effectively means, "any number greater than 0.1" but with no upper bound.

The second answer, similarly, is `1 / (-10 .. 0) = (-inf .. -0.1)'.

Calc normally treats division by zero as an error, so that the formula `1 / 0' is left unsimplified. Our third problem, `1 / [0 .. 10]', also (potentially) divides by zero because zero is now a member of the interval. So Calc leaves this one unevaluated, too.

If you turn on "infinite" mode by pressing m i, you will instead get the answer `[0.1 .. inf]', which includes infinity as a possible value.

The fourth calculation, `1 / (-10 .. 10)', has the same problem. Zero is buried inside the interval, but it's still a possible value. It's not hard to see that the actual result of `1 / (-10 .. 10)' will be either greater than 0.1, or less than -0.1. Thus the interval goes from minus infinity to plus infinity, with a "hole" in it from -0.1 to 0.1. Calc doesn't have any way to represent this, so it just reports `[-inf .. inf]' as the answer. It may be disappointing to hear "the answer lies somewhere between minus infinity and plus infinity, inclusive," but that's the best that interval arithmetic can do in this case.


Go to the first, previous, next, last section, table of contents.