How to define the following matrix? enter image description here

  • 2
    $\begingroup$ Please provide any code that you've tried. $\endgroup$
    – Domen
    Commented Aug 20, 2021 at 20:16
  • 5
    $\begingroup$ You could use ToeplitzMatrix for this, e.g., ToeplitzMatrix[{1,0,0,0},{1,a,b,c}]//MatrixForm. $\endgroup$
    – Carl Woll
    Commented Aug 20, 2021 at 20:33

1 Answer 1


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

enter image description here

  • $\begingroup$ 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. $\endgroup$ Commented Aug 21, 2021 at 6:28
  • $\begingroup$ @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. $\endgroup$ Commented Aug 21, 2021 at 13:32
  • 1
    $\begingroup$ @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. $\endgroup$ Commented Aug 23, 2021 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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