function f = pendulum2( y, t )
%
%  return the RHS of the equation for a damped pendulum
%    theta'' = - nu theta' - (g/L)*sin(theta) + A*sin(omega*t)
%
% Forcing function frequency is obtained from a global variable:
global omega A g L

g = 9.8;              %  acceleration of gravity (m/sec^2)
L = 9.8;              %  length of pendulum (m)
nu = 0.1;             %  damping coefficient (sec^{-1})


f1 = y(2);            %  d y_1 / dt = y_2
f2 = -nu*y(2) - (g/L)*sin( y(1) ) + A*sin(omega*t);

f = [ f1, f2 ];       % cast result as vector
