Example: B = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] C = [[1, 2.3, 3], [4.4, 25, 6], [7.4, 8, 9]] output: [[-0.6772, -0.0126, 0.2342], [-0.0184, 0.0505, -0.0275], [0.5732, -0.0345, -0.0569]] reasoning: The transformation matrix P from basis B to C can be found using matrix operations involving the inverse of matrix C.
A transformation matrix allows us to convert the coordinates of a vector in one basis to coordinates in another basis. For bases B and C of a vector space, the transformation matrix P from B to C is calculated by:
This matrix \(P\) can be used to transform any vector coordinates from the B basis to the C basis.
Resources: Change of basis | Chapter 13, Essence of linear algebra by 3Blue1Brown
import numpy as np def transform_basis(B, C): C = np.array(C) B = np.array(B) C_inv = np.linalg.inv(C) P = np.dot(C_inv, B) return P.tolist()