How to Perform Matrix Multiplication

import numpy as np

matrix_a = np.array([[1, 2], [3, 4]])
matrix_b = np.array([[5, 6], [7, 8]])
result_matrix = np.dot(matrix_a, matrix_b)
print(f"Matrix A:\n{matrix_a}\nMatrix B:\n{matrix_b}\nResult Matrix:\n{result_matrix}")

Output:

Matrix A:
[[1 2]
[3 4]]
Matrix B:
[[5 6]
[7 8]]
Result Matrix:
[[19 22]
[43 50]]

Leave a Comment

Your email address will not be published.