Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-226

Polar Decomposition 2x2

Problem

Compute the polar decomposition A = U*P of a nonsingular 2x2 matrix, where U is orthogonal and P is symmetric positive definite.

Set P to the symmetric square root of A^T A and U = A * inv(P). Return [U, P], or None if P is singular.

Hint

P captures the stretching and U the rotation/reflection of the linear map.

Test cases

case 1
in: [[[1,0],[0,1]]]
expected: [[[1,0],[0,1]],[[1,0],[0,1]]]
case 2
in: [[[2,0],[0,3]]]
expected: [[[1,0],[0,1]],[[2,0],[0,3]]]
case 3
in: [[[0,-1],[1,0]]]
expected: [[[0,-1],[1,0]],[[1,0],[0,1]]]
case 4
in: [[[1,1],[0,1]]]
expected: [[[0.8944271909999157,0.4472135954999578],[-0.4472135954999578,0.8944271909999157]],[[0.894427190999916,0.44721359549995804],[0.4472135954999579,1.3416407864998…
Starter codePython
def polar_decomposition_2x2(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor