# Import NumPy import numpy as np # Create two 2x2 matrices A = np.array([[1, 2], [3, 4]]) B = np.array([[5, 6], [7, 8]]) # Matrix addition S = A + B print("Sum:\n", S) # Matrix subtraction D = A - B print("Difference:\n", D) # Element-wise multiplication (warning: not usually what you want) E = A * B print("Element-wise multiplication:\n", E) # Matrix multiplication P = A @ B print("Matrix multiplication:\n", P) # Transpose of a matrix G = A.T print("Transpose:\n", G) # Determinant of a matrix det_A = np.linalg.det(A) print("Determinant:\n", det_A) # Inverse of a matrix inv_A = np.linalg.inv(A) print("Inverse:\n", inv_A) #Solve a linear system b = np.array([1, 4]) # Define the right-hand side vector x = np.linalg.solve(A, b) # Solve for x print("Solution to Ax = b:\n", x)