<s>[INST] rank of a matrix First of all I am sorry because I have asked similar kind of question a few days ago.But I still have problem with row reductions when there are letters in a matrix.The question is asking the value of 'a' when the rank of matrix  is 1 , 2 , 3 and 4. I am not good at row reductions.In each row operations the matrix became more confusing.If someone help me with the row reductions , I will be very happy.
         $$
\left(
\begin{array}{ccc}
1&1&2&0\\
2&a+1&3&a-1\\
-3&a-2&a-5&a+1\\
a+2&2&a+4&-2a
\end{array}
\right)
$$
 [/INST] You just need to work the algebra, just like you do with regular algebra.
Subtract twice the first row from the second row to get
$$\left(\begin{array}{rrrr}
1 & 1 & 2 & 0\\
0 & a-1 & -1 & a-1\\
-3 & a-2 & a-5 & a+1\\
a+2 & 2 & a+4 & -2a
\end{array}\right).$$
This is just algebra (e.g., the (2,2) entry is $a-1$ because $(a+1)-2 = a-1$).
Add three times the first row to the second row. The (3,2) entry will be $(a-2) + 3(1) = a+1$; the (3,3) entry will be $(a-5)+3(2) = a+1$. Etc. You get:
$$\left(\begin{array}{rrrr}
1 & 1 & 2 & 0\\
0 & a-1 & -1 & a-1\\
0 & a+1 & a+1 & a+1\\
a+2 & 2 & a+4 & -2a
\end{array}\right).$$
Subtract $a+2$ times the first row from the fourth row; that means subtracting $1(a+2)$ from the first entry; $1(a+2)$ from the second entry; $2(a+2)$ from the third entry; and $0$ from the fourth entry. You get:
$$\left(\begin{array}{rrrr}
1 & 1 & 2 & 0\\
0 & a-1 & -1 & a-1\\
0 & a+1 & a+1 & a+1\\
0 & -a & -a & -2a
\end{array}\right).$$
Add the fourth row to the third row to simplify things:
$$\left(\begin{array}{rrrr}
1 & 1 & 2 & 0\\
0 & a-1 & -1 & a-1\\
0 & 1 & 1 & -a+1\\
0 & -a & -a & -2a
\end{array}\right).$$
Exchange second and third row:
$$\left(\begin{array}{rrrr}
1 & 1 & 2 & 0\\
0 & 1 & 1 & -a+1\\
0 & a-1 & -1 & a-1\\
0 & -a & -a & -2a
\end{array}\right).$$
Add $1-a$ times the second row to the third row:
$$\left(\begin{array}{rrrr}
1 & 1 & 2 & 0\\
0 & 1 & 1 & -a+1\\
0 & 0 & -a & -1+2a-a^2\\
0 & -a & -a & -2a
\end{array}\right).$$
We are just doing algebra, only in several columns at the same time. Keep going until you get a matrix for which the rank will be easy to figure out, depending on the values of $a$. I've gotten you almost all of the way there.
</s>