Editor

Find the Eigenvalues

Advanced · Write the code · from NumPy Linear Algebra: Dot Products, Inverses, and Eigenvalues

From the lesson: NumPy Linear Algebra: Dot Products, Inverses, and Eigenvalues

Linear algebra is the math behind machine learning, computer graphics, physics simulations, and data science. Every time a game rotates a 3D object, a search engine ranks pages, or a neural network makes a prediction, matrix operations are doing the heavy lifting.

Read the lesson

Find and print the eigenvalues of the following matrix, sorted from largest to smallest:

A = np.array([[5, 1],
              [1, 5]])

Use np.sort() with [::-1] to reverse the order.

import numpy as np
A = np.array([[5, 1],
[1, 5]])
# Find eigenvalues, sort descending, print

More NumPy Linear Algebra exercises

All Python exercises · 50 practice problems · Data Science & Machine Learning quiz