Find all integer solutions to $7595x + 1023y=124$

Using the Euclidean algorithm I have found the $\gcd(7595,1023)=31$ and found the Bezout identity $31=52\cdot1023-7\cdot7595$ but I'm not really sure how to go about finding all solutions to that equation.

I believe you can divide the equation through by the $\gcd$ - which gives $245x+33y=4$ - but I'm not sure what to do next.


Solution 1:

Hint $\ $ For $\rm A\:$ linear, $\rm\ AX_1\! = B = AX_2 \iff 0 = AX_1\! - AX_2 = A(X_1\!-X_2)$

This implies that the general solution of $\rm\,\ AX = B\,\ $ is the sum of any particular solution plus the general solution of the associated homogeneous equation $\rm\ AX = 0.\:$ This property holds true for every linear operator, e.g. for matrices, linear differential equations, linear recurrences, etc, a fact which will come to the fore if you study linear algebra and vector/affine spaces, modules, etc, e.g. see various posts on this topic.

In particular for $\,{\rm AX} := (a,b)\cdot (x,y) = ax+by\ $ the above becomes

$$\begin{align}&{\rm if}\!\! \overbrace{ax_p+by_p = c}^{{\rm particular\ solution\ }{\large \color{#0a0}{(x_p,y_p)}}}\!\!{\rm then}\\[.4em] &\ \ \ \ \ \ ax\ +\ by\,=\,c \iff a(x\!-\!x_p)+b(y\!-\!y_p) = 0\\[.4em] \iff\! \ &{\underbrace{x-x_p = x_h,\ y-y_p = y_h}_{\textstyle \color{#0a0}{(x,y) = (x_p,y_p)+(x_h,y_h)}}\ \ \,{\rm and}\!\!\!\!\underbrace{ a\, x_h +b\,y_h= 0}_{{\rm homogeneous\ solution}\ \large \color{#0a0}{(x_h,y_h)}}\!\!\!\!}\end{align}\qquad$$

i.e. general solution $\,\color{#0a0}{(x,y)}\,$ of $\,ax+by = c\,$ is any particular solution $\,\color{#0a0}{(x_p,y_p)\,\ \rm summed}$ with the general $ $ solution $\ \color{#0a0}{(x_h,y_h)}\ $ of $\,ax+by = \color{#c00}0\ $ (the associated $\rm\color{#c00}{homogeneous}$ equation).

Solving the associated homogeneous equation in your case

$7593 x\! +\! 1023 y = 0 \iff 7593 x = -1023 y$ $ \iff \dfrac{x}y = \dfrac{-1023}{7593} = \dfrac{-33}{245}\overset{\color{#90f}{\rm UF}\!\!}\iff \begin{align}&x = -33k\\ &y =\ 245k\end{align}$

The final equivalence uses $\color{#90f}{\rm UF} =$ unique fractionization (known implicitly since grade school).

Thus the general homogeneous solution is $\,(x_h,y_h) = (-33k,245k).\,$ As above, adding that homogeneous solution to your particular solution $\,(x_p,y_p) = 4(-7,52) = (-28,208)\,$ we obtain the sought general solution, namely $\,(x,y) = (-28-33k,\,208+245k)$

Alternatively we can apply the (forward) Extended Euclidean algorithm, where the particular and homogeneous solutions occur as the final two rows - see here.

Solution 2:

From your remark $31 = 52\times 1023-7\times7595$, you get $124=4\times 31 = 7595\times(-4\times7)+1023\times(52\times 4)$, so you have a first solution $x_0=-28$ and $y_0=208$. So you have $7595(x-x_0)+1023(y-y_0)=0$, or $245(x-x_0) = - 33(y-y_0)$ (*). Now $245$ and $33$ are coprime, so for this equality to hold, you need to have: $$ x-x_0=33\lambda\\ y-y_0=245\mu $$

When you replace this into (*), you get $\lambda = -\mu$, so at the end the solution is given by: $$ x=33\lambda+x_0\\ y=-245\lambda+y_0 $$ Where $\lambda\in\mathbb{Z}$.