The RayleighQuotient method is a variant of the Inverse Iteration Method, (please refer to "Eigenvalue Inverse Iteration Method") for computing
one of the eigenvalues and the corresponding eigenvector. This method changes the shift in each iteration, so it does not
necessarily find the dominant eigenvalue.
Algorithm
For a given symmetric matrix A and nonzero vector v, the
Rayleigh quotient is defined as:
R(A,v) = v^{T}Av / v^{T}v

where v^{T} is the transpose of v. Also, R(A,cv) = R(A,v) for
any scalar constant c.
The Rayleigh quotient reaches its smallest eigenvalue of A,λ_{min} when
v is the x_{min} (the corresponding eigenvector). Similarly,
R(A,v) <= λ_{max} and R(A,x_{max}) = λ_{max}

In order to use the RayleighQuotient method to compute the eigenvalue and the corresponding eigenvector, we followed the process below:
For a given n x n symmetric A and an initial vector
x_{0} normalize x_{0}.
Calculate the quantity λ = x_{0}^{T} Ax_{0}.
Solve the equation (A  λI)x = x_{0} for x.
Set x_{0} = x.
Repeat the above steps until the relative change in λ is less than the tolerance.
In addition to the matrix A and the tolerance, this method also takes as input an integer flag
parameter. This flag parameter takes two values, 1 and 2, corresponding to the case that the initial vector is filled with
random numbers and the case that initial vector and eigenvalue are approximate solutions.
Running this set up produces the results shown above.
The reader can try variations by entering new values to
Matrix A.
Testing the RayleighQuotient Method
In order to test the Power method as defined above, a new TestRayleighQuotient()
static method has been added and executed. Supporting code and methods are not shown.
static void RayleighQuotient();
{
ListBox1.Items.Clear();
ListBox2.Items.Clear();
Label5.Text = "";
MatrixR A = new MatrixR(new double[,] { { t1, t2, t3 }, { t4, t5, t6 },
{ t7, t8, t9 } });
VectorR x;
double lambda;
Eigenvalue.RayleighQuotient(A, 1e8, 1, out x, out lambda);
ListBox1.Items.Add(" " + lambda);
ListBox1.Items.Add(" " + x);
x = new VectorR(3);
lambda = 0.0;
Eigenvalue.RayleighQuotient(A, 1e8, 2, out x, out lambda);
ListBox2.Items.Add(" " + lambda);
ListBox2.Items.Add(" " + x);
}
