## weak formulation

multiply a function $v(x)$ on both sides of the original equation.

\begin{aligned}&-\frac{d}{dx}\left( c(x)\frac{du(x)}{dx} \right)=f(x),\quad a<x<b\\ \Rightarrow &-\frac{d}{dx}\left( c(x)\frac{du(x)}{dx} \right)v(x)=f(x)v(x), \quad a<x<b \\ \Rightarrow &-\int_a^b\frac{d}{dx}\left( c(x)\frac{du(x)}{dx} \right)v(x)=\int_a^b f(x)v(x).\end{aligned}

$u(x)$ is called a trial function and $v(x)$ is called a test funcion.

using integeration by part, we obtain
\begin{aligned}&\int_a^b \frac{d}{dx}\left(c(x)\frac{du(x)}{dx}\right)v(x)dx\\=&\int_a^b(cu')'v\quad dx\\=&cu'v|_a^b-\int_a^bcu'dv\end{aligned}

then

$$-c(b)u'(b)v(b)+c(a)u'(a)v(a)+\int_a^bcu'dv=\int_a^b fv dx$$

since the solution at $x=a$ and $x=b$are given by $u(a)=g_a,u(b)=g_b$, then we can choose the test function $v(x)$ such that $v(a)=v(b)=0$

hence

$$\int_a^bcu'v'dx=\int_a^b fv dx$$

• Weak formulation: find $u\in H^1(I)$ such that$$\int_a^bcu'v'\;dx=\int_a^bfv\;dx$$for any $v\in H_0^1(I)$where $I=(a,b)$

Let $a(u,v)=\int_a^bcu'v'\;dx$ and $(f,v)=\int_a^bfv\;dx$.

• Weak formulation: find $u\in H^1(I)$ such that$$a(u,v)=(f,v)$$for any $v\in H_0^1(I)$where $I=(a,b)$

Assume there is a finite dimensional subspace $U_h \sub H^1(a,b).$ Define $U_{h0}$ to be the space which consists of the functions of $U_h$ with value 0 on the Dirichlet boundary.

• Galerkin formulation: find $u_h \in U_h$ such that $$a(u_h,v_h)=(f,v_h)$$ for any $v_h\in U_{h0}$

## Sobolve spaces

• support

• compactly support

• $C_0^{\infty}(I)$ is the set of all functions that are infinitely differentiable on $I$ and compactly supported in $I$

• for $v \in C_0^\infty$ ,we have $v(a)=v(b)=0$

$$\int_a^bu'v'dx=-\int_a^b fv dx \tag{1}$$

• weak derivative
$$\int_a^b wv \;dx=-\int_a^buv'\;dx$$
$u'$不存在，$w$替代$u'$，$w$叫做弱导数(weak dericative)

• $L^2 space$
$$L^2(I)=\left\{v: I\to R:\int_a^bv^2dx<\infty\right\}$$
where $I=(a,b)$

• $H^1 space$
$$H^1(I)=\left\{v\in L^2(I):v'\in L^2(I)\right\}$$
where $I=(a,b)，v'$ is weak dericative

• $H_0^1$ space
$$H_0^1(I)=\left\{ v\in H^1(I):v(a)=v(b)=0 \right\}$$
where $I=(a,b)$

## Discretization formulation

For an easier implementation, we use the following Galerkin formulation (without considering the Dirichlet boundary condition, which will be handled later): find $u_h\in U_h$ such that $$a(u_h,v_h)=(f,v_h)$$ for any $v_h\in U_h$

Since $u_h\in U_h=span\left\{ \phi_j \right\}_{j=1}^{N+1}$, then$$u_h=\sum_{j=1}^{N+1}u_j\phi_j$$ for some coefficients $u_j$

if we can set up a linear algebraic system for $u_j\;(J=1,\cdots,N+1)$ and solve it, then we can obtain the finite element solution $u_h$

Therefore, we choose the test function $v_h=\phi_i\;(i=1,\cdots,N+1)$. Then the finite element formulation gives \begin{aligned}&\int_a^bc\left( \sum_{j+1}^{N+1}u_j\phi_j \right)'\phi_i'\;dx=\int_a^bf\phi_i\;dx\quad i=1,\cdots,N+1 \\ \Rightarrow& \sum_{j=1}^{N+1}u_j\left[ \int_a^bc\phi_j'\phi_i'\;dx \right]=\int_a^bf\phi_i\;dx\quad i=1,\cdots,N+1\end{aligned}(有限求和算子，可以交换积分号与求和号，弱导数不影响)

• Define the stiffness matrix(刚度矩阵)(对称)$$A=[a_{ij}]_{i,j=1}^{N+1}=\left[\int_a^bc\phi_j'\phi_i'\;dx\right]_{i,j=1}^{N+1}$$

• Define the load vector$$\overrightarrow{b}=[b_i]_{i=1}^{N+1}=\left[\int_a^bf\phi_i\;dx\right]_{i=1}^{N+1}$$

Then we obtain the linear algebraic system$$A\overrightarrow{X}=\overrightarrow{b}$$Here $A$ is symmetric positive-definite if the original elloptic equation is symmetric positive-definite.