Questions tagged [modular-arithmetic]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
73 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 ...
0
votes
1answer
29 views

Find a solution to a congruence within a specified range

My problem is to find all the integer solutions of the following conguence: $$P=0\ \text{mod}\ 4$$ where $$p=q^2∗r^2∗y^4∗z^2∗(2∗w^4+2∗r^2∗w^4∗y^4∗z^2+r^2∗w^8∗y^4∗z^2+2) + q^2+ 2∗r^6∗w^4∗y^m∗z^6∗(w+w^2+...
0
votes
0answers
53 views

Command to find the pre-image of a set that is mapped to by the function $f(x)=3^x \mod{17}$

$$f(x)=3^x \mod{17}$$ How to find the pre-image of the set if this function maps from real numbers to real numbers. What command would I use, to see the pre-image if the function would map from ...
2
votes
1answer
93 views

Plot solution to damped driven pendulum in $(-\pi,\pi)$

I'm solving the damped driven pendulum: ...
0
votes
1answer
61 views

Modulus option quietly nerfed for Solve?

Recently asked my students to put together something like this: Reduce[x^2 ==b, b, Modulus -> 11] For me, on 12.1, this gives: ...
0
votes
0answers
43 views

PowerMod solve for b (exponent)

Using PowerMod[a, b, m] = x I get ...
2
votes
2answers
318 views

How to ask Mathematica to solve a simple modular equation

What's the most straightforward way to ask Mathematica to find all solutions of an equation like $$3x + 2y + 4z = 0 \pmod {11}$$ (for instance), where either $x$, $y$, $z$ can be considered to be ...
3
votes
1answer
51 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, ...
1
vote
1answer
60 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 ...
0
votes
1answer
42 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 ...
2
votes
1answer
46 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: ...
2
votes
1answer
81 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 ...
11
votes
3answers
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$...
2
votes
1answer
58 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 ...
1
vote
0answers
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 ...
2
votes
0answers
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 <...
4
votes
3answers
111 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 ...
0
votes
0answers
54 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 ...
5
votes
1answer
641 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 }
2
votes
1answer
330 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 ...
5
votes
1answer
103 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 ...
1
vote
1answer
228 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 ...
3
votes
1answer
197 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 ...
1
vote
1answer
68 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 ...
4
votes
3answers
363 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 ...
0
votes
1answer
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{}? ...
2
votes
1answer
170 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 ...
6
votes
1answer
469 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 ...
0
votes
0answers
115 views

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

I have the following $2$-dimensional implicitly defined map ...
1
vote
1answer
118 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 ...
0
votes
1answer
53 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: ...
7
votes
2answers
1k views

How can I solve a certain congruence equation?

I want to solve the congruence $3x^2 + 6x + 1 \equiv 0 \pmod {19}$. I know that one way to solve this is to first solve the congruence: $t^2 \equiv 5 \pmod {19}$, because $b^2 - 4ac \equiv 24 \equiv ...
4
votes
1answer
273 views

Matrix operations “Modulus->non-prime” problem

I am using Mathematica 10.4.1.0. When I specify the "Modulus" option to be a non-prime, the functions RowReduce and MatrixRank return the error ...
2
votes
1answer
172 views

How to remove symmetries from this list?

First of all, I work with modular arithmetics and the elements of the arithmetics are lists themselves. I recognize two kinds of symmetries - shift and mirroring. We could define shift of a list like ...
9
votes
1answer
180 views

Modular equation problem

I have problem solving this modular equation $67^n \equiv 67 \pmod {317026939759222841944}$ with $n>1$. I have tried my Laptop and Wolfram Alpha engine, but I don't get any solution, I'm very ...
1
vote
0answers
69 views

Last digits via PowerMod [closed]

Do you have an idea why this produces different results? PowerMod[2003, 2002^2001, 1000] 241 ...
6
votes
2answers
201 views

Memory problem when solving a system of modular equations [duplicate]

I need to solve the following system of modular equations, but the computation can't finish because I run out of memory (I have 12 GB of RAM). Is there any workaround to this problem? I am using ...
0
votes
0answers
53 views

Function to add two matrices mod 2 [duplicate]

I have: lightstep[m_, gg_] := Which[gg == {1, 1}, m = Mod[m + m, 2]] Then I entered: A = {{1, 1, 0}, {1, 0, 0}, {0, 0, 0}} ...
2
votes
0answers
101 views

Finite fields package doesn't simplify

I'm trying to do arithmetic using the FiniteFields package. Supposing a is a generator of a Galois field (say GF(2^5)) I want to be able to simplify things like a^32 and (a^8)^-1. I don't care about ...
0
votes
1answer
58 views

Putting some calculations together to form an algorithm

Considering these below where n is an odd number, k is also an odd number less than n: <...
3
votes
1answer
205 views

Coppersmith method of small integer solutions to multivariate polynomials

In http://link.springer.com/chapter/10.1007%2F3-540-68339-9_14#page-7 is presented a method for finding small solutions to multivariate polynomials. (Although here he mentions that it "is not rigorous"...
3
votes
2answers
353 views

Evaluate modular fractions

If I have a list of numbers l = {256/11, 258/11, 263/11, 263/11, -22, -22, 251/11, 0, 261/11, -22, 265/11, 259/11, 0, 259/11} which I want to evaluate mod 26, how ...
-2
votes
1answer
72 views

Want code for a modular operation

Given numbers a1 and a2 and a positive integer k, such that ...
12
votes
2answers
984 views

MatrixPower with Modulus

I have a matrix that will be multiplied with itself by an extremely large amount of times under $Z/pZ$. The matrix itself contains small numbers, so ...
4
votes
0answers
181 views

Sparse matrix multiplication mod p

Let A and B be sparse matrices with integer coefficients between 0 and ...
2
votes
1answer
408 views

Get Mathematica to solve Modular Arithmetic problem [closed]

How would I get Mathematica to solve something like this for $x$? $4x \equiv 1 \pmod 5$
2
votes
0answers
128 views

What does Mod^(1,0) mean in mathematica output [closed]

I am trying to take he derivative of mod(remainder). In:= D[Mod[x, y], x] Out = Mod^(1,0)[x,y] I cannot understand the meaning of Mod^(1,0). What does the ...
-1
votes
3answers
121 views

Create table of elements which belongs to specific sets

I would like to produce elements (preferably by Table or For-If commands) that they belong to specific sets. For example I want to write positive integers from 1 to 100 such that they are $2 \pmod 3$, ...
2
votes
1answer
94 views

A Difficult Application of Modular Arithmetic

Looking to input a $p$ for the first line: p=6; Build a list of primes from the 3rd to $p-1$: ...
2
votes
1answer
151 views

Twin Prime Max Gaps (Performance Tuning)

Ok, let's build a foundation here: A common way of testing primality, is dividing by all primes smaller than the number's square root. For instance, $97$ is prime because dividing by none of the ...