MATHEMATICS

Sabtu, 22 Oktober 2011

Solving quadratic congruence equations in Mathematica

This is as yet the last post in the LQR series. If you are only interested in -solving- ( quadratic ) congruence equations then this is the way to do it in Mathematica:

As a general Diophantic equation:
In[1]:= Reduce[x^2==123456+1299709 k,{x,k},Integers]

Out[1]= (C[1]\[Element]Integers&&x==427784-1299709 C[1]&&k==140800-855568 C[1]+1299709 C[1]^2)||(C[1]\[Element]Integers&&x==871925-1299709 C[1]&&k==584941-1743850 C[1]+1299709 C[1]^2)


Or slightly more elegant as a pure congruence equation ( thanks to: Mr. Wizard ):
In[2]:= Reduce[x^2 == 123456, x, Modulus -> 1299709]

Out[2]= x == 427784 || x == 871925

Tidak ada komentar:

Posting Komentar