function f = fun(x)

L = [x(1:6)' ; x(7:12)'];
A = [-0.746 0.387 -12.9 0 0.952 6.05;
      0.024 -0.174 4.31 0 -1.76 -0.416;
     0.006 -0.999 -0.0578 -0.0369 0.0092 -0.0012; 
  1 0 0 0 0 0 ;
  0 0 0 0 -10 0 ; 
0 0 0 0 0 -5];
B=[0 0 ; 0 0 ; 0 0 ; 0 0 ; 20 0 ; 0 10];

[v,d]=eig(A-B*L);
[y,ind]=sort(real(diag(d)));
v = v(:,ind);
d = d(ind,ind);
z = [imag(v(2,4)) real(v(2,4)); real(v(3,4)) -imag(v(3,4))]\[1 ; 1];
z = z(1)+i*z(2);

v(:,3)=v(:,3)./v(1,3);
v(:,4)=v(:,4)*z;
v(:,6)=v(:,6)./v(4,6);

   
f = [v(2,3) ; v(3,3); real(v(1,4)); imag(v(1,4)); real(v(4,4)); 
imag(v(4,4)); real(v(3,6)); d(3,3)+4; real(d(4,4))+0.63; imag(d(4,4))-2.42; 
d(6,6)+0.05; d(1,1)/d(2,2)-2];
