function dydt = spring_deriv ( t, y )

%*****************************************************************************80
%
%% spring_deriv() returns the right hand side of the spring ODE.
%
%  Discussion:
%
%    Y1 is the displacement;
%    Y2 is the velocity;
%
%    M is the mass.
%    B is the damping.
%    K is the spring stiffness.
%
%    The second order ODE:
%
%      m * x'' + b * x' + k * x = 0
%
%    is transformed into a pair of first order ODE's
%    using the variables:
%
%      y(1) = x,
%      y(2) = x'
%
%    so that
%
%      y'(1) = y(2)
%      y'(2) = - ( k / m ) y(1) - ( b / m ) y(2)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 December 2020
%
%  Author:
%
%    John Burkardt
%
%  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.
%
  [ m, b, k, t0, y0, tstop ] = spring_parameters ( );

  u = y(1);
  v = y(2);

  dudt = v;
  dvdt = - ( k / m ) * u - ( b / m ) * v;

  dydt = [ dudt; dvdt ];

  return
end

