Final answer:
To create a function that returns the lower triangular matrix of a given square matrix, you can iterate through each element of the given matrix and set the value to zero if the element's column index is greater than its row index.
Step-by-step explanation:
To create a function that returns the lower triangular matrix of a given square matrix, you can iterate through each element of the given matrix and set the value to zero if the element's column index is greater than its row index. Here's how the function can be implemented in Python:
def lower_triangular_matrix(matrix):
n = len(matrix)
lower_matrix = [[0] * n for _ in range(n)]
for i in range(n):
for j in range(i + 1):
lower_matrix[i][j] = matrix[i][j]
return lower_matrix
For example, if the input matrix is [[1, 2, 3], [4, 5, 6], [7, 8, 9]], the output will be [[1, 0, 0], [4, 5, 0], [7, 8, 9]].