To find the finite element solution, we can either start with the
strong form and derive the weak form, or we can start with a weak form
derived from a variational principle.
Let us assume that the approximate solution is
and plug
it into the ODE. We get

where
is the residual. We now try to minimize the residual in a weighted average sense

where
is a weighting function. Notice that this equation is similar to equation (5) (see 'Weak form: integral equation') with
in place of the variation
. For the two equations to be equivalent, the weighting function must also be such that
.
Therefore the approximate weak form can be written as

In Galerkin's method we assume that the approximate solution can
be expressed as

In the Bubnov-Galerkin method, the weighting function is chosen to be of the same form as the approximate solution (but with arbitrary coefficients),

If we plug the approximate solution and the weighting functions into
the approximate weak form, we get

This equation can be rewritten as
![{\displaystyle \sum _{j=1}^{n}b_{j}\left[\int _{0}^{L}AE\left(\sum _{i=1}^{n}a_{i}{\cfrac {d\varphi _{i}}{dx}}{\cfrac {d\varphi _{j}}{dx}}\right)~dx\right]=\sum _{j=1}^{n}b_{j}\left[\int _{0}^{L}\mathbf {q} \varphi _{j}~dx+\left.\left({\boldsymbol {R}}~\varphi _{j}\right)\right|_{x=L}\right]~.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/08eb686776c56bd4516969ddbf1bf2d5056f4f42)
From the above, since
is arbitrary, we have

After reorganizing, we get
![{\displaystyle \sum _{i=1}^{n}\left[\int _{0}^{L}{\cfrac {d\varphi _{j}}{dx}}AE{\cfrac {d\varphi _{i}}{dx}}~dx\right]a_{i}=\int _{0}^{L}\varphi _{j}\mathbf {q} ~dx+\left.\varphi _{j}{\boldsymbol {R}}\right|_{x=L}~,~j=1\dots n}](https://wikimedia.org/api/rest_v1/media/math/render/svg/52e2732f97d7b1db49e5bb7d99fbea509f424821)
which is a system of
equations that can be solved for the unknown coefficients
. Once we know the
s, we can use them to compute approximate solution. The above equation can be written in matrix form as

where

and

The problem with the general form of the Galerkin method is that the
functions
are difficult to determine for complex domains.