# FindInstance and cosine system of equations

I'm intrigued by Mathematica indisposition to find an example of the following system of equations

$$\cos(x) + \cos(y) + \cos(z) = \lambda_1,$$ $$\cos(x+u) + \cos(y+v) + \cos(z+w) = \lambda_2,$$ $$\cos(u) + \cos(v) + \cos(w) = \lambda_3,$$

for a given set of $$\vec{\lambda}$$.

For example, if I start with a given set of $$x$$, $$y$$, $$z$$, $$u$$, $$v$$, and $$w$$,

cond = Thread[{x, y, z, u, v, w} -> (# &@RandomReal[{-π, π}, 6])]


then

result = {Cos[x] + Cos[y] + Cos[z], Cos[x + u] + Cos[y + v] + Cos[w + z],
Cos[u] + Cos[v] + Cos[w]} /. cond


the following code never terminates,

FindInstance[Thread[{Cos[x] + Cos[y] + Cos[z],
Cos[x + u] + Cos[y + v] + Cos[w + z],
Cos[u] + Cos[v] + Cos[w]} == result], {x, y, z, u, v, w}]


Is there any way to obtain an instance of such system? I've tried using Interval and Reals to constrain my variables without success.

One way to get answers for such a system is to rewrite it as a minimization problem. Define your equations (using your test case "result"):

eqn = Thread[{Cos[x] + Cos[y] + Cos[z],
Cos[x + u] + Cos[y + v] + Cos[w + z], Cos[u] + Cos[v] + Cos[w]} - result]


Then minimize:

NMinimize[Norm[eqn], {u, v, w, x, y, z}]


This gives you a set of values {u, v, w, x, y, z} which solve the equations. I might guess that FindInstance has problems because you are using floating point numbers and so attaining actual equality is unlikely. NMinimize returns an answer that is accurate to 10^-10 or so, which is about what you might expect from floating point calculations.