# Dynamic programming example

I am going to buy a family car at the beginning of the New Year. I am going to stay in the UK for the next 4 years. I am considering the possibility of being a customer of company A which sells BMW models. Not only I can buy a car from this company but I can also trade in my car at this company and have my car serviced by the company. Company A gives a warranty that the annual maintenance costs and trade-in prices will remain the same for the next 4 years. They are:

$$\begin{array}{cc}\hline\text{Age of Car}&\text{Annual Maintenance}&\text{Trade-in Price at the}\\&\text{Cost}&\text{end of the period}\\\hline0&{\it\unicode{xA3}}2,000&{\it\unicode{xA3}}6,000\\1&{\it\unicode{xA3}}4,000&{\it\unicode{xA3}}5,000\\2&{\it\unicode{xA3}}6,000&{\it\unicode{xA3}}4,000\\3&{\it\unicode{xA3}}7,000&{\it\unicode{xA3}}2,000\\\hline\end{array}$$

a) Suppose that I can buy a new car at £12000, a price which is fixed for the next 4 years. What strategy should I choose to minimize the net cost (purchasing costs + maintenance costs - money received in trade-ins) incurred during the next four years? Given the optimal strategy found, do I have to solve the problem again if the company changes the price from £12000 to £$$x$$ before I buy a car?

Solution to a) Question: Could somebody please explain how do they get the values in the first table? Isn't the cost for using a car for 1 year supposed to be $$2000+4000$$?

The "cost" values in the lower left table are calculated as the sum of the cost of buying the car ($$12000$$), plus the total maintenance cost of each year of owning the car, minus the trade in cost after the specified number of years has elapsed.
So, the total cost of owning the car for one year is $$12000$$ (price of car) $$+$$ $$2000$$ (maintenance cost during year $$0$$) $$-$$ $$6000$$ (the value of the car at the end of period $$0$$, i.e., after $$1$$ year) $$= 8000$$.
Similarly, the total cost of owning the car for two years is $$12000$$ $$+$$ $$2000$$ (maintenance cost during year $$0$$) $$+$$ $$4000$$ (maintenance cost during year $$1$$) $$-$$ $$5000$$ (value of the car at the end of period $$1$$, i.e., after the second year) $$=$$ $$13000$$.