if I have a finite difference approximation of the first derivative on an interval [0,n] such as
$$\frac{u_{j+1}-u_{j-1}}{2\Delta x}$$
and the problem specifies to use periodic boundary conditions. Does that mean that at the left boundary where $j=0$ and $u_{j-1}$ doesn't exist should I replace $u_{j-1}$ with $u_{n}$ which is equal to $u_0$ or I should use $u_{n-1}$?
vice versa at the right boundary where $u_{j+1}$ doesn't exist should I replace it with $u_0$ or $u_1$?
Update: The reason I am asking is because I wrote a program to solve the transport equation
$$\frac{du}{dt}=c\frac{du}{dx}$$
using 4th order Runge Kutta time stepping and it causes a phase shift only when the wave crosses the boundary. If I change $u_{j+1}$ to $u_1$ instead of using $u_0$ I don't have the phase shift.
You replace $u_{j-1}$ with $u_n$ and replace $u_{j+1}$ with $u_0$ because your box does not have overlap. i.e. $u_0$ is not the same point as $u_n$. These two points are 'next' to each other across the periodic boundary box.