(34S) Solving a Single Congruence Equation
|
08-04-2015, 06:02 AM
(This post was last modified: 06-15-2017 01:20 PM by Gene.)
Post: #1
|
|||
|
|||
(34S) Solving a Single Congruence Equation
Problem:
Solve the equation: \(a\cdot x\equiv b \mod n\) Algorithm: With the definition \(d=\left\lfloor\frac{n}{a}\right\rfloor\) iterate the following until \(a{'}\) is 0: \( \begin{bmatrix} 0 & 1 \\ 1 & -d \end{bmatrix}\cdot\begin{bmatrix} p & n \\ q & a \end{bmatrix}=\begin{bmatrix} p{'} & n{'} \\ q{'} & a{'} \end{bmatrix}=\begin{bmatrix} q & a \\ p-dq & n-da \end{bmatrix} \) Then \(p{'}\equiv a^{-1}\mod n\). Multiply this by b to get the solution. It's possible to use the same matrix for the result of a multiplication: \( \begin{bmatrix} 00 & 01 \\ 02 & 03 \end{bmatrix}\cdot\begin{bmatrix} 04 & 05 \\ 06 & 07 \end{bmatrix}=\begin{bmatrix} 04 & 05 \\ 06 & 07 \end{bmatrix} \) Program: Code: LBL'SCE' ; a b n Examples: \(5\cdot x\equiv 3 \mod 17\) 5 ENTER↑ 3 ENTER↑ 17 XEQ'SCE' 4 \(999,999,999,989\cdot x\equiv 1 \mod 999,999,999,999\) 999,999,999,989 ENTER↑ 1 ENTER↑ 999,999,999,999 XEQ'SCE' 899,999,999,999 |
|||
08-04-2015, 01:59 PM
Post: #2
|
|||
|
|||
RE: (WP-34S) Solving a Single Congruence Equation
(08-04-2015 06:02 AM)Thomas Klemm Wrote: Problem: Thomas - FYI, small typo - in example 1, both should be either 7 or 17. --Bob Prosperi |
|||
08-04-2015, 03:29 PM
Post: #3
|
|||
|
|||
RE: (WP-34S) Solving a Single Congruence Equation | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)