TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Calculate Eigenvalues of a Matrix

Linear Algebra
Medium

Calculate the eigenvalues of a square matrix whose eigenvalues are guaranteed to be real.

Av=λvAv = \lambda vAv=λv

Here, AAA is the input matrix, vvv is a nonzero eigenvector, and λ\lambdaλ is its eigenvalue. Return all eigenvalues in ascending order as a NumPy array of floats.

Loading visualization...

Examples

Input: matrix = [[4, 1], [2, 3]]

Output: [2.0, 5.0]

Explanation: Both values satisfy the characteristic equation of the matrix.

Input: matrix = [[5]]

Output: [5.0]

Hint 1

Use np.linalg.eigvals(matrix) to compute the eigenvalues.

Hint 2

Use .real followed by np.sort() for the guaranteed-real output.

Requirements

  • Compute the eigenvalues with NumPy
  • Sort them in ascending order
  • Return a NumPy array of floating-point values

Constraints

  • matrix is a nonempty square numeric list
  • Every eigenvalue is real
  • Matrix dimensions are at most 100×100100 \times 100100×100
  • Use NumPy only
Try Similar Problems
Matrix InversePca ProjectionCovariance MatrixMatrix TraceMatrix Normalization

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

You must run your code first.
PrevNext

Calculate Eigenvalues of a Matrix

Linear Algebra
Medium

Calculate the eigenvalues of a square matrix whose eigenvalues are guaranteed to be real.

Av=λvAv = \lambda vAv=λv

Here, AAA is the input matrix, vvv is a nonzero eigenvector, and λ\lambdaλ is its eigenvalue. Return all eigenvalues in ascending order as a NumPy array of floats.

Loading visualization...

Examples

Input: matrix = [[4, 1], [2, 3]]

Output: [2.0, 5.0]

Explanation: Both values satisfy the characteristic equation of the matrix.

Input: matrix = [[5]]

Output: [5.0]

Hint 1

Use np.linalg.eigvals(matrix) to compute the eigenvalues.

Hint 2

Use .real followed by np.sort() for the guaranteed-real output.

Requirements

  • Compute the eigenvalues with NumPy
  • Sort them in ascending order
  • Return a NumPy array of floating-point values

Constraints

  • matrix is a nonempty square numeric list
  • Every eigenvalue is real
  • Matrix dimensions are at most 100×100100 \times 100100×100
  • Use NumPy only
Try Similar Problems
Matrix InversePca ProjectionCovariance MatrixMatrix TraceMatrix Normalization

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

You must run your code first.