← Back to context

Comment by belter

1 year ago

> Strictly speaking, the rational number 1 is not the same as the integer 1

So does that mean you can have different 0 zero's ?

Yes. 0/1, 0/2, 0/3 are all different in some sense, but they belong in the same equivalence class.

  • Even there, it would help to not apply the zero numerator equivalence class too early.

    I.e. 2/3, 2/5, 2/7 are the numbers that divide 2 to get 3, 5 and 7 respectively.

    Likewise, with full consistency, 0/1, 0/2, 0/3 cannot be reduced using common factors (the core equivalence for ratios), so have different ratio normal forms, and are the numbers that when they divide 0 produce 1, 2, and 3 respectively. All consistently.

    The advantage of not applying zero numerator equivalence too early, is that you get reversibility, associativity and commutivity consistency in intermediate calculations even when zeros appear in ratios.

    You can still apply zero numerator ratio equivalence to final values, but avoid a lot of reordering of intermediate calculations required to avoid errors if you had applied it earlier.

    Of course, if you are coding it doesn't help that you are unlikely to find any numerical libraries, functions or numeric data types, that don't assume division by zero is an error, inf, or NaN, and that all zeros divided by non-zero numbers are equivalent to 0. So you simply can't get the benefits of holding off on that equivalence.

    You have to do a lot of reasoning and reordering to ensure generally correct results, as apposed to "I am sure it will be fine" results.

    I find it very surprising that this separate treatment of factor reduced equivalence, and zero numerator (and zero denominator) equivalences, on ratios, is not taught more explicitly. They are very different kinds of equivalence, with very different impacts on calculation paths.

    • Thanks!

      I was actually toying with writing a rational number library going in the direction you sketch out. My inspiration was a trick in computational geometry for dealing with points at infinity. I think it's called homogeneous coordinates.

      My point was to treat both p and q in p/q as symmetrically as possible.

      Oh, I remember now: the motivating example was to write a nice implementation of an optimal player for the 'guessing game' for rational numbers.

      One player, Alice, commits to a (rational) number. The other player, Bob, makes guesses, and Alice answers whether the guess was too high, too low or was correct. Bob can solve this in O(log p + log q). And the continued-fraction-based strategy Bob wants to use is generally symmetrical between p and q. So I was looking into expressing the code as symmetrically as possible, too.

    • How is the case of the zero numerator special? When you take any fraction 0/n with n>0 and reduce it by the greatest common factor, you get 0/1.

      3 replies →

  • Which can be made "visible" by substituting 0 with e.g. `1 - 1`:

       0/1 = (1 - 1)/1 = 1/1 - 1/1
       0/2 = (1 - 1)/2 = 1/2 - 1/2
       ...

Note how your parent comment has specified "rational" 1 and "integer" 1. They use the symbol 1 for two similar concepts: We all "know" that 1 + 1 = 2 and 1.0 + 1.0 = 2.0. I have deliberately specified 1 for an int and 1.0 for a rational. Now we have two different representations for two very similar but not identical concepts.

At which point does 1 + a tiny amount cease to be an integer? By definition that tiny amount can have any magnitude and 1 plus anything will cease to be an integer. That is the property that defines an integer. Integers have subsequent "behaviours" that other types of numbers might lack.

You have picked zero/0. Now that is a sodding complicated concept 8) There are lots of things called zero but no more nor less than any other.

Zero might be defined by: 1 - 1 = 0. I have £1 in my bank account and I pay out £1 for a very small flower, my bank balance is now £0. Lovely model, all good except that interest calcs intervened and I actually have a balance of £0.00031. Blast. My pretty integer has morphed into a bloody complicated ... well is it a rational thingie or a ... what is it?

Now I want to withdraw my balance. I put a shiny £1 in, bought something and I have some change. What on earth does a 0.031p coin look like? Obviously, it doesn't exist. My lovely integer account has gone rational.

Symbols mean what we agree on with some carefully and well chosen language. Mathematicians seem to think they are the ultimate aces at using spoken and written language to make formal definitions, derivations and so on. That is a bit unfair, obviously. We all believe that what we think is communicable in some way. Perhaps it is but I suspect that it isn't always.

Have a jolly good think about what zero, nothing, 0 and so on really mean. Concepts and their description to others is a really hard problem, that some funky symbols sort of helps with.

Yes there are loads of things called zero. If I had to guess: infinitely things are zero! Which infinity I could not say.