Maths & numbers

Linear congruence system calculator over a composite modulus

A system Ax=b modulo m requires every row to hold for the same vector of unknown residues.

Your numbers

One comma-separated row per line.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A system Ax=b modulo m requires every row to hold for the same vector of unknown residues. Coupling distinguishes it from combining separate scalar residue statements. Composite moduli also contain nonunits,so ordinary real-valued Gaussian elimination cannot be applied by dividing through every nonzero pivot.

THE FORMULAAx=b mod m;solutions=x0+ker(A),with all combinations interpreted modulo m.

A worked example

For A=[[2,4],[0,3]],b=[2,3],m=6,there are6 solutions. One is(2,1);kernel generators(3,0),(2,2) span all homogeneous solutions.

Good to know

Integer matrix≤6×4,modulus2–50,m^unknowns≤250,000;complete residue enumeration. Kernel generators may be dependent;at most80 representatives displayed.

Coupled congruences are equations over a residue ring

A system Ax=b modulo m requires every row to hold for the same vector of unknown residues. Coupling distinguishes it from combining separate scalar residue statements. Composite moduli also contain nonunits,so ordinary real-valued Gaussian elimination cannot be applied by dividing through every nonzero pivot.

The page solves the bounded residue problem exactly. Each coordinate is represented by an integer from zero through m−1. Negative coefficients and right-hand sides are reduced consistently;two vectors differing by a multiple of m in a coordinate represent the same residue solution.

Coupled linear congruences over a composite modulusSix residues solve2x+4y ≡ 23y ≡ 3 (mod 6)
Scroll across to see the full diagram.
For A=[[2,4],[0,3]],b=[2,3],m=6,there are6 solutions. One is(2,1);kernel generators(3,0),(2,2) span all homogeneous solutions.

Compare this with the Chinese remainder theorem calculator. Solve coupled matrix congruences Ax=b mod m and return a parametrized solution family; CRT combines scalar residue constraints.

Input dimensions determine the finite search size

Enter one matrix row per line and a matching right-hand-side list. There may be up to six equations and four unknowns. The total residue-vector search m^n must not exceed250,000,so a larger modulus requires fewer unknown coordinates even when the displayed dimension limits are satisfied.

This implementation uses complete bounded enumeration rather than claiming a Smith-form transformation it does not calculate. The cap is visible because it controls actual work,not the truth of a theorem. A rejected large system may still have a perfectly well-defined mathematical solution family.

Find both an affine solution and the kernel

The algorithm evaluates A on every residue vector. It records solutions of the supplied system and,independently,vectors mapped to zero. If one particular solution x0 exists,adding any kernel element to it produces another solution,and every solution differs from x0 by a kernel element.

This coset property gives a useful check:the solution count must equal the kernel size whenever the affine system is consistent. The implementation verifies that equality. An inconsistent right-hand side has zero solutions even though the homogeneous kernel always contains the zero vector.

Generators describe the complete family

The output builds additive generators of the finite kernel and checks that their modular span reaches the entire enumerated kernel. Together with x0,they describe all solutions as x0 plus integer combinations of the generators modulo m. This remains useful when the representative table is shortened.

The generators are not asserted to form an independent basis over a field. They may satisfy relations or have additive orders smaller than m. Allowing each coefficient from zero through m−1 is sufficient to generate the family,but it need not produce each vector exactly once.

A composite-modulus example

Take rows2,4 and0,3,right side2,3,and modulus six. The second equation forces the second coordinate to be odd. Checking the first equation gives six solutions:2,1;5,1;1,3;4,3;0,5;and3,5,with each pair understood modulo six.

One particular solution is2,1. Kernel generators3,0 and2,2 generate all six homogeneous solutions,and shifting them by that particular solution recovers the listed family. Notice that dividing the second equation by three as though three were invertible modulo six would discard essential information.

Counts and representative lists have different roles

The count always comes from the completed finite search. At most eighty affine representatives are displayed. If there are more,the complete-representative-list flag is false,but the particular solution and verified kernel generators still describe the full family under the stated coefficient convention.

A numerical residual close to zero is not used here. All products and reductions stay within safe integer bounds,and each row is checked modulo m. The page does not accept fractional coefficients,because interpreting fractions would first require checking whether each denominator is invertible in the chosen residue ring.

Choose an algorithm appropriate to larger systems

For larger dimensions,a certified Smith-normal-form solver with transformation matrices would be more suitable than enumeration. This page deliberately reports its narrower computational method and bounds. It does not convert a resource rejection into an inconsistency result or return a partial family without saying so.

When recording a solution,include the modulus,the particular vector,the generator list and its dependent-generator convention. A generator matrix without its modulus can describe a different object over the integers or a field,and should not be reused as an ordinary real null-space basis.

A few questions, answered

Can I divide by any nonzero coefficient?

Only units have modular inverses;composite-modulus nonunits require special care and this solver uses exact residue enumeration instead.

Does the generator list form a field basis?

No. Additive kernel generators may have relations and orders smaller than the modulus.

Can an inconsistent system have a kernel?

Yes. The homogeneous kernel always contains zero,while an affine right-hand side can have no solutions.

What if the result has more than eighty vectors?

The exact count and generating family remain complete;the displayed representative list is explicitly marked shortened.

Find your calculator

Start typing to explore the library.