function xprime = ring(t,x)
%
% Compute diffusion reaction described in Turing's paper "The Chemical Basis 
% of Morphogenesis  (p.61)
%
%     rate = ring.m(t,init)
%
%  Call:  ode45('ring',0,200,[1.13,0.929])
my_eps = 0.01;
cx = 5*10^(-4);
cy = 2.5*10^(-4);
gamma = 0.1;         % just an arbitrary value in interval [-0.5,0.5]

X1 = x(1);
Y1 = x(2);
X2 = x(3);
Y2 = x(4);

% X1 and Y1 in cell 1
rate = 1/32*(50*X1*Y1 + 7*X1^2 - 55*(1 - gamma));
X1prime = -rate+(1/16)+cx*(X2-X1);
if abs(Y1)>my_eps
  Y1prime = rate - Y1/16 + cy*(Y2-Y1);
end;

% X2 and Y2 in cell 2
rate = 1/32*(50*X2*Y2 + 7*X2^2 - 55*(1 - gamma));
X2prime = -rate+(1/16)+cx*(X1-X2);
if abs(Y2)>my_eps
  Y2prime = rate - Y2/16 + cy*(Y1-Y2);
end;

xprime = [X1prime;Y1prime;X2prime;Y2prime];


