v9.1.1
Menu

2x2 Eigenvalues

mediumFREEEigenvalues & EigenvectorsLinear AlgebraCV: Mathematical Foundations

Implement a solution to compute the eigenvalues of a 2×2 matrix using the characteristic equation. This task involves finding the scalar values, λ, that represent how much change occurs in a linear transformation.

The concept of eigenvalues and eigenvectors is crucial in linear algebra, as it helps describe the properties of linear transformations. For a 2×2 matrix A=(abcd)A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}, the eigenvalues satisfy the equation det⁡(A−λI)=0\det(A - \lambda I) = 0, where II is the identity matrix.

  1. Start with the matrix AA and the identity matrix II.
  2. Construct the matrix A−λIA - \lambda I.
  3. Compute the determinant of A−λIA - \lambda I and set it equal to zero.
λ2−(a+d)λ+(ad−bc)=0\lambda^2 - (a+d)\lambda + (ad-bc) = 0

This technique is widely used in computer vision for image processing and analysis.

Example

Input
A = [[4, 1], [2, 3]]
Output
eigenvalues = [5.0, 2.0]
Reasoning
  • Input: AA is a 2×22 \times 2 real matrix with a=4a = 4, b=1b = 1 in the top row and c=2c = 2, d=3d = 3 in the bottom row.
  • Characteristic polynomial: subtracting λ\lambda from the diagonal gives (4−λ123−λ)\begin{pmatrix} 4-\lambda & 1 \\ 2 & 3-\lambda \end{pmatrix}, whose determinant is (4−λ)(3−λ)−1⋅2=λ2−7λ+10(4-\lambda)(3-\lambda) - 1 \cdot 2 = \lambda^2 - 7\lambda + 10. This matches a+d=7a+d = 7 and ad−bc=10ad - bc = 10.
  • Roots: λ2−7λ+10=(λ−5)(λ−2)\lambda^2 - 7\lambda + 10 = (\lambda - 5)(\lambda - 2), so the eigenvalues are 55 and 22. Check: 5+2=75 + 2 = 7 (the trace) and 5×2=105 \times 2 = 10 (the determinant).
  • Output: two real numbers, largest first and rounded to 4 decimal places, giving [5.0, 2.0].
  • Notice: the off-diagonal entries matter only through their product bcbc. Swapping bb and cc (as in (4213)\begin{pmatrix} 4 & 2 \\ 1 & 3 \end{pmatrix}) leaves both eigenvalues unchanged. When the discriminant (a+d)2−4(ad−bc)(a+d)^2 - 4(ad-bc) is 00, the two eigenvalues coincide, e.g. [1.0, 1.0] for the identity.

Constraints

  • A is a 2×2 real matrix
  • Return eigenvalues sorted in descending order
  • Round to 4 decimal places
  • Assume real eigenvalues (discriminant ≥ 0)

Learn this in

More from CV: Mathematical Foundations

solution.py

Test results

Sign in to run your code against the test cases.