Suppose I have a reduced row echelon form of a matrix for linear equations. The pivots from the corresponding Gaussian elimination are available. For example, in $$ \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 1 \\ 0 & 0 & 0 \end{pmatrix} \cdot \begin{pmatrix} y_1 \\ y_2 \\ y_3 \end{pmatrix} = \begin{pmatrix} a \\ 0 \\ 0 \end{pmatrix} $$ I'd remove $y_2$ and $y_3$, together with the last 2 rows and columns, to obtain $y_1 = a$. This is required for arbitrary such matrices in the row-echelon form.
Q: If the matrix is underdetermined, how to programmatically find the free variables?
(Alternatively, I could seek the dependent variables, like $y_1$ in the example.) I could get this information by attempting to solve the equations system. As the solutions are not needed, could another way be more efficient?