Electricity, Complex Systems, Numerical Analysis, Algorithms, Network.
Var<-function(N,Y,S,U_old,phi_old){ U=U_old*complex(real=cos(phi_old),imaginary=sin(phi_old)) Y_eq=t(N)%*%Y%*%N I_eq=Y_eq%*%U delta_S=c() for(i in 1:nrow(Y_eq)){ delta_S[i]=U[i]*Conj(I_eq[i])-S[i] } if(sum(delta_S^2)==0){ var=c(U_old,phi_old) } else{