# Find values of $k$, $l$, and $m$ such that the following equation is satisfied

I am trying to find the (numerical) subset of $$(k,l,m)\in[-\pi,\pi)\times[-\pi,\pi)\times[-\pi,\pi)$$ where the next expression is valid $$\tan \Bigl( \frac{k+l+m}{2} \Bigr) = \frac{ \sin k+ \sin l+\sin m }{ \cos k+ \cos l+\cos m }.$$ When I fix $$k$$ I am able, using ContourPlot, to obtain a set of curves revealing where the previous expression is satisfied. However, I'd like to get not a curve but the values of $$l$$ and $$m$$.

Note that using NSolve returns "This system cannot be solved with the methods available to Solve.". NMinimize only gives a point on the curve.

• findM[k_,l_] := FindRoot[Tan[(k + l + m)/2] - (Sin[k] + Sin[l] + Sin[m])/( Cos[k] + Cos[l] + Cos[m]) == 0, {m, 0, -π, π}][[1, 2]]? – AccidentalFourierTransform Aug 22 '19 at 18:48
• ContourPlot3D[Tan[(k+l+m)/2]-(Sin[k]+Sin[l]+Sin[m])/(Cos[k]+Cos[l]+Cos[m])==0, {k,-π,π}, {l,-π,π}, {m,-π,π}] gives a good overview of the solution branches. – Roman Aug 22 '19 at 19:21
• @Roman There is only 1 branch. The rest are artifacts due to diverging tan function. It is better to use ContourPlot3D[Tan[(k + l + m)/2] (Cos[k] + Cos[l] + Cos[m]) - (Sin[k] + Sin[l] + Sin[m]) == 0, {k, -π, π]}, {l, -π],π}, {m, -π, π]}, RegionFunction -> Function[{k, l, m}, Cos[k + l + m] > -0.98]] – yarchik Aug 22 '19 at 21:22
• You have 3 parameters and only 1 equation. Thus, the solution forms a 2-dimensional surface in 3d space. You cannot use Solve for that. In contrast ContourPlot3D nicely reveals this surface. A more meaningful and challenging question would be to find a 2d parametrization of this surface. – yarchik Aug 22 '19 at 21:26
• Please, feel free to wrap up these comments into an answer as they solved my question. @yarchik Yes, definitely that would be nice but I imagine that it would be pretty non-straightforward. I know that I did not ask this in my original question, but is possible to sample the surface? – David Aug 23 '19 at 3:17

Some mathematical simplifications are needed before plotting in order to deal with divergencies of $$\tan x$$ for $$x=\frac\pi2+n \pi$$, where $$n\in \mathbb{Z}$$. One can use that $$\tan\frac{x+y}{2}=\frac{\sin x+\sin y}{\cos x+\cos y}.$$

The rest is automatic

Clear[eq]
eq[0]=(Sin[k]+Sin[l+m])(Cos[k]+Cos[l]+Cos[m])-(Cos[k]+Cos[l+m])(Sin[k]+Sin[l]+Sin[m])
eq[1]=FullSimplify[eq[0]]
eq[2]=TrigFactor[eq[1]]
Out[1]= -(Cos[k]+Cos[l+m]) (Sin[k]+Sin[l]+Sin[m])+(Cos[k]+Cos[l]+Cos[m]) (Sin[k]+Sin[l+m])
Out[2]= Sin[k-l]+Sin[l]+Sin[k-m]-Sin[k-l-m]+Sin[m]
Out[3]= 2 Cos[k/2-l/2-m/2] (-Sin[k/2-l/2-m/2]+Sin[k/2+l/2-m/2]+Sin[k/2-l/2+m/2])


The first factor is describing planes $$k+l+m=\pi+2n\pi$$, where $$\tan\frac{k+l+m}{2}$$ is diverging. The second factor is a regular solution. Now we plot the two factors

ContourPlot3D[Evaluate[{eq[2][[2]]==0,eq[2][[3]]==0}],{k,-π,π},{l,-π,π},{m,-π,π},PlotTheme->{"Minimal"},ContourStyle->{Opacity[0.35],Automatic}]