Finite difference method, boundaries I have a problem solving this problem. 
$$
−3u''(x) + (x + 2)u(x) = 4x, \hspace{10pt} x \in (−1, 1), 
$$
subject to
$$
u'(−1) + 4u(−1) = 3, \hspace{10pt} −u'(1) + 2u(1) = 0,\hspace{10pt} h=0.001
$$
Then $p = -3,\, q= (x+2)$.

So I got to the point that I can estimate 
$$
\frac{p}{h^2}u(x-h) + \left(\frac{2p}{h^2} + q\right)u(x) + \frac{p}{h^2}u(x+h) = f(x).
$$

For equation above I need at least boundaries and
I know that I can rewrite $u'(x)$ like this: 
$$
u'(x) \approx \frac{u(x+h) − u(x)}{h}
$$
and rewrite boundaries as: 
$$
\frac{u(-0.999) - u(-1)}{0.001} + 4u(-1) =3
$$
$$
-\frac{u(1.001) - u(1)}{0.001} + 2u(1) = 0
$$

But this is where I got stucked and I cannot find boundaries. Can somebody help me? Thank you.
 A: You could make use of the ghost-point method. Intuitively, ghost-point method is based on the analytic continuity of the solution. It assumes that the governing equation not only holds for all $x\in\left(-1,1\right)$, but also holds on $x=-1$ and $x=1$. With this trick, the Robin (or simply Neumann) boundary conditions could be implemented in a natural fashion.
Suppose
$$
-1=x_0<x_1<\cdots<x_N=1
$$
are your equi-spaced grid points, with
$$
x_j=jh-1,\quad h=\frac{2}{N}.
$$
Now define
\begin{align}
x_{-1}&=-1-h,\\
x_{N+1}&=1+h.
\end{align}
Plus, implement
$$
-3\frac{u_{j+1}-2u_j-u_{j-1}}{h^2}+\left(x_j+2\right)u_j=4x_j,\quad j=0,1,\cdots,N
$$
for the governing equation, with boundary conditions
\begin{align}
\frac{u_1-u_{-1}}{2h}+4u_0&=3,\\
-\frac{u_{N+1}-u_{N-1}}{2h}+2u_N&=0.
\end{align}
Note that for the governing equation, the index $j$ runs from $0$ to $N$, instead of the usual boundary-value-problem case from $1$ to $N-1$. Thus combine the main scheme with the boundary conditions from above, you will be able to determine all of $x_{-1}$, $x_0$, ..., $x_{N+1}$, because there are $N+3$ unknowns, and you have $N+3$ linear equations.
