我想计算python中二阶导数矩阵的特征向量。根据数学,第一个向量应该等于0到pi之间的sin-函数,第二个等于0到2*pi之间的sin函数。因此,我的代码看起来就像
import numpy as np
from matplotlib import pyplot as plt
from scipy import sparse
import scipy.integrate as integrate
import scipy.special as special
import scipy
def create_second_deriv(size, h):
delta_matrix_2_
我正在使用Python导出与3x3矩阵中的特征值相关联的特征向量。我的代码返回正确的特征值,但返回错误的特征向量。
A = np.array([[-2, -4, 2],
[-2, 1, 2],
[4, 2, 5]])
print (A)
print ('-------------------------------------------------------')
eigenvalues, eigenvectors = np.linalg.eig(A) # must use this line of cod
Hermitian矩阵是一个复方阵,等于它的共轭转置。其矩阵元素满足以下条件:
每次我用Python计算Hermitian矩阵的特征向量时,特征向量的第一个系数是一个纯实数。这是Hermitian矩阵的属性吗?
我附加了一个代码片段来生成一个Hermitian矩阵,计算它的特征向量,并打印出对应于最小特征值的特征向量。
import numpy as np
from numpy import linalg as LA
N = 5 # Set size of a matrix
# Generate real part of the matrix at first
real_matr
我想知道是否有Python包,numpy或其他,它有一个函数,可以计算一个小矩阵的第一个特征值和特征向量,比如2x2。我可以使用numpy中的linalg包,如下所示。
import numpy as np
def whatever():
A = np.asmatrix(np.rand(2, 2))
evals, evecs = np.linalg.eig(A)
#Assume that the eigenvalues are ordered from large to small and that the
#eigenvectors are ordered