function dydt = lorenz06_deriv ( t, y )

%*****************************************************************************80
%
%% lorenz96_deriv() evaluates the right hand side of lorenz96_ode().
%
%  Discussion:
%
%    dy(i)/dt = ( y(i+1) - y(i-2) ) * y(i-1) - y(i) + force
%    where force is a constant independent of i
%    and the indices wrap around.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 September 2025
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Edward Lorenz,
%    Predictability - A problem partly solved,
%    Seminar on Predictability, Volume I, 
%    European Center for Medium-Range Weather Forecasts, 1996.
%
%  Input:
%
%    real T: the value of the independent variable.
%
%    real Y(N): the values of the dependent variables at time T.
%
%  Output:
%
%    real DYDT(N): the right hand side of the ODE.
%
  [ n, force, ~, ~, ~, ~ ] = lorenz96_parameters ( );

  i = 1 : n;
  ip1 = circshift ( i,  1 );
  im1 = circshift ( i, -1 );
  im2 = circshift ( i, -2 );

  dydt = ( y(ip1) - y(im2) ) .* y(im1) - y(i) + force;
%
%  Derivative is returned as a column vector.
%
  dydt = dydt(:);

  return
end

