function y = pendulum_exact ( t )

%*****************************************************************************80
%
%% pendulum_exact() returns the exact solution pendulum_ode().
%
%  Discussion:
%
%    This solution satisfies the pendulum ODE:
%
%    u' = v
%    v' = - g / l * u
%
%    u(t0) = u0 = y0(1)
%    v(t0) = v0 = y0(2)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 May 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T(:): the current time.
%
%  Output:
%
%    real Y(2): the exact solution.
%
  [ g, l, m, t0, y0, tstop ] = pendulum_parameters ( );

  p = sqrt ( g / l );

  u =               y0(1) * cos ( p * ( t - t0 ) ) ...
    + ( 1.0 / p ) * y0(2) * sin ( p * ( t - t0 ) );

  v =       - p   * y0(1) * sin ( p * ( t - t0 ) ) ...
    +               y0(2) * cos ( p * ( t - t0 ) );

  y = [ u, v ];

  return
end

