Finding the value based on the value of the remainder

  • Thread starter Thread starter Vital
  • Start date Start date
  • Tags Tags
    Remainder Value
Click For Summary

Homework Help Overview

The discussion revolves around solving modular arithmetic equations, specifically the equation (y - z + i) mod m = x - z, where participants are exploring how to find the unknown variable y given certain known values. The context includes examples of specific values and the need for a general algorithm applicable to various scenarios.

Discussion Character

  • Exploratory, Conceptual clarification, Mathematical reasoning, Problem interpretation

Approaches and Questions Raised

  • Participants discuss the challenge of finding both y and k in the equation, with some suggesting that choosing a random value for k may allow for solving y. Others express confusion about reversing the operation when x is known and y is not. There is an exploration of how to express y in terms of k and the implications of multiple possible values for y based on different k values.

Discussion Status

The discussion is ongoing, with participants sharing their attempts to clarify the problem and explore potential solutions. Some guidance has been offered regarding the nature of the equations and the relationship between y and k, but no consensus has been reached on a definitive method or algorithm.

Contextual Notes

Participants note that certain values, such as z and m, are fixed, while others vary. There is a specific interest in finding an algorithm for decryption in a programming context, which adds complexity to the problem. The range for y is also mentioned as being between 97 and 122.

Vital
Messages
108
Reaction score
4

Homework Statement


Hello!
Please, help me to learn how to solve the following task - I really have no idea how to do that. What's important is that I need an algorithm that I can apply to the equation with different values.

Homework Equations


The initial equation:
(y - z + i) mod m = x - z

Meaning that the value of (x - z) is the value of the remainder after dividing (y - z + i) by m.
Let me show one example with numbers, so it will be clear what I am asking about.

The Attempt at a Solution


[/B]
(y - 97 + 20) mod 26 = 98 - 97

According to the definition: a mod b = c, and a=c+kb

Therefore in my example:

c = 98 - 97 (I am not computing this difference on purpose, because it is important for me to see all values involved)
a = (y - 97 + 20)
b = 26
k is unknown, but also y is unknown, so I have two unknowns here.
Proceeding further I get:

k×26+98−97=y−97+20

How can I find both k and y? Is there a general algorithm for such equations?
I will be very grateful for your help and explanation - I need to learn this.
Thank you very much!
 
Physics news on Phys.org
Vital said:
How can I find both k and y?

You can't.

If you want to solve
Vital said:
(y - 97 + 20) mod 26 = 98 - 97

for y then choose a random value for k in
Vital said:
k×26+98−97=y−97+20

and solve for y.
 
Buffu said:
You can't.

If you want to solvefor y then choose a random value for k inand solve for y.

Oh, this is so sad. You see I have an initial expression, in which y is known, but x is unknown; and then I need to do the reverse operation, in which x is now known and y is not.
Given my previous example:
First it was (116 – 97 + 8) mod 26 + 97 = x, so x = 98
But in the next round I know x, which is 98, but I don't know y, and I need to find it, and it has to become 116, so I need to find the way to get back to 116.
The second expression I need to solve: (y – 97 + 8) mod 26 + 97 = 98
I hope my explanation didn't sound too awfully cluttered. :)
 
Last edited:
Vital said:
I have an initial expression,
can you show me that ?
Vital said:
First it was (116 – 97 + 8) % 26 + 97 = x, so x = 98

Which operator is % ?
 
Buffu said:
can you show me that ?Which operator is % ?
I am sorry - I have edited my post to substitute % for mod. % comes from the programming language.
 
Vital said:
Oh, this is so sad. You see I have an initial expression, in which y is known, but x is unknown; and then I need to do the reverse operation, in which x is now known and y is not.
Given my previous example:
First it was (116 – 97 + 8) mod 26 + 97 = x, so x = 98
But in the next round I know x, which is 98, but I don't know y, and I need to find it, and it has to become 116, so I need to find the way to get back to 116.
The second expression I need to solve: (y – 97 + 8) mod 26 + 97 = 98
I hope my explanation didn't sound too awfully cluttered. :)
For this example, you have chosen y=116, and as a result, x is 98 .

You seem to be asking:
Can we recover the value of y from the following?
(y – 97 + 8) mod 26 + 97 = 98​

Of course that can be restated as, "We need to find y such that (y – 97 + 8) mod 26 =1 ."

What does this tell you about possible values for (y – 97 + 8), which is the same as (y – 89) ?
 
SammyS said:
For this example, you have chosen y=116, and as a result, x is 98 .

You seem to be asking:
Can we recover the value of y from the following?
(y – 97 + 8) mod 26 + 97 = 98​

Of course that can be restated as, "We need to find y such that (y – 97 + 8) mod 26 =1 ."

What does this tell you about possible values for (y – 97 + 8), which is the same as (y – 89) ?
Yes, this is exactly what I need to find. And I have no idea how to solve these equations. As I have posted in my original post there are two unknowns.
Once again: I can get as far as k x 26 + 1 = y - 97 + 8, which boils down to k x 26 + 90 = y
Two unknowns here.
So I am looking for the algorithm to solve this type of equations:
(y - z + i) mod m = x - z
y - z + i = k x m + (x - z)
where y is the value I am interested in and it is unknown, and k is unknown; all other values are given.
 
How much is 22 mod 3?
How much is 61 mod 3?
How much is 334 mod 3?

Do you begin to see the problem?
 
Vital said:
Yes, this is exactly what I need to find. And I have no idea how to solve these equations. As I have posted in my original post there are two unknowns.
Once again: I can get as far as k x 26 + 1 = y - 97 + 8, which boils down to k x 26 + 90 = y
Two unknowns here.
So I am looking for the algorithm to solve this type of equations:
(y - z + i) mod m = x - z
y - z + i = k x m + (x - z)
where y is the value I am interested in and it is unknown, and k is unknown; all other values are given.

Vital said:
Once again: I can get as far as k x 26 + 1 = y - 97 + 8, which boils down to k × 26 + 90 = y
Two unknowns here.
One more step to say
k × 26 = y – 90
In words, that is: y – 90 is some multiple of 26.

Therefore, there is no single value of y which will work. There are many values which solve this. Each results from a different value of k, and k must be an integer.

In the case of y = 116, this requires that k = 1.

If k = –3, we have y = 12.
 
  • #10
SammyS said:
One more step to say
k × 26 = y – 90
In words, that is: y – 90 is some multiple of 26.

Therefore, there is no single value of y which will work. There are many values which solve this. Each results from a different value of k, and k must be an integer.

In the case of y = 116, this requires that k = 1.

If k = –3, we have y = 12.
I am starting to see the problem. Do you think an algorithm can be found if I know that my values of y have to be strictly between [97, 122]?
 
  • #11
Vital said:
I am starting to see the problem. Do you think an algorithm can be found if I know that my values of y have to be strictly between [97, 122]?
Yes.
 
  • #12
SammyS said:
Yes.
Can you help me, please? I am very weak at math yet.
 
  • #13
Vital said:

Homework Equations


The initial equation:
(y − z + i) mod m = x − z
Assuming that the above is the general equation, which of those have some fixed value?
 
  • #14
SammyS said:
Assuming that the above is the general equation, which of those have some fixed value?
Only z, it is always 97; all other values change in each consecutive equation, but they are all known except for y (and k, which is a partial quotient, and it is not shown in the above equation).
 
  • #15
Vital said:
Only z, it is always 97; all other values change in each consecutive equation, but they are all known except for y (and k, which is a partial quotient, and it is not shown in the above equation).
OK.

You have been using m = 26 . Also, you wanted y to be in some specific range of values.
Vital said:
I am starting to see the problem. Do you think an algorithm can be found if I know that my values of y have to be strictly between [97, 122]?
It will be more efficient to lead you through some specific case, then try to get a more general approach.
 
  • #16
SammyS said:
OK.

You have been using m = 26 . Also, you wanted y to be in some specific range of values.

It will be more efficient to lead you through some specific case, then try to get a more general approach.

Sorry! Yes, 26 and 97 are fixed. All other values change.
I can write a few equations, which are part of a larger set; the set can be of any size, that is why I need to create a general algorithm - I am learning programming, and have written a tiny program, which encrypts letters in the text, and then it have to decrypt them; and the algorithm I need to compute is for this decryption stage.

Let's say I have 3 initial equations:

(1) (99 – 97 + 17) mod 26 + 97 = x; x = 116
(2) (104 – 97 + 20) mod 26 + 97 = x; x = 98
(3) (105 – 97 + 18) mod 26 + 97 = x; x = 97

The next step is to do the reverse, namely finding Y:
(1) (Y – 97 + 17) mod 26 + 97 = 116
(2) (Y – 97 + 20) mod 26 + 97 = 98
(3) (Y – 97 + 18) mod 26 + 97 = 97
 
  • #17
Vital said:
Sorry! Yes, 26 and 97 are fixed. All other values change.
I can write a few equations, which are part of a larger set; the set can be of any size, that is why I need to create a general algorithm - I am learning programming, and have written a tiny program, which encrypts letters in the text, and then it have to de-crypt them; and the algorithm I need to compute is for this decryption stage.
(y − 97 + i) mod 26 = x − 97

OK. That helps a lot.

You appear to be doing a very basic encryption in which each letter of the alphabet is assigned a value (code) from 0 through 25. It looks like the letter to be given the code 0 is determined by the variable, i. The rest follow in alphabetical order, with letter a getting the code equal to one more than the code for letter z.
Added in Edit:
Actually the 0 - 25 code is the quantity (x − 97), the right hand side. So the "code letter" represented by x is also an ASCII character, rather than being a number in the range 0 - 25..​

"Why the 97?", you may ask. 97 is the ASCII code for the (lower case) letter 'a'.

What is this "mod" function?

"n mod m" is the remainder that results from dividing n by m .

So,
what is the meaning of
(y − 97 + i) mod 26​
?
 
Last edited:
  • #18
Vital said:
Sorry! Yes, 26 and 97 are fixed. All other values change.
I can write a few equations, which are part of a larger set; the set can be of any size, that is why I need to create a general algorithm - I am learning programming, and have written a tiny program, which encrypts letters in the text, and then it have to decrypt them; and the algorithm I need to compute is for this decryption stage.

Let's say I have 3 initial equations:

(1) (99 – 97 + 17) mod 26 + 97 = x; x = 116
(2) (104 – 97 + 20) mod 26 + 97 = x; x = 98
(3) (105 – 97 + 18) mod 26 + 97 = x; x = 97

The next step is to do the reverse, namely finding Y:
(1) (Y – 97 + 17) mod 26 + 97 = 116
(2) (Y – 97 + 20) mod 26 + 97 = 98
(3) (Y – 97 + 18) mod 26 + 97 = 97
SammyS said:
(y − 97 + i) mod 26 = x − 97

OK. That helps a lot.

You appear to be doing a very basic encryption in which each letter of the alphabet is assigned a value (code) from 0 through 25. It looks like the letter to be given the code 0 is determined by the variable, i. The rest follow in alphabetical order, with letter a getting the code equal to one more than the code for letter z.
Added in Edit:
Actually the 0 - 25 code is the quantity (x − 97), the right hand side. So the "code letter" represented by x is also an ASCII character, rather than being a number in the range 0 - 25..​
No, it is much easier. I have written this equation because it allows me to wrap around the set of alphabetical characters - by taking the remainder of 26 I just make sure I don't get beyond these 26 letters. But I am fine with the code, I just need to figure out the reverse math. :-)

SammyS said:
"Why the 97?", you may ask. 97 is the ASCII code for the (lower case) letter 'a'.

What is this "mod" function?

"n mod m" is the remainder that results from dividing n by m .

So,
what is the meaning of
(y − 97 + i) mod 26​
?
Yes, of course, 97 is the ASCII code for 'a' - I won't wonder as I wrote that myself. :-)

As to your last question about the meaning: well, I have showed it above in previous messages, that (y − 97 + i) mod 26 gives the remainder, and of dividing (y − 97 + i) by 26, hence the expression is:
(y − 97 + i) / 26 = K x 26 + [(y − 97 + i) mod 26], where K is the partial quotient. How do I find y and K?
 
  • #19
Vital said:
k×26+98−97=y−97+20

How can I find both k and y?
Suppose you had a solution pair. Consider adding 1 to k. What would you have to do to y to make a second solution pair?

You need another constraint, the allowed range of y, perhaps?
 
  • #20
haruspex said:
Suppose you had a solution pair. Consider adding 1 to k. What would you have to do to y to make a second solution pair?

You need another constraint, the allowed range of y, perhaps?
I have a constraint on values of y, and I have showed them above. From 97 to 122 including.
 
  • #21
Vital said:
I have a constraint on values of y, and I have showed them above. From 97 to 122 including.
Ok, and you have
Vital said:
k×26+98−97=y−97+20
So what is the range for k##\times##26?
 
  • #22
haruspex said:
Ok, and you have

So what is the range for k##\times##26?
In this specific case (with these values):
k×26 = y -78, hence k×26 shall have the range ( [97,122] - 87 ), though it looks horrible mathematically.
k×26 equals some number between 97 and 122, inclusive, minus 87.
 
  • #23
Vital said:
y -78
Yes.
Vital said:
- 87
No.
Vital said:
it looks horrible mathematically
No, it simplifies trivially.
 
  • #24
haruspex said:
Yes.

No.

No, it simplifies trivially.
That was a typo: 78
k×26 = y -78, hence k×26 shall have the range ( [97,122] - 78 ).
k×26 equals some number between 97 and 122, inclusive, minus 78.
 
  • #25
Vital said:
hence k×26 shall have the range ( [97,122] - 78 )
Yes, but can't you see how to simplify that immediately?
 
  • #26
haruspex said:
Yes, but can't you see how to simplify that immediately?
The only thing I see is k = ( [97,122] - 78 ) / 26
But what is the exact value of y, namely that value in the range [97,122]?
 
  • #27
Vital said:
The only thing I see is k = ( [97,122] - 78 ) / 26
But what is the exact value of y, namely that value in the range [97,122]?
If x+78 is in the range [97, 122], what is the smallest possible value of x? What is the largest?
 
  • #28
haruspex said:
If x+78 is in the range [97, 122], what is the smallest possible value of x? What is the largest?
The smallest x = 19 and the largest x = 44
 
  • #29
Vital said:
The smallest x = 19 and the largest x = 44
Right, so what is the range for 26k? What values of k fit?
 
  • #30
haruspex said:
Right, so what is the range for 26k? What values of k fit?
Well... [19/26 , 44/26] (I am not reducing the second value yet)
I don't yet see where you are guiding me to, but I am really curious, and all in hope :)
 

Similar threads

Replies
6
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
3K
Replies
11
Views
2K
Replies
21
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 8 ·
Replies
8
Views
4K