1
$\begingroup$

I am constructing a matrix using the following code

a[μ_] := {{2 μ + 1, 0, 0, 2 Sqrt[μ (μ + 1)]}, {0, 
    2 μ + 1, 2 Sqrt[μ (μ + 1)], 0}, {0, 
    2 Sqrt[μ (μ + 1)], 2 μ + 1, 
    0}, {2 Sqrt[μ (μ + 1)], 0, 0, 2 μ + 1}};
b[μ_] := {{2 μ + 1, 0, 0, -2 Sqrt[μ (μ + 1)]}, {0, 
    2 μ + 1, -2 Sqrt[μ (μ + 1)], 
    0}, {0, -2 Sqrt[μ (μ + 1)], 2 μ + 1, 
    0}, {-2 Sqrt[μ (μ + 1)], 0, 0, 2 μ + 1}};
gamma[μ_] := ArrayFlatten[{{a[μ], 0, 0, 0}, {0, a[μ], 0, 0}, {0, 0, 
         b[μ], 0}, {0, 0, 0, b[μ]}}];

The problem is that in my calculations, I need a gamma matrix of different dimensions, but I am finding no way to generalize this so that I can construct an n*n matrix efficiently.

$\endgroup$
  • 1
    $\begingroup$ maybe gamma2[μ_] := SparseArray[Band[{1, 1}] -> {a[μ], a[μ], b[μ], b[μ]}, {16, 16}]? $\endgroup$ – kglr Aug 2 '18 at 13:51
  • $\begingroup$ no not this way ,, in this way i have to write a[mu] and b[mu] four time ,, but i want i write a[mu] and b[u] just one time , it take itself two or three times of a[mu ] and b[mu] , or in otherworda i want that i just given dimension and i required desired matrix $\endgroup$ – muhammad asif Aug 3 '18 at 6:42

Browse other questions tagged or ask your own question.