Wednesday, 28 November 2012

Bike-riding & Math: My bike’s odometer makes me ‘crazy’

My bike’s odometer is not working properly. If all is well, it should get incremented properly to show the total distance that the bike travelled. It has five digits. Third digit from left stopped at ‘2’. By that time the first two digits (from left) were showing 4 and 8 respectively. As a result, the first three digits are not moving ahead from the figure ‘482’ even if the last two digits are working properly (I mean, last two digits getting incremented properly). This faulty meter is always running in the range: ‘48200’ to ‘48299’.

It reminds me about the decimal number system. What might be the logic behind the implementation of odometer’s functionality?
It has five digits. Each digit can take numbers from 0 to 9. Each digit gets incremented by one number starting from ‘0’ up to ‘9’ and returns back to ‘0’ after ‘9’. Each digit follows a cycle of 10 numbers (‘0’ to ‘9’ and back to ‘0’). When a digit reaches 9, and in the next instance, when it moves to ‘0’, its adjacent digit (digit at its immediate left) gets incremented by 1. This logic seems okay for all the digits except for the left most one as it doesn’t have a digit to its left. For the extreme left digit, when the turn comes that it moves from 9 to 0, all the other four digits also change to ‘0’ (by that time all those digits show 9’s), such that the meter gets reset and all-zeroes figure appears. It can be explained in a better way like this: When the magic figure 99999 appears on the meter, the next turn is initiated from the right most digit. The right  most digit changes from ‘9’ to ‘0’ and initiates movement of second-right digit from ‘9’ to ‘0’, which triggers third-right digit to change to ‘0’, which very action triggers fourth-right digit to change to ‘0’ and all this cascading effect triggers finally the fifth-right (or left-most) digit to change to ‘0’. In all, the range of the meter is from ‘00000’ to ‘99999’.

That’s fine. But the odometer continues to haunt me. It reminds me about the frequency with which each digit changes. In the meter’s overall journey from 00000 to 99999, how many times does the left-most digit change? What about the right-most digit?

The key lies in the very fact that “when each digit completes its full turn of 10 levels (0-to-9) and changes from 9 to 0, its immediate-left digit changes by 1 level”.  Here I stress upon the usage of numbers 10 and 1. I can say it in the other way like this: “By the time a digit turns up 1 level, its immediate-right digit turns by 10 levels”. So if the frequency of a digit is ‘f’ then the frequency of its immediate right digit is ‘10f’.

Now let us start with the left most digit. By the time meter runs from 00000 to 99999, the left most digit runs through its full turn (ie, from 0 to 9) by one time. So if we define ‘frequency’ as ‘number of times a digit changes through’, the frequency of left most digit can be taken as ‘10’. From then on we can easily calculate the frequencies of other successive digits by simply going for successive 10-multiples. The frequency of second-left digit is 10*10=100, that of third-left digit is 1000, that of fourth-left digit is 10000 and that of fifth-left (or right-most) digit is 100000.

If all is well, by the time my bike completes ‘99999’ kilometres of journey, the right most digit of odometer completes ‘100000’ turns.

When you go for next ride and when you casually look at the odometer, I hope it would not make you think about all this and that and go crazy.

Happy bike riding... 

No comments:

Post a Comment