-
Notifications
You must be signed in to change notification settings - Fork 0
eigmax
Josh Fogg edited this page Aug 8, 2024
·
1 revision
eigmax(matrix, max_iterations, tolerance)
Compute the largest eigenvalue of any matrix using the power method.
-
matrix : ArrayLike
Any matrix or matrix-like object. -
max_iterations : int, optional
Maximum number of iterations to spend improving approximation of the largest eigenvalue. If reached, whatever was the best approximation at that iteration will be returned. Default is stop at 1000 iterations. -
tol: float, optional
Tolerance with which to check convergence. Default is$10^{-7}$ .
- float The largest eigenvalue of the of the matrix, or the closest approximation if the maximum iteration count was reached.
If we have the matrix
>>> A = np.array([
[1. 0. 0.5 0.5 0.5 0.5 0.5 0. 0.25 ],
[0. 1. 0.5 0.5 0.5 0. 0. 0.5 0.25 ],
[0.5 0.5 1. 0.5 0.5 0.25 0.25 0.25 0.25 ],
[0.5 0.5 0.5 1. 0.5 0.25 0.25 0.25 0.25 ],
[0.5 0.5 0.5 0.5 1. 0.25 0.25 0.25 0.25 ],
[0.5 0. 0.25 0.25 0.25 1. 0.25 0. 0.125],
[0.5 0. 0.25 0.25 0.25 0.25 1. 0. 0.5 ],
[0. 0.5 0.25 0.25 0.25 0. 0. 1. 0.5 ],
[0.25 0.25 0.25 0.25 0.25 0.125 0.5 0.5 1. ]])
then we can compute maximum eigenvalue as
>>> eigmax(A)
3.517160078658142
Alternatively, we could use NumPy to compute all the eigenvalues and then take their maximum
>>> max(np.linalg.eigvals(A))
3.5171601498626526
This documentation relates to the latest version of the package on GitHub. For past versions, download the zip bundled with the release from here. If anything in this wiki looks incorrect or you think key information is missing, please do open an issue.