I think in Mathematica the omission of a function that can create a bordered matrix. This code works

m = {{a, b}, {c, d}};
k = {α, β}
l1 = Insert[ k, 0, 1];
c1 = Insert[Transpose[m], k, 1] // Transpose;
m1 = Insert[c1, l1, 1];
m1 // MatrixForm

and gives

$\begin{pmatrix} 0 & \alpha & \beta\\ \alpha & a & b\\ \beta & c & d \end{pmatrix}$

as expected.

So I have tried to design a function. But obviously it doesn't work

bordhess[mat_?MatrixQ[mat], vec_?VecQ[vec] ] := 
 Block[{x = mat, y = vec},
  l1 = Insert[ y, 0, 1];
  c1 = Insert[Transpose[x], k, 1] // Transpose;
  Insert[c1, l1, 1]

and even If I have been able to create such a function, I wonder how to generalize the problem to many vectors.

  • 3
    $\begingroup$ ArrayFlatten[{{0, {k}}, {Transpose@{k}, m}}] $\endgroup$ Jan 18 '17 at 9:10
  • $\begingroup$ Thanks too much simple for my complicated mind! $\endgroup$ Jan 18 '17 at 9:18
  • $\begingroup$ @SimonRochester You should make this an answer :) $\endgroup$
    – xzczd
    Jan 18 '17 at 10:07


borderF = ArrayReshape[{0, #, Transpose[{##}]}, 1 + Dimensions@#2] &;

mat = Array[Subscript[a, ##] &, {4, 4}];
multipliers = Array[Subscript[λ, #] &, 4];
borderF[multipliers, mat] // MatrixForm

Mathematica graphics

  • $\begingroup$ Does this do the multi-row block-bordering shown in the last images of Simon's and my answers? I believe that's what the OP is asking about (when wondering "how to generalize the problem to many vectors"), but I could be wrong. $\endgroup$
    – Michael E2
    Jan 19 '17 at 1:58
  • $\begingroup$ @MichaelE2, no it doesn't handle multi-row borders. Still trying to figure out the appropriate argument for ArrayReshape to get multi-row borders. $\endgroup$
    – kglr
    Jan 19 '17 at 2:14
  • $\begingroup$ @cyrcyrille.piatecki , i suppose the Accept is a mistake:) considering the generality and elegance of Simon's and Michal's answers. $\endgroup$
    – kglr
    Jan 19 '17 at 3:00
  • $\begingroup$ Of course, I have checked yours as I could have checked an other because all were satisfying I should have checked the more elegant but I do not know <hich is the one. Perhaps we could ask for the possibility to multi check some time. $\endgroup$ Jan 19 '17 at 12:38

You can do this with ArrayFlatten. Here is a generalization to one or more vectors -- I'm not sure if it's what you're looking for:

bordhess[mat_?MatrixQ, mat1_?MatrixQ] := ArrayFlatten[{{0, mat1}, {Transpose@mat1, mat}}]

bordhess[mat_?MatrixQ, vec_?VectorQ] := bordhess[mat, {vec}]

Then you have

m = {{a, b}, {c, d}};
k = {α, β};
j = {γ, δ};

bordhess[m, k] // MatrixForm

Mathematica graphics

bordhess[m, {k, j}] // MatrixForm

Mathematica graphics


Here's an answer to the title question, about constructing a bordered Hessian, in case someone come looking for answer to it. It comes directly from calculus, instead of playing with matrices.

Basically thus:

D[f + λ.g, {{λ1, λ2,..., x1, x2,...}, 2}]


λ = {λ1, λ2,...}

are the Lagrange multipliers and

x = {x1, x2,...}

are the variables of f and g.


bH[f_, g_List, x_List, param_: K] := bH[f, g, x, Array[param, Length@g]];
bH[f_, g_List, x_List, λ_List] := D[f + λ.g, {Join[λ, x], 2}];

bH[w^4 x + x^3 y + y^2 z + z^4,
 {w^2 + x^2 + y^2 + z^2, w^2 + 2 x^2 + 3 y^2 + 4 z^2},
 {w, x, y, z}, {λ, μ}] // MatrixForm

Mathematica graphics

  • $\begingroup$ Bordered Hessian can also be used in checking quasi-concavity $\endgroup$ Jan 19 '17 at 12:40
  • $\begingroup$ @cyrille.piatecki Yes, second derivatives are useful. (I'm not sure why the comment, actually. I suppose you mean specializing at bH[f, {f}, {x, y,..}, {λ}] /. λ -> 0.) $\endgroup$
    – Michael E2
    Jan 19 '17 at 13:19
  • $\begingroup$ Michael E2 Not exactly. In economics, one is obliged to assume that every upper level set of the consumer's ordering is convex, which is equivalent to the condition that any function that represents the consumer's ordering is quasiconcave (for definition see mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/…). If the function is $C^2$ the condition of quasiconcavity is linked to the bordered hessian $\endgroup$ Jan 20 '17 at 6:01
  • $\begingroup$ -> continued --- principal minors should be alternatively negative/ positive beginning with the second order --- by construction the first order is 0. If the function is strtictly quasi-convex then on has a maximum. $\endgroup$ Jan 20 '17 at 6:01
  • $\begingroup$ @cyrille.piatecki It seems the same thing, no? At least the formula for bordered Hessian in the ref. link in your comment is the same. $\endgroup$
    – Michael E2
    Jan 20 '17 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.