2
$\begingroup$

I have the following code to solve the algebraic equations, but some solutions such as the first one and the second one means the same when we draw them on a circle. Thus I want to apply Mod(,2Pi) functions to all solutions in order to obtain unique solutions. Could anyone help? Thanks in advance.

Solve[Sin[d12] + Sin[d13] == 0 && -Sin[d12] + Sin[d23] == 0 &&  Sin[d13] + Sin[d23] == 0 && Mod[d12 + d23 - d13, 2*Pi] == 0 && 0 <= d12 <= 2*Pi && 0 <= d23 <= 2*Pi && 0 <= d13 <= 2*Pi, {d12, d13,d23}]
{{d12 -> 0, d13 -> 0, d23 -> 0}, {d12 -> 0, d13 -> 0, 
  d23 -> 2 \[Pi]}, {d12 -> 0, d13 -> \[Pi], d23 -> \[Pi]}, {d12 -> 0, 
  d13 -> 2 \[Pi], d23 -> 0}, {d12 -> 0, d13 -> 2 \[Pi], 
  d23 -> 2 \[Pi]}, {d12 -> (2 \[Pi])/3, d13 -> (4 \[Pi])/3, 
  d23 -> (2 \[Pi])/3}, {d12 -> \[Pi], d13 -> 0, 
  d23 -> \[Pi]}, {d12 -> \[Pi], d13 -> \[Pi], 
  d23 -> 0}, {d12 -> \[Pi], d13 -> \[Pi], 
  d23 -> 2 \[Pi]}, {d12 -> \[Pi], d13 -> 2 \[Pi], 
  d23 -> \[Pi]}, {d12 -> (4 \[Pi])/3, d13 -> (2 \[Pi])/3, 
  d23 -> (4 \[Pi])/3}, {d12 -> 2 \[Pi], d13 -> 0, 
  d23 -> 0}, {d12 -> 2 \[Pi], d13 -> 0, 
  d23 -> 2 \[Pi]}, {d12 -> 2 \[Pi], d13 -> \[Pi], 
  d23 -> \[Pi]}, {d12 -> 2 \[Pi], d13 -> 2 \[Pi], 
  d23 -> 0}, {d12 -> 2 \[Pi], d13 -> 2 \[Pi], d23 -> 2 \[Pi]}}
$\endgroup$
1
  • $\begingroup$ What is the purpose of the constraint ` Mod[d12 + d23 - d13, 2*Pi] == 0` ? $\endgroup$ Feb 6, 2022 at 10:39

3 Answers 3

2
$\begingroup$

Define the list of replacement rules as

sltn = Solve[
  Sin[d12] + Sin[d13] == 0 && -Sin[d12] + Sin[d23] == 0 && 
   Sin[d13] + Sin[d23] == 0 && Mod[d12 + d23 - d13, 2*Pi] == 0 && 
   0 <= d12 <= 2*Pi && 0 <= d23 <= 2*Pi && 0 <= d13 <= 2*Pi, {d12, 
   d13, d23}]

Check the dimensions of the list

sltn // Dimensions

Replace the abstract d12, d13 and d23 by their solutions and mod them like so:

Table[Mod[{d12, d13, d23} /. sltn[[i]], 2 Pi], {i, 1, 16}]

the outcome of which is

{{0, 0, 0}, {0, 0, 0}, {0, π, π}, {0, 0, 0}, {0, 0, 0}, {(
  2 π)/3, (4 π)/3, (2 π)/3}, {π, 
  0, π}, {π, π, 0}, {π, π, 0}, {π, 
  0, π}, {(4 π)/3, (2 π)/3, (4 π)/3}, {0, 0, 0}, {0, 
  0, 0}, {0, π, π}, {0, 0, 0}, {0, 0, 0}}
$\endgroup$
2
  • 3
    $\begingroup$ Mod is Listable. Use Mod[{d12, d13, d23} /. sltn, 2 Pi] $\endgroup$
    – Bob Hanlon
    Feb 5, 2022 at 23:55
  • $\begingroup$ thanks for the comment! $\endgroup$
    – user49048
    Feb 6, 2022 at 0:26
2
$\begingroup$

If I remove the restrictions from the system to be solved except the one that d12 - d13 + d23 is a multiple of 2 Pi, I get a set of mod-$2\pi$ families of solutions, with each family having a unique base point on the unit circle. I can replace the parameters C[k] with 0 to get just the desired base points:

sol = Solve[
    Sin[d12] + Sin[d13] == 0 && -Sin[d12] + Sin[d23] == 0 && 
     Sin[d13] + Sin[d23] == 0 &&
     Cos[d12 - d13 + d23] == 1, (* replace restrictions with Mod below *)
    {d12, d13, d23}
    ] /. _C -> 0
(*
{{d12 -> 0,       d13 -> 0,       d23 -> 0},
 {d12 -> 0,       d13 -> π,       d23 -> π},
 {d12 -> (4 π)/3, d13 -> (2 π)/3, d23 -> (4 π)/3},
 {d12 -> (2 π)/3, d13 -> (4 π)/3, d23 -> (2 π)/3},
 {d12 -> π,       d13 -> 0,       d23 -> π},
 {d12 -> π,       d13 -> π,       d23 -> 0}}
*)

Or I can replace ConditionalExpression[s, cond] with Simplify[Mod[s, 2 Pi], cond] to reduce the solution to just the base points:

sol = Solve[
    Sin[d12] + Sin[d13] == 0 && -Sin[d12] + Sin[d23] == 0 && 
     Sin[d13] + Sin[d23] == 0 &&
     Cos[d12 - d13 + d23] == 1, (* replace restrictions with Mod below *)
    {d12, d13, d23}
    ] /.
   ConditionalExpression -> (Simplify[Mod[#, 2 Pi], #2] &) //
  DeleteDuplicates
(* same output as above *)

The first method is simpler, but it assumes the base points are from 0 up to 2 Pi. The second actually applies Mod[-, 2 Pi] as requested.

$\endgroup$
2
$\begingroup$

You can use DeleteDuplicatesBy with an appropriate discriminator function that applies Mod[#, 2 Pi] to the right-hand side in each Rule (i.e. the value):

sol = 
 Solve[
   Sin[d12] + Sin[d13] == 0 && -Sin[d12] + Sin[d23] == 0 && 
    Sin[d13] + Sin[d23] == 0 && Mod[d12 + d23 - d13, 2*Pi] == 0 && 
     0 <= d12 <= 2*Pi && 0 <= d23 <= 2*Pi && 0 <= d13 <= 2*Pi,
   {d12, d13, d23}
 ];

DeleteDuplicatesBy[
  sol,
  Mod[#[[2]], 2 Pi] &
]

(* Out:
{{d12 -> 0, d13 -> 0, d23 -> 0},
 {d12 -> 0, d13 -> π, d23 -> π},
 {d12 -> 0, d13 -> 2 π, d23 -> 0},
 {d12 -> (2 π)/3, d13 -> (4 π)/3, d23 -> (2 π)/3},
 {d12 -> (4 π)/3, d13 -> (2 π)/3, d23 -> (4 π)/3}}
*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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