I have certain systems of equations for which I need ANY solution if one exists. Can I get MMa to just do that?
This doesn't work:
nParticles = 4;
nPow = 2;
m = {0, 1, 0, 1};
soln = Table[Sum[a[i]^n, {i, 1, nParticles}]/nParticles == m[[n]], {n, 1, nPow}];
start = Table[{a[i], RandomReal[1] - .5}, {i, 1, nParticles}];
aa = FindRoot[soln, start]
...because it's underdetermined. It works perfectly if nParticles==nPow.
There's a similar question here: Any solution to system of equations? but the Answer-er gave an elegant MATH solution instead of a MMa solution.
FindInstance[soln, {a[1], a[2], a[3], a[4]}]
. $\endgroup$FindRoot
type of approach, you can for a sum of squares and useFindMinimum
. If the min is zero, you have located a root. $\endgroup$