Skip to content

Instantly share code, notes, and snippets.

@Xorgon
Created March 14, 2017 14:23
Show Gist options
  • Save Xorgon/68fe6598017eb854f36ddc33c8245e5b to your computer and use it in GitHub Desktop.
Save Xorgon/68fe6598017eb854f36ddc33c8245e5b to your computer and use it in GitHub Desktop.
Solving an eigenvalue problem in Python.
import numpy as np
matrix = np.array([[0., 0.16, 0., -9.81],
[-0.1250, -0.5, 212., 0.],
[0., -0.0082, -0.5, 0.],
[0., 0., 1., 0.]])
print("Matrix:\n" + str(matrix))
# Get the eigenvalues (eig returns tuple with eigenvalues and eigenvectors)
eigenvalues = np.linalg.eig(matrix)[0]
print("\nEigenvalues:")
for eigenvalue in eigenvalues:
print(eigenvalue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment