function F = steadystate4(x)
global U1;global U2;global U3;global U4;global U5;

%global U;global t;global P; global W;
% U1 = U(t,1); U2 = U(t,2); U3=U(t,3); U4=U(t,4); U5=U(t,5); % adjusted 94-2011

d=x(5);
n =48;
wl = x(1);
wh = x(2);
pl(1,1) = exp(-exp(x(3)));
ph(1,1) = exp(-exp(x(4)));

for i=2:n
pl(i,1) = exp(-exp(x(3)+(i-1)*d));
ph(i,1) = exp(-exp(x(4)+(i-1)*d));
end

uhat(1,1) = wl+wh;

for j=2:n
uhat(j,1) = wl*prod(pl(1:j-1,1),1)+wh*prod(ph(1:j-1,1),1);
end

uhat1 = uhat(1,1);
uhat23 = sum(uhat(2:3,1),1);
uhat46 = sum(uhat(4:6,1),1);
uhat712 = sum(uhat(7:12,1),1);
uhat13 = sum(uhat(13:n,1),1);

X = [uhat1-U1;
     uhat23-U2;
     uhat46-U3;
     uhat712-U4;
     uhat13-U5];

F = sqrt(X'*X);
F = F*1.e4;
