3
$\begingroup$

A Hermitian matrix is a complex square matrix which is equal to its conjugate transpose. Its matrix elements fulfil following condition:

$$a_{ij} = \bar{a}_{ji}$$

Everytime, I compute eigenvectors of a Hermitian matrix using Python, the first coefficient of the eigenvector is a pure real number. Is this an attribute of Hermitian matrices?

I attach a code snippet to generate a Hermitian matrix, compute its eigenvectors and print the eigenvector corresponding to the lowest eigenvalue.

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_matrix = np.random.uniform(-1.0, 1.0, size=(N,N))
real_matrix = (real_matrix + real_matrix.T)/2
# Generate imaginary part of the matrix
imaginary_matrix = np.random.uniform(-1.0, 1.0, size=(N,N))
imaginary_matrix = (imaginary_matrix + imaginary_matrix.T)/2
imaginary_matrix = imaginary_matrix.astype(complex) * 1j
for row in range(N):
    for column in range(row,N):
        if row == column:
            imaginary_matrix[row][column] = 0.0
        else:
            imaginary_matrix[row][column] *= -1
# Combine real and imaginary part
matrix = real_matrix + imaginary_matrix
# Compute and print eigenvector
eigenvalues, eigenvectors = LA.eigh(matrix)
print(eigenvectors[:,0])

This question was originally posted on StackOverflow.

$\endgroup$
  • $\begingroup$ I know that SO told you to post here, but this is really a python question. Any scalar multiple of any eigenvector is again an eigenvector (with the same eigenvalue), so whatever python's output is, it could be multiplied by, e.g., $i$ and it would still be correct. So it comes down to how function calls used in your code chose to represent the eigenvectors. $\endgroup$ – Morgan Sherman May 2 '18 at 19:17
  • $\begingroup$ P.S. here is the source code for LA.eigh(). You can trace through there how that function decides to represent the eigenvectors. $\endgroup$ – Morgan Sherman May 2 '18 at 19:25
  • $\begingroup$ It doesn't matter what the first coefficient of an eigenvector is, since if $v$ is an eigenvector, then so is $zv$ for any complex number $z$. It's not meaningful to look very hard at the individual coefficents. $\endgroup$ – Joppy May 3 '18 at 2:25
2
$\begingroup$

Reposting my comment as an answer:

Any scalar multiple of any eigenvector is again an eigenvector (with the same eigenvalue), so whatever your code's output (for representing the eigenvectors) is, it could be multiplied by, e.g., $i$ and it would still be correct. So it comes down to how function calls used in your code chose to represent the eigenvectors.

See here is the source code for LA.eigh(), which is used in your code to get the eigenvectors.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.