# How to define the following matrix

How to define the following matrix in Mathematica?

$$A(n) = \begin{pmatrix} B_{1} & B_{2} & \cdots & B_{n} & 1 \\ B_{n} & B_{1} & \cdots & B_{n-1} &1 \\ \vdots & \vdots & \ddots & \vdots \\ B_{2} & B_{3} & \cdots & B_{1} & 1\\ A_{1} & A_{2} & \cdots & A_{n} &1 \end{pmatrix}$$

For instance :

for $n=4$

Table[Subscript[B, k], {k, 1, 4}]


$$A(4) = \begin{pmatrix} B_{1} & B_{2} & B_{3} & B_{4}&1 \\ B_{4} & B_{1} & B_{2} & B_{3}&1 \\ B_{3} & B_{4} & B_{1} & B_{2}&1 \\ B_{2} & B_{3} & B_{4} & B_{1}&1 \\ A_{1} & A_{2} & A_{3} & A_{4}&1 \end{pmatrix}$$

how to define $A(n)$ as a function of $n$?

And then I wanna manipulate $A(n)$

Manipulate[A[n], {n, 2, 30}]


Thank you in advance to any one who may be able to give me some ideas

Three possibilities:

With[{n = 4},
ArrayFlatten[{{NestList[RotateRight, Array[B, n], n - 1], 1}, {{Array[A, n]}, 1}}]]

With[{n = 4},
ArrayFlatten[{{ToeplitzMatrix[RotateRight[Reverse[Array[B, n]]],
Array[B, n]], 1}, {{Array[A, n]}, 1}}]]

With[{n = 4},
PadRight[Append[NestList[RotateRight, Array[B, n], n - 1], Array[A, n]],
{n + 1, n + 1}, 1]]

• +1. But, can you use Subscript[B, n]  $B_{n}$ instead $B[n]$? Manipulate[ ArrayFlatten[{{ToeplitzMatrix[RotateRight[Reverse[Array[B, n]]], Array[B, n]], 1}, {{Array[A, n]}, 1}}] // MatrixForm, {n, 2, 5, 1}] // TraditionalForm see here
– vito
Jun 23, 2016 at 19:29
• You can replace Array[B, n] with the appropriate call to Table[] and Subscript[]. Jun 23, 2016 at 19:30