function dydt = lindberg_deriv ( t, y )

%*****************************************************************************80
%
%% lindberg_deriv() returns the derivative for lindberg_ode().
%
%  Discussion:
%
%    Note that components y1(t) and y2(t) first sink to extraordinarily
%    small values, and then undergo explosive growth, sometime before t=1.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 August 2021
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Bengt Lindberg,
%    On a dangerous property of methods for stiff differential equations,
%    BIT Numerical Mathematics,
%    Volume 14, 1974, pages 430-436.
%
%    Daniel Watanabe, Qasim Sheikh,
%    One-leg formulas for stiff ordinary differential equations,
%    SIAM Journal on Scientific and Statistical Computing,
%    Volume 5, Number 2, June 1984, pages 489-496.
%
%  Input:
%
%    real T: the current time.
%
%    real Y(4): the current solution value.
%
%  Output:
%
%    real DYDT(4): the value of dY/dT.
%
  y1 = y(1);
  y2 = y(2);
  y3 = y(3);
  y4 = y(4);

  dydt = zeros ( 4, 1 );

  dydt(1) =   10.0^4 * y1 * y3 + 10.0^4 * y2 * y4;  
  dydt(2) = - 10.0^4 * y1 * y4 + 10.0^4 * y2 * y3; 
  dydt(3) = 1.0 - y3;
  dydt(4) = - 0.5 * y3 - y4 + 0.5;
 
  return
end

