Re: Diophant equation
- To: mathgroup at smc.vnet.net
- Subject: [mg42114] Re: [mg42016] Diophant equation
- From: Ken Levasseur <klevasseur at mac.com>
- Date: Thu, 19 Jun 2003 03:59:53 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Wolfgang:
ExtendedGCD contains all of the information you need to construct the general solution. Here is one way to put it into the form {x,y}
LinearDiophantine[a_,b_,c_,k_:k]:=
ExtendedGCD[a,b]//If[Mod[c,First[#]]=!=0,{},c Last[#]+k{b/First[#],-a/First[#]}]&
In[16]:=LinearDiophantine[120, 45, 15, k]
Out[16]={3*k - 15, 45 - 8*k}
In[17]:=LinearDiophantine[120, 43, 1, l]
Out[17]= {43*l + 19, -120*l - 53}
In[18]:= LinearDiophantine[120, 48, 1, l]
Out[18]= {}
Ken Levasseur
Math. Sci.
UMass Lowell
On Monday, June 16, 2003, at 03:58AM, Dr. Wolfgang Hintze <weh at snafu.de> wrote:
>How can I solve a linear Diophant equation like
>
>a x + b y = c
>
>where a, b, and c are given integers >0 for integer x and y in Mathematica?
>
>The solution is a one parameter family of the type
>
>x = A t + B, y = C t + D
>
>Any hint welcome.
>
>Wolfgang
>
>
>