0
$\begingroup$

Please help in executing the following problem in Mathematica:

I have the following set:$A=\{1, 2,3,4,5,6,7,8,9,10\}$ (my actual data has more than 10 points). I need to do the following three steps:

(A) Form all possible pairs of two digits in the above set, like $(1,2), (4,6)$ etc. Remember $(1,2)$ and $(2,1)$ are to be treated as different pairs. Since my actual data is big, I want Mathematica to find all these possible pairs.

(B) Then I have to put these pairs in the following expression: $\eta(x_1,x_2)= x_1+5x_2+10$ and compute the value of $\eta(x_1,x_2)$, for the pair $(x_1,x_2)$.

(C) Similarly, I have to this for all pairs and arrange the values of $\eta(x_1,x_2)$ is decreasing order.

$\endgroup$
5
  • $\begingroup$ Look at Tuples eg Tuples[Range@10, 2] and eta@@@Tuples[Range@10, 2] $\endgroup$ Jul 10, 2018 at 17:20
  • $\begingroup$ What is the size of data? $\endgroup$ Jul 10, 2018 at 17:21
  • $\begingroup$ My actual data contains around 100 points. $\endgroup$
    – H. Kenan
    Jul 10, 2018 at 17:28
  • $\begingroup$ If you don't want (1,1) then use Permutations[Range@10, {2}] $\endgroup$ Jul 10, 2018 at 17:28
  • $\begingroup$ Thank you, friends. I would appreciate if you put a slightly detailed answer. $\endgroup$
    – H. Kenan
    Jul 10, 2018 at 17:30

1 Answer 1

3
$\begingroup$
f[x1_, x2_] := x1 + 5 x2 + 10
SeedRandom@2;
data = RandomReal[10, 100];
pair = Permutations[data, {2}];
values=Sort[f @@@ pair];
ListPlot[values]
$\endgroup$
2
  • $\begingroup$ Never knew mathematica had permutation function. Neat answer! $\endgroup$ Jul 10, 2018 at 18:42
  • 2
    $\begingroup$ Thanks. It says "Introduced in 1988 (1.0) | Updated in 2007 (6.0)" $\endgroup$ Jul 10, 2018 at 22:42

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.