# powerMethod

##### Power Method for Eigenvectors

Finds a dominant eigenvalue, \(\lambda_1\), and its corresponding eigenvector, \(v_1\), of a square matrix by applying Hotelling's (1933) Power Method with scaling.

##### Usage

`powerMethod(A, v = NULL, eps = 1e-06, maxiter = 100, plot = FALSE)`

##### Arguments

- A
a square numeric matrix

- v
optional starting vector; if not supplied, it uses a unit vector of length equal to the number of rows / columns of

`x`

.- eps
convergence threshold for terminating iterations

- maxiter
maximum number of iterations

- plot
logical; if

`TRUE`

, plot the series of iterated eigenvectors?

##### Details

The method is based upon the fact that repeated multiplication of a matrix \(A\) by a trial vector \(v_1^{(k)}\) converges to the value of the eigenvector, $$v_1^{(k+1)} = A v_1^{(k)} / \vert\vert A v_1^{(k)} \vert\vert $$ The corresponding eigenvalue is then found as $$\lambda_1 = \frac{v_1^T A v_1}{v_1^T v_1}$$

In pre-computer days, this method could be extended to find subsequent eigenvalue - eigenvector pairs by "deflation", i.e., by applying the method again to the new matrix. \(A - \lambda_1 v_1 v_1^{T} \).

This method is still used in some computer-intensive applications with huge matrices where only the dominant eigenvector is required, e.g., the Google Page Rank algorithm.

##### Value

a list containing the eigenvector (`vector`

), eigenvalue (`value`

), iterations (`iter`

),
and iteration history (`vector_iterations`

)

##### References

Hotelling, H. (1933). Analysis of a complex of statistical variables into principal components. *Journal of Educational Psychology*, 24, 417-441, and 498-520.

##### Examples

```
# NOT RUN {
A <- cbind(c(7, 3), c(3, 6))
powerMethod(A)
eigen(A)$values[1] # check
eigen(A)$vectors[,1]
# demonstrate how the power method converges to a solution
powerMethod(A, v = c(-.5, 1), plot = TRUE)
B <- cbind(c(1, 2, 0), c(2, 1, 3), c(0, 3, 1))
(rv <- powerMethod(B))
# deflate to find 2nd latent vector
l <- rv$value
v <- c(rv$vector)
B1 <- B - l * outer(v, v)
powerMethod(B1)
eigen(B)$vectors # check
# a positive, semi-definite matrix, with eigenvalues 12, 6, 0
C <- matrix(c(7, 4, 1, 4, 4, 4, 1, 4, 7), 3, 3)
eigen(C)$vectors
powerMethod(C)
# }
```

*Documentation reproduced from package matlib, version 0.9.2, License: GPL (>= 2)*