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

- October 31st 2013, 11:27 AMtopsquarkModular 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 - October 31st 2013, 12:17 PMSlipEternalRe: Modular arithmetic in Mathematica
Did you try:

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

? - October 31st 2013, 04: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 - October 31st 2013, 04:28 PMSlipEternalRe: Modular arithmetic in Mathematica
Ok, I checked a bit, and this might work:

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