In the book "A Primer on PDEs" by Salsa et al. they use the finite difference method to solve the one dimensional non-homogeneous diffusion equation $$ u_t(x,t)-u_{xx}(x,t)=f(x,t) $$ For $x \in \, (0,1)$ with Dirichlet boundary condition $u(0,t)=0$ and Neumann boundary condition $u_x(1,t)=0$ and a smooth initial condition. Then the book introduces an $N$ component vector $\mathbf{U}(t)$ such that $U_i(t)=u(x_i,t)$ where $x_i$ is the discretized spatial coordinate and $1\leq i\leq N$. For the Neumann boundary condition the book uses the following approximation for the first order derivative at the boundary point ($i=N$): $$u_x(x_N,t)=\frac{1}{2h}(-3u(x_{N-2},t)+2u(x_{N-1},t)-u(x_N,t))$$ And writes the discretized equation as: \begin{equation} \dot{\mathbf{U}}(t)+\mathbf{A}\mathbf{U}(t)=\mathbf{F}(t) \,\,\, \, \, \, \, \, \, \, \, \, (i) \end{equation} Where $$\mathbf{A}=\frac{1}{\Delta x^2}\begin{bmatrix} 2 & -1 & 0 & \dots & \dots & \dots & 0 \\ -1 & 2 & -1 & 0 & \dots & \dots & 0\\ 0 & -1 & 2 & -1 & 0 & \dots & 0\\ \vdots & & \ddots & \ddots & \ddots & & \vdots \\ 0 & \dots & & -1 & 2 & -1 & 0\\ 0 & \dots & & 0 & -1 & 2 & -1 \\ 0 & \dots & & 0 & -\frac32 & 2 & -\frac12 \end{bmatrix}$$ Where $\Delta x = \frac{1}{N}$ and $$ \mathbf{F}(t)=\begin{pmatrix} f(x_1,t) \\ f(x_2,t) \\ \vdots \\ f(x_{N-1},t) \\ 0 \end{pmatrix}$$
My problem is with that last row of $\mathbf{A}$. I know that it has something to with the Neumann boundary condition, but it doesn't imply that the Neumann condition gets satisfied. If we put $\mathbf{A}$ into $(i)$ we find a relation for the time derivative of $u(x_N,t)$. So I would like to know that how the Neumann condition is satistied in equation $(i)$.
The last row of the matrix gives $$-\frac{3}{2}u_t(x_{N-2})+2u_t(x_{N-1})-\frac{1}{2}u_t(x_N)$$ which is a second-order expression for $(u_x)_t(x_N)$, and the last entry of $\mathbf{F}$ is 0. This is a discrete statement that $(u_x)_t=0$ at $x_N$. You are correct that there is something fishy about this. It does not work unless $u_x=0$ initially, which perhaps it is.
A different way to do it would be to ignore the last row and compute $u_t$ and hence $u$ for $n=0,1..N-2,N-1$, and then find $u_N$ by extrapolation
It is very hard to write a textbook with no errors at all.