For the resolution of this equation, I do not understand the computation of the (elementary) matrix's elements way below.
The main problem is
$$
\begin{cases}
-u''(x) = f \\
u(0) = u(1) = 0
\end{cases}
$$
The variational formulation is
$$
\int_{0}^{1} u'(x)v'(x) = \int_{0}^{1} f(x)v(x)
$$
with $v, u \in V = \left\{u \in L^2 , u' \in L^2, u(0) = u(1) = 0 \right\} = H_{0}^{1}$
We set:
$$
\begin{cases}
a(u,v) = \int_{0}^{1} u'v' \\
l(v) = \int_{0}^{1} fv
\end{cases}
$$
$x_i = ih, \quad 0 \le i \le N+1; x_{N+1} = 1 \quad \text{and} \quad x_0 = 0$
With the help of those functions, we have the basis: \
$\Phi_i(x_j) = \delta_{i,j}$ pour $0\le i<N$,
$$
\begin {cases}
\Phi_i(x)=\frac {x-x_{i-1}} h \text { si }x_{i-1}\le x\le x_{i},\\
\Phi_i(x)=\frac {-x+x_{i+1}} h \text { si }x_{i}\le x\le x_{i+1},\\
\Phi_i(x)=0\text { sinon }.
\end {cases}
$$
$\{\Phi_i \}_{0\le i< N}$ is a basis of $V_h$:
$$
\forall v\in V_h,\quad v=\sum_{i=0}^{N-1}v(x_i)\Phi_i.
$$
then:
$$
\sum_{i}^{n} (u_h)_i \int_{0}^{1} \phi_i^{'}\phi_j^{'}dx = \int_{0}^{1} f\phi_j dx
$$
where $(u_h)_i$ are the coordinates $U_h$ in the previous basis.
The linear system become:
$$
A_h U_h = b_h
$$
$U_h = (u_h)_i$
$$
A_h = (a_{i,j}) = \int_{0}^{1} \phi_i^{'}\phi_j^{'}dx
$$
$A_h$ is a tridiagonal matrix
so for $i = j+1$, we have:
\begin{align*}
(a_{i,j}) & = \int_{0}^{1} \phi_i^{'}\phi_{i-1}^{'}dx\\
& = \int_{ih}^{(i-1)h} \phi_i^{'}\phi_{i-1}^{'} dx \\
& = \int_{ih}^{(i-1)h} -\frac{1}{h}\frac{1}{h}dx \\
& = -1/h
\end{align*}
I don't understand why is
$$
\phi_i^{'} = -\frac{1}{h}
$$
here.
in $[x_{i-1},x_{i}] = [(i-1)h,ih]$
I have the same problem with the equation:
$-u'' + u = f$ where for $i= j+1$, we have:
\begin{align*}
(a_{i,j}) & = \int_{0}^{1} \phi_i^{'}\phi_{i-1}^{'} + \phi_i \phi_{i-1}dx\\
& = \int_{ih}^{(i-1)h} \phi_i^{'}\phi_{i-1}^{'} + \phi_i \phi_{i-1}dx dx\\
& = \int_{ih}^{(i-1)h} -\frac{1}{h}\frac{1}{h} + \left(\frac{1}{h}x + (1-i)\right)\left(-\frac{1}{h}x + (2-i)\right)dx\\
& = \cdots
\end{align*}
Why is $\left(\frac{1}{h}x + (1-i)\right) = \phi_i$?
Best Answer
To solve your first doubt, just compute the derivative of $\Phi_i$.
About your second doubt, just notice $(1-i)=-(i-1)h/h$.