Mean-Variance Optimization
00 · Symbol Glossary
Column vector in . Coordinate is the share of the book in asset . A negative coordinate is a short sale. Fully invested means .
with . The portfolio mean is the scalar . Chapter 02 already has the one-line version .
A number the investor requires: . It is an input, not an optimum. Different targets produce different books.
Symmetric matrix, . Portfolio variance is . The optimizer below needs positive definite, which is Linear Algebra Chapter 14.
The column of ones. is the budget, the sum of the weights.
prices the mean constraint and prices the budget. They are solved for, together with . They are not the risk-aversion parameter.
Positive scalar in the objective . Large punishes variance more heavily. A different object from and .
, , , and . All four are numbers. when is positive definite and the assets do not all share one mean.
The fully invested book of smallest variance, with no target mean imposed. , and its variance is .
01 · The Choice
Chapter 02 fixed a weight vector and computed and . This chapter turns that around. The means and the covariance are the inputs. The unknown is .
An investor who cares only about mean and variance faces a quadratic program. The objective is quadratic because variance is the quadratic form . The constraints used here are linear equalities: spend the whole budget, and hit a chosen mean. A quadratic objective with linear equality constraints is the Markowitz problem in the form where a closed form still exists.
Two modeling choices are already settled, and both are easy to reopen by accident.
The budget is . Drop it and the coordinates of are no longer portfolio weights: they are an unscaled position, and is no longer a return on wealth. The zero vector has variance zero and is the unconstrained minimizer of . It is also not a portfolio.
Short sales stay legal. A coordinate of may be negative. Forbidding that is an inequality constraint, , and the problem becomes a quadratic program whose active set changes with the target. That version is Chapter 10. Nothing in the inverse formula below knows about a no-short rule.
A risk-free asset is not in the menu. Every name in and is risky. Mixing cash with a risky book, and the capital market line that comes with it, is Chapter 05.
02 · Two Programs
The same preference can be written in either of two ways. They select the same books, for a reason derived in Section 08. The algebra is different enough that both are worth setting up.
Choose to
The factor does not move the minimizer. It makes the gradient of the objective equal to rather than , which keeps the first-order condition free of a stray .
For a fixed , choose to
The mean is rewarded one-for-one. Variance is charged at price . There is no separate target : the optimal mean is whatever this tradeoff produces.
The target-mean program is the one with an explicit closed form in and . The risk-aversion program is the one that says which of those targets a mean-loving investor will actually pick.
With the target-mean program has two unknowns and two linear equalities. If , the feasible set is a single point, and never votes on the weights.
Take , , and . Then and give . The book is half and half for every covariance matrix. still sets the variance of that unique feasible book, and it still sets the multipliers, but it does not set .
A genuine variance-versus-mean choice inside the target-mean program starts at , where two equalities leave free directions. The risk-aversion program still has a real tradeoff at , because it imposes only the budget.
03 · The Lagrangian
Work with the target-mean program. Attach a multiplier to each equality and build
The sign in front of each multiplier is a convention. Flipping both signs flips the signs of and and leaves the combination unchanged, so the weight formula in the next section is the same either way. With the sign written here, is the derivative of the minimized objective with respect to , and is the derivative with respect to the required sum of weights.
Differentiate in . For a symmetric matrix the gradient of the quadratic form is
One line of coordinates is enough to see the factor. The form is . The derivative in hits the left factor and the right factor:
Symmetry is what lets the two halves add into rather than into a half-and-half of and . Feed in symmetric. A covariance matrix already is.
The linear terms contribute . Stationarity, together with the two constraints that were built into , is the first-order system.
A triple is a critical point of the target-mean program when
If is invertible the first block is the weight structure
The multipliers are still unknown. They are the numbers that make this obey the two equalities.
Minimize instead of half of it, and the stationarity condition becomes . The weights match the formula above with . Quote multipliers from a paper only after checking which objective that paper differentiated. The identity , coming up in Section 05, belongs to the half-objective convention, the one in which .
04 · Positive Definiteness
Existence and uniqueness are the content of , in the sense of Linear Algebra Chapter 14: for every , equivalently every eigenvalue of strictly positive, equivalently a Cholesky factor with a positive diagonal.
Assume is symmetric positive definite, and assume is not a scalar multiple of . Then for every target the target-mean program has exactly one solution . The multipliers at that solution are unique as well.
Three separate facts are packed in there.
The objective is strictly convex. The Hessian of is itself. Positive definite Hessian means strict convexity: along any line, the graph of the objective bends upward. A strictly convex function on a convex set has at most one minimizer. The feasible set is an affine subspace, cut out by two linear equalities, so it is convex.
A minimum is attained. Along the feasible set, as . There is no feasible direction with , because there is no such direction anywhere. The objective cannot slide off to infinity and stay finite, so a minimizer exists. Combined with strict convexity, it is the only one.
The critical point is that minimizer. An affine constraint set needs no inequality-multiplier theory. The gradient condition , plus feasibility, is necessary and sufficient. Sufficiency is the Hessian: the second derivative in is at every point, so the critical point cannot be a maximum or a saddle.
The multipliers are unique when the two constraint gradients are linearly independent. Those gradients are and . They are independent precisely when is not a multiple of , i.e. when at least two assets have different expected returns. That is the constraint qualification behind the "unique " half of the definition.
If instead , every fully invested book has mean . A target is infeasible: no weights satisfy both equalities. A target makes the mean constraint a copy of the budget. The weight problem collapses to the global minimum-variance portfolio of Section 07, which is still unique under . The multipliers are no longer unique, because a redundant constraint can have its shadow price split arbitrarily between and . The weight does not care how that split is made: the stationarity condition says is a multiple of either way.
Let two assets satisfy . The eigenvalues are and , so is positive semidefinite and singular. The formula asks for and stops.
The kernel vector has and . Adding preserves the budget and preserves the variance: . Every fully invested book has
If the two means are equal, every fully invested book is optimal for the global minimum-variance problem, and the target-mean problem is either the same problem or infeasible. If the two means differ, , so moving along hits every target mean at this same variance. The minimum is attained on a whole line, not at a point.
Consequence: a sample covariance from periods on assets has rank at most . When it is singular for this exact reason, and Chapter 14's criterion says it is not positive definite. The closed form is not a formula for that matrix. A computer inverse of a matrix with a tiny eigenvalue is the ill-conditioned cousin of this failure, taken up in Section 09.
05 · The Closed Form
Impose and substitute into the two equalities. Positive definiteness also puts , because the eigenvalues of the inverse are the reciprocals of the eigenvalues of , and reciprocals of positive numbers are positive. The four scalars
are therefore well defined, and . Symmetry of gives as well. The inner product obeys Cauchy–Schwarz, so
which is , with equality if and only if and are linearly dependent. Under the standing assumption that the means are not all equal, .
Write the constraints in . Dot the weight formula with and with :
Eliminate . The budget row gives . Substitute into the mean row and clear the denominator:
Hence .
Read off both multipliers. With ,
The second one is the same elimination run the other way. From and ,
Assemble the weight. Substitute the multipliers back into the stationarity condition:
As varies, moves on a straight line in weight space: it is an affine function of the target. The curve those books trace in the plane is the subject of Chapter 04.
One identity falls out of stationarity and is worth keeping as a check. Because ,
The right-hand side is a quadratic polynomial in the target. Its minimum over sits at , and the minimal value is . That minimizing target is the mean of the global minimum-variance portfolio, which is the next section. Chapter 04 reads the geometry of this quadratic; the algebra is already finished once the multipliers are known.
06 · Three Assets, Both Ways
The numbers are in percentage points: a mean of is two percent, and is in percent squared. Dividing every mean by and every entry of by converts to decimal returns and does not change . The integers are chosen so the inverse stays integral.
The inverse is the integer matrix
Check the first column: times equals . The other two columns match the same way. Leading principal minors of are , , and , all positive, so Sylvester's criterion from Chapter 14 gives , and therefore .
The four scalars. , so . Then . And , so . Hence .
Multipliers. and .
Weights. , and
The three coordinates sum to . The mean is .
Variance, two ways. The multiplier identity gives . The quadratic formula gives . Stationarity itself: , and dotting with recovers .
The same point should come out of elementary calculus, with the two equalities substituted in before any matrix inverse. That route is available because a three-asset problem with two equalities has one free variable.
Kill the budget. Set .
Kill the mean. becomes , which simplifies to . One free weight remains. Write it as , so . This tie is special to the target ; a different leaves and in a different linear relation.
Variance as a quadratic in . Applying produces . Dot with :
Minimize. The derivative vanishes at , and the second derivative is positive. Then , so , in agreement with the matrix formula. The variance at this is again.
Keep the running and , and the target , but drop the budget. Stationarity is , so . The mean constraint reads . With this is , and
The coordinates sum to , not to . The variance is , smaller than the fully invested .
Why it breaks: is the variance of a position with the right mean and the wrong gross exposure. Multiplying by restores the budget and scales the mean from to . The cheaper variance was never a variance at mean on a fully invested book.
Consequence: the zero vector is the same mistake taken to the end. It minimizes with no constraints, its mean is , and it is not a portfolio. Both equalities are part of the program.
07 · The Global Minimum-Variance Portfolio
Ignore the target. The investor who wants the smallest variance among fully invested books solves
The Lagrangian is . Stationarity is . Under ,
The variance identity collapses to , since and . The mean is whatever that book happens to earn:
This is the target-mean solution at . The formula for gives , so the mean constraint's multiplier vanishes exactly there: the target is the one the minimum-variance book already hits. In the running example, and
Asset 2, the high-variance name, is held at zero weight. That is legal. Nothing in the equality-constrained problem forces an interior holding. Raise the target from to , as in Section 06, and asset 2's high mean pulls it back in, at weight .
has a zero, and the Section 06 book is strictly positive, while other targets on this same produce a short. Sign patterns are an output. Imposing in advance deletes some of these books and is a different program. Chapter 10 treats that quadratic program. This chapter's formula applies when the only restrictions are the two equalities.
08 · One Risk-Aversion Parameter
Now solve the risk-aversion program. The Lagrangian, with the budget multiplier written so it is not confused with , is
Stationarity is . For and ,
The budget forces , so . Rearrangement is the useful form: the optimal book is the global minimum-variance portfolio plus a tilt toward high mean, in the geometry, scaled by .
The tilt is orthogonal to in the ordinary dot product — its coordinates sum to zero — so every preserves the budget. The mean it delivers is
For and this mean sits at or above . Sending kills the tilt and returns . Sending down toward inflates the tilt without bound: a vanishing penalty on variance is a license for arbitrarily large long-short positions in the direction marks as high mean. Every target strictly below solves the target-mean program for someone who asked for that mean, and it solves the risk-aversion program for no . Chapter 04 draws that distinction on the frontier. The algebra that forces it is the display above.
On the running example, take . Then , , and the optimal mean is . The excess-mean vector is , and sends it to . One fifth of that tilt, added to , is
Check the first-order condition directly. , so and . That is with . Budget and stationarity both hold.
The same book comes out of the target-mean formulas at . There and , so
One risk aversion, one target mean, one weight vector. Varying and varying are two parameterizations of one set of books. The map between them is .
09 · Errors in the Inputs
The map is exact for the and that are typed in. Those two objects are estimated. This section records how the closed form responds. It does not build a robust estimator.
Differentiate the risk-aversion stationarity condition in the mean, holding and fixed. The Hessian in is , so the weight moves by
The correction keeps . The size of the move is governed by . A small risk aversion inflates every input error. A small eigenvalue of inflates the component of the error that lies in the corresponding eigenvector, because that eigenvalue is a large eigenvalue of . Chapter 14's is the quantitative version of "how positive definite": close to zero means a large inverse and unstable weights.
A two-asset family makes the factor visible. Normalize both variances to and set the correlation equal to with , so
The eigenvalue check is immediate: and . The small eigenvalue is , on the long-short direction, so . Equal variances force , whose mean is . The excess-mean vector is therefore . Section 08's tilt at multiplies that vector by :
The long-short imbalance is the mean gap divided by twice the residual eigenvalue. At and the book is : a mean gap of standard deviations, on a pair with correlation , puts the entire budget in the higher-mean name. Misread the gap as and the same formula returns , a half-short of the other name. The first-order condition confirms the first of these: , which is the budget multiplier .
Nothing here says to shrink , to blend toward a prior, or to cap the shorts. Each of those is a different estimator. The only claim is that the Markowitz map is steep exactly where is small or is small, and that a singular sample covariance is the cliff at the end of that slope. Adding a ridge is what the two-asset family just did by hand; choosing , and imposing the short-sale inequalities of Chapter 10, are later repairs. They are not implied by the first-order condition.
A covariance with eigenvalues and is positive definite, so Section 04's uniqueness theorem applies: there is exactly one for the matrix that was typed. Uniqueness is not stability. The inverse amplifies the low-eigenvalue direction by , and the weight formula multiplies by that inverse.
Why it breaks: the theorem guarantees a unique solution of the problem you wrote down. It says nothing about the distance between that solution and the solution of the neighboring problem with a slightly different or a slightly different small eigenvalue. Those two solutions can sit far apart in weight space while both being the exact optimum of their own inputs.
Consequence: report the condition number, or , next to any book that came out of . A unique critical point of a badly conditioned quadratic is still a badly conditioned answer. If the inverse fails outright because a sample eigenvalue is zero, stop: that is the singular case in Section 04, and no weight vector is "the" solution.
10 · Exercises
One constraint, the budget. Stationarity is . Invert, then choose so the weights sum to . The variance equals that same under the half-objective convention. As a check, should be a constant vector.
and . Then and , so
The variance is . The mean is . And , so the budget multiplier is , matching the variance. The lower-variance asset gets the larger weight. It does not get the whole book: the off-diagonal makes a mix cheaper than concentration, and equal marginal contributions are the first-order condition for that mix.
Two assets have and . Find the global minimum-variance weights, their variance, and their mean. Verify that is a multiple of , and name the multiple.
With the inverse is free: , , . Use and , then . Check the variance both as and as .
, , , and . Then and , so
The coordinates sum to . The mean is . The variance is , and . The short is in asset , the lowest mean. Hitting a target mean of , above the equal-weight mean , takes a long position in the high-mean name funded in part by shorting the low-mean name. Because , covariance is not what creates the short. The means and the budget are.
Three uncorrelated assets have variance each, so , and . Using the closed form, find at the target . Confirm the budget, the mean, and the variance. Which asset is held short, and why does that short survive even though every covariance is zero?
Keep and . With only the mean constraint, stationarity is and , so . Compare the sum of the coordinates, and the variance, with Exercise 3.2. If you rescale to restore the budget, recompute the mean before comparing variances.
and , so . The coordinates sum to . The variance is , and because while .
That comparison does not say the budget-free position is a better portfolio at the same mean. Divide by to force the weights to sum to : the rescaled book is , whose mean is , not . Leaving the target is what made the variance look cheap. The admissible variance at mean on a fully invested book is the from Exercise 3.2. The zero vector is the same error with both constraints dropped: variance , mean , budget .
Using the data of Exercise 3.2, minimize subject to and with no budget constraint. Report the resulting vector, the sum of its coordinates, and its variance. Explain why that variance is not comparable to the variance of the fully invested solution, and what happens to the mean if the vector is rescaled to sum to .
Section 09's two-asset family, at risk aversion , has . The imbalance is the mean gap divided by twice the small eigenvalue. Compute that coefficient at each pair . Correlation is , so a larger is a less collinear pair.
(a) , so .
(b) , so . The same correlation, with the mean gap four times larger, flips asset from a long quarter to a half short.
(c) , so . The mean gap is the original one from (a). The book stays near equal weight because is two and a half times the eigenvalue of (a) and (b), and the long-short coefficient shrinks by that same factor. The change from (a) to (b) is the mean gap, four times larger at a fixed eigenvalue, and that is what opens the short. The change from (a) to (c) is the eigenvalue, and that is what keeps the book near .
In the two-asset family of Section 09, variances are normalized to , the correlation is , the mean gap is , and . (a) Compute at and . (b) Keep and replace the gap by the mismeasured value . (c) Compute at and . Say which change, the mean gap or the small eigenvalue, turns the mild book in (a) into the short-sale book in (b), and why (c) stays close to equal weight.
11 · Chapter Summary
| Object | Role |
|---|---|
| Target-mean program | subject to and |
| Risk-aversion program | subject to the budget alone |
| Stationarity | , hence when is invertible |
| Strictly convex objective, exists, exactly one fully invested minimizer | |
| Positive when means are not all equal; the denominator of both multipliers | |
| Variance check under the half-objective convention; a quadratic in | |
| Target-mean solution at , where ; variance | |
| Risk-aversion weights | plus a tilt ; mean |
| target-mean | Two equalities pin whenever ; prices the variance and does not choose the mix |
| Singular or tiny | Inverse formula unavailable, or available and violently sensitive to |
Varying moves along a line in weight space and traces a curve of . Drawing that curve, and separating the limb a risk-averse investor will hold from the rest of the minimum-variance set, is the next chapter. Cash, the capital market line, and the CAPM are not inputs here.
Next: Chapter 04 — The Minimum-Variance Frontier, which takes the weights computed here and reads off the curve they trace.