isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0;
if isOctave
    pkg load optim
end;

fun = @(x)[ x(5) * 0.1 +  x(4) * 0.25 +  x(3) * 0.5 +  x(2) * 0.25 +  x(1) * 0.1 - 0.3;
x(6) * 0.1 +  x(5) * 0.25 +  x(4) * 0.5 +  x(3) * 0.25 +  x(2) * 0.1 - 0.62500001;
x(7) * 0.1 +  x(6) * 0.25 +  x(5) * 0.5 +  x(4) * 0.25 +  x(3) * 0.1 - 0.500000025;
x(8) * 0.1 +  x(7) * 0.25 +  x(6) * 0.5 +  x(5) * 0.25 +  x(4) * 0.1 - 0.22500005;
x(9) * 0.1 +  x(8) * 0.25 +  x(7) * 0.5 +  x(6) * 0.25 +  x(5) * 0.1 - 0.050000025;
x(10) * 0.1 +  x(9) * 0.25 +  x(8) * 0.5 +  x(7) * 0.25 +  x(6) * 0.1 - 1e-08];
options = optimset("Display", "iter","FinDiffType" ,"central","MaxIter", 20000, "MaxFunEvals", 40000, "TolFun", 1e-39, "TolX", 1e-39);
x0 = [0.5,0.5,0.5,0.5,0.5,5e-08,2e-08,1e-08,2e-08,5e-08];
lb = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0];
ub = [2.9999999999999996,1.2,0.6,1.2,0.50000025,1e-07,4e-08,2e-08,4e-08,1e-07];
[x,val] = lsqnonlin(fun, x0, lb, ub, options);
