Reputation: 314
I would like to find a symbolic Cholesky factorisation with Sympy. The Matrix M (see example) is real symmetric (hence hermitian). But Sympy raises ValueError: Matrix must be Hermitian.
Two questions:
from sympy import *
x, y = symbols('x y')
M = Matrix([
[ exp(x**2), exp(x*y)],
[ exp(x*y), exp(y**2)]
])
print(M == M.T) #True
L = M.cholesky() #ValueError: Matrix must be Hermitian.
Upvotes: 1
Views: 1188
Reputation: 2936
M
is not Hermitian, because there is no restriction for values x
and y
to be complex.Since M
is not necessary Hermitian, you should use
M.cholesky(hermitian=False)
Out[17]:
Matrix([
[ sqrt(exp(x**2)), 0],
[exp(x*y)/sqrt(exp(x**2)), sqrt(exp(y**2) - exp(-x**2)*exp(2*x*y))]])
hermitian
is a parameter that appears in sympy version 1.4
. You can find changes on this page. For earlier versions cholesky
method works with your example as is.
Upvotes: 2