In linear algebra, a heptadiagonal matrix is a matrix that is nearly diagonal; to be exact, it is a matrix in which the only nonzero entries are on the main diagonal, and the first three diagonals above and below it. So it is of the form
It follows that a heptadiagonal matrix has at most nonzero entries, where n is the size of the matrix. Hence, heptadiagonal matrices are sparse. This makes them useful in numerical analysis.