对角矩阵的极分解是否可交换?

问题描述 投票:0回答:1

我在理解极分解时犯了一个错误。 我以为极分解是

PU
,其实是
UP
。在试图理解出了什么问题时,我意识到这对于我提供给它的输入来说是可以交换的,因此我无法意识到这个大错误。 如果有人可以解释这一点,以便我能够理解它是否对于所有对角矩阵都是可交换的,那就太好了? 有没有极性分解为
PU
的极性分解公式?谢谢您的大力帮助。

import numpy as np
from scipy.linalg import polar
A= np.array([[-2, 1, 0, 0],
              [1, -2, 1, 0],
              [0, 1, -2, 1],
              [0, 0, 1, -2]])
U, P = polar(A)
print(U)
print(P)
A1 = U @ P
print(A1)
A2 = P @ U
print(A2)
are_equal = np.allclose(A1, A2)
print("Are matrix equal:", are_equal)
python scipy svd
1个回答
0
投票

您发布的矩阵是对称的,并且是实值的。 (换句话说,

A = A.T
,并且它没有复数。)这很重要,因为所有对称且实值的矩阵都是正规矩阵来源。如果矩阵是正规矩阵,则它的任何极分解都遵循
PU = UP
来源

任何对角矩阵也是对称的。然而,从技术上讲,您发布的矩阵不是对角线 - 它在主对角线之外有条目。矩阵只是三对角。这些矩阵不一定是对称的。但是,如果您的三对角矩阵是对称且实值的,则其极分解是可交换的。

除了从数学上证明这个想法之外,你还可以通过实验来检验它。以下代码生成数千个矩阵及其极分解,并检查它们是否可交换。

import numpy as np
from scipy.linalg import polar

N = 4
iterations = 10000
for i in range(iterations):
    A = np.random.randn(N, N)
    # A = A + A.T
    U, P = polar(A)
    are_equal = np.allclose(U @ P, P @ U)
    if not are_equal:
        print("Matrix A does not have commutative polar decomposition!")
        print("Value of A:")
        print(A)
        break
    if (i + 1) % (iterations // 10) == 0:
        print(f"Checked {i + 1} matrices, all had commutative polar decompositions")

如果你运行这个,它会立即找到一个反例,因为矩阵不是对称的。但是,如果取消注释

A = A + A.T
,这会强制随机矩阵对称,则所有矩阵都有效。

最后,如果您需要左侧极坐标分解,您可以使用

side='left'
的参数
polar()
来实现。 文档解释了如何执行此操作。

© www.soinside.com 2019 - 2024. All rights reserved.