function value = stiff_exact ( t )

%*****************************************************************************80
%
%% stiff_exact() evaluates the exact solution of stiff_ode().
%
%  Discussion:
%
%    y' = lambda * ( cos(t) - y )
%    y(t0) = y0
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 June 2025
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T(:): the evaluation times.
%
%  Output:
%
%    real Y(:): the exact solution values.
%
  [ lambda, t0, y0, tstop ] = stiff_parameters ( );

  mu = y0 - lambda^2 / ( lambda^2 + 1.0 );

  value = lambda   * sin ( t - t0 ) / ( lambda^2 + 1.0 ) ...
        + lambda^2 * cos ( t - t0 ) / ( lambda^2 + 1.0 ) ... 
        + mu * exp ( - lambda * ( t - t0 ) );

  return
end

