NumPy tril preserves a lower triangular region and replaces entries above it with zero
Keeping a triangular region is different from collecting selected entries into a shorter vector. NumPy tril returns an array whose upper positions are replaced with zero while the lower region remains in place. Academia Master Trader presents this English lesson for readers in Chad, using constructed matrices to explain the diagonal boundary, offset direction and preserved output shape.
The default includes the main diagonal
After import numpy as np, define m = np.array([[2,4,6],[7,9,11],[12,14,16]]). The call np.tril(m) returns [[2,0,0],[7,9,0],[12,14,16]].
The main diagonal entries two, nine and sixteen remain. Entries below that diagonal also remain, while entries above it become zero. The operation follows positions rather than deciding which numeric values are larger or smaller.
Using zero-based indices, a position belongs to the default retained region when its column index is no greater than its row index. That positional rule explains why the first row keeps one entry, the second row keeps two and the third row keeps three.

Negative offsets retain a smaller region
The call np.tril(m,k=-1) returns [[0,0,0],[7,0,0],[12,14,0]]. Its boundary lies one diagonal below the main diagonal. The original main diagonal is therefore replaced with zero along with the positions above it.
The call does not move entries down one row. Seven, twelve and fourteen stay in their original coordinates. The offset changes which positions are retained, not where values are placed in the output.
This distinction matters when a result contains many zeros. A zero can represent a position excluded by the triangular rule, or it can be an original value already present in a retained position. Looking only at output values cannot distinguish those cases.
Positive offsets retain an additional upper diagonal
The call np.tril(m,k=1) returns [[2,4,0],[7,9,11],[12,14,16]]. The first diagonal above the main diagonal is included. In this example, only the upper-right entry six is replaced with zero.
A positive k expands the retained region upwards, while a negative k narrows it downwards. The general retained-position rule is column index minus row index less than or equal to k. Stating this rule avoids relying on the visual appearance of a particular square matrix.
The retained entries keep their signs and magnitudes. Negative values are not excluded merely for being negative, and positive values above the boundary are still replaced with zero. Geometry, rather than a numeric threshold, determines the selection.
Shape and data storage remain separate questions
All three results keep shape (3,3) and the input data type. Tril returns a copy, so the result can be edited without changing the input matrix. It does not reduce the array to a list of lower entries or sum the triangular region.
Rectangular matrices also have lower triangular regions. For arrays with more than two dimensions, tril applies the rule to the final two axes, separately across the leading dimensions. Record those axes when explaining several matrix-shaped layers within one array.
Continue learning with Academia Master Trader at academiamastertrader.com.br and in Aprenda. Keep the offset, positional rule and expected shape beside each triangular result.