function [out]=lyapunov(var,A,W)
%
%
a=A(1,1);
b=A(1,2);
c=A(2,1);
d=A(2,2);
x1=var(:,1);
y1=var(:,2);
phi11=W(1,1)*max(0*x1,-(1-x1).*((c-a)*y1+(d-b)*(1-y1)));
phi12=W(1,2)*max(0*x1,x1.*((c-a)*y1+(d-b)*(1-y1)));
phi21=W(2,1)*max(0*y1,-(1-y1).*((a-b)*x1+(c-d)*(1-x1)));
phi22=W(2,2)*max(0*y1,y1.*((a-b)*x1+(c-d)*(1-x1)));
out(:,1)=(phi11.^2+phi12.^2)/2;
