# Ritz method

In the study of differential equations, the Ritz method is a direct method to find an approximate solution for boundary value problems. The method is named after Walther Ritz. Some alternative formulations include the Rayleigh–Ritz method and the Ritz-Galerkin method.
In quantum mechanics, a system of particles can be described in terms of an "energy functional" or Hamiltonian, which will measure the energy of any proposed configuration of said particles. It turns out that certain privileged configurations are more likely than other configurations, and this has to do with the eigenanalysis ("analysis of characteristics") of this Hamiltonian system. Because it is often impossible to analyze all of the infinite configurations of particles to find the one with the least amount of energy, it becomes essential to be able to approximate this Hamiltonian in some way for the purpose of numerical computations.
The Ritz method can be used to achieve this goal. In the language of mathematics, it is exactly the finite element method used to compute the eigenvectors and eigenvalues of a Hamiltonian system.

## Definitions

As with other variational methods, a trial wave function, $\Psi$, is tested on the system. This trial function is selected to meet boundary conditions (and any other physical constraints). The exact function is not known; the trial function contains one or more adjustable parameters, which are varied to find a lowest energy configuration.
It can be shown that the ground state energy, $E_{0}$, satisfies an inequality:
$E_{0}\leq {\frac {\langle \Psi |{\hat {H}}|\Psi \rangle }{\langle \Psi |\Psi \rangle }}.$
That is, the ground-state energy is less than this value. The trial wave-function will always give an expectation value larger than or equal to the ground-energy.
If the trial wave function is known to be orthogonal to the ground state, then it will provide a boundary for the energy of some excited state.
The Ritz ansatz function is a linear combination of N known basis functions $\left\lbrace \Psi _{i}\right\rbrace$, parametrized by unknown coefficients:
$\Psi =\sum _{i=1}^{N}c_{i}\Psi _{i}.$
With a known Hamiltonian, we can write its expected value as
$\varepsilon ={\frac {\left\langle \displaystyle \sum _{i=1}^{N}c_{i}\Psi _{i}\right|{\hat {H}}\left|\displaystyle \sum _{i=1}^{N}c_{i}\Psi _{i}\right\rangle }{\left\langle \left.\displaystyle \sum _{i=1}^{N}c_{i}\Psi _{i}\right|\displaystyle \sum _{i=1}^{N}c_{i}\Psi _{i}\right\rangle }}={\frac {\displaystyle \sum _{i=1}^{N}\displaystyle \sum _{j=1}^{N}c_{i}^{*}c_{j}H_{ij}}{\displaystyle \sum _{i=1}^{N}\displaystyle \sum _{j=1}^{N}c_{i}^{*}c_{j}S_{ij}}}\equiv {\frac {A}{B}}.$
The basis functions are usually not orthogonal, so that the overlap matrix S has nonzero nondiagonal elements. Either $\left\lbrace c_{i}\right\rbrace$ or $\left\lbrace c_{i}^{*}\right\rbrace$ (the conjugation of the first) can be used to minimize the expectation value. For instance, by making the partial derivatives of $\varepsilon$ over $\left\lbrace c_{i}^{*}\right\rbrace$ zero, the following equality is obtained for every k = 1, 2, ..., N:
${\frac {\partial \varepsilon }{\partial c_{k}^{*}}}={\frac {\displaystyle \sum _{j=1}^{N}c_{j}(H_{kj}-\varepsilon S_{kj})}{B}}=0,$
which leads to a set of N secular equations:
$\sum _{j=1}^{N}c_{j}\left(H_{kj}-\varepsilon S_{kj}\right)=0\quad {\text{for}}\quad k=1,2,\dots ,N.$
In the above equations, energy $\varepsilon$ and the coefficients $\left\lbrace c_{j}\right\rbrace$ are unknown. With respect to c, this is a homogeneous set of linear equations, which has a solution when the determinant of the coefficients to these unknowns is zero:
$\det \left(H-\varepsilon S\right)=0,$
which in turn is true only for N values of $\varepsilon$. Furthermore, since the Hamiltonian is a hermitian operator, the H matrix is also hermitian and the values of $\varepsilon _{i}$ will be real. The lowest value among $\varepsilon _{i}$ (i=1,2,..,N), $\varepsilon _{0}$, will be the best approximation to the ground state for the basis functions used. The remaining N-1 energies are estimates of excited state energies. An approximation for the wave function of state i can be obtained by finding the coefficients $\left\lbrace c_{j}\right\rbrace$ from the corresponding secular equation.

## Applications in mechanical engineering

The Rayleigh–Ritz method is often used in mechanical engineering for finding the approximate real resonant frequencies of multi degree of freedom systems, such as spring mass systems or flywheels on a shaft with varying cross section. It is an extension of Rayleigh's method. It can also be used for finding buckling loads and post-buckling behaviour for columns.
Consider the case whereby we want to find the resonant frequency of oscillation of a system. First, write the oscillation in the form,
$y(x,t)=Y(x)\cos \omega t$
with an unknown mode shape $Y(x)$. Next, find the total energy of the system, consisting of a kinetic energy term and a potential energy term. The kinetic energy term involves the square of the time derivative of $y(x,t)$ and thus gains a factor of $\omega ^{2}$. Thus, we can calculate the total energy of the system and express it in the following form:
$E=T+V\equiv A[Y(x)]\omega ^{2}\sin ^{2}\omega t+B[Y(x)]\cos ^{2}\omega t$
By conservation of energy, the average kinetic energy must be equal to the average potential energy. Thus,
$\omega ^{2}={\frac {B[Y(x)]}{A[Y(x)]}}=R[Y(x)]$
which is also known as the Rayleigh quotient. Thus, if we knew the mode shape $Y(x)$, we would be able to calculate $A[Y(x)]$ and $B[Y(x)]$, and in turn get the eigenfrequency. However, we do not yet know the mode shape. In order to find this, we can approximate $Y(x)$ as a combination of a few approximating functions $Y_{i}(x)$
$Y(x)=\sum _{i=1}^{N}c_{i}Y_{i}(x)$
where $c_{1},c_{2},\cdots ,c_{N}$ are constants to be determined. In general, if we choose a random set of $c_{1},c_{2},\cdots ,c_{N}$, it will describe a superposition of the actual eigenmodes of the system. However, if we seek $c_{1},c_{2},\cdots ,c_{N}$ such that the eigenfrequency $\omega ^{2}$ is minimised, then the mode described by this set of $c_{1},c_{2},\cdots ,c_{N}$ will be close to the lowest possible actual eigenmode of the system. Thus, this finds the lowest eigenfrequency. If we find eigenmodes orthogonal to this approximated lowest eigenmode, we can approximately find the next few eigenfrequencies as well.
In general, we can express $A[Y(x)]$ and $B[Y(x)]$ as a collection of terms quadratic in the coefficients $c_{i}$:
$B[Y(x)]=\sum _{i}\sum _{j}c_{i}c_{j}K_{ij}=\mathbf {c} ^{\mathsf {T}}K\mathbf {c}$
$A[Y(x)]=\sum _{i}\sum _{j}c_{i}c_{j}M_{ij}=\mathbf {c} ^{\mathsf {T}}M\mathbf {c}$
where $K$ and $M$ are the stiffness matrix and mass matrix of a discrete system respectively.
The minimization of $\omega ^{2}$ becomes:
${\frac {\partial \omega ^{2}}{\partial c_{i}}}={\frac {\partial }{\partial c_{i}}}{\frac {\mathbf {c} ^{\mathsf {T}}K\mathbf {c} }{\mathbf {c} ^{\mathsf {T}}M\mathbf {c} }}=0$
Solving this,
$\mathbf {c} ^{\mathsf {T}}M\mathbf {c} {\frac {\partial \mathbf {c} ^{\mathsf {T}}K\mathbf {c} }{\partial \mathbf {c} }}-\mathbf {c} ^{\mathsf {T}}K\mathbf {c} {\frac {\partial \mathbf {c} ^{\mathsf {T}}M\mathbf {c} }{\partial \mathbf {c} }}=0$
$K\mathbf {c} -{\frac {\mathbf {c} ^{\mathsf {T}}K\mathbf {c} }{\mathbf {c} ^{\mathsf {T}}M\mathbf {c} }}M\mathbf {c} =\mathbf {0}$
$K\mathbf {c} -\omega ^{2}M\mathbf {c} =\mathbf {0}$
For a non-trivial solution of c, we require determinant of the matrix coefficient of c to be zero.
$\det(K-\omega ^{2}M)=0$
This gives a solution for the first N eigenfrequencies and eigenmodes of the system, with N being the number of approximating functions.

### Simple case of double spring-mass system

The following discussion uses the simplest case, where the system has two lumped springs and two lumped masses, and only two mode shapes are assumed. Hence M = [m$_1$, m$_2$] and K = [k$_1$, k$_2$].
A mode shape is assumed for the system, with two terms, one of which is weighted by a factor B, e.g. Y = [1, 1] + B[1, −1]. Simple harmonic motion theory says that the velocity at the time when deflection is zero, is the angular frequency $\omega$ times the deflection (y) at time of maximum deflection. In this example the kinetic energy (KE) for each mass is 1/2 ω$^2$Y$_1$$^2$m$_1${\textstyle {\frac {1}{2}}\omega ^{2}Y_{1}^{2}m_{1}} etc., and the potential energy (PE) for each spring is 1/2 k$_1$Y$_1$$^2${\textstyle {\frac {1}{2}}k_{1}Y_{1}^{2}} etc.
We also know that without damping, the maximal KE equals the maximal PE. Thus,
$\sum _{i=1}^{2}\left({\frac {1}{2}}\omega ^{2}Y_{i}^{2}M_{i}\right)=\sum _{i=1}^{2}\left({\frac {1}{2}}K_{i}Y_{i}^{2}\right)$
The overall amplitude of the mode shape cancels out from each side, always. That is, the actual size of the assumed deflection does not matter, just the mode shape.
Mathematical manipulations then obtain an expression for $\omega$, in terms of B, which can be differentiated with respect to B, to find the minimum, i.e. when $d\omega /dB=0$. This gives the value of B for which $\omega$ is lowest. This is an upper bound solution for $\omega$ if $\omega$ is hoped to be the predicted fundamental frequency of the system because the mode shape is assumed, but we have found the lowest value of that upper bound, given our assumptions, because B is used to find the optimal 'mix' of the two assumed mode shape functions.
There are many tricks with this method, the most important is to try and choose realistic assumed mode shapes. For example, in the case of beam deflection problems it is wise to use a deformed shape that is analytically similar to the expected solution. A quartic may fit most of the easy problems of simply linked beams even if the order of the deformed solution may be lower. The springs and masses do not have to be discrete, they can be continuous (or a mixture), and this method can be easily used in a spreadsheet to find the natural frequencies of quite complex distributed systems, if you can describe the distributed KE and PE terms easily, or else break the continuous elements up into discrete parts.
This method could be used iteratively, adding additional mode shapes to the previous best solution, or you can build up a long expression with many Bs and many mode shapes, and then differentiate them partially.

## The relationship with the finite element method

In the language of the finite element method, the matrix $H_{kj}$ is precisely the stiffness matrix of the Hamiltonian in the piecewise linear element space, and the matrix $S_{kj}$ is the mass matrix. In the language of linear algebra, the value $\epsilon$ is an eigenvalue of the discretized Hamiltonian, and the vector $c$ is a discretized eigenvector.