Does anyone know how to code Mathematica to solve modular problems? For example, say I want to solve 4x == 1 mod 5. My best guess was Mod[Solve[4x == 1, x], 5] but that only resulted in the response Mod[1/4, 5].

Thanks!

-Dan

Printable View

- Oct 31st 2013, 12:27 PMtopsquarkModular arithmetic in Mathematica
Does anyone know how to code Mathematica to solve modular problems? For example, say I want to solve 4x == 1 mod 5. My best guess was Mod[Solve[4x == 1, x], 5] but that only resulted in the response Mod[1/4, 5].

Thanks!

-Dan - Oct 31st 2013, 01:17 PMSlipEternalRe: Modular arithmetic in Mathematica
Did you try:

Solve[Mod[4x,5] == 1,x]

? - Oct 31st 2013, 05:21 PMtopsquarkRe: Modular arithmetic in Mathematica
No good. I get back {{x -> 1/4 InverseFunction[Mod, 1, 2][1, 5]}}, which leads me to believe that it doesn't understand the Mod[ ] in this context. I don't know. WolframAlpha will solve simple ones but even that site doesn't tell me how the problem needs to be coded. Ach!

-Dan - Oct 31st 2013, 05:28 PMSlipEternalRe: Modular arithmetic in Mathematica
Ok, I checked a bit, and this might work:

Solve[4x == 1 && Modulus == 5,x] - Oct 31st 2013, 05:36 PMSlipEternalRe: Modular arithmetic in Mathematica
- Oct 31st 2013, 05:48 PMtopsquarkRe: Modular arithmetic in Mathematica