I would like to create an array of length n with each element i equal to the function
σEk[j_, k_, n_] :=
Insert[ConstantArray[IdentityMatrix[2], n - 1], PauliMatrix[j], k ]
evaluated at k=i
, i.e.
σEklist[j_, n_] := {σEk[j, 1, n], σEk[j, 2, n], ..., σEk[j, n, n]}
I tried using the Mathematica function for one-variable functions, Array[f,n] = {f[i], ..., f[n]}
, using:
σEklist[j_, n_] := Array[σEk, n]
and I also tried to define σEk[j, k, n]
as a function of the variable k
only within the function σEklist[j_, n_]
using Module
, i.e.
σEklist[j_, n_] :=
Module[{f[k_] := σEk[j, k, n]}, Array[f, n]]
but in each case the function σEklist[j_, n_]
doesn't read the n
and j
variables in the function σEk[j, k, n]
as being its own variables.
Any help or tips would be appreciated, thanks.
σEklist[j_, n_] := Array[σEk[j,#,n]&, n]
? $\endgroup$ – swish Nov 4 at 18:19