Two Teams, Two Slanted Grids

Vector Spaces, Span & BasisMedium+20 XP+20

Two Teams, Two Slanted Grids

Two survey teams map the same space, but each uses its own slanted axes, its own basis.

  • Team North writes a point as coordinates (c1,…,cn)(c_1, \dots, c_n)(c1​,…,cn​) in its basis b1,…,bn\mathbf{b}_1, \dots, \mathbf{b}_nb1​,…,bn​, meaning the point is c1b1+⋯+cnbnc_1\mathbf{b}_1 + \dots + c_n\mathbf{b}_nc1​b1​+⋯+cn​bn​.
  • Team South does the same with its own basis d1,…,dn\mathbf{d}_1, \dots, \mathbf{d}_nd1​,…,dn​.

Between the two surveys a machine moves every point: in ordinary standard coordinates it sends x\mathbf{x}x to MxM\mathbf{x}Mx.

North logged each point before the move, in North coordinates. South needs each point after the move, in South coordinates. Every step here is linear, so a single n×nn \times nn×n matrix TTT does the whole conversion: if c\mathbf{c}c is a point's North coordinate vector, then TcT\mathbf{c}Tc is the moved point's South coordinate vector.

Task: write north_to_south(B, D, M) returning TTT as a list of rows, every entry rounded to 4 decimal places.

  • B[k] is North's basis vector bk+1\mathbf{b}_{k+1}bk+1​ and D[k] is South's dk+1\mathbf{d}_{k+1}dk+1​, each given as a list of nnn numbers.
  • M is an n×nn \times nn×n matrix given as a list of rows.
  • Both are genuine bases of Rn\mathbb{R}^nRn (independent vectors), so every point has exactly one set of coordinates in each.

Examples

B = [[1, 2], [0, 1]]
D = [[1, 1], [-1, 2]]
M = [[1, 0], [0, 1]]
returns [[1.3333, 0.3333], [0.3333, 0.3333]]
B = [[2, 1], [3, 4]]
D = [[1, 0], [0, 1]]
M = [[1, 2], [0, 1]]
returns [[4.0, 11.0], [1.0, 4.0]]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run