Tricky algebra / algorithm, anyone?

I am trying to understand the pricing model of a cab firm from looking at quotes generated on their app. They charge like this; there is a minimum fare for a set number of miles (say £12.00 for 3 miles), and after that a flat rate per mile (say £2.00 per mile thereafter). That must mean there are three unknown variables:

Minimum Fare: x
Number of miles: y
Price per mile thereafter: z

What I do have, though, is a couple of quotes:

Where the journey distance is 7 miles, the quoted fare is £18.29
Where the journey distance is 22 miles and the quoted fare is £35.49

I did think more than two quotes might be needed, but maybe it’s not even possible given the fact of three variables.

Anyway, I’d be very grateful for any thoughts. Cheers.

There might be a fourth variable, “surcharge for distances we really don’t want to travel and are willing to price ourselves out of.”

Can’t be done with this info. Also need the number of miles for the fixed minimum after that, all you need is EITHER of those two examples. (OR, if you had a third example, that would work too, I think.)

It is definitely underdetermined with just those two quotes. Assuming y < 7, any number of quotes for trips 7 miles or longer will be insufficient to determine what y and x are exactly.

Basically the pricing scheme has a flat region and a non-flat linear region, and you need two quotes from the non-flat region, and one from the flat region to make the determination (at least assuming the pricing is continuous).

If I understand correctly, the OP’s situation yields the following two equations:
x + (7-y)z = 18.29, or x + 7z - yz = 18.29
x + (22-y)z = 35.49, or x + 22 - yz = 35.49

By subtracting one from another, we can eliminate the x and the yz terms, and get
15z = 17.20

but this would yield a fractional value for z (1.146666…)

Hi guys - great response! Thanks. I can do more quotes :smiley:

Maybe one of the earlier quotes was wrong - these are correct:

5 miles 14.39
7 miles 18.29
13 miles 29.99
22 miles 47.54

Thanks again for the great response!

Fwiw, my instinct was it might be one of those ‘black box’, 10,000 iterations-type thing …

Looks like those four match:

4.64 + (1.95 * miles)

Hi chrisk, forgive me for quoting myself here:

I presume 1.95 would represent z ?

I’m no shakes at this, how does 4.64 break down?

He’s saying 4.64 is the minimum x, 1.95 is the per mile charge z. The slight twist here is that there is no small amount of travel that you get for 4.64, that is the charge for zero distance. All travel is charged at 1.95 per mile plus the fixed fee of 4.64.

So the formula is X + (Y*Z) or Fare = 4.64 + (1.95 * Y).

Still not enough information to establish y, since we don’t see two trips that are at the same price, or that don’t fit on the same slope. x could be 4.64 for a y of 0, or y could be any value up to 5, and then you’d raise x by (1.95 * y)

Does that help?

(Basically what Crotalus just said.)

Thank you everyone who piped up earlier, and thatk you Crotalus for your explanation.

chrisk - as far as I’m concerned, you should get the Nobel prize! I guess I was maybe asking for the impossible and what you have offered is really so helpful. Thanks.

On a varitaion of the modern theme, is there a formula for that? :wink:

eta: sorry, I see Crotalus has added a formula. Cheers.


I just plotted the numbers you gave me in an Excel graph, noticed that they formed a straight line, and solved the linear equation.

I’m guessing that means you solved what you already had?

I’ve been staring at this on a speadsheet and the magic connection has come yet …

okay, with the information I have : £14.39 = X + (Z * 5)

… I don’t know how to plug this into Excel with two variables. Could you help one step further?

Okay, I’ll take you through my entire process in Excel, as best I can remember it, including the graph, which was the important bit.

First, I typed in all four pairs of values, miles in column A, pounds in column B:

5	14.39
7	18.29
13	29.99
22	47.54

Then I highlighted the entire block, chose Insert, Chart, X-Y (Scatter), and just finished with the default options from there. That shows the graph of the four trips, with cost up the left axis, miles along the bottom axis, and shows that they all fall along a fairly straight, diagonal line, which intersected the left axis.

From there, I went into the next column, cell C2, and typed in =A2-A1 as a formula. Copied this formula two cells down and one cell to the right. So now column C shows the difference in miles between adjacent trips, and column D shows the difference in price. Finally, in E2, I entered = D2/C2, and copied that down to row 4. So column E shows the ratio of marginal price over marginal distance. If I was right that the line on the graph was straight, the values in column E would be constant, and they are, at 1.95 – that’s our cost per additional mile.

Then I probably went down to A6, typed in =1.95 * 5 to see how much the cost for 5 miles would be at 1.95 a mile, and then punched = b1-a6 into cell B2 to see how much higher the total for the 5 mile trip was. That gave me the fixed fee of 4.64 for a 0 mile trip

5	14.39			
7	18.29	2	3.9	1.95
13	29.99	6	11.7	1.95
22	47.54	9	17.55	1.95

9.75	4.64			

This isn’t the proper way to solve a linear equation, it just seemed to make sense as I was doing it. :wink:

Okay, that was great of you to take the time.

I should mention you probably meant B6 when you said B2 here, but I’m only mentioning that for anyone following …

This will take me a while to digest but (a) it’s seriously impressive and (b) it does highlight (graphically) the mystery of <5.

Thanks again.

Yes, that’s right, I meant B6, but was thinking of the second column, typed a two, and didn’t catch it.

<5 is definitely mysterious, as I’m not sure what you’re talking about. :smiley:

Just that x and y relate to under £5.00 and are not determinable.

z is definitely very cool though :slight_smile: