# Finding an easy way to find decomposition nonzero integer $x$ into $x = sa + tb$?

Suppose that some nonzero integer $x$ is $x = pa + qb$ where $p, q, a, b$ are also nonzaero integers.

What would be the easy way to find another decomposition of $x$ into following: $x = ra + sb$ where $a, b$ are the equal $a, b$ in the previous case and $r and s$ are free to be set (= are not fixed numbers)?

-

Plug in the new translated integers

$p\rightarrow p+d_1$

$q\rightarrow q+d_2$

to get

$x=(p+d_1)a+(q+d_2)b=x+(d_1 a+d_2 b),$

i.e. you want to solve

$d_1 a+d_2 b=0,$

and so

$d_1=b\ n$

$d_2=-a\ n$

for some $n$, which you choose to make every number in the system an integer.

-

Let $d$ be the gcd of $a$ and $b$, let $a=da'$, $b=db'$. Use $$r=p+tb', \qquad s=q-ta',$$ where $t$ is any integer.

-

If $x = p a + q b$ and also $x = r a + s b$, then $(r - p) a = (q - s) b$. You could take $r = p + k b$ and $s = q - k a$ for any integer $k$ (and these will be all the possibilities if $\gcd(a,b) = 1$).

-