How to Solve Modular Equations in Mathematica?

  • Context: Mathematica 
  • Thread starter Thread starter heartless
  • Start date Start date
  • Tags Tags
    Arithmetic Mathematica
Click For Summary

Discussion Overview

The discussion revolves around solving modular equations using Mathematica, specifically the equation 11x = 1 (mod 360). Participants explore methods for inputting this equation into Mathematica and discuss various approaches to finding the solution.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant seeks guidance on how to input the modular equation into Mathematica.
  • Another participant claims to have found the solution x = 131 through trial and error and mentions working on a formula.
  • A participant explains that finding the solution involves determining the modular inverse of 11 modulo 360 and suggests that Mathematica may have a function for this.
  • There is a mention of using the extended Euclidean algorithm to compute the modular inverse if Mathematica does not provide a direct function.
  • Another participant introduces the Chinese Remainder Theorem as a method to solve the equation, discussing the relative primeness of factors and providing a specific example.
  • One participant expresses a lack of knowledge in Number Theory and asks for clarification on the concept of modulo.
  • A response provides a brief explanation of the modulo operation, indicating that it relates to remainders when dividing by a number.

Areas of Agreement / Disagreement

Participants do not reach a consensus on a single method for solving the equation, as multiple approaches are discussed, and some participants express uncertainty about their understanding of the concepts involved.

Contextual Notes

Some participants highlight the need for familiarity with Number Theory concepts, such as modular inverses and the Chinese Remainder Theorem, which may limit their ability to engage fully with the discussion.

Who May Find This Useful

This discussion may be useful for individuals interested in modular arithmetic, those learning to use Mathematica for mathematical computations, and students seeking to understand the application of Number Theory in solving equations.

heartless
Messages
220
Reaction score
2
Hello,
I'm not very experienced with mathematica, and I have some problems in making an equation like this,
Find x such that 11x = 1 (mod 360) and x < 360.
Any ideas on how to input this into mathematica?
Thanks,
 
Physics news on Phys.org
or at least tell me how to find x?
 
actually x equals 131. It took me quite a few minutes to brute force it though (trial and error). I'm working out a formula now.
 
AFAIK, you have to do the solving yourself. :frown: But at least you can still get Mathematica to do the computation...

The whole problem boils down to finding the modular inverse of 11, modulo 360. That is, the number a such that 11a = 1 (mod 360).

Mathematica might have a modular inverse function.

If not, the normal way to compute modular inverses is through the extended Euclidean algorithm for GCD's... Mathematica ought to have that!

This algorithm gives you the numbers u and v such that 11u + 360v = 1, so u is easily seen to be the inverse of 11 modulo 360. (Of course, this only works because GCD(11, 360) = 1)

If Mathematica doesn't have that, I think the easiest solution is to write a function that implements the extended Eucllidean algorithm. :smile:

But if you really don't want to, you could still manage something with modular exponentiation, since:

11^EulerPhi[360] = 1 (mod 360)

so you can spend a little bit of time figuring out the possibilities for things which 11a = 1 (mod 360).

(the Carmichael lambda function is better to use than the EulerPhi function, but I don't know if Mathematica has that)
 
There is a neat way to do this relying on the Chinese Remainder Theorem. We look at M, the total product and we divided by each Mi , the result we call individually Mi*. We must have all the M*s relatively prime to each other. So, while that may not be clear, we have 5x8x9=360, and the three factors 5,8,9 are relatively prime.

Then we solve X/Mi Modulo, 5, 8, and 9, giving us a series of Qi.

We have the equation X = Sum of Mi*(Qi). This gives the answer, which we reduce to lowest terms.

This requires good nomenclature to put it down right. But the proof is rather simple, since we have Mi*(Qi)==X Modulo Mi.

For instance in the case of 8x9(X/8x9 Mod 5) gives 8x9(11/72 Mod 5)=72(1/2 Mod 5)=72x3=216.

If you want to use a computer program, Pari has no problem with such things. Just use the Mod function: Mod(1/11,360) =Mod(131,360) in an augenblick!

In fact, it has no trouble with 13X==1 Mod 11!, Mod(1/13,11!)= Mod(36846277, 39916800)
 
Last edited:
im sorry for my ignorance, but i havnt learned anything in Number Theory yet.

here goes...

What exactly is mod?
 
You can have a look at this page: Modulo to get some ideas about what modulo is.
We write:
[tex]a \equiv b (\mbox{mod } c)[/tex], that means when divided by c, a and b have the same remainder. :)
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K