I've been asked to create a mathematical formula that will be used to price taxi bookings at a local taxi company.
Current system used:
- A table is used as a reference

Variables:
- x is the total number of miles
- y is every stop made
Conditions:
- Add £3 for the first 2 miles
- Add £1 for every extra mile incurred (after two miles)
- Add 50p extra for every half a mile incurred (after two miles)
- Add 50p for every stop made (excluding pickup and drop off
- Round to .50 or .00 once calculated
What I've come up with so far based on the variables and conditions above:
$$ f(x,y)= \begin{cases} 3 + 0.50y & \text{$x \leq 2$}\\ x + 1 + 0.50y & \text{$x > 2$}\\ \end{cases} $$
How I need your help:
- Is this formula suitable?
- Can it be improved to factor in an expression that will round the price end result to .50 or .00?
- Can both parts be combined to get rid of the conditional (or perhaps streamlined further if this is not possible)?
To round a number $z$ to the nearest multiple of $a$, you can use $\lfloor \frac za+\frac12\rfloor \cdot a$. Hence you can use
$$f(x,y)=\begin{cases}3+0.50y&\text{if $x\le 2$}\\ .50\cdot \bigl(\lfloor 2x+\frac12\rfloor +y+2\bigr)&\text{if $x>2$}\end{cases} $$