function dxdt=mlcGenVERHS(t,x,p)
%RHS of the MLC circuit and the generic variational equation
%needed for the computation of the Lyapunov exponents
%in the Pecora Carroll approach to study the stability of the synchronous motion
  dxdt=zeros(12,1);
  dxdt(1)=x(2)/p.L-p.r0*x(1)/p.L;
  dxdt(2)=-x(1)/p.C-p.alpha*x(2)*x(3)/p.C;
  dxdt(3)=x(2)*x(2)-p.beta;
  Jac=[-p.r0/p.L,1/p.L,0;
       -1/p.C,-p.alpha*x(3)/p.C,-p.alpha*x(2)/p.C;
        0,2*x(2),0];
  E=[0,0,0;
     0,1/p.C,0
     0,0,0]; 
  xvar=reshape(x(4:12),3,3);
%  xvar=[x(4),x(7),x(10);
%     x(5),x(8),x(11);
%     x(6),x(9),x(12)];
  dxdt(4:12)=(Jac+p.gamma*E)*xvar;