2
$\begingroup$

I'd like to create a matrix with specific elements subscripts. Matrix is like below. enter image description here

This matrix is sized at M*M and subscripts are indexed by (m-n,n). And I need to input subscripts into function as arguments.

I got this idea because I know the List in Mathematica can operate listablly. But I'm not sure this kind of subscripts is achievable.

Basically speaking, all I need to do is just to input subscripts(i.e.(m-n,n)) as arguments and fetch the results(i.e. Lambda(x,y)) to save them into this matrix at corresponding position. But how can I assign these specific subscripts to elements?

$\endgroup$
6
$\begingroup$

Is this what you are looking for?

M=3;
Table[Which[
  col<row,0,
  True,Subscript[λ,col-row,row]
],{col,0,M},{row,0,M}]

which returns

{{Subscript[λ, 0, 0], 0,                  0,                  0},
 {Subscript[λ, 1, 0], Subscript[λ, 0, 1], 0,                  0}, 
 {Subscript[λ, 2, 0], Subscript[λ, 1, 1], Subscript[λ, 0, 2], 0}, 
 {Subscript[λ, 3, 0], Subscript[λ, 2, 1], Subscript[λ, 1, 2], Subscript[λ, 0, 3]}}

without more fiddling and time I can't make those subscripts into tiny digits, but it appears to be what you are asking for when I evaluate that in a notebook.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks a lot Bill! $\endgroup$ – PalvinWang Jul 5 at 3:43
3
$\begingroup$
ClearAll[array]
array[m_Integer, n_Integer] := 
 Array[If[# < #2, 0, Subscript[λ, # - #2, #2]] &, {m, n}, {0, 0}]


MatrixForm @ array[5, 5]

enter image description here

TeXForm @ MatrixForm@array[5, 5]

$$\left( \begin{array}{ccccc} \lambda _{0,0} & 0 & 0 & 0 & 0 \\ \lambda _{1,0} & \lambda _{0,1} & 0 & 0 & 0 \\ \lambda _{2,0} & \lambda _{1,1} & \lambda _{0,2} & 0 & 0 \\ \lambda _{3,0} & \lambda _{2,1} & \lambda _{1,2} & \lambda _{0,3} & 0 \\ \lambda _{4,0} & \lambda _{3,1} & \lambda _{2,2} & \lambda _{1,3} & \lambda _{0,4} \\ \end{array} \right)$$

| improve this answer | |
$\endgroup$
2
$\begingroup$

This is very easy to do with SparseArray:

Normal @ SparseArray[{{i_, j_} /; i >= j :> Subscript[λ, i - j, j - 1]}, {5, 5}]
| improve this answer | |
$\endgroup$

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.