Can you use modular arithmetic to solve this?

  • Thread starter jey1234
  • Start date
  • Tags
    Arithmetic
In summary: For example, with n=5 you only need to check 1,2,3,4 since 5^2 = 25 = 0 \mod 5 and 6^2 = 36 = 1 \mod 5 and the numbers will start repeating. In summary, modular arithmetic can be used to solve the problem of determining if an expression is divisible by a given integer n. This involves finding the squares \mod n and checking for congruence between the given expression and the integer k in terms of n. Additional resources for learning modular arithmetic can be found on Wikipedia or by experimenting with different values.
  • #1
jey1234
38
0
I came across a problem like this (not homework)
[tex] x^2+y^2-k[/tex]

For example,
[tex] x^2+y^2-24 \text{ ,n=4}[/tex]
[tex] x^2+y^2-45 \text{ ,n=8}[/tex]

If x and y are any positive integers (not given) and k is a positive integer (given), is this expression divisible by n (a positive integer that is given). A friend told me that you could use modular arithmetic to solve this. Having never learned modular arithmetic, I don't if that is true. Is it? And if yes, can someone please point me to some online resources where I can learn it? Thanks.
 
Mathematics news on Phys.org
  • #2
Well, modular arithmetic is something that is really easy to mess with after you have learned it, but it is kind of strange to learn. I suggest reading the wikipedia article and then try to understand what I am about to say:

So, say you have [itex]x^2 + y^2 - k[/itex] and you want to know if this is divisible by [itex]n[/itex]. If you think about it, this is the same as saying that if you divide [itex]x^2 + y^2[/itex] by [itex]n[/itex] and get a remainder [itex]r[/itex] this is the same as the remainder that you get after dividing [itex]k[/itex] by [itex]n[/itex]. In this case, we say that [itex]x^2 + y^2[/itex] and [itex]k[/itex] are congruent modulo [itex]n[/itex]. Now, each integer [itex]n[/itex] has a finite number of squares [itex]\mod n[/itex] which means that we only need to check a finite number of combinations.

Example: does 4 divide [itex]x^2+y^2-24[/itex] for any [itex]x,y[/itex]? Well, [itex]24[/itex] is [itex] 0 \mod 4[/itex], and the only squares [itex]\mod 4[/itex] are [itex]0,1[/itex] (e.g. [itex]2^2 = 0 \mod 4[/itex] and [itex]1^2 = 1 \mod 4[/itex].) So, the answer is yes: if [itex]x,y[/itex] are either [itex]0 \mod 4[/itex] or [itex]2 \mod 4[/itex] then [itex]4[/itex] divides [itex]x^2 + y^2 - 24[/itex]. For example, let [itex]x = 10[/itex] (which is 2 mod 4) and let [itex]y=12[/itex] (which is 0 mod 4). Then [itex]x^2 + y^2 - 24 = 100 + 144 - 24 = 220 = 4*55[/itex].

This might not make sense, but it will after you read the wikipedia article and play aroud with it for a while.
 
  • #3
I followed you until ("the only squares mod 4 are 0,1"). I don't understand what you mean by that. Could you please elaborate? Thanks.
 
  • #4
jey1234 said:
I followed you until ("the only squares mod 4 are 0,1"). I don't understand what you mean by that. Could you please elaborate? Thanks.
Square an even number: (2n)2 = 4n2 = 0 mod 4.
Square an odd number: (2n+1)2 = 4n2+4n+1 = 1 mod 4.
 
  • #5
jey1234 said:
I followed you until ("the only squares mod 4 are 0,1"). I don't understand what you mean by that. Could you please elaborate? Thanks.

To check which numbers are squares [itex]\mod n[/itex], all you need to do is square the integers less than [itex]n[/itex] and see what the squares are. With [itex]n=4[/itex] this means we only need to check [itex]1,2,3[/itex]. So [itex]1^2 = 1 \mod 4[/itex], [itex]2^2 = 4 = 0 \mod 4[/itex] and [itex]3^2 = 9 = 1 \mod 4[/itex]. So, the only squares [itex]\mod 4[/itex] are [itex]0,1[/itex].

You can carry this same procedure out with any integer [itex]n[/itex].
 

1. Can you explain what modular arithmetic is?

Modular arithmetic is a mathematical system where numbers wrap around after reaching a certain value, called the modulus. This means that when performing operations such as addition, subtraction, multiplication, and division, the answer will always be within the range of 0 to the modulus.

2. How can modular arithmetic be used to solve problems?

Modular arithmetic can be used to solve problems that involve repeating patterns, such as finding the remainder when dividing two numbers or determining the day of the week a particular date falls on. It can also be used in cryptography and computer science.

3. What are the benefits of using modular arithmetic?

One of the main benefits of using modular arithmetic is that it simplifies calculations and makes them easier to perform. It can also help in solving problems that would be difficult to solve using traditional arithmetic methods.

4. Can modular arithmetic be used in real-world applications?

Yes, modular arithmetic has many real-world applications. It is used in fields such as computer science, cryptography, engineering, and finance. For example, it is used in coding and decoding messages in cryptography and in calculating the checksum of data in computer networks.

5. Are there any limitations to using modular arithmetic?

While modular arithmetic is a useful tool, it does have some limitations. For instance, it can only be used with whole numbers, and division can be problematic if the modulus is not relatively prime with the divisor. Additionally, some problems may require more complex mathematical techniques, making modular arithmetic unsuitable for solving them.

Similar threads

Replies
35
Views
2K
Replies
5
Views
2K
Replies
1
Views
1K
Replies
2
Views
258
Replies
3
Views
977
Replies
13
Views
1K
Replies
9
Views
1K
Replies
1
Views
406
Replies
1
Views
2K
Back
Top