Message Boards Message Boards

Filtering in solutions that are found using PowersRepresentations

Posted 4 years ago

Well, I have the following code: PowersRepresentations[1000, 5, 2] and this code gives me 145 solutions. But I want to filter the solutions, in the problem that I am working on the solution involving a 0 or a solution with two or more of the same numbers is not what I am looking for.

Question: How can I filter in the solutions found by the code PowersRepresentations[1000, 5, 2] that only gives unique* solutions not involving a zero?


*: This means that when a given solution looks like: {{a1,a2,a3,a4,a5},{b1,b2,b3,b4,b5},...} I am looking for the ones where:

  1. $$a_1\ne a_2\ne a_3\ne a_4\ne a_5\tag1$$ For all $a_n$ and $b_n$ etc., so $a_n\ne a_{n+1}$ and $b_n\ne b_{n+1}$ etc.
  2. $$\forall a_n>0\space\wedge\space\forall b_n>0...\text{etc}.\tag2$$
POSTED BY: Jan Eerland

Hi Jan, here is one solution (out of many):

preps0 = PowersRepresentations[1000, 5, 2]

(* solutions without `0`: *)
preps1 = Select[preps0, Times @@ # != 0 &]

(* solutions without same integers: *)
Select[preps1, Length[#] == Length[Union[#]] &]
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract