1. 程式人生 > >裴蜀定理

裴蜀定理

\forall a,b\inz,d=gcd\left(a,b \right )

關於x,y的線性不定方程:(裴蜀等式)ax+by=c有整數解\left(x,y \right )\Leftrightarrow d\mid c 有解時有無窮解

通解為\left(m_{0}x_{0}+\frac{kb}{d},m_{0}y_{0}-\frac{ka}{d} \right )\left( k\in z \right )

或者\left(\frac{c}{d}x_{0}+\frac{kb}{d},\frac{c}{d}y_{0}-\frac{ka}{d} \right )\left( k\in z \right )

其中ax+by=c,\left(x0,y0 \right )ax_{0}+by_{0}=d=gcd\left(a,b \right)的特解,m_{0}=\frac{c}{d}

接下來給出證明

-----------------------------------------------------------------

先證明ax+by=gcd\left(a,b \right )有解

證明:

\because d=gcd\left(a,b \right )

\therefore d\mid a,d\mid b

d\mid \left(ax+by \right )

設s是a,b的線性組合中最小的正元素,則 \exists x,y\in z,使s=ax+by \in z

q=\left \lfloor \frac{a}{b} \right \rfloor

r=a\%s=a-qs=a-q\left(ax+by \right )=\left(r-qx\right)a-by

∴r也是a,b的線性組合

\because r=a\%s

\therefore 0\leq r < s (因為取餘的結果必然小於模的數)

∵s是s是a,b的線性組合中最小的正元素

\thereforer比線性組合中最小正元素的還小,r=0

\therefore s\mid a

同理可證s\mid b

\therefores是a,b的公約數

\becaused是a,b的最大公約數

\therefore d\geq s

\because d\mid\left ( ax+by \right ),s=ax+by

\therefore d\mid s

\therefore s\geq d

\because d\geq s

\therefore s=d=gcd\left ( a,b \right )

ax+by=s

ax+by=gcd\left ( a,b \right )有解

---------------------------------------------

接著證明 gcd\left ( a,b \right )\mid c \Leftrightarrow ax+by=c 有整數解

證明:充分性d=gcd\left ( a,b \right )

ax+by=gcd\left ( a,b \right ) 解為 \left ( x_{0},y_{0} \right )

\because d\mid c

\therefore \exists k\in z, 使得c=kd

\because ax_{0}+by_{0}=d

kax_{0}+kby_{0}=kd=c

\therefore ax+by=c 的解為\left(kx_{0},ky_{0} \right )

必要性:ax_{1}+by_{1}=c

d=gcd\left(a,b \right )

\therefore d\mid a,d\mid b

\therefore d\mid \left ( ax_{1}+by_{1} \right )

\therefore d\mid c

\therefore gcd(a,b)\mid c

\therefore gcd\left(a,b \right )\mid c\Leftrightarrow ax+by=c 有整數解

------------------------------------------

最後證明有無窮解以及通解形式

證明:設ax_{0}+by_{0}=d,c=m_{0}d

am_{0}x_{0}+bm_{0}y_{0}=m_{0}d=c

a\left ( m_{0}x_{0}+\frac{kd}{b} \right )+b\left ( m_{0}y_{0}-\frac{ka}{b} \right )\left ( k\in z \right )\\ =am_{0}x_{0}+a\frac{kb}{d}+bm_{0}y_{0}-b\frac{ka}{d}\\ =am_{0}x_{0}+bm_{0}y_{0}\\ =c

ax+by=c 的通解為

\left ( m_{0}x_{0}+\frac{kb}{d},m_{0}y_{0}-\frac{ka}{d} \right )\left ( k\in z \right )

或者\left ( \frac{c}{d}x_{0}+\frac{kb}{d},\frac{c}{d}y_{0}-\frac{ka}{d} \right )\left ( k\in z \right )也就是證明了無窮解

其中 ax+by=c,\left ( x_{0},y_{0} \right )ax_{0}+by_{0}=d=gcd\left ( a,b \right )的特解,m_{0}=\frac{c}{d}