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.

  • 1
    $\begingroup$ 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]]? $\endgroup$ – AccidentalFourierTransform Aug 22 '19 at 18:48
  • 2
    $\begingroup$ 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. $\endgroup$ – Roman Aug 22 '19 at 19:21
  • 2
    $\begingroup$ @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]] $\endgroup$ – yarchik Aug 22 '19 at 21:22
  • 1
    $\begingroup$ 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. $\endgroup$ – yarchik Aug 22 '19 at 21:26
  • $\begingroup$ 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? $\endgroup$ – 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

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


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.