Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Open In Colab

Let us consider the operator AA:

A=(100010002).A = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 2 \end{pmatrix}.

To verify that it is a Hermitian matrix, we can verify its conjugate transpose:

A=(100010002)=A.A^\dagger = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 2 \end{pmatrix} = A.

Its eigenvalues are:

[1,  1,  2].[1,\;1,\;2].

And the corresponding eigenvectors (each column is an eigenvector) are

(100010001).\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}.

We have then that eigenvalue 1 is degenerate. We can reconstruct matrix AA by spectral decomposition:

A=(100010002).A = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 2 \end{pmatrix}.

We have now defined a Hermitian matrix BB:

B=(310140005).B = \begin{pmatrix} 3 & 1 & 0 \\ 1 & 4 & 0 \\ 0 & 0 & 5 \end{pmatrix}.

We can verify that they commute, that is, ABBA=0AB-BA=0:

ABBA=(000000000).AB-BA = \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{pmatrix}.

In the simplest case, we then have a subspace of only one dimension for eigenvalue 2. We can see that Bv=bvBv=bv, with b=5b=5:

B(001)=(005).B \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix} = \begin{pmatrix} 0\\ 0\\ 5 \end{pmatrix}.

Now for eigenvalue 1, we have a two-dimensional subspace formed by the vectors

(100100).\begin{pmatrix} 1 & 0\\ 0 & 1\\ 0 & 0 \end{pmatrix}.

All non-null vectors in this subspace continue to be eigenvectors of AA with the same eigenvalue 1.

If we denote the two eigenvectors by (v1,v2)(v_1,v_2) and use them as a basis, any non-null vector that is a linear combination of them,

u=av1+bv2,u = av_1+bv_2,

is also an eigenvector of AA. In fact,

Au=A(av1+bv2)=aAv1+bAv2=av1+bv2=u.Au = A(av_1+bv_2) = aAv_1+bAv_2 = av_1+bv_2 = u.

Now applying BB to the first eigenvector, we can see that it is a linear combination of the other two vectors in the subspace and is not a BB eigenvector:

B(100)=(310).B \begin{pmatrix} 1\\ 0\\ 0 \end{pmatrix} = \begin{pmatrix} 3\\ 1\\ 0 \end{pmatrix}.

That is, even though these two eigenvectors associated with 1 are a basis for this subspace, they do not form a common eigenvector basis. But we can build one.

Since all non-null vectors in this subspace are eigenvectors of AA, we only need to find those who are also eigenvectors of BB.

In this two-dimensional space, BB’s action on the vectors of the space is given by:

B1=(3114).B_1 = \begin{pmatrix} 3 & 1\\ 1 & 4 \end{pmatrix}.

Its eigenvalues are

[2.38,  4.62].[2.38,\;4.62].

And the corresponding eigenvectors (each column is an eigenvector) are:

(0.850.530.530.85).\begin{pmatrix} -0.85 & -0.53\\ 0.53 & -0.85 \end{pmatrix}.

Combining with the previous results, we can have a new basis given by the eigenvectors (where each column corresponds to a vector of the new basis):

(0.850.5300.530.850001).\begin{pmatrix} -0.85 & -0.53 & 0\\ 0.53 & -0.85 & 0\\ 0 & 0 & 1 \end{pmatrix}.

We can test by applying AA to the vectors of the new basis:

A(0.850.530)=(0.850.530),A \begin{pmatrix} -0.85\\ 0.53\\ 0 \end{pmatrix} = \begin{pmatrix} -0.85\\ 0.53\\ 0 \end{pmatrix},
A(0.530.850)=(0.530.850),A \begin{pmatrix} -0.53\\ -0.85\\ 0 \end{pmatrix} = \begin{pmatrix} -0.53\\ -0.85\\ 0 \end{pmatrix},
A(001)=2(001).A \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix} = 2 \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix}.

With the corresponding eigenvalues:

[1,  1,  2].[1,\;1,\;2].

We can test by applying BB to the vectors of the new basis:

B(0.850.530)=2.38(0.850.530),B \begin{pmatrix} -0.85\\ 0.53\\ 0 \end{pmatrix} = 2.38 \begin{pmatrix} -0.85\\ 0.53\\ 0 \end{pmatrix},
B(0.530.850)=4.62(0.530.850),B \begin{pmatrix} -0.53\\ -0.85\\ 0 \end{pmatrix} = 4.62 \begin{pmatrix} -0.53\\ -0.85\\ 0 \end{pmatrix},
B(001)=5(001).B \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix} = 5 \begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix}.

With the corresponding eigenvalues:

[2.38,  4.62,  5].[2.38,\;4.62,\;5].
zdef printa():
  import numpy as np
  np.set_printoptions(suppress=True, precision=2)

  print("Vamos considerar o operador A:")
  A = np.array([
      [1, 0, 0],
      [0, 1, 0],
      [0, 0, 2]
  ])
  print(A)
  print("\nPara verificar que é uma matriz hermitiana, podemos verificar seu transposto conjugado:")
  m=A.T
  m=m.conj()
  print(m)

  autovalores, autovetores = np.linalg.eig(A)
  print("\nSeus autovalores são:")
  print(autovalores)

  print("\nE os correspondentes autovetores (cada coluna é um autovetor) são")
  print(autovetores)


  print("\nTemos então que o autovalor 1 é degenerado. Podemos reconstruir a matriz A pela decomposição espectral:")
  av1=autovetores[:, 0].reshape(-1, 1)
  av2=autovetores[:, 1].reshape(-1, 1)
  av3=autovetores[:, 2].reshape(-1, 1)
  m=autovalores[0]*av1@av1.T+autovalores[1]*av2@av2.T+autovalores[2]*av3@av3.T
  print(m)

  print("\nDefinimos agora uma matriz hermitiana B:")
  B = np.array([
      [3, 1, 0],
      [1, 4, 0],
      [0, 0, 5]
  ])
  print(B)
  print("\nPodemos verificar que eles comutam, isto é, AB-BA=0:")
  print(A@B-B@A)

  print("\nNo caso mais simples, temos então um subespaço de apenas uma dimensão para o autovalor 2. Podemos conferir que Bv=bv, sendo b=5")
  v=B@av3
  print(v)

  print("\nAgora para o autovalor 1, temos um subespaço de duas dimensões formada pelos vetores")
  print(autovetores[:, :2])

  print("\nTodos vetores não nulos neste subespaço continuam a serem autovetores de A com o mesmo autovalor (c).")
  print("Se denotamos os dois autovetores calculados por (v1,v2) e os utilzarmos como base, qualquer vetor não nulo que seja uma combinação linear deles u=av1+bv2 também é um autovetor de A. De fato Au=aAv1+bAv2 =acv1+bcv2=c(av1+bv2)=cu.")
  print("Agora aplicando B ao primeiro autovetor, podemos ver que ele é uma combinação linear dos outros 2 vetores do espaço e não é um autovetor de B:")
  v=B@av1
  print(v)

  print("Ou seja, ainda que esses dois autovetores associados a 1 sejam uma base para esse subespaço, eles não formam uma base de autovetores comum. Mas podemos construir uma.")
  print("Como todos vetores não nulos neste subespaço são autovetores de A, só precisamos encontrar aqueles que também são autovetores de B.")
  print("Neste espaço bidimensional, atuação de B sobre os vetores do espaço é dada apenas por:")
  B2 = np.array([
      [3, 1],
      [1, 4]])
  print(B2)

  autovaloresB2, autovetoresB2 = np.linalg.eig(B2)
  print("\nSeus autovalores são")
  print(autovaloresB2)

  print("\nE os correspondentes autovetores (cada coluna é um autovetor) são:")
  print(autovetoresB2)

  print("\nCombinando então com resultados anteriores, podemos ter nova base dada pelos autovetores comuns(onde cada coluna corresponde a um vetor da nova base):")
  base = np.array([[-0.85065081,-0.52573111,0],
  [ 0.52573111,-0.85065081,0],
                  [ 0,0,1],])
  print(base)
  autovaloresA, autovetoresA = np.linalg.eig(A)
  autovaloresB, autovetoresB = np.linalg.eig(B)
  av1=base[:, 0].reshape(-1, 1)
  av2=base[:, 1].reshape(-1, 1)
  av3=base[:, 2].reshape(-1, 1)
  print("Podemos testar aplicando A aos vetores da nova base:")
  print(A@av1/autovaloresA[0])
  print(A@av2/autovaloresA[1])
  print(A@av3/autovaloresA[2])
  print("Onde dividimos cada vetor já pelo correspondente autovalor:")
  print(autovaloresA)
  print("Podemos testar aplicando B aos vetores da nova base:")
  print(B@av1/autovaloresB[0])
  print(B@av2/autovaloresB[1])
  print(B@av3/autovaloresB[2])
  print("Onde dividimos cada vetor já pelo correspondente autovalor:")
  print(autovaloresB)