I want to know $PA=LU$ , what is $P$?? I know that if there is a $0$ in the diagonal, I use multiply $P$ to $A$.
But, I saw the use of $P$ even if there was no zero.
I want to know what $P$ is and what role it is for.
 A: The matrix $P(l,s)$ if multiplied by the matrix $A$ from the left switches the $l^{th}$ and the $s^{th}$ rows of $A$, and if multiplied by $A$ from the right, it switches the $l^{th}$ and the $s^{th}$ columns of $A$
A: I'm assuming you are referring to LU decomposition with partial pivoting (I'm not familiar with full pivoting, but I believe partial pivoting is more commonly used in practice).
The matrix $P$ is a permuation matrix - i.e. its rows/columns are a permutation of the rows/columns(respectively) of the identity matrix, e.g. $\begin{pmatrix}0&1&0\\1&0&0\\0&0&1\end{pmatrix}$ is a permutation matrix).
You are correct that a perumtation is applied to the rows of a reduced matrix so that there is a nonzero term to pivot on. Typically we will still permute the rows even if the diagonal element is nonzero. This is because pivoting on the largest (in terms of absolute value) number available is more numerically stable.
For example we would rather pivot on,
$$\begin{pmatrix}
1&4&8\\
0&1&7\\
0&0.1&1\\
\end{pmatrix}$$
than pivot on
$$\begin{pmatrix}
1&4&8\\
0&0.1&1\\
0&1&7\end{pmatrix}$$
for numerical stability.
