%%
%% Damped Hill's equation is the equation of y(x) where:
%% y'' + k * y' + (a + e * cos(x))/(1 + e * cos(x)) y = 0
%%
%%
%% Damped Hill's equation is the equation of y(x) where:
%% y'' + k * y + 2 * (theta(0) + theta(1)*cos(2 * x)
%%       + theta(2) * cos(4 *x) + ... + theta(n) * cos(2 * n * x) +...) y = 0
%% Interpretation 1: A swing with periodically variable length.
%% Interpretation 2: Used in the theory of Lunar motions.
%% if k = 0 and theta(n) = 0 for n >= 1, this is Mathieu equation. 
%% Example: y'' + (a + e * cos(x))/(1 + e * cos(x)) * y = 0
%% Let y = y(1) and y' = y(2). 
%% Also, we store k in y(3), w in y(4) and e in y(5)
%%
%%
function wdotOut = hill(t, w) 
  k = .2;
  a = w(3);
  e = w(4);
  wdot(1) = w(2);
  wdot(2) = - (a + e * cos(t)) / (1 + e * cos(t)) * w(1) - k * w(2);
  %% wdot(2) = - (a + e * cos(t)) / (1 + e * cos(t)) * w(1);
  wdot(3) = 0;
  wdot(4) = 0;
  wdotOut = wdot';
