# Fare Conversion

By Susam Pal on 24 Dec 2013

## Approximation Problem

Auto rickshaw fare in Bangalore was revised on Fri, 20 Dec 2013. The old rate for an auto rickshaw ride was a minimum of 20 rupees for the first 1.8 km and 11 rupees per km thereafter. The new rate is a minimum of 25 rupees for the first 1.9 km and 13 rupees per km thereafter.

It usually takes a few months for auto rickshaw drivers to upgrade their meters to display the fare as per the revised rate, so the old meters still display the fare as per the old rate. The auto rickshaw drivers carry printed conversion charts to look up the fare displayed on an old meter and convert it to the actual fare to be paid as per the new rate.

If an old meter displays the minimum fare of 20 rupees, we know that the actual fare to be paid is 25 rupees, the minimum as per the new fare rate. We will not discuss this case of minimum fare again in this post because this conversion is trivial and straightforward.

In the remaining post, we will now only consider the case where the fare displayed on the old meter is more than the minimum fare, i.e., when more than 1.8 km has been travelled. Is there a convenient way to quickly and mentally convert it to an approximation of the actual fare to be paid as per the new rate?

## Quick Approximation

Assuming an old meter displays a fare that exceeds the minimum fare of 20 rupees, here is a quick three-step method I arrived at to get an approximation of the actual fare as per the new rate:

1. Remove the units digit and the decimal digits from the fare displayed in the old meter.
2. Double the previous result.
3. Add the previous result to the fare displayed in the meter.

## Example

Let us do an example to see how accurately our three-step method can determine the actual fare. Let us assume that we travelled 8.3 km and the fare displayed on the old meter is 91.50 rupees.

1. Remove the units and decimal digits. We get 9.
2. Double 9. We get 18.
3. Add 18 to 91.50. We get 109.50.

The actual fare for 8.3 km as per the new rate is 108.20 rupees. Our three-step method overestimated the actual fare by 1.30 rupees only.

In fact, for any distance within 15 km, this three-step method may underestimate or overestimate the actual fare by a maximum of 2.70 rupees only. That's a pretty good approximation.

If you were looking only for a quick method to get an approximation of the actual fare as per the new rate, this is all you need to know. You may skip the remaining post unless you want to know why this method works.

## Exact Conversion Formula

Before we try to understand why the above three-step method works, let us obtain a conversion formula that would convert the fare displayed in an old meter to the exact actual fare to be paid.

If we take a ride for $$d$$ km, the fare displayed on an old meter is $$20 + 11 (d - 1.8)$$ rupees. But the actual fare to be paid as per the new rate is $$25 + 13 (d - 1.9)$$ rupees.

From the above formulae, we can see that if the fare displayed on an old meter is $$x$$ rupees, then we have travelled $$\frac{x - 0.2}{11}$$ km. Thus the actual fare as per the new rate is $$25 + 13 \left( \frac{x - 0.2}{11} - 1.9 \right)$$ rupees = $$\frac{13x + 0.7}{11}$$ rupees.

We have obtained at an exact conversion formula of $$y = \frac{13x + 0.7}{11}$$ where $$x$$ is the fare displayed on an old meter and $$y$$ is the actual fare to be paid as per the new rate.

## Approximate Conversion Formula

In this section, we will see why the three-step method works. First, we arrive at a formula that is equivalent to the three-step method. The three steps convert a displayed fare of $$x$$ to an approximation of actual fare $$\left\lfloor \frac{x}{10} \right\rfloor \cdot 2 + x$$ as follows:

1. Removing the units and decimal digits of $$x$$ gives us $$\left\lfloor \frac{x}{10} \right\rfloor.$$
2. Doubling the previous result gives us $$\left\lfloor\frac{x}{10} \right\rfloor \cdot 2.$$
3. Adding it to $$x$$ gives us $$\left\lfloor \frac{x}{10} \right\rfloor \cdot 2 + x.$$

We have obtained an approximate conversion formula of $$\overset{\approx}{y} = \left\lfloor \frac{x}{10} \right\rfloor \cdot 2 + x$$ where $$x$$ is the fare displayed on an old meter and $$\overset{\approx}{y}$$ is an approximation of the actual fare to be paid as per the new rate.

Is $$\overset{\approx}{y}$$ really a good approximation for $$y?$$ Yes, it is, as shown below: \begin{align*} y & = \frac{13x + 0.7}{11} \\ & = x + \frac{2x}{11} + \frac{0.7}{11} \\ & \approx x + \frac{2x}{10} \\ & \approx x + 2 \left\lfloor \frac{x}{10} \right\rfloor = \overset{\approx}{y}. \end{align*}

## Approximation Error

We have seen so far that the three-step method works and it provides a good estimate of the actual fare as per the new rate. However, since this is an approximation, the estimated fare has some error due to which it does not match the actual fare to be paid exactly. In this section, we will see how much that error is. It turns out the error is not too bad, so the three-step method can be used to quickly get a ballpark figure for the actual fare as per the revised fare rate.

The Python 3 code below shows for every 100 metres of ride, the displayed fare (meter) on an old meter, the actual fare (actual) as per the new rate, the approximate fare (approx) computed with the three-step method, and the difference (error) between the actual fare and approximate fare:

print('  km   meter  actual  approx  error')

km = 1.9

while km < 30.01:
old_fare = 20 if km <= 1.8 else 20 + 11 * (km - 1.8)
new_fare = 25 if km <= 1.9 else 25 + 13 * (km - 1.9)
approx_fare = (old_fare // 10) * 2 + old_fare
error = approx_fare - new_fare

print('{:4.1f}  {:6.2f}  {:6.2f}  {:6.2f}  {:5.2f}'.format(
km, old_fare, new_fare, approx_fare, error))

km += 0.1

The output of the above program is provided below. Scroll down to see the complete output.
  km   meter  actual  approx  error
1.9   21.10   25.00   25.10   0.10
2.0   22.20   26.30   26.20  -0.10
2.1   23.30   27.60   27.30  -0.30
2.2   24.40   28.90   28.40  -0.50
2.3   25.50   30.20   29.50  -0.70
2.4   26.60   31.50   30.60  -0.90
2.5   27.70   32.80   31.70  -1.10
2.6   28.80   34.10   32.80  -1.30
2.7   29.90   35.40   33.90  -1.50
2.8   31.00   36.70   37.00   0.30
2.9   32.10   38.00   38.10   0.10
3.0   33.20   39.30   39.20  -0.10
3.1   34.30   40.60   40.30  -0.30
3.2   35.40   41.90   41.40  -0.50
3.3   36.50   43.20   42.50  -0.70
3.4   37.60   44.50   43.60  -0.90
3.5   38.70   45.80   44.70  -1.10
3.6   39.80   47.10   45.80  -1.30
3.7   40.90   48.40   48.90   0.50
3.8   42.00   49.70   50.00   0.30
3.9   43.10   51.00   51.10   0.10
4.0   44.20   52.30   52.20  -0.10
4.1   45.30   53.60   53.30  -0.30
4.2   46.40   54.90   54.40  -0.50
4.3   47.50   56.20   55.50  -0.70
4.4   48.60   57.50   56.60  -0.90
4.5   49.70   58.80   57.70  -1.10
4.6   50.80   60.10   60.80   0.70
4.7   51.90   61.40   61.90   0.50
4.8   53.00   62.70   63.00   0.30
4.9   54.10   64.00   64.10   0.10
5.0   55.20   65.30   65.20  -0.10
5.1   56.30   66.60   66.30  -0.30
5.2   57.40   67.90   67.40  -0.50
5.3   58.50   69.20   68.50  -0.70
5.4   59.60   70.50   69.60  -0.90
5.5   60.70   71.80   72.70   0.90
5.6   61.80   73.10   73.80   0.70
5.7   62.90   74.40   74.90   0.50
5.8   64.00   75.70   76.00   0.30
5.9   65.10   77.00   77.10   0.10
6.0   66.20   78.30   78.20  -0.10
6.1   67.30   79.60   79.30  -0.30
6.2   68.40   80.90   80.40  -0.50
6.3   69.50   82.20   81.50  -0.70
6.4   70.60   83.50   84.60   1.10
6.5   71.70   84.80   85.70   0.90
6.6   72.80   86.10   86.80   0.70
6.7   73.90   87.40   87.90   0.50
6.8   75.00   88.70   89.00   0.30
6.9   76.10   90.00   90.10   0.10
7.0   77.20   91.30   91.20  -0.10
7.1   78.30   92.60   92.30  -0.30
7.2   79.40   93.90   93.40  -0.50
7.3   80.50   95.20   96.50   1.30
7.4   81.60   96.50   97.60   1.10
7.5   82.70   97.80   98.70   0.90
7.6   83.80   99.10   99.80   0.70
7.7   84.90  100.40  100.90   0.50
7.8   86.00  101.70  102.00   0.30
7.9   87.10  103.00  103.10   0.10
8.0   88.20  104.30  104.20  -0.10
8.1   89.30  105.60  105.30  -0.30
8.2   90.40  106.90  108.40   1.50
8.3   91.50  108.20  109.50   1.30
8.4   92.60  109.50  110.60   1.10
8.5   93.70  110.80  111.70   0.90
8.6   94.80  112.10  112.80   0.70
8.7   95.90  113.40  113.90   0.50
8.8   97.00  114.70  115.00   0.30
8.9   98.10  116.00  116.10   0.10
9.0   99.20  117.30  117.20  -0.10
9.1  100.30  118.60  120.30   1.70
9.2  101.40  119.90  121.40   1.50
9.3  102.50  121.20  122.50   1.30
9.4  103.60  122.50  123.60   1.10
9.5  104.70  123.80  124.70   0.90
9.6  105.80  125.10  125.80   0.70
9.7  106.90  126.40  126.90   0.50
9.8  108.00  127.70  128.00   0.30
9.9  109.10  129.00  129.10   0.10
10.0  110.20  130.30  132.20   1.90
10.1  111.30  131.60  133.30   1.70
10.2  112.40  132.90  134.40   1.50
10.3  113.50  134.20  135.50   1.30
10.4  114.60  135.50  136.60   1.10
10.5  115.70  136.80  137.70   0.90
10.6  116.80  138.10  138.80   0.70
10.7  117.90  139.40  139.90   0.50
10.8  119.00  140.70  141.00   0.30
10.9  120.10  142.00  144.10   2.10
11.0  121.20  143.30  145.20   1.90
11.1  122.30  144.60  146.30   1.70
11.2  123.40  145.90  147.40   1.50
11.3  124.50  147.20  148.50   1.30
11.4  125.60  148.50  149.60   1.10
11.5  126.70  149.80  150.70   0.90
11.6  127.80  151.10  151.80   0.70
11.7  128.90  152.40  152.90   0.50
11.8  130.00  153.70  154.00   0.30
11.9  131.10  155.00  157.10   2.10
12.0  132.20  156.30  158.20   1.90
12.1  133.30  157.60  159.30   1.70
12.2  134.40  158.90  160.40   1.50
12.3  135.50  160.20  161.50   1.30
12.4  136.60  161.50  162.60   1.10
12.5  137.70  162.80  163.70   0.90
12.6  138.80  164.10  164.80   0.70
12.7  139.90  165.40  165.90   0.50
12.8  141.00  166.70  169.00   2.30
12.9  142.10  168.00  170.10   2.10
13.0  143.20  169.30  171.20   1.90
13.1  144.30  170.60  172.30   1.70
13.2  145.40  171.90  173.40   1.50
13.3  146.50  173.20  174.50   1.30
13.4  147.60  174.50  175.60   1.10
13.5  148.70  175.80  176.70   0.90
13.6  149.80  177.10  177.80   0.70
13.7  150.90  178.40  180.90   2.50
13.8  152.00  179.70  182.00   2.30
13.9  153.10  181.00  183.10   2.10
14.0  154.20  182.30  184.20   1.90
14.1  155.30  183.60  185.30   1.70
14.2  156.40  184.90  186.40   1.50
14.3  157.50  186.20  187.50   1.30
14.4  158.60  187.50  188.60   1.10
14.5  159.70  188.80  189.70   0.90
14.6  160.80  190.10  192.80   2.70
14.7  161.90  191.40  193.90   2.50
14.8  163.00  192.70  195.00   2.30
14.9  164.10  194.00  196.10   2.10
15.0  165.20  195.30  197.20   1.90
15.1  166.30  196.60  198.30   1.70
15.2  167.40  197.90  199.40   1.50
15.3  168.50  199.20  200.50   1.30
15.4  169.60  200.50  201.60   1.10
15.5  170.70  201.80  204.70   2.90
15.6  171.80  203.10  205.80   2.70
15.7  172.90  204.40  206.90   2.50
15.8  174.00  205.70  208.00   2.30
15.9  175.10  207.00  209.10   2.10
16.0  176.20  208.30  210.20   1.90
16.1  177.30  209.60  211.30   1.70
16.2  178.40  210.90  212.40   1.50
16.3  179.50  212.20  213.50   1.30
16.4  180.60  213.50  216.60   3.10
16.5  181.70  214.80  217.70   2.90
16.6  182.80  216.10  218.80   2.70
16.7  183.90  217.40  219.90   2.50
16.8  185.00  218.70  221.00   2.30
16.9  186.10  220.00  222.10   2.10
17.0  187.20  221.30  223.20   1.90
17.1  188.30  222.60  224.30   1.70
17.2  189.40  223.90  225.40   1.50
17.3  190.50  225.20  228.50   3.30
17.4  191.60  226.50  229.60   3.10
17.5  192.70  227.80  230.70   2.90
17.6  193.80  229.10  231.80   2.70
17.7  194.90  230.40  232.90   2.50
17.8  196.00  231.70  234.00   2.30
17.9  197.10  233.00  235.10   2.10
18.0  198.20  234.30  236.20   1.90
18.1  199.30  235.60  237.30   1.70
18.2  200.40  236.90  240.40   3.50
18.3  201.50  238.20  241.50   3.30
18.4  202.60  239.50  242.60   3.10
18.5  203.70  240.80  243.70   2.90
18.6  204.80  242.10  244.80   2.70
18.7  205.90  243.40  245.90   2.50
18.8  207.00  244.70  247.00   2.30
18.9  208.10  246.00  248.10   2.10
19.0  209.20  247.30  249.20   1.90
19.1  210.30  248.60  252.30   3.70
19.2  211.40  249.90  253.40   3.50
19.3  212.50  251.20  254.50   3.30
19.4  213.60  252.50  255.60   3.10
19.5  214.70  253.80  256.70   2.90
19.6  215.80  255.10  257.80   2.70
19.7  216.90  256.40  258.90   2.50
19.8  218.00  257.70  260.00   2.30
19.9  219.10  259.00  261.10   2.10
20.0  220.20  260.30  264.20   3.90
20.1  221.30  261.60  265.30   3.70
20.2  222.40  262.90  266.40   3.50
20.3  223.50  264.20  267.50   3.30
20.4  224.60  265.50  268.60   3.10
20.5  225.70  266.80  269.70   2.90
20.6  226.80  268.10  270.80   2.70
20.7  227.90  269.40  271.90   2.50
20.8  229.00  270.70  273.00   2.30
20.9  230.10  272.00  276.10   4.10
21.0  231.20  273.30  277.20   3.90
21.1  232.30  274.60  278.30   3.70
21.2  233.40  275.90  279.40   3.50
21.3  234.50  277.20  280.50   3.30
21.4  235.60  278.50  281.60   3.10
21.5  236.70  279.80  282.70   2.90
21.6  237.80  281.10  283.80   2.70
21.7  238.90  282.40  284.90   2.50
21.8  240.00  283.70  288.00   4.30
21.9  241.10  285.00  289.10   4.10
22.0  242.20  286.30  290.20   3.90
22.1  243.30  287.60  291.30   3.70
22.2  244.40  288.90  292.40   3.50
22.3  245.50  290.20  293.50   3.30
22.4  246.60  291.50  294.60   3.10
22.5  247.70  292.80  295.70   2.90
22.6  248.80  294.10  296.80   2.70
22.7  249.90  295.40  297.90   2.50
22.8  251.00  296.70  301.00   4.30
22.9  252.10  298.00  302.10   4.10
23.0  253.20  299.30  303.20   3.90
23.1  254.30  300.60  304.30   3.70
23.2  255.40  301.90  305.40   3.50
23.3  256.50  303.20  306.50   3.30
23.4  257.60  304.50  307.60   3.10
23.5  258.70  305.80  308.70   2.90
23.6  259.80  307.10  309.80   2.70
23.7  260.90  308.40  312.90   4.50
23.8  262.00  309.70  314.00   4.30
23.9  263.10  311.00  315.10   4.10
24.0  264.20  312.30  316.20   3.90
24.1  265.30  313.60  317.30   3.70
24.2  266.40  314.90  318.40   3.50
24.3  267.50  316.20  319.50   3.30
24.4  268.60  317.50  320.60   3.10
24.5  269.70  318.80  321.70   2.90
24.6  270.80  320.10  324.80   4.70
24.7  271.90  321.40  325.90   4.50
24.8  273.00  322.70  327.00   4.30
24.9  274.10  324.00  328.10   4.10
25.0  275.20  325.30  329.20   3.90
25.1  276.30  326.60  330.30   3.70
25.2  277.40  327.90  331.40   3.50
25.3  278.50  329.20  332.50   3.30
25.4  279.60  330.50  333.60   3.10
25.5  280.70  331.80  336.70   4.90
25.6  281.80  333.10  337.80   4.70
25.7  282.90  334.40  338.90   4.50
25.8  284.00  335.70  340.00   4.30
25.9  285.10  337.00  341.10   4.10
26.0  286.20  338.30  342.20   3.90
26.1  287.30  339.60  343.30   3.70
26.2  288.40  340.90  344.40   3.50
26.3  289.50  342.20  345.50   3.30
26.4  290.60  343.50  348.60   5.10
26.5  291.70  344.80  349.70   4.90
26.6  292.80  346.10  350.80   4.70
26.7  293.90  347.40  351.90   4.50
26.8  295.00  348.70  353.00   4.30
26.9  296.10  350.00  354.10   4.10
27.0  297.20  351.30  355.20   3.90
27.1  298.30  352.60  356.30   3.70
27.2  299.40  353.90  357.40   3.50
27.3  300.50  355.20  360.50   5.30
27.4  301.60  356.50  361.60   5.10
27.5  302.70  357.80  362.70   4.90
27.6  303.80  359.10  363.80   4.70
27.7  304.90  360.40  364.90   4.50
27.8  306.00  361.70  366.00   4.30
27.9  307.10  363.00  367.10   4.10
28.0  308.20  364.30  368.20   3.90
28.1  309.30  365.60  369.30   3.70
28.2  310.40  366.90  372.40   5.50
28.3  311.50  368.20  373.50   5.30
28.4  312.60  369.50  374.60   5.10
28.5  313.70  370.80  375.70   4.90
28.6  314.80  372.10  376.80   4.70
28.7  315.90  373.40  377.90   4.50
28.8  317.00  374.70  379.00   4.30
28.9  318.10  376.00  380.10   4.10
29.0  319.20  377.30  381.20   3.90
29.1  320.30  378.60  384.30   5.70
29.2  321.40  379.90  385.40   5.50
29.3  322.50  381.20  386.50   5.30
29.4  323.60  382.50  387.60   5.10
29.5  324.70  383.80  388.70   4.90
29.6  325.80  385.10  389.80   4.70
29.7  326.90  386.40  390.90   4.50
29.8  328.00  387.70  392.00   4.30
29.9  329.10  389.00  393.10   4.10
30.0  330.20  390.30  396.20   5.90


The error does not exceed 2.70 rupees for the first 15 km and 5.90 rupees for the first 30 km. We can say that the three-step method discussed in this post provides a pretty good approximation for the actual fare as per the new rate. Therefore, the three-step method can be used as a quick sanity check to confirm that the actual fare demanded by the auto rickshaw driver is close to what it should be.