Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I only want to get all the solutions of this system of the solutions with a value of $k$, we have the same values ​​of $m$

A = {1, 2, 3};
B = {2, 1, 0};
M = {a, b, c};
Solve[{a - b + c + m == 0, 
  SquaredEuclideanDistance[B, M] == k, (A - M). (B - M) == 0, 
  k > 0}, {a, b, c, m, k}, Integers]

In this ystem of the solutions, for example, $k = 6$, $m=1$ and $m = 3$.

A = {1, 2, 3};
B = {2, 1, 0};
M = {a, b, c};
Solve[{a - b + c + m == 0, 
  SquaredEuclideanDistance[B, M] == 6, (A - M). (B - M) == 0}, {a, b, 
  c, m}, Integers]

I do not how to start. How do I tell Mathematica to do that?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Perhaps

  {#, GatherBy[Solve[{a - b + c + m == 0, 
  SquaredEuclideanDistance[B, M] == #, (A - M).(B - M) == 0}, 
  {a, b, c, m}, Integers], Last]} & /@ Range[10];
  Grid[%]

enter image description here

or

 Table[{k, GatherBy[
   Solve[{a - b + c + m == 0,
   SquaredEuclideanDistance[B, M] == k,
   (A - M).(B - M) == 0},
   {a, b, c, m}, Integers], 
  Last]},
  {k, Range[10]}];
 Grid[%]

or, (the solutions grouped by the values of k and m?):

GatherBy[
Solve[{a - b + c + m == 0,
SquaredEuclideanDistance[B, M] == k,
(A - M).(B - M) == 0},
{a, b, c, k, m}, Integers], 
#[[-2 ;;]] &]
share|improve this answer

By the linguistically esoteric phrase,

"...with a value of k, we have the same values ​​of m"

I guess you mean that you want to collect/filter the set of solutions given by Solve for cases where values of both $k$ and $m$ are constant! If this is indeed the case then try the following where res is the list of $23$ solution returned by your Solve.

collected=
Sort[
 Select[
   GatherBy[res, (#[[4]] && #[[5]]) &],
   Length@# >= 2 &
   ],
 #1[[1, 5, 2]] < #2[[1, 5, 2]] &
]

This gives us $10$ pairs of solutions where for a fixed value of $k$ we have same value of $m$. The Sort is used just to order the pairs according to the value of $k$. Following are the $3$ outliers that do not follow above pattern are

Complement[res, collected]

{{a -> 1, b -> 2, c -> 0, m -> 1, k -> 2},

{a -> 1, b -> 2, c -> 3, m -> -2, k -> 11},

{a -> 2, b -> 1, c -> 3, m -> -4, k -> 9}}

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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