``` import numpy import math def polar_decomposition(matrix): u, s, vh = numpy.linalg.svd(matrix) pu = u @ vh # rotation matrix angle = math.atan2(pu[1,0], pu[0,0]) pp = vh.T @ numpy.diag(s) @ vh # scaling matrix return pp, angle def recompose_polar(pp, angle): pu = numpy.array([[math.cos(angle), -math.sin(angle)], [math.sin(angle), math.cos(angle)]]) return pu @ pp ```