I am a data scientist working on time series forecasting (using R and Python 3) at the London Ambulance Service NHS Trust. I earned my PhD in cognitive neuroscience at the University of Glasgow working with fmri data and neural networks. I favour linux machines, and working in the terminal with Vim as my editor of choice.
At this point in my studies, I have learned about eigenvalues and how to discover them in the context of the determinant (reviewed below) but this method is not practical for size >3 matrices. Therefore, I had to skip ahead to quickly implement the algorithms for finding eigenvalues (and the corresponding eigenvectors). At present the methods cannot handle complex numbers, and so should be used for symmetric and triangular real matrices (since they always have real eigenvalues). This means I don't have a deep understanding of how these algorithms work so I'll postpone the usual description of how the code works until later, and instead focus on what I understand theoretically.
Thinking of a matrix $A$ as encoding a linear transformation of a vector space, any vector $x$ that points in the same direction after the transformation (i.e. after the multiplication $Ax$) as before it is called an eigenvector. The amount by which their length is changed is called the eigenvalue (typically denoted with $\lambda$). Typically we think of the eigenvalues and eigenvectors as properties of the matrix $A$. You can also view eigenvalues as the roots of a polynomial, which comes from the determinant. We have 2 unknowns to find: $x$ and $\lambda$:
$$ \begin{equation} Ax = \lambda x \end{equation} $$The first thing we do is rewrite the equation:
$$ \begin{equation} Ax = \lambda Ix \end{equation} $$Then rearrange:
$$ \begin{equation} Ax - \lambda Ix = 0 \end{equation} $$Factoring out the $x$:
$$ \begin{equation} (A - \lambda I)x = 0 \end{equation} $$This tells us that the matrix $(A - \lambda I)$ is singular, which means its determinant is zero.
In the 2 by 2 case we have:
$$ \begin{equation} \begin{bmatrix} a - \lambda & b \\ c & d - \lambda \end{bmatrix} \end{equation} $$The determinant of that matrix is:
$$ \begin{equation} (a - \lambda)(d - \lambda) - (bc) = 0 \end{equation} $$Expanding, we see the familiar polynomial form:
$$ \begin{equation} \lambda^2 -(a + dlambda + (ad - bc) = 0 \end{equation} $$Notice the trace and the determinant appearing in the above equation:
$$ \begin{equation} \lambda^2 -(tracelambda + (determinant) = 0 \end{equation} $$We refactor that equation:
$$ \begin{equation} (\lambda - z_1)(\lambda - z_2) = 0 \end{equation} $$ \begin{equation}Where $z_1$ and $z_2$ are those numbers which bring about the trace and determinant in the previous equation. Whatever $z_1$ and $z_2$ are, they must be equal to $\lambda$ and therefore are the eigenvalues of the matrix.
We create a matrix, call the eigvalues method and print the result:
Outputs:
We create a matrix, call the eig method and print the results. Then we check that an eigenvector multiplied by $A$ gives the same result as the eigenvector scaled by the eigenvalue:
Outputs:
back to project main page
back to home