square calculator for 2x2, 3x3 matrices

choose the size of the matrix:

method 1: see if its rank is 1. if it is 1, it can be written as one row (a) times one column (b), that is, a=ab. in this case, a^2=a(ba)b. note that ba is a number here. it can be proposed that a^2=(ba)a;

method 2: see if it can be diagonalized. if so, there will be an invertible matrix a such that a^(-1)aa=∧, so a=a∧a^(-1), a^2=a∧a ^(-1)a∧a^(-1)=a∧^2a^(-1); finally, use the most primitive method to multiply, matrix multiplication.