I am looking for roots of the function eqs defined below. It has $2k$ unknowns and returns a vector of $2k-1$ components.
The sole purpose of the following block is to define eqs, no need to try and understand it:
phi[p_, T_, t_] := -1/Sqrt[m[[p]]]*Sum[Cos[omegas[[j]]*t/2]/(omegas[[j]]*Sin[omegas[[j]]*T/2]) q[[p, j]]*q[[n,j]], {j, 1, n}];
psi[p_, sigma_, t_] := 1/Sqrt[m[[p]]]* Sum[Sin[omegas[[j]]*t/2]/(Sin[omegas[[j]]*sigma/2]) q[[p, j]]* q[[n,j]], {j, 1, n}];
n=2;
m={.5,.5};
q={{-0.8506508083520401`,-0.5257311121191336`},{0.5257311121191336`,-0.8506508083520401`}};
omegas={3.23606797749979`,1.2360679774997898`};
aMat[sList_]:=Block[{tmp,T=Total[sList],k=Length[sList]},
tmp=Table[0,{i,1,k},{j,1,k}];
Table[tmp[[i,j]]=Sqrt[m[[n]]]*psi[n,T,2(Total[sList[[1;;j]]]-Total[sList[[1;;i]] ])-T],{i, 1, k}, {j, i+1,k}];
Table[tmp[[j,i]]=-tmp[[i,j]],{i,1,k},{j,i,k}];tmp
];
bMat[sList_]:=Block[{tmp,T=Total[sList],k=Length[sList]},
tmp=Table[0,{i,1,k},{j,1,k}];
Table[tmp[[i,j]]=phi[n,T,2(Total[sList[[1;;j]]]-Total[sList[[1;;i]] ])-T],{i, 1, k}, {j, i,k}];
Table[tmp[[j,i]]=tmp[[i,j]],{i,1,k},{j,i,k}];tmp
];
eqs[vars_]:=Block[{k=Length[vars]/2},(aMat[vars[[1;;k]]].vars[[k+1;;2k]])[[1;;-2]]~Join~(bMat[vars[[1;;k]]].vars[[k+1;;2k]]-ConstantArray[1,k])]
I am looking for solutions with all positive values and FindRoot cannot deal with constraints. Of course one choice could be to use FindRoot until the $2k-1$ components of solution are positive, but I think this is not an optimal strategy.
As suggested in this SE question, I wrote the problem as a constrained optimisation problem:
subdomain = Fold[And, Table[0 < vars[[i]], {i, 2, 2 k}]];
res = FindMinimum[{Total[eqs[vars0]^2], subdomain},
Transpose[{vars[[2 ;; -1]], RandomReal[{1, 4}, 2 k - 1]}],
Method -> "InteriorPoint"]
I managed to get positive solutions for $k=6$ but it is not very robust and I would like to get solutions for larger $k$ (such as $15$, e.g.).
So my question is if someone see a way of improving my code or strategy in terms of robustness and efficiency.
A second optional question is to force the first $k$ values of the solution to be all different.
Note I have already asked a different question on the same set of equations here. Answers to the present question will probably make the previous one obsolete, so I'll delete it (or answer it if it is relevant).
eqs) and should not be understood in details. I'll edit my question to make it clear, and remove the part onFindRootto lighten it. – anderstood Nov 28 '15 at 17:49