I am having trouble understanding how to approximate the solution to this problem using the Ritz method and the weak form:
$$\frac{d^2u}{dx^2} - u=0; \ \ x \in [0,1]$$ $$u(x=0)=0; \ \ \frac{du}{dx} \bigg|_{x=1} = 20$$
We multiply the strong form of the equation by a weight function $w$ and integrate over the domain by parts to get
$$ \int_0^1w\left[\frac{d^2u}{dx^2} - u \right] dx = \int_0^1 w \frac{d^2 u}{dx^2} dx - \int_0^1wu \ dx$$
$$\int_0^1 \frac{du}{dx} \frac{dw}{dx} dx - \int_0^1 wu \ dx - 20 w(1) = 0$$
which is the weak form. Now, I am confused because when I try to change this into a matrix equation, I practically try to solve
$$\int_0^1 \frac{du}{dx} \frac{dw}{dx} dx = \int_0^1 wu \ dx + 20 w(1) $$
If I try to use, say $$u\approx\hat{u}=a_1 \phi_1 + a_2 \phi_2$$
I should be able to form a linear problem $$\mathbf{K} \vec{a} = \vec{b}$$
where $\mathbf{K}$ is a $2 \times 2$ matrix obtained from the left hand side of the equation where $w \to \phi_i$ and $u \to \phi_j$ to get the entries $K_{ij}$, but this substitution would not work to obtain the components of $\vec{b}$ since I this substitution gives me terms of $\phi_i$ and $\phi_j$ and this makes no sense since $\vec{b}$ is indexed only by one subindex. I know I am not understanding something, but this was my professor's explanation and I am confused.
Thank you so much for your help!