Implement the power iteration method to find the dominant eigenvalue and its corresponding eigenvector of a matrix.
Algorithm:
1. Start with a random vector b
2. Repeat: b = A*b / ||A*b||
3. The dominant eigenvalue λ = (b^T * A * b) / (b^T * b)
Example:
Input: A = [[2, 1], [1, 2]], iterations = 100
Output: eigenvalue ≈ 3.0
**Explanation:** The dominant eigenvalue of [[2,1],[1,2]] is 3, with eigenvector [1/√2, 1/√2].
Constraints:
Test Cases
Test Case 1
Input:
[[2, 1], [1, 2]], 100Expected:
3.0Test Case 2
Input:
[[4, 1], [2, 3]], 100Expected:
5.0Test Case 3
Input:
[[3, 0], [0, 1]], 50Expected:
3.0+ 2 hidden test cases