function [ y, dydt ] = lindberg_exact ( t )

%*****************************************************************************80
%
%% lindberg_exact() evaluates the exact solution of lindberg_ode().
%
%  Discussion:
%
%    The formula was supplied by Wenlong Pei.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 August 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real t(n): the evaluation points.
%
%  Output:
%
%    real y(n,4): the function values.
%
%    real dydt(n,4): the derivative values.
%
  n = length ( t );
  y = zeros ( n, 4 );
  dydt = zeros ( n, 4 );

  g1 = 10.0^4 * ( t + 2.0 * exp ( - t ) - 2.0 );
  g2 = 10.0^4 * ( 1.0 - exp ( - t ) - t .* exp ( -t ) );

  dg1dt = 10.0^4 * ( 1.0 - 2.0 * exp ( - t ) );
  dg2dt = 10.0^4 * (  t .* exp ( - t ) );

  y(:,1) = exp ( g1 ) .* ( cos ( g2 ) + sin ( g2 ) );
  y(:,2) = exp ( g1 ) .* ( cos ( g2 ) - sin ( g2 ) );
  y(:,3) = 1.0 - 2.0 * exp ( - t(:) );
  y(:,4) = t(:) .* exp ( - t(:) );
 
  dydt(:,1) = exp ( g1 ) .* dg1dt .* ( cos ( g2 ) + sin ( g2 ) ) ...
            + exp ( g1 ) .* ( - sin ( g2 ) + cos ( g2 ) ) .* dg2dt;

  dydt(:,2) = exp ( g1 ) .* dg1dt .* ( cos ( g2 ) - sin ( g2 ) ) ...
            + exp ( g1 ) .* ( - sin ( g2 ) - cos ( g2 ) ) .* dg2dt;

  dydt(:,3) = 2.0 * exp ( - t(:) );
  dydt(:,4) = ( 1.0 - t(:) ) .* exp ( - t(:) );

  return
end

