'Return reduced row-echelon form of matrix and indices of pivot vars.
Parameters
iszerofunc : Function
A function used for detecting whether an element can
act as a pivot.  `lambda x: x.is_zero` is used by default.
simplify : Function
A function used to simplify elements when looking for a pivot.
By default SymPy\'s `simplify`is used.
pivots : True or False
If `True`, a tuple containing the row-reduced matrix and a tuple
of pivot columns is returned.  If `False` just the row-reduced
matrix is returned.
normalize_last : True or False
If `True`, no pivots are normalized to `1` until after all entries
above and below each pivot are zeroed.  This means the row
reduction algorithm is fraction free until the very last step.
If `False`, the naive row reduction procedure is used where
each pivot is normalized to be `1` before row operations are
used to zero above and below the pivot.
Notes
The default value of `normalize_last=True` can provide significant
speedup to row reduction, especially on matrices with symbols.  However,
if you depend on the form row reduction algorithm leaves entries
of the matrix, set `noramlize_last=False`
Examples
>>> from sympy import Matrix
>>> from sympy.abc import x
>>> m = Matrix([[1, 2], [x, 1 - 1/x]])
>>> m.rref()
(Matrix([
[1, 0],
[0, 1]]), (0, 1))
>>> rref_matrix, rref_pivots = m.rref()
>>> rref_matrix
Matrix([
[1, 0],
[0, 1]])
>>> rref_pivots
(0, 1)'

def rref(self, iszerofunc=_iszero, simplify=False, pivots=True, normalize_last=True):

    simpfunc = (simplify if isinstance(simplify, FunctionType) else _simplify)
    (ret, pivot_cols) = self._eval_rref(iszerofunc=iszerofunc, simpfunc=simpfunc, normalize_last=normalize_last)
    if pivots:
        ret = (ret, pivot_cols)
    return ret
