I am new to Mathematica and try to define a simple recursive formula which is illustrated as below:
A[1] := {{0, 0}, {0, 0}} // MatrixForm;
identity := {{1, 0}, {0, 1}};
A[n_] := KroneckerProduct[identity, A[n - 1]];
A[2] // MatrixForm
The result is expected to be a zero matrix with size 4$\times$4, i.e.
$$ \begin{pmatrix} 0&0&0&0\\ 0&0&0&0\\ 0&0&0&0\\ 0&0&0&0 \end{pmatrix} $$
if I let n=2. However, the returned result is
$$ \begin{pmatrix} 0&0&0&1\\ 0&0&1&0\\ 0&1&0&0\\ 1&0&0&0 \end{pmatrix} $$
I have checked many times but still don't know what's the error for my code. Could anyone give some hints?
MatrixForm) in variable definitions. Use eitherMatrixForm[A[1] = ... ]or(A[1] = ... )//MatrixFormto isolate the wrapper from the variable definition. – Bob Hanlon Sep 28 '21 at 05:39