Differentiation Matrix for central-difference scheme? Central-difference scheme is defined to be:
$f'(x) = \frac{f(x+d(x)) - f(x-d(x)))} {2*d(x)} + O(d(x)^2)$
Assume periodic boundary conditions, so that: $f(n+1)=f(1)$
I understand how to find all the center values of the matrix, but what I don't get is the first and last rows using the "periodic boundary condition" statement.
$\left[ {\begin{array}{ccccc}
 f_1'(x) \\
 f_2'(x) \\
 f_3'(x) \\
... \\
 f_n'(x)\\
  \end{array} } \right] =
\frac{1} {2*d(x)} * 
A * \left[ {\begin{array}{ccccc}
 f_1(x) \\
 f_2(x) \\
 f_3(x) \\
... \\
 f_n(x)\\
  \end{array} } \right]$
Where A is a matrix with $1$'s, $0$'s and $-1$'s.
What I have is that the upper diagonal will be all 1's and the lower will be -1's and the actual diagonal is all 0's and rest is 0 too. Except the first and the last row, can someone help me with those?

$$
A =
\pmatrix{  0 & 1     &   0    &        & \dots  &  -1     \cr
          -1 &  0     &  1    &        &        &        \cr
           0 & -1     &   0    & 1     & \ddots & \vdots \cr
      \vdots & \ddots &        & \ddots &        &        \cr
             &        &        &  -1    &   0    & 1     \cr
           1 & \dots  &        &  0     &  -1    &  0     \cr}
$$
