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.
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.
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.
The numerators and denominators of 0/2 and 0/3 do not have a common factor to reduce.
Think of 0 as a prime number for the purpose of ratio factor reduction.
Treating 0/2 and 0/3 as the same number is an entirely different equivalence.
2 replies →
Which can be made "visible" by substituting 0 with e.g. `1 - 1`: