##
## 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 yprime = hill(y, x)
  ## Symbolic names for the three coordinates
  a = y(3);
  e = y(4);
  ## Hill's equation reduced to order 1
  yprime(1) =  y(2);
  yprime(2) = - (a + e * cos(x))/(1+ e * cos(x)) * y(1);
  ## Derivatives corresponding to constants are 0
  yprime(3) = 0;		# a
  yprime(4) = 0;		# e
endfunction

## ;;; Local Variables: ***
## ;;; mode: octave ***
## ;;; End: ***
