# Finite elements/Choosing weight function
## Choice of weighting functions

As you have seen, we need to know the weighting functions (also called test functions) in order to define the weak (or variational) statement of the problem more precisely.
Consider the second model problem (3). If $w(x)$ is a weighting function, then the weak form of equation (3) is
    ${\text{(17)}}\qquad {\int _{0}^{1}\left[-{\frac {d^{2}}{dx^{2}}}[u(x)]+u(x)-x\right]~w(x)~dx=0}$
Let the possible weighting functions $w(x)$ for this equation be such that they satisfy the boundary conditions, that is $w(0)=0$ and $w(1)=0$. This set of weighting functions will be denoted by the symbol ${\mathcal {H}}$.
The exact weak form of the problem can then be stated as:
To get to an approximate weak form, we need to choose trial functions. Let these trial functions ($u_{h}$) reside in the function space ${\mathcal {S}}$. The approximate weak form of the problem is
One requirement that these trial functions ($u_{h}$) have to satisfy is that
    $\int _{0}^{1}\left({\cfrac {d^{2}u_{h}}{dx^{2}}}\right)w(x)~dx<\infty ~.$
The trial functions also have to satisfy the boundary conditions.
If you look at the weak form shown above, you will notice that the highest derivatives of $u_{h}$ are of the second order while there are no derivatives of $w$. This leads to a lack of symmetry in the formulation that is usually avoided for numerical reasons.
To get a symmetric weak form, we integrate the first term inside the integral by parts to get
    $\int _{0}^{1}{\frac {d^{2}u_{h}}{dx^{2}}}~w(x)~dx=\left.{\frac {du_{h}}{dx}}~w(x)\right|_{0}^{1}-\int _{0}^{1}{\frac {du_{h}}{dx}}{\frac {dw}{dx}}~dx~.$
(Recall that the formula for integration by parts is $\int a~db=ab-\int b~da$.)
Applying the boundary conditions on $w(x)$, we get
    $\int _{0}^{1}{\frac {d^{2}u_{h}}{dx^{2}}}~w(x)~dx=-\int _{0}^{1}{\frac {du_{h}}{dx}}{\frac {dw}{dx}}~dx~.$
Therefore the problem can be restated in symmetric form as :
Since the same order of derivatives appear in both the trial and the weighting functions, we can choose our functions from the same set ${\mathcal {H}}_{0}^{1}$, where ${\mathcal {H}}={\mathcal {S}}={\mathcal {H}}_{0}^{1}$. As you can see, the smoothness requirements on $w$ are further weakened. This boundary value problem is also called the variational boundary value problem.
The variational boundary value problem (18) can be (and often is) written using bilinear function notation as
where
    ${a(u_{h},w)=\int _{0}^{1}{\frac {du_{h}}{dx}}{\frac {dw}{dx}}~dx~;\qquad (u_{h},w)=\int _{0}^{1}u_{h}~w~dx~;\qquad (x,w)=\int _{0}^{1}x~w~dx~.}$

### Characteristics of admissible functions

Let us now characterize ${\mathcal {H}}_{0}^{1}$, the class of admissible functions for the problem. We know that if $u_{h}$ and $w$ are irregular then their derivatives are even more irregular. Therefore, the most irregular term in the problem statement is
    $\int _{0}^{1}{\frac {du_{h}}{dx}}{\frac {dw}{dx}}~dx~.$
Now, both $u_{h}$ and $w$ are functions in the space ${\mathcal {H}}_{0}^{1}$. So we can choose $w$ to be equal to $u_{h}$. Hence the minimum requirement for $w$ is
    ${\int _{0}^{1}\left({\frac {dw}{dx}}\right)^{2}~dx<\infty \qquad w(0)=w(1)=0~.}$
Functions like the above are called square integrable.
Thus, our weighting functions have to be square integrable. This is a stricter condition than just requiring $w$ to be piecewise continuous, and reduces the number of functions that you can choose from.
There are two other interesting properties of the space ${\mathcal {H}}_{0}^{1}$. These are :
* It is a linear space which means that if $w_{1}$ and $w_{2}$ are two arbitrary functions in this space, then the following operations hold :
    ${\begin{aligned}&w_{1}+w_{2}\in {\mathcal {H}}_{0}^{1}\\&\alpha w_{1}+\beta w_{2}\in {\mathcal {H}}_{0}^{1},\alpha ,\beta ~{\text{are scalars}}\end{aligned}}$
* It is an infinite dimensional space. This means that an infinity of parameters are needed to uniquely determine a weighting function $w~\in {\mathcal {H}}_{0}^{1}$. Thus,
    $w(x)=\sum _{i=1}^{\infty }a_{i}N_{i}(x)$
    where, $N_{i}$ are linearly independent functions (also called basis functions) and $a_{i}$ are constants. If we choose only $n$ of these basis functions $\{N_{1},N_{2},\dots ,N_{n}\}$ then this is a $n$-dimensional (i.e., finite dimensional) subspace of ${\mathcal {H}}_{0}^{1}$ and we denote this as ${\mathcal {H}}_{0}^{n}$.