function theta = globalerror(X,Xk)
i         = sqrt(-1);
tem       = trace(X'*Xk);
temreal   = real(tem);
temimag   = imag(tem); 
testpoint = [0 ; 2*pi];
if abs(temreal) < 10^(-6)
    testpoint = [testpoint ; pi/2 ; 3*pi/2];
else
    temtan    = - temimag / temreal;
    temtheta  = atan(temtan);
    if temtheta >= 0
        testpoint = [testpoint ; temtheta ; pi + temtheta];
    else
        testpoint = [testpoint ; pi + temtheta ; 2*pi + temtheta];
    end
end
testvalue = zeros(size(testpoint));
for k = 1 : length(testpoint)
    testvalue(k) = norm(X-exp(i*testpoint(k))*Xk,'fro');
end
[minerror , minerrorindex] = min(testvalue);
theta                     = testpoint(minerrorindex);