6
$\begingroup$

I want to solve this system of two equations for $x$ $$\{ \sin (2\pi x)+\sin (\frac{2\pi}y)=0 \quad , \quad \cos (2\pi x)-\cos (\frac{2\pi}y)=0 \} \qquad (1)$$

I use Solve:

Solve[  {  Sin[ 2 π  x] + Sin[(2 π )/y ] == 0, Cos[ 2 π  x] - Cos[(2 π )/y ] == 0  }, x ] // Simplify

(*{{x -> ConditionalExpression[ArcTan[Cos[(2 π )/y], -Sin[(2 π )/y]]/(2 π ) + C[1], C[1] \[Element] Integers]}}*)

The result is in the form of a conditional expression:

$$x=\frac{1}{2\pi}\text{ArcTan}[\cos (\frac{2\pi}y),-\sin (\frac{2\pi}y)]+c_1, \qquad c_1\in\mathbb{Z}$$

Substituting $x=\dfrac{1}{2\pi}\arctan\left(\frac{-\sin (\frac{2\pi}y)}{\cos (\frac{2\pi}y)}\right)+m$ into $(1)$, I get

Sin[ 2 π  x] + Sin[(2 π )/y] /. x -> ((ArcTan[-(Sin[(2 π )/y]/Cos[(2 π )/y])]/(2 π )) + m) // FullSimplify[#,  Assumptions ->  y > 0 && y \[Element] Reals && m \[Element] Integers] &
Cos[ 2 π  x] - Cos[(2 π )/y] /. x -> ((ArcTan[-(Sin[(2 π )/y]/Cos[(2 π )/y])]/(2 π )) +  m) // FullSimplify[#,  Assumptions ->  y > 0 && y \[Element] Reals && m \[Element] Integers] &

(* (-1 + Sign[Sec[(2 π )/y]]) Sin[(2 π )/y]*)
(* (-1 + Sign[Sec[(2 π )/y]]) Cos[(2 π )/y] *)

which means that the equations vanish simultaneously if $\text{sgn} (\frac{2\pi}y)=+1$, i.e., only for those $y$ for which $\text{sgn} (\frac{2\pi}y)=+1$, we can simplify $x=\dfrac{1}{2\pi}\arctan\left(\frac{-\sin (\frac{2\pi}y)}{\cos (\frac{2\pi}y)}\right)+m$ as $x=m-\frac1y$

On the other hand, it is evident that both equations $(1)$ vanish at $x=m-\frac1y$ for all values of $y$ (while some of them may not satisfy $\text{sgn} (\frac{2\pi}y)=+1$).

 Sin[ 2 π x] + Sin[(2 π)/y] /. x -> m - 1/y //  FullSimplify[#, Assumptions ->  y > 0 && y \[Element] Reals && m \[Element] Integers] &

Cos[ 2 π x] - Cos[(2 π)/y] /. x -> m - 1/y // FullSimplify[#,  Assumptions ->  y > 0 && y \[Element] Reals && m \[Element] Integers] &

(*0*)
(*0*)
$\endgroup$
9
  • $\begingroup$ ArcTan[x, y] is the same as $\arctan(y/x)$. I think you have it switched when you plugged the thing back in. $\endgroup$
    – march
    Sep 24, 2021 at 22:20
  • $\begingroup$ Indeed, when I just copy and past the result out of the ConditionalExpression, changing C[1] to m in your second code block, I get zero. $\endgroup$
    – march
    Sep 24, 2021 at 22:21
  • $\begingroup$ @march I have used the same expression as you mentioned $\arctan(y/x)$. $\endgroup$
    – sara96
    Sep 24, 2021 at 22:22
  • $\begingroup$ Note that if you run Simplify[expr, y > 2 \[Pi]] on the conditional expression, it gives you m - 1/y. $\endgroup$
    – march
    Sep 24, 2021 at 22:23
  • $\begingroup$ @march Yes, for $y>4$, the conditional solution is the same as $x=m-\frac1y$. But my question is that while both equations vanish for $x=m-\frac1y$ for all values of $y$, the conditional solution of Mathematica only works for $y>4$? Which one should I trust? $\endgroup$
    – sara96
    Sep 24, 2021 at 22:25

2 Answers 2

14
$\begingroup$

I think your assumption is that $y\in \mathbb{R}$ is real, so you can put it as the condition (otherwise it is assumed to be complex):

SolveValues[
Sin[2π x]+Sin[2π/y]==0&&
Cos[2π x]-Cos[2π/y]==0&&
y∈Reals
,x]//FullSimplify

So after FullSimplify you get 2 answers that you are looking for:

$\begin{array}{l} \fbox{$-\frac{1}{y}+2 c_1\text{ if }y\in \mathbb{R}\land c_1\in \mathbb{Z}$} \\ \fbox{$-\frac{1}{y}+1+2 c_1\text{ if }y\in \mathbb{R}\land c_1\in \mathbb{Z}$} \\ \end{array}$

If you are looking for a similar compact answer in the complex domain then this should do:

SolveValues[
Sin[2π x]+Sin[2π/y]==0&&
Cos[2π x]-Cos[2π/y]==0
,x]//FullSimplify

$\fbox{$c_1-\frac{i \log \left(e^{-\frac{2 i \pi }{y}}\right)}{2 \pi }\text{ if }c_1\in \mathbb{Z}$}$

$\endgroup$
9
$\begingroup$

The reason that the second code snippet in the OP doesn't evaluate to zero is because ArcTan[x, y] is not the same as ArcTan[y/x] for every choice of x and y. This is explained in the documentation for ArcTan: it matters which quadrant the points $(x,y)$ is in. To see this, notice:

Plot[{
   ArcTan[Cos[(2 π)/y], -Sin[(2 π)/y]]/(2 π),
   ArcTan[-Sin[(2 π)/y]/Cos[(2 π)/y]]/(2 π)},
 {y, 1, 6}, 
 PlotRange -> {{0, 6}, All}, PlotPoints -> 100]

results in

enter image description here

Indeed, if we plug the solution that Solve actually spits out, we get zero:

FullSimplify[
  Sin[2 π x] + Sin[(2 π)/y] /. x -> ArcTan[Cos[(2 π)/y], -Sin[(2 π)/y]]/(2 π) + m,
  m ∈ Integers]
(* 0 *)

The second issue in the OP is that Mathematica doesn't simplify to the simple solution m - 1/y, which is a solution (with caveats), which we can see from

Simplify[ArcTan[Cos[(2 π)/y], -Sin[(2 π)/y]]/(2 π) + m, {y > 4}]

However, the issue is that the function actually has an infinite number discontinuities as we approach $y=0$. On each continuous piece of the function, it is equal to m - 1/y for some integer m, but it seems like Mathematica is unable to come up with a general expression for the location of the discontinuities, and hence it doesn't simplify the expression to m - 1/y until it's sure that there will be no discontinuities.

To see this, consider the plot:

Plot[ArcTan[Cos[(2 π)/y], -Sin[(2 π)/y]]/(2 π), {y, 0.2, 6}, PlotRange -> {{0, 6}, All}, PlotPoints -> 300]

enter image description here

Now, interestingly enough, we can paste the solutions that Mathematica spits out together (i.e., the set of solutions for every m), and it turns out that it maps out the set of curves m - 1/y!

GraphicsRow[{
  Plot[Table[ArcTan[Cos[(2 π)/y], -Sin[(2 π)/y]]/(2 π) + m, {m, -5, 5}] // Evaluate, {y, 0.2, 6}, PlotRange -> {{0, 6}, {-6, 6}}],
  Plot[Table[m - 1/y, {m, -5, 5}] // Evaluate, {y, 0.2, 6}, PlotRange -> {{0, 6}, {-6, 6}}]
  }]

enter image description here

I suspect that because Mathematica tries to find general solutions first, it writes things in terms of ArcTan[x, y], and once it's there, it gets stuck, because it needs to care about an infinite number of discontinuities, and it's hard for a computer algebra system to dealt with and recognize that m - 1/y is a general solution to the problem.


Finally, note that Mathematica does at least know that this family of curves solves the original set of equations:

Sin[2 π x] + Sin[(2 π)/y] /. x -> m - 1/y /. Sin[a_] :> Sin@Expand@a // TrigExpand // Simplify
Cos[2 π x] - Cos[(2 π)/y] /. x -> m - 1/y /. Cos[a_] :> Cos@Expand@a // TrigExpand // Simplify
(* 2 Cos[π (m - 2/y)] Sin[m π] *)
(* -2 Sin[m π] Sin[π (m - 2/y)] *)

From which we can see that both of these are clearly zero when m is an integer.

$\endgroup$
2
  • $\begingroup$ Thank you for the answer. $\endgroup$
    – sara96
    Sep 24, 2021 at 22:57
  • 1
    $\begingroup$ @sara96. Yeah, sorry for the mix-up! The problem was more interesting than I expected on a first viewing. $\endgroup$
    – march
    Sep 24, 2021 at 22:59

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.