Quant500 Academy

4. What mathematical optimization actually means

Level 7: Linear algebra and portfolio optimization

Putting limits on an optimizer never improves the theoretical result, and yet almost everybody puts them there.

To understand that apparent contradiction you first have to unpack what optimizing means. The word "optimize" is used very loosely, but in mathematics it has a precise meaning.

What optimizing means, exactly

To optimize is to look for the maximum or minimum value of something within a set of permitted possibilities.

That definition hides two pieces worth naming separately from the start:

In the Markowitz problem, the objective function can be "minimize portfolio variance" or "maximize expected return", depending on which version of the problem you pose.

Constraints, from the basic to the realistic

The typical constraints are that the weights add up to 1 and, if short positions are not allowed, that none is negative.

Additional and considerably more realistic constraints are sometimes added to those basic ones:

Why pen and paper stop working

With two or three assets, finding the optimum is literally a geometry exercise. It can be solved with pen and paper or a calculator, and the efficient frontier from the previous module can be traced by hand by combining the variance formulas for two or three assets.

The problem is that this approach does not scale, so look at what is on the table with 500 assets, the full S&P 500 universe:

It is not that the problem is conceptually different from the 2-asset one: it is exactly the same question.

What changes is the scale, because the space of possible weight combinations is so enormous that no person could explore it by hand in a whole lifetime. This is where the computer comes in, not as a luxury, but as a structural requirement of the problem.

How the algorithms walk down the mountain

The algorithms that solve this are known generically as numerical optimization methods. They neither try combinations at random nor enumerate them all, which would be infeasible even for a computer, since the weights are continuous numbers, not a finite set of options.

Instead, they start from an initial combination of weights and adjust it systematically, step by step, in the direction that improves the objective function, until further adjustment no longer improves the result appreciably.

It is similar, allowing for the differences, to walking down a mountain in thick fog. You cannot see the whole valley, but at each point you can feel which way the ground slopes and take a step in that direction. Repeating the process many times, you end up at the bottom without ever having seen the whole landscape at once.

Local minimum and global minimum

An important distinction appears here, between two kinds of valley floor:

In many optimization problems, the algorithm can get trapped in a local minimum without realizing that a deeper valley exists elsewhere on the map.

The property that saves Markowitz

The good news is that the classical Markowitz problem, minimizing variance subject to weights adding up to 1 and no short positions, has a favorable mathematical property called convexity.

In a convex problem, the terrain has a single bowl shape, with no secondary valleys. So any local minimum found is automatically the global minimum.

That property is precisely what makes the Markowitz problem reliably solvable, even with hundreds of assets.

The price of adding constraints

However, that guarantee is easily lost as soon as more realistic constraints or objective functions are added.

Some variants preserve that property and others destroy it completely:

And there is one important side effect of adding constraints. The new, constrained efficient frontier always lies below or at best equal to the theoretical unconstrained frontier.

Put another way: restricting the search space can never improve the optimal result, only worsen it or leave it unchanged.

So why does everyone restrict, if the theoretical optimum can only get worse? Because what you gain from constraints is realism and control over specific risks, not more theoretical return.

One example of that control makes it clear: preventing the optimizer from concentrating 80% of the capital in a single stock because of an estimation artefact.

The rest of Quant500

What you are learning, applied to the index every day:

The model portfolio, weekly in your inbox

Every Saturday, its week in one minute: how it went, the best and the worst, and which insiders bought with their own money. Plus, the day the model is rebuilt, which stocks come in and which go out. A simulation, not advice. At most one email a week, no ads, no account; one-click unsubscribe. Made by one person: Pol Gracia.

A model portfolio with simulated results, not a personalized recommendation. Your email is used for this only: privacy.

Behind the Academy and the rest of Quant500 there is one person: Pol Gracia Serrahima.