function y=bottle(t,x)

%BOTTLE system of equations for wobbling soda bottle       
%
%   BOTTLE(t,x) takes as imput a time t (which is 
%   ignored) and a vector x consisting of two spatial
%   coordinates x(1), x(2) and the velocities in those 
%   directions, x(3) and x(4) respectively.
%
%   BOTTLE returns the derivative vector y=x'.
%
% Record of Revisions:
%
%        Date       Description
%        ====       ===========   
%  0. 16-Apr-2001   File created. (DGCH)
%  1. 24-Apr-2001   Comments added. (DGCH)
%

% Setup

     y=zeros(4,1);
     global k;

% Which foot is the bottle standing on?
     
     n=(1:5)';
     P=[cos(2*pi*n/5) sin(2*pi*n/5)];
     D=sqrt((x(1)-P(n,1)).^2+(x(2)-P(n,2)).^2);

     m=1;
     
     for i=2:5
      if D(i)<D(m)
       m=i;
      end
     end

% Computation of y

     y(1)=x(3);
     y(2)=x(4);
     y(3)=k.*(x(1)-P(m,1));
     y(4)=k.*(x(2)-P(m,2));




