I need to construct special matrix in mathematica which is given in the following image
Answer
The Array
command provides a simple way to transform a function into a matrix.
n = 6;
η = ConstantArray[1, n+1];
η[[1]] = 2;
a = Array[{i, j} \[Function] UnitStep[i - j] Mod[i - j, 2] 4 (i - 1)/η[[j]], {n+1, n+1}];
a // TeXForm
$$\left( \begin{array}{ccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 2 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 8 & 0 & 0 & 0 & 0 & 0 \\ 6 & 0 & 12 & 0 & 0 & 0 & 0 \\ 0 & 16 & 0 & 16 & 0 & 0 & 0 \\ 10 & 0 & 20 & 0 & 20 & 0 & 0 \\ 0 & 24 & 0 & 24 & 0 & 24 & 0 \\ \end{array} \right)$$
Is this what you are looking for? Zero-based indexing is quite untypical in mathematics...
Comments
Post a Comment