n=1:8
x=1+2*cos(n*pi/4)
d=sin((n-1)*pi/4)
R=mean(x.*x)
P=mean(x.*d)
Wopt=R^(-1)*P