function ux = dbydx_pp ( u, dx )

%*****************************************************************************80
%
%% dbydx_pp: estimate spatial derivative; both boundaries are periodic.
%
%  Discussion:
%
%    The array U has NX entries.
%
%    The values in U correspond to X locations with spacing DX.
%
%    The first and last values of U should be equal, since the periodic
%    condition applies.
%
%    We estimate the derivative using finite differences.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 December 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real u(nu,nx), the value at each point.
%
%    real dx, the spacing between points.
%
%  Output:
%
%    real ux(nu,nx), the derivative estimate.
%
  [ nu, nx ] = size ( u );

  ux = [ u(:,2)-u(:,nx-1), u(:,3:nx)-u(:,1:nx-2), u(:,2)-u(:,nx-1) ] / 2.0 / dx;

  return
end

