function dydt = sawtooth_deriv ( t, y )

%*****************************************************************************80
%
%% sawtooth_deriv() returns the right hand side of sawtooth_ode().
%
%  Discussion:
%
%    y1' = y2
%    y2' = -y1 + sawtooth(omega*t)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 December 2020
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    John D Cook,
%    Driving vibrations with sawtooth waves,
%    https://www.johndcook.com/blog/2020/09/19/sawtooth-waves/
%    
%  Input:
%
%    real T, the current time.
%
%    real Y(2), the current state values.
%
%  Output:
%
%    real dydt(2), the time derivatives of the current state values.
%
  u = y(1);
  v = y(2);

  dudt = v;
  dvdt = - u + sawtooth_driver ( t );

  dydt = [ dudt; dvdt ];

  return
end

