Quadratic Programming: The Form Behind Portfolio Optimisation
Quadratic programming is optimisation where the objective holds a decision multiplied by a decision and every rule stays a straight line. One change, one visible consequence: the best answer no longer has to land on a corner of the region. At the Amaltas workshop the bent objective is best at 9 plain crates and 4 lined crates, partway along an edge, worth Rs 3,640/- a day.
Three results are taken as settled here. The Amaltas workshop makes exactly two things and has three limits on its day. A straight line objective over straight line rules tops out on a corner, and that result is settled separately, under linear programming. And the shape argument that gives such a problem a single top is settled separately too, under convex optimisation. Precisely one thing changes here, the objective. The rules stay exactly where they were, and everything that follows from the objective moves.
One habit everybody carries forward without noticing is what moves. Once the lesson that the answer lives at a corner has been learned, corners become where the eye goes, and looking there is fast, finite and satisfying. There are five corners at this workshop, all five can be priced in under a minute, and the highest one is obviously the answer. Bend the objective and that whole procedure keeps working perfectly and stops being correct. A procedure that keeps running while it gives the wrong answer is far more dangerous than one that breaks. Nothing errors. Nothing looks wrong. The comparison was run properly and the number it produced is Rs 140/- short.
What makes an objective quadratic rather than linear?
Somewhere in it, a decision is multiplied by a decision. A decision multiplied by a decision is the whole definition, and the definition is narrower than people expect. The words are worth holding exactly as they stand. Multiplying a decision by a fixed number is not it. Adding two decisions together is not it. Squaring is multiplying a thing by itself, and squaring a decision is it. Multiplying one decision by a different decision is it. A quadratic objective is one where at least one term contains two decision variablesA quantity that is chosen, as against one the world hands over. Here there are exactly two of them, and everything else follows from what they are set to. multiplied together, counting a variable multiplied by itself.
Here is what that means in plain terms, and it is easier to feel than to define. In the straight line case, a crate is worth what a crate is worth. The ninth one of the day pays exactly what the first one paid, and the workshop could make four hundred of them at that rate if the timber held out. In the quadratic case, what a crate is worth depends on how many of them there already are. The ninth is not the first. The difference is that single sentence, and everything else follows from it.
An everyday version sits in most kitchens. The first cup of tea of the morning is worth a great deal. The fourth is worth something. The seventh is doing nobody any favours at all. The amount per cup is not fixed. The amount falls as the cups pile up, and past some point the next cup is a cost rather than a benefit. Nobody would model the enjoyment of tea as a fixed amount per cup multiplied by cups. A falling amount per cup is a bent objective, and most people have been using one all their lives without writing it down.
Notice what has not changed. The rules stay straight lines throughout, and only the objective bends. The word programming inside the name is doing exactly that work. Boards, bench hours and cloth still add up the way they always did: a plain crate still takes one board and two hours, a lined one still takes two boards, one hour and one roll. The shape of the allowed region is untouched. Programming here means the whole set of methods that solve for a best answer under limits, and quadratic names the objective only. A problem with a bent rule and a straight objective is a different animal with a different name, and it is not this one.
What has to turn up in the objective before the problem counts as quadratic?
Why would a workshop have a bent objective at all?
Because somebody made an arrangement, and arrangements are where bends come from. The Amaltas workshop has taken a standing wholesale order, and the terms of it are that the wholesale buyerSomebody who takes goods in quantity on agreed terms rather than one at a time over a counter. The price is settled in advance and can depend on how many arrive. pays a little less for each further crate of the same kind that turns up in one day. Nobody at the workshop chose to make the arithmetic harder. The workshop chose a buyer who takes everything, and the price ladder came attached.
The arrangement is familiar from the other side. A caterer quoting for a wedding does not charge the four hundredth plate what they charged the fortieth. A vegetable seller clearing the last crates at six in the evening is not asking the morning price. A printer quoting a thousand copies quotes less per copy than for fifty. In every one of those, the rate per unit slides as the count rises, and the moment a rate slides with the count, the total is no longer a rate multiplied by a count. The total is something bent.
Written out, the day's takings under these terms come to two expressions, one per crate type. The plain crates bring in 500 times the plain crate count, less 20 times that count multiplied by itself. The lined crates bring in 310 times the lined crate count, less 30 times that count multiplied by itself. Each expression has the count multiplied by the count sitting inside it. By the definition above that makes the objective quadratic, and the amount being taken off grows faster than the count does.
Amaltas is the same workshop under the same three daily rules, with a different arrangement with its buyer, and nothing about the workshop itself has changed. Twenty boards still arrive. There are still 22 bench hoursThe unit the workshop counts its capacity in. One person at one bench for sixty minutes is one of them, and the day has a fixed number of them to spend. in the day and 8 rolls of clothLining fabric wound on a roll, bought and counted a whole roll at a time. Nothing but the lined crate ever touches it. on the shelf. The figures of Rs 300/- and Rs 450/- of contributionWhat a crate leaves behind once the spending that rises with it has been taken off. Rent and wages still have to come out of the total, so it is not profit. a crate that the earlier work runs on belong to the arrangement where the price does not move, and they are perfectly correct there. The two figures simply describe a different deal. Mixing the two arrangements produces an answer that belongs to neither, so the two sets have to be kept apart.
Under the wholesale arrangement, why does what a crate is worth fall as the day goes on?
What do the two tables actually say?
No calculus is needed here. Both expressions are worked out at every count the workshop could actually reach, and the result is two short tables that can be checked with a pencil. Crates come in whole cratesCounts that cannot carry a fraction. Two thirds of a crate is sawdust and half a plan, so every count here is a round one., the plain count can never pass eleven and the lined count can never pass eight, so between them the two tables hold every value the objective can take.
| Plain crates | What the plain work is worth | What this crate added |
|---|---|---|
| 1 | Rs 480/- | Rs 480/- |
| 2 | Rs 920/- | Rs 440/- |
| 3 | Rs 1,320/- | Rs 400/- |
| 4 | Rs 1,680/- | Rs 360/- |
| 5 | Rs 2,000/- | Rs 320/- |
| 6 | Rs 2,280/- | Rs 280/- |
| 7 | Rs 2,520/- | Rs 240/- |
| 8 | Rs 2,720/- | Rs 200/- |
| 9 | Rs 2,880/- | Rs 160/- |
| 10 | Rs 3,000/- | Rs 120/- |
| 11 | Rs 3,080/- | Rs 80/- |
| Lined crates | What the lined work is worth | What this crate added |
|---|---|---|
| 1 | Rs 280/- | Rs 280/- |
| 2 | Rs 500/- | Rs 220/- |
| 3 | Rs 660/- | Rs 160/- |
| 4 | Rs 760/- | Rs 100/- |
| 5 | Rs 800/- | Rs 40/- |
| 6 | Rs 780/- | Rs 20/- less |
| 7 | Rs 700/- | Rs 80/- less |
| 8 | Rs 560/- | Rs 140/- less |
The third column of each table repays a careful reading. The whole argument is sitting in those two columns. Every further crate adds less than the crate before it, by Rs 40/- each time in the plain table and by Rs 60/- each time in the lined one, and the lined table stops adding anything at all after the fifth crate. The fifth lined crate is worth Rs 40/-, very little but still worth having. The sixth takes Rs 20/- off the day. The seventh takes off Rs 80/- and the eighth Rs 140/-.
The sixth lined crate is genuinely strange the first time, and it repays a moment's attention. The workshop has cloth left, boards left and hours left. Nothing anywhere says it cannot build a sixth lined crate, and building it makes the day worse. Under the arrangement where the price does not move, no such thing could happen: another lined crate was another Rs 450/-, full stop, and the only reason to stop was that a rule forced a halt. Now there is a second reason to stop, and it lives inside the objective rather than in the rules.
The lined table climbs to five crates and then turns down. What does that say about the answer?
The panel below walks the plain crate count from none up to eleven, setting the lined count to the best the rules then allow. Before it moves: where does the walk reach its highest reading?
Walk the plain crate count and watch where the day peaks
One control moves the plain crate count. At each setting the panel fills in the best lined crate count the three daily rules still allow, redraws the marker on the region, extends the walk beneath it, and says in words what the day comes to. The panel opens at 9 plain crates, the plan given above as the answer.
Educational illustration. The Amaltas workshop and its wholesale arrangement were made up for teaching. The three daily rules are unchanged from the arrangement where the price does not move, and only the objective has bent. Crates are counted whole.
Where does the best plan sit, and why is it not a corner?
Under the bent objective, no allowed plan beats 9 plain crates with 4 lined ones. The figure reads straight off the two tables: nine plain crates are worth Rs 2,880/- and four lined ones are worth Rs 760/-, so the day comes to Rs 3,640/-. The rules hold as well. Boards: nine plus eight is seventeen, against the twenty that arrive. Bench hours: eighteen plus four is twenty two, against the twenty two available. Cloth: four rolls against eight. All three hold, so the plan is allowed, and no other allowed plan of whole crates reaches Rs 3,640/-.
The corner method says to price the five corners under the same objective. An empty day is Rs 0/-. Eleven plain with none lined gives Rs 3,080/- from the tables. Eight plain with six lined: Rs 2,720/- and Rs 780/-, so Rs 3,500/-. Four plain with eight lined: Rs 1,680/- and Rs 560/-, so Rs 2,240/-. None plain with eight lined is Rs 560/- flat. Lined up, the five are headed by Rs 3,500/-.
The corners miss the answer by Rs 140/- a day, and the answer sits partway along the bench hours edge rather than at either end of it. The gap of Rs 140/- is the entire claim, stated as a number. The plan 9 plain and 4 lined lies on the straight boundary running between the corner at eleven plain crates and the corner at eight plain with six lined, one step in from one end and two steps in from the other, and there is nothing at all special about the point except that it is where the bent objective happens to top out.
There is a detail in the reshuffle that is worth more than it looks. Under the arrangement where the price does not move, the five corners rank with eight plain and six lined on top. Under the bent objective they rank with eight plain and six lined on top as well. The bend genuinely reorders three of the five underneath, pushing eleven plain and no lined up from fourth to second, but the corner that wins does not change. So the corner method does not even offer a different corner to be suspicious about. The corner method returns the same familiar plan it always returned, and that plan is now wrong.
The best corner is worth Rs 3,500/- and the answer is worth Rs 3,640/-. Was the corner comparison done badly?
What does the answer leave unused?
Score the answer against each limit in turn and one of them is full while two are not. All 22 bench hours go into 9 plain crates and 4 lined ones, so there is nothing left there. Boards: seventeen of the twenty that arrived get cut, so three are still in the yard at the end of the day. Cloth: four of the eight rolls are opened, so four are still on the shelf. Three boards and four rolls sit idle at the best plan the workshop can reach, and the workshop is not being careless.
Compare that with what happened before. Under the arrangement where the price does not move, the best plan used every board and every bench hour, and left only two rolls of cloth. Boards were worth having, so the answer bought all it could. Now the answer walks away from three of them. The three boards stay in the yard because the tenth plain crate would only add Rs 120/- and the fifth lined crate only Rs 40/-, and neither of those is enough to be worth the bench hours it would take, given what has to be given up elsewhere to find them.
The practical gift of the whole method costs nothing. Under a straight line objective a limit expected to bind normally does bind. A limit left with room to spare at the answer is therefore the visible tell that the objective has bent. Noticing it takes no inspection of anybody's formulas. The solved plan and the limits are enough: when something that seemed certain to be tight comes back loose, the objective is worth reading before the answer is trusted.
The answer leaves three boards and four rolls unused. Why is that worth noticing rather than shrugging at?
What does the shape around the answer look like?
Stand at the answer and take one step each way along the same edge. Every plan on that edge uses all 22 bench hours, so a step is a trade: one more plain crate costs two bench hours, and the only place to find them is by giving up two lined crates. Step down to 8 plain and 6 lined and the day is Rs 2,720/- plus Rs 780/-, or Rs 3,500/-. Step up to 10 plain and 2 lined and the day is Rs 3,000/- plus Rs 500/-, or Rs 3,500/- again. One step either way costs exactly the same Rs 140/-, and that is arithmetic rather than coincidence.
Here is why it has to come out that way. A bend of this kind is symmetric about its own top. Walk away from the top in one direction and the fall follows the same shape as walking away in the other, so equal steps cost equal amounts. Reading anything into the two figures matching would be a mistake, and so would hunting for a connection between the plan with six lined crates and the plan with two. There is no connection. The match is what the top of a bend looks like from the inside, and it would happen at the top of any bend like this one.
The symmetry is also a useful test. Given a plan said to be the best one, one step each way, priced both times, settles it. Two steps that cost roughly the same is consistent with standing at a top. One step that costs a lot and one that costs almost nothing means the plan is on a slope and the top is further along in the cheap direction. The test takes two multiplications and is available to anybody, whatever solved the problem in the first place.
One crate either side of the answer is worth Rs 3,500/-, the same on both sides. Coincidence?
Does the single peak property survive the bend?
Here, yes, and for a reason that can be stated. Both expressions bend the same way, downward, so the whole objective is one hill rather than a landscape with several. The allowed region is still one unbroken shape, unchanged from before. One downward hill over one unbroken region means the shape argument settled separately under convex optimisation still applies, so there is one top and any honest climb finds it. Walking the plain crate count from none to eleven, the readings run Rs 800/-, Rs 1,280/-, Rs 1,720/-, Rs 2,120/-, Rs 2,480/-, Rs 2,800/-, Rs 3,080/-, Rs 3,320/-, Rs 3,520/-, Rs 3,640/-, Rs 3,500/- and Rs 3,080/-. Nine climbs, then two falls. One top, and it is not at either end.
Now the limit of that claim, and it matters more than the claim. The property comes from which way the objective bends, not from the word quadratic, and an objective that bends upward in one decision while bending downward in another does not have it. Suppose the buyer had offered the opposite kind of lined crate arrangement: a bulk bonus that grows, so each further lined crate pays more than the one before it rather than less. The plain side keeps its downward bend, the lined side now bends upward, and the objective is a hill in one direction and a valley in the other.
| Plain crates | Under the wholesale arrangement above | If the lined side bent upward instead |
|---|---|---|
| 0 | Rs 800/- | Rs 2,400/- |
| 1 | Rs 1,280/- | Rs 2,880/- |
| 2 | Rs 1,720/- | Rs 3,320/- |
| 3 | Rs 2,120/- | Rs 3,720/- |
| 4 | Rs 2,480/- | Rs 4,080/- |
| 5 | Rs 2,800/- | Rs 3,890/- |
| 6 | Rs 3,080/- | Rs 4,170/- |
| 7 | Rs 3,320/- | Rs 3,960/- |
| 8 | Rs 3,520/- | Rs 4,160/- |
| 9 | Rs 3,640/- | Rs 3,600/- |
| 10 | Rs 3,500/- | Rs 3,240/- |
| 11 | Rs 3,080/- | Rs 3,080/- |
The right hand column reads the same way as the left. The column climbs to Rs 4,080/- at four plain crates, drops, climbs again to Rs 4,170/- at six, drops, climbs again to Rs 4,160/- at eight, and then falls away. Three tops rather than one. A search that moves one crate at a time and keeps only improvements sets off from the bottom, reaches four plain crates, finds that five is worse, and halts on Rs 4,080/- while Rs 4,170/- sits two crates further on. The search is short by Rs 90/-, and it has no way of knowing.
So quadratic is not a synonym for safe, and it never was. Quadratic names the form of the objective and nothing about its behaviour. The thing actually worth knowing is the direction of every bend in it, and that is a separate question, to be asked separately, every time.
Does a quadratic objective always carry the single top property?
Where is this form most often met, and where is that taught?
Not in a workshop. The best known use of quadratic programming by a wide margin is the problem of settling what share of a total to put into each of several holdingsOne of the things somebody has put money into and still has. Holding is a stock word rather than a workshop word, used only to name where a subject lives., where one quantity has to be traded off against another, and where the arithmetic of that trade off multiplies one holding by another. The multiplication of one holding by another is what makes it the same form as the workshop's day. The problem has a name, the allocationDeciding how much of a total goes to each of several places. The word is used here to name a subject, not to work one. problem, and it has a name because it has a home.
The allocation problem is covered separately, under portfolio construction and investment management. Every quantity above is a crate, a board, a bench hour or a roll of cloth.
The claim made here is narrower and more useful than it might look. The form is the same form. Everything set out above carries across to it without a single change: the answer need not be at a corner, so a corner search will quietly miss it; limits can come back with room to spare at the answer, and that is a tell rather than an error; steps either side of the top cost about the same; and whether there is one top at all depends on which way each part of the objective bends. The four points just listed, learned on crates where everything can be counted by hand, are recognisable at once in the subject where they live.
How is a quadratic objective spotted?
A spreadsheet arrives with a question attached: is the answer at the bottom right? With four minutes to spend, here is the order to look in, cheapest first.
The objective cell itself comes first, read for a quantity multiplied by a quantity. A cell reference appearing twice in its own formula is the loudest version, and a squared term is the same thing written shorter. The rates come next. A rate that is a constant is fine; a rate fetched by looking up the very volume being decided is a bend in disguise. Nothing in the objective cell looks unusual, and the disguised rate is the one people miss. After that comes any trade off between two things written as a product of both. Finally, if the sheet is somebody's model of a real arrangement rather than a formula, the person who negotiated the terms can say whether the price moves with the quantity. The price usually does.
Then the check that costs nothing: if the solved answer leaves a limit unused that was expected to bind, the objective has probably bent and the corner reasoning has stopped applying. The check on what the answer left over is the one that needs no formula opened at all. A lender reviewing a borrower's production plan, an analyst handed a pricing model, a household deciding how many hours of overtime are worth taking on when the later hours are taxed harder than the first: all three can look at the answer, look at what it left on the table, and know whether to go digging.
A spreadsheet arrives whose objective cell multiplies two decided quantities together. What does that change?
The failure: a correct comparison that reaches a wrong plan
A planner at the Amaltas workshop is asked for the best day under the new wholesale terms. The planner knows the answer sits at a corner. The answer sat at one every other time they looked. So they list the five corners, price all five under the bent objective, get Rs 0/-, Rs 3,080/-, Rs 3,500/-, Rs 2,240/- and Rs 560/-, take the highest, and hand in a day of 8 plain with 6 lined, worth Rs 3,500/-.
Every step of that is done properly. All five corners are the right corners, all five are priced correctly under the right objective, and the comparison picks the genuine highest of the five. The answer is 9 plain and 4 lined at Rs 3,640/-. The report is still Rs 140/- a day short, and no amount of rechecking the corners could ever have found the answer. The mistake was not in the arithmetic. The mistake was in the sentence nobody said out loud: that the answer had to be among the corners.
The tell was sitting in plain view the whole time and it was two lines long. The real answer leaves three boards and four rolls unused. The reported plan uses every single board. A planner who had glanced at what the answer left over would have seen a limit come back loose where limits had always come back tight, and that is the moment to go and read the objective. The fix is one habit: before a corner is trusted, the objective has to be confirmed as still a straight line, and if a rate anywhere inside it moves with the volume being decided, it is not. Over a working year, Rs 140/- a day is not a rounding error at a workshop this size.
Where this guide stops. Linear programming and the corner result it rests on are settled separately, and so is the shape argument that decides whether a problem has a single top. The best known use of quadratic programming, settling what share of a total goes into each of several holdings, is named above and covered separately, under portfolio construction and investment management. Every quantity above belongs to a workshop that makes crates, and the only trade made anywhere above is two bench hours for one plain crate.
Which of these figures could be looked up, and which had to be stated outright?
Every rupee amount above comes out of the two bent expressions and the three daily limits, so every one of them can be reproduced with a pencil. The last column names a second route to each figure, quicker than redoing the whole day.
| Number printed above | The arithmetic that made it | A second route to the same figure |
|---|---|---|
| The two bent expressions, with 500 and 20 on plain crates and 310 and 30 on lined ones | Written down by hand as part of a wholesale arrangement that was made up, and fixed before any answer was worked out | Put one crate through the first expression: 500 less 20 is 480, the top row of the plain table |
| The plain column, Rs 480/- climbing to Rs 3,080/- | Eleven substitutions into the same expression, one crate count at a time | Take each row from the one under it and watch all eleven differences shrink by Rs 40/- each time |
| The lined column, Rs 280/- climbing to Rs 800/- and falling to Rs 560/- | Eight substitutions into the second expression | The differences run Rs 280/-, Rs 220/-, Rs 160/-, Rs 100/-, Rs 40/-, and the sixth turns |
| Rs 3,640/- at nine plain crates and four lined | Every plan of whole crates the three daily limits leave standing, priced and compared against every other | Read 9 off the plain column and 4 off the lined column and add: Rs 2,880/- and Rs 760/- |
| The five corner readings, Rs 0/-, Rs 3,080/-, Rs 3,500/-, Rs 2,240/- and Rs 560/- | The same two columns read off at the five crossings the three limits leave standing | Five pairs of look-ups and five additions, which is a minute of work |
| The Rs 140/- between the best corner and the answer | One subtraction, taken from two amounts that were never rounded on the way to it | Rs 3,640/- take away Rs 3,500/- |
| That this shape of problem is the one behind choosing across a set of holdings | Long settled common ground in the study of optimisation, and stated here only to point at where the subject lives | Nothing to test. The allocation problem is worked nowhere above, and is covered separately |
The Amaltas workshop, the plain crate and the lined crate it builds, and the wholesale arrangement that bends what its day is worth are invented.
Educational material. Not advice on any investment, tax, budget or market position.
