Message Boards Message Boards

0
|
13163 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

ReplaceAll and Reduce

I set this formula:

Reduce [Mod [31 x 90] == 4, {x}]

that function, result:

x = 154 = 64 mod90

If I wanted to apply the formula by replacing the result "4" with a list of values "M"

Reduce [Mod [31 x 90] == M, {x}]
ReplaceAll {M -> {}} 4,35,66,59,0,31,24,55,86 

what is the correct syntax?

POSTED BY: Mutatis Mutandis
3 Replies

Hi,

some comments:

1) the function you give

Reduce [Mod [31 x 90] == 4, {x}] 

does not seem to work in my version of Mathematica (10.0.2 on OSX 10.10.2). I can make it work if I slightly modify it:

Reduce[Mod[31 x , 90] == 4, {x}, Integers] 

which gives

C[1] \[Element] Integers && x == 64 + 90 C[1]

as expected.

2) If I replace the 4 by M without specifying a list

Reduce[Mod[31 x , 90] == M, {x}, Integers]

I get a comprehensive list of results:

C[1] \[Element] 
  Integers && ((M == 0 && x == 90 C[1]) || (M == 1 && 
     x == 61 + 90 C[1]) || (M == 2 && x == 32 + 90 C[1]) || (M == 3 &&
      x == 3 + 90 C[1]) || (M == 4 && x == 64 + 90 C[1]) || (M == 5 &&
      x == 35 + 90 C[1]) || (M == 6 && x == 6 + 90 C[1]) || (M == 7 &&
      x == 67 + 90 C[1]) || (M == 8 && x == 38 + 90 C[1]) || (M == 9 &&
      x == 9 + 90 C[1]) || (M == 10 && 
     x == 70 + 90 C[1]) || (M == 11 && 
     x == 41 + 90 C[1]) || (M == 12 && 
     x == 12 + 90 C[1]) || (M == 13 && 
     x == 73 + 90 C[1]) || (M == 14 && 
     x == 44 + 90 C[1]) || (M == 15 && 
     x == 15 + 90 C[1]) || (M == 16 && 
     x == 76 + 90 C[1]) || (M == 17 && 
     x == 47 + 90 C[1]) || (M == 18 && 
     x == 18 + 90 C[1]) || (M == 19 && 
     x == 79 + 90 C[1]) || (M == 20 && 
     x == 50 + 90 C[1]) || (M == 21 && 
     x == 21 + 90 C[1]) || (M == 22 && 
     x == 82 + 90 C[1]) || (M == 23 && 
     x == 53 + 90 C[1]) || (M == 24 && 
     x == 24 + 90 C[1]) || (M == 25 && 
     x == 85 + 90 C[1]) || (M == 26 && 
     x == 56 + 90 C[1]) || (M == 27 && 
     x == 27 + 90 C[1]) || (M == 28 && 
     x == 88 + 90 C[1]) || (M == 29 && 
     x == 59 + 90 C[1]) || (M == 30 && 
     x == 30 + 90 C[1]) || (M == 31 && x == 1 + 90 C[1]) || (M == 32 &&
      x == 62 + 90 C[1]) || (M == 33 && 
     x == 33 + 90 C[1]) || (M == 34 && x == 4 + 90 C[1]) || (M == 35 &&
      x == 65 + 90 C[1]) || (M == 36 && 
     x == 36 + 90 C[1]) || (M == 37 && x == 7 + 90 C[1]) || (M == 38 &&
      x == 68 + 90 C[1]) || (M == 39 && 
     x == 39 + 90 C[1]) || (M == 40 && 
     x == 10 + 90 C[1]) || (M == 41 && 
     x == 71 + 90 C[1]) || (M == 42 && 
     x == 42 + 90 C[1]) || (M == 43 && 
     x == 13 + 90 C[1]) || (M == 44 && 
     x == 74 + 90 C[1]) || (M == 45 && 
     x == 45 + 90 C[1]) || (M == 46 && 
     x == 16 + 90 C[1]) || (M == 47 && 
     x == 77 + 90 C[1]) || (M == 48 && 
     x == 48 + 90 C[1]) || (M == 49 && 
     x == 19 + 90 C[1]) || (M == 50 && 
     x == 80 + 90 C[1]) || (M == 51 && 
     x == 51 + 90 C[1]) || (M == 52 && 
     x == 22 + 90 C[1]) || (M == 53 && 
     x == 83 + 90 C[1]) || (M == 54 && 
     x == 54 + 90 C[1]) || (M == 55 && 
     x == 25 + 90 C[1]) || (M == 56 && 
     x == 86 + 90 C[1]) || (M == 57 && 
     x == 57 + 90 C[1]) || (M == 58 && 
     x == 28 + 90 C[1]) || (M == 59 && 
     x == 89 + 90 C[1]) || (M == 60 && 
     x == 60 + 90 C[1]) || (M == 61 && 
     x == 31 + 90 C[1]) || (M == 62 && x == 2 + 90 C[1]) || (M == 63 &&
      x == 63 + 90 C[1]) || (M == 64 && 
     x == 34 + 90 C[1]) || (M == 65 && x == 5 + 90 C[1]) || (M == 66 &&
      x == 66 + 90 C[1]) || (M == 67 && 
     x == 37 + 90 C[1]) || (M == 68 && x == 8 + 90 C[1]) || (M == 69 &&
      x == 69 + 90 C[1]) || (M == 70 && 
     x == 40 + 90 C[1]) || (M == 71 && 
     x == 11 + 90 C[1]) || (M == 72 && 
     x == 72 + 90 C[1]) || (M == 73 && 
     x == 43 + 90 C[1]) || (M == 74 && 
     x == 14 + 90 C[1]) || (M == 75 && 
     x == 75 + 90 C[1]) || (M == 76 && 
     x == 46 + 90 C[1]) || (M == 77 && 
     x == 17 + 90 C[1]) || (M == 78 && 
     x == 78 + 90 C[1]) || (M == 79 && 
     x == 49 + 90 C[1]) || (M == 80 && 
     x == 20 + 90 C[1]) || (M == 81 && 
     x == 81 + 90 C[1]) || (M == 82 && 
     x == 52 + 90 C[1]) || (M == 83 && 
     x == 23 + 90 C[1]) || (M == 84 && 
     x == 84 + 90 C[1]) || (M == 85 && 
     x == 55 + 90 C[1]) || (M == 86 && 
     x == 26 + 90 C[1]) || (M == 87 && 
     x == 87 + 90 C[1]) || (M == 88 && 
     x == 58 + 90 C[1]) || (M == 89 && x == 29 + 90 C[1]))

Sorry for the awkward typesetting.

3) If I want substitute M by the values of your list I think that this syntax will do:

Reduce[Mod[31 x , 90] == #, {x}, Integers] & /@ {4, 35, 66, 59, 0, 31,24, 55, 86}

It gives

{C[1] \[Element] Integers && x == 64 + 90 C[1], 
 C[1] \[Element] Integers && x == 65 + 90 C[1], 
 C[1] \[Element] Integers && x == 66 + 90 C[1], 
 C[1] \[Element] Integers && x == 89 + 90 C[1], 
 C[1] \[Element] Integers && x == 90 C[1], 
 C[1] \[Element] Integers && x == 1 + 90 C[1], 
 C[1] \[Element] Integers && x == 24 + 90 C[1], 
 C[1] \[Element] Integers && x == 25 + 90 C[1], 
 C[1] \[Element] Integers && x == 26 + 90 C[1]}

Cheers,

M.

POSTED BY: Marco Thiel

thanks very much, I was despairing that someone help me!

POSTED BY: Mutatis Mutandis

TableForm[Reduce[Mod[N x , 90] == M, {x}, Integers]]

would instead can Map M with this list: {4, 35, 66, 59, 0, 31,24, 55, 86}, and N with this one: {7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43} and solve MOD for all possible pairs {M, N}?

tnk

POSTED BY: Mutatis Mutandis
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