# Questions tagged [modular-arithmetic]

The tag has no usage guidance.

87 questions
Filter by
Sorted by
Tagged with
33 views

### ListPlot vs. ListLinePlot How Do You Remove Discontinuous Artefacts from Introduced by Mod?

I have some data that inherently describes a phase and would like to plot it in between [0, 2*pi). When I use ListPlot with the ...
51 views

### Reduce does not work with Mod operation

We have a constant issue about working with some functions like Mod and Log. here when I add a ...
38 views

### What is the meaning of this Modulus output?

Quick question, what is the meaning of the $\mathbb{c}_1$ subscript in the output of Modulus (shown as an image below)? I understand there are two solutions to this linear congruence, 6 and 15 (6+9), ...
93 views

### Eliminate an expression with Mod operation

The target below should equal 0, since 2x + c = a + b + c = 6c, and Mod[6c,3] == 0 But ...
32 views

56 views

### Can Mathematica automatically optimize an expression with PowerMod?

PowerMod[x,p,m] is significantly faster than Mod[x^p, m] for a large p I have an expression, ...
64 views

### A modular version of LinearRecurrence?

I'm playing around with implementing the Lucas probable prime test (mainly so I can understand it better), and would love a version of the LinearRecurrence function that used addition modulo n (with n ...
44 views

### Find relationship between values within finate range of integer domain

Update: There are some misakes in the coefficient of left and right. But still get similar result. I understand the mathematica ...
48 views

### How to simplify quotient and mod in integer domain

I want to simplify (a*32 + a%32)/32, and a is integer. So I write: ...
107 views

### Non-valid modulus when using LinearSolve

I have a system of linear equations I want to solve mod 4, and I happen to know the solution, but I get an error when trying to solve it using LinearSolve. I define the matrix ...
1k views

### How can I program the last digits of Fibonacci numbers?

Is there a way to compute the last digits of an arbitrarily large Fibonacci number? For the $10^n$th Fibonacci number, we can just find the $2^n$-th Fibonacci number (if that isn't too large) $\bmod n$...
61 views

### How to get the modulus of two functions [closed]

I might be overlooking something, because what I want to do is quite elementary. I want the following term Mod[2(1 + z), (1 + z)] to evaluate to ...
57 views

### How to apply PolynomialMod to a SparseArray?

I have a list bdrs of SparseArrays, whose entries are polynomials in the variable t with ...
45 views

### Why gives Modulo of complex numbers different answers for rationals and reals

When running Table[1.*Mod[(1 + I)^(1 + k*I), 1 + k*I], {k, 49, 50, 0.5}] Table[1.*Mod[(1 + I)^(1 + k*I), 1 + k*I], {k, 49, 50, 1/2}] I get for the first table <...
112 views

### how can I calculate $a_{n+3}=a_n+a_{n+1}+a_{n+2}$?

recently I need to calculate this: $a(n+1)=((a(n-2)+a(n-1)+a(n)) \bmod 10000)$ and get $a(20000000)$ (for example). I know RecurrenceTable,but ...
55 views

### Finding a solution to a modular problem efficiently

I want to find a naïve hash function of the form Mod[a x + b, 2^p] which would produce a value less or equal to v for all ...
648 views

### modulo with n instead of 0 without using if-statement

Is there a way to to express the following without using an if statement, but with mathematical operations instead? { 5 if x % 5 = 0, x % 5 otherwise }
379 views

### How to Plot modulo function Mod on a function of two variables? [closed]

I know that Plot[Mod[x, 2], {x, -6, 6}] is a Mathematica command to plot the remainder of x over 2 when I range x over reals -6 to 6. How do I plot the same ...
105 views

### FindEquationalProof to prove divisor theorem

I'm trying to implement proofs of concepts for Equational Proofs on some basic number theory theorems. One such example is: "let a and b be positive integers and let d = gcd (a, b). If t divides ...
253 views

### Polynomial PowerMod

Is there equivalent of PowerMod for polynomials in Mathematica? We have Mod[a^e,m]==PowerMod[a,e,m], $a$, $e$ and $m$ all ...
208 views

### List of invertible congruence classes

I am attempting to create a list of the invertible congruence classes $\bmod 120$. The code I have is ...
70 views

### Is this decryption function idiomatic?

This is my first non-trivial Mathematica notebook, which I wrote for a cryptology homework. It encrypts/decrypts strings using an affine cipher. Is the code readable/idiomatic? How could it be ...
370 views

### How to reverse in modular arithmetic

Given an RGB color {127, 255, 212} where scale is 0-255, VBA's RGB function find a long integer x such that ...
45 views

### Looping on ranges (Modular iterations)

Is it possible to make the following code modular, so that it works up till depth n, and returns an array of all possible combinations for used{}? ...
187 views

### How to solve a system with GCD?

For example, Solve[{x + y == 150, GCD[x, y] == 30}, {x, y}, Integers] Solve::nsmet: This system cannot be solved with the methods available to Solve. The same ...
531 views

### RowReduce modulo 3

When I wanted to compute a row echelon form of a matrix over the finite field ${\Bbb F}_9$ with 9 elements (which is the three element field ${\Bbb F}_3$ adjoined a square root of $-1$ which I denote ...
122 views

### Variables defined modulo $\pi$ and avoiding singularities; phase plotting for a map

I have the following $2$-dimensional implicitly defined map ...
121 views

### Solving a modular equation with a large modulus [duplicate]

I am having trouble solving this equation: $17^n\equiv 1 \mod 640826899755722841329632946651705039010285107743541637238400825304943424424715705661705191669759$ for the smallest integer $n > 0$ I ...
54 views

### Get missing cyclic numbers via modulus?

Consider a list of numbers: list = {1,2,3,4,5}; Taking a random set of three of these numbers: ...