We start with the second order ODE
$$C^{\prime\prime}(x) = x-1 + rC(x)$$ with boundary conditions $C(0) = 1$, $C(1) = 3$.
I wish to construct a central difference approximation to $C$ for the points defined by $x_j = jh$, $j = 0, 1, 2, \ldots, n$, $h = 1/n$.
I have obtained the finite difference equation:
$$2hx_j - 2h + 2hru_j = u_{j+1} - 2u_j + u_{j-1}$$
Can anyone confirm if this is correct, and if so, write this in matrix form? I so far have a tri-diagonal matrix with $-(2+2hr)$ along the main diagonal. Can someone confirm if this sounds correct so far?
hint
Let $C (x_j)=u_j $.
by second order Taylor approximation, we have
$$u_{j+1}=u_j+hC'(x_j)+\frac {h^2}{2}C''(x_j) $$
and
$$u_{j-1}=u_j-hC'(x_j)+\frac {(-h)^2}{2}C''(x_j) $$
hence by sum,
$$u_{j+1}+u_{j-1}=2u_j+h^2C''(x_j) $$
You can take it from here.