1

I know the values of $x_1, x_2, y_1, y_2$ and I would like to calculate $a$ and $b$ How do I do it because I have to program the method.

$$\begin{align*}x_1\cdot a + b = y_1 \mod 26\\ x_2\cdot a + b = y_2 \mod 26\end{align*}$$

Jimmy R.
  • 35,868
  • 1
    Assuming $x_1 \neq x_2 \pmod{26}\ (x_1 \equiv x_2 \Rightarrow y_1 \equiv y_2 \pmod{26}\ )$, subtract the second equation from the first to get $( x_1 - x_2 ) \cdot a \equiv y_1 - y_2 \pmod{26}$. – Singhal Feb 22 '14 at 16:56
  • Since x1,x2,y1,y2 are known, I think that you can just solve the system by ignoring the mod 26. Two equations, two unknowns, probably I am missing something... – Jimmy R. Feb 22 '14 at 17:04
  • then I will have to resolve this: (x1−x2)⋅a≡y1−y2(mod26)
    That is done
    – user3341195 Feb 22 '14 at 17:07

1 Answers1

0

As Singhal says in his comment, to get $a,$ simply subtract the two congruences and multiply by $(x_1-x_2)^{-1}.$ (If the inverse doesn't exist, then there is no possible value of $a.$)

To get $b$ afterwards, you could either substitute the value of $a$ into one of the congruences and solve, or you could multiply the first congruence by $x_2,$ the second by $x_1,$ and subtract.

It's really like a normal system of equations, just with modular inverses instead of division.

Michael T.
  • 166
  • 6