# How to define the following matrix?

How to define the following matrix?

• Please provide any code that you've tried. Commented Aug 20, 2021 at 20:16
• You could use ToeplitzMatrix for this, e.g., ToeplitzMatrix[{1,0,0,0},{1,a,b,c}]//MatrixForm. Commented Aug 20, 2021 at 20:33

It's often easiest to construct matrices like this using SparseArray and Normal:

\[CapitalUpsilon][k_, a_] = (k + 1)^(a + 1) - 2 k^(a + 1) + (k - 1)^(a + 1);
mat[n_, a_] := 1/(n^a Gamma[a + 2]) Normal[
SparseArray[{{i_, i_} -> 1,
{i_, j_} /; j > i -> \[CapitalUpsilon][j - i, a]},
{n, n}]]


In words, SparseArray creates an $$n \times n$$ matrix, sets all elements of the matrix of the form $$M_{ii}$$ to 1, and sets all elements of the form $$M_{ij}$$ for which $$j>i$$ equal to $$\Upsilon_{j-i}$$.

mat[5,2] // MatrixForm


• Thank you. When I run your SparseArray code, I get the error SparseArray::adims: Array dimension specification {n,n} should be Automatic, a non-negative machine integer, or a list of non-negative machine integers. And When I run mat[5,2] // MatrixForm, I get 1/150. First of all; If I define n=3 etc., the code yields right results. Commented Aug 21, 2021 at 6:28
• @rbrt_cpr: Yes, this snippet only works for numerical values of n; matrices in Mathematica have to have a definite size. I'm not quite sure what the behavior you're describing might be due to. It's possible that I had a stray variable in memory when I was defining things; I will check on it again later today to confirm. Commented Aug 21, 2021 at 13:32
• @rbrt_cpr: Ah, I see the problem: I put a line break in an unfortunate place in my code snippet. To be clear, the factor 1/(n^a Gamma[a + 2]) should be multiplying Normal[SparseArray[ .... ]] I think it will work better if you cut and paste it now. Commented Aug 23, 2021 at 20:35