2

How does one solve a system like the following:

$$a_{11}x_{1}+a_{12}x_{2}+...a_{1n}x_{n}=b_{1}\space (mod \space p^{k} )\\\vdots \\ a_{n1}x_{1}+a_{n2}x_{2}+...a_{nn}x_{n}=b_{n}\space (mod \space p^{k}) $$ Where $a_{11}, a_{12},\dots ,a_{n(n-1)},a_{nn} $ and $b_{i}$ are $(mod \space p^{k})$ integers?

I could only find linear congruence systems where the Chinese remainder theorem helps but that's not the case here. The only solution that seems good is adding $y_{i} *p^{k}$ to each line and solving the linear system but then we will have $n$ equations for $2n$ uknowns. Is there a better way of solving this?

Afntu
  • 2,393
Nesa
  • 1,295
  • 11
  • 23
  • Use Gaussian elimination on $A$ in $Ax \equiv b \pmod{p^k}$ to get $LUx \equiv b \pmod{p^k}$ where $L$ is a lower matrix and $U$ an upper matrix. $Ux \equiv L^{-1}b \pmod{p^k}$ , https://en.wikipedia.org/wiki/Gaussian_elimination –  Oct 26 '16 at 23:28
  • @arthur how will that help? – Nesa Oct 27 '16 at 19:09
  • 1
    Nesa - In the best case you'll have equations with only one new variable being introduced in each equation. e.g. in $Ux \equiv L^{−1}b \equiv c\pmod{p^k}$ the bottom line/equation could be $u_nx_n \equiv c_n \pmod{p^k}$ where $u_n,c_n$ are constants. This gives $x_n \equiv u_n^{-1} c_n \pmod{p^k}$. This next line up may be of the form $u_{n-1}x_{n-1} + u_nx_n \equiv c_{n-1} \pmod{p^k}$ giving $x_{n-1} \equiv u_{n-1}^{-1}(c_{n-1} - u_nx_n) \pmod{p^k}$. etc $\dots$ The equations all have the same modulus $p^k$, linear operations on the equations can be performed such as $LU$ factorization. –  Oct 27 '16 at 20:37
  • @arthur How do you mean 'in the best case'? Isn't it always the case? – Nesa Oct 27 '16 at 20:57
  • 1
    Nesa - No. If the equations are not linearly independent then more than one new variable will appear in an equation. In linear algebra two variables represents a line e.g. $a_1 x_1 + a_2 x_2 = c$. –  Oct 27 '16 at 21:01

1 Answers1

2

We consider finding one of solutions of $\mathbf{Ax}=\mathbf{b} \, (\mathrm{mod} p^{k})$ for given $\mathbf{A} \in \mathbb{Z}^{m \times n}$ and $\mathbf{b} \in \mathbb{Z}^{m}$.

Let the Smith normal form (SNF) of $\mathbf{A}$ be $\mathbf{D}=\mathbf{LAR}$, where $L$ and $R$ are some unimodular matrices. Now it is sufficient to solve $\mathbf{Dy} = \mathbf{Lb} \, (\mathrm{mod} p^{k})$ for $\mathbf{y} \in \mathbb{Z}^{m}$. After we obtain $\mathbf{y}$, we easily obtain the solution of the original linear systems as $\mathbf{x} = \mathbf{Ry} \, (\mathrm{mod} p^{k})$.

We write the SNF as $\mathbf{D} = \mathrm{diag}(d_{1}, \cdots, d_{r}, 0, \cdots)$. Then, the $i$th element of $\mathbf{y}$ is determined by solving $$ d_{i} y_{i} = [\mathbf{Lb}]_{i} \quad (\mathrm{mod} \, p^{k}) $$ for $i=1, \cdots, r$. The above can be solved by the extended Euclidean algorithm. If $\mathrm{GCD}(d_{i}, p^{k})$ does not divide $p^{k}$ for some $i$, no solution exists.

Note that multiple solutions $\mathbf{x}$ may exist for $k \geq 2$. If we need all the solutions, the next task is to construct an integer lattice formed by $\mathbf{Ax}=\mathbf{0} \, (\mathrm{mod}\,p^{k})$. I mention this problem can also be solved by a lattice algorithm shown in this lecture note.

The generalization from prime powers $p^{k}$ to other composite numbers $l$ is straightforward. After factoring $l$ and solving the linear equations for each prime power, we can get a solution of $\mathbf{Ax} = \mathbf{b} \, (\mathrm{mod}\, n)$ by the Chinese remainder theorem.

P.S. I have also encountered the situation to solve the modular linear equation and I cannot find a useable implementation to solve it. So, I have implemented the above method in my Python package.