# Finite element discretization example clarification

We introduce on the domain $$\Omega = (0,1)$$ a mesh $$0=x_0 and let $$V_h$$ be the space of piecewise linear hat functions $$\varphi_i$$ such that

$$\varphi_i'= \left\{ \begin{array}{ll} \frac{1}{x_i-x_{i-1}}=\frac{1}{h_i}, & \quad x_{i-1}

We can then easily compute the corresponding stiffness matrix $$K$$ and mass matrix $$M$$ by evaluating the integrals below,

$$K_{ij}:=(\varphi_i', \varphi_j') = \int_0^1 \varphi'_i\varphi'_jdx$$ $$M_{ij}:=(\varphi_i, \varphi_j) = \int_0^1 \varphi_i\varphi_jdx$$

So that

$$K_{ij} = (\varphi_i', \varphi_j') = \left\{ \begin{array}{ll} -\frac{1}{h_i}, & \quad j=i-1 \\ \frac{1}{h_i} + \frac{1}{h_{i+1}}, & \quad j=i \\ \frac{-1}{h_{i+1}}, & \quad j=i+1 \\ 0, & \quad\text{ otherwise} \end{array} \right.$$

$$M_{ij} = (\varphi_i, \varphi_j) = \left\{ \begin{array}{ll} \frac{1}{6}h_i, & \quad j=i-1 \\ \frac13({h_i} +{h_{i+1}}), & \quad j=i \\ \frac16 h_{i+1}, & \quad j=i+1 \\ 0, & \quad\text{ otherwise} \end{array} \right.$$

What I don't understand in this example is how actually the values $$K_{ij}$$ and $$M_{ij}$$ were obtained. Let me explain what I mean:

Let $$x\in (x_{i-1}, x_i)$$, then

$$K_{ij}=(\varphi_i', \varphi_j')=\int_0^1 \varphi_i'\varphi_j' dx =\int_0^1 \frac{1}{h_i}\frac{1}{h_j}dx=\frac{1}{h_i h_j}=\frac{1}{h_i^2},$$ which does not coincide with what is in the book.

What is it that I'm misunderstanding?

## 2 Answers

The piecewise linear hat function $$\;\phi_i\;$$ itself is: $$\phi_i(x)= \left\{ \begin{matrix} (x-x_{i-1})/(x_i-x_{i-1}) & \quad \text{for} \quad x_{i-1} < x < x_i \\ (x_{i+1}-x)/(x_{i+1}-x_{i}) & \quad \text{for} \quad x_{i}< x < x_{i+1} \\ 0 & \quad \text{ otherwise} \end{matrix} \right.$$ But I think that the mass matrix is given instead by the integral below: $$M_{i,j}:=(\phi_i, \phi_j) = \int_{x_{i-1}}^{x_{i+1}} \phi_i(x)\phi_j(x)\;dx$$ Three non-zero cases (make a sketch): $$M_{i,i-1} = \int_{x_{i-1}}^{x_{i+1}} \phi_i(x)\phi_{i-1}(x)\;dx = \\ \frac{1}{(x_i-x_{i-1})^2} \int_{x_{i-1}}^{x_i} (x-x_{i-1})(x_{i}-x)\;dx = \frac{x_i-x_{i-1}}{6}$$ $$M_{i,i+1} = \int_{x_{i-1}}^{x_{i+1}} \phi_i(x)\phi_{i+1}(x)\;dx = \\ \frac{1}{(x_{i+1}-x_{i})^2} \int_{x_{i}}^{x_{i+1}} (x-x_{i+1})(x_{i}-x)\;dx = \frac{x_{i+1}-x_{i}}{6}$$ $$M_{i,i} = \int_{x_{i-1}}^{x_{i+1}} \phi_i(x)\phi_{i}(x)\;dx = \\ \frac{1}{(x_{i}-x_{i-1})^2} \int_{x_{i-1}}^{x_{i}} (x-x_{i-1})^2\;dx +\frac{1}{(x_{i+1}-x_{i})^2} \int_{x_{i}}^{x_{i+1}} (x_{i+1}-x)^2\;dx = \frac{x_{i+1}-x_{i-1}}{3}$$ Suppose that also the stiffness matrix is given instead by the integral below: $$K_{i,j}:=(\phi_i', \phi_j') = \int_{x_{i-1}}^{x_{i+1}} \phi'_i(x)\phi'_j(x)\;dx$$ Then can you do this part of the exercise yourself?

I wouldn't be much surprised if the confusion is due to a typo in your book: a mix up of local and global coordinates could be the case. The following two references at MSE seem to be related to your question and might be helpful:

.

Imagine that $$x_i$$ is an interior node: then $$\varphi_i$$ is nonzero only in the interval $$(x_{i-1},x_{i+1})$$, and the same happens with $$\varphi_i'$$. The integral is computed over $$(0,1)$$ but the functions are nonzero in smaller intervals.

• Thanks, but then $\int_0^1 \frac{1}{h_i} \frac{1}{h_j}dx = \int_{x_{i-1}}^{x_i} \frac{1}{h_i} \frac{1}{h_j}dx+ \int_{x_{i}}^{x_{i+1}} \frac{1}{h_i} \frac{1}{h_j}dx=0$ because the integrands are products of functions which are only defined on their respective intervals. Isn't this true? – sequence Apr 8 at 20:44