 
 
 
7.1.23  Solving Diophantine equations
The isolve command attempts to solve
the given equations over the integers.
Note that it automatically solves for all of the indeterminates present in the equations.
- 
isolve takes one mandatory argument and two optional arguments:
- 
eq, an equation or list of equations.
- Optionally, symb, a (sequence or list of) symbol(s)
which are used as the names for global variables present in the solution.
These names default to _Z0,_Z1,… for general integers
and to _N0,_N1,… for positive integers.
- Optionally, seq=false, which makes isolve return only
particular/fundamental solution(s) found by the solver.
By default, seq=true, which makes isolve return sequences (classes)
of solutions whenever possible.
 
- isolve can solve the following types of equations:
- 
(systems of) linear equation(s).
- general quadratic equations with two indeterminates.
- equations of the type Q(x,y,z)=0, where Q is a ternary quadratic form.
- equations of the type f(x)=g(y), where f,g∈ℤ[X] are monic polynomials with degrees m and n such that gcd(m,n)>1 and f(x)−g(y) is irreducible in ℚ[X,Y].
 
Examples
Linear equations and systems can be solved.
|  | | |  | ⎡ ⎣
 | x=−10+42_Z0,y=1−5_Z0 | ⎤ ⎦
 | 
 |  |  |  |  |  |  |  |  |  |  | 
 | 
| isolve([x+y-z=4,x-2y+3z=3],m) | 
|  | | |  | ⎡ ⎣
 | x=m,y=−4 m+15,z=−3 m+11 | ⎤ ⎦
 | 
 |  |  |  |  |  |  |  |  |  |  | 
 | 
To find the general solution to Pell-type equation x2−23y2=1:
| sol:=isolve(x^2-23y^2=1,n) | 
|  | | |  | ⎡ ⎢
 ⎢
 ⎢
 ⎢
 ⎣
 | x= | | | ⎛ ⎜
 ⎝
 | 24+5 | √ |  | ⎞ ⎟
 ⎠
 |  | + | ⎛ ⎜
 ⎝
 | 24−5 | √ |  | ⎞ ⎟
 ⎠
 |  | 
 |  |  |  | 2 | 
 | ,y= | | | ⎛ ⎜
 ⎝
 | 24+5 | √ |  | ⎞ ⎟
 ⎠
 |  | − | ⎛ ⎜
 ⎝
 | 24−5 | √ |  | ⎞ ⎟
 ⎠
 |  | 
 |  |  |  |  | 
 | ⎤ ⎥
 ⎥
 ⎥
 ⎥
 ⎦
 | 
 |  |  |  |  |  |  |  |  |  |  | 
 | 
To check that it is indeed the solution, enter:
| simplify(subs(x^2-23y^2-1,sol)) | 
Now to obtain e.g. the first four solutions, enter:
| simplify(apply(unapply(apply(rhs,sol),n),[1,2,3,4])) | 
|  | | |  | ⎡ ⎣
 | [24,5],[1151,240],[55224,11515],[2649601,552480] | ⎤ ⎦
 | 
 |  |  |  |  |  |  |  |  |  |  | 
 | 
To obtain only the fundamental solution, enter:
| isolve(x^2-23y^2=1,seq=false) | 
The following two examples demonstrate solving quadratic equations with two indeterminates.
|  | | |  | | ⎡ ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎣
 | | x=−4, | y=−5 |  | x=0, | y=−2 |  | x=4, | y=0 |  | x=10, | y=2 |  | x=21, | y=5 |  | x=4, | y=5 |  | x=0, | y=2 |  | x=−4, | y=0 |  | x=−10, | y=−2 |  | x=−21, | y=−5 | 
 | ⎤ ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎦
 | 
 | 
 |  |  |  |  |  |  |  |  |  |  | 
 | 
| isolve(x^2-3x*y+y^2-x=2,n) | 
|  | | [[x | | = | | | ⎛ ⎜
 ⎜
 ⎝
 |  | ⎞ ⎟
 ⎟
 ⎠
 |  |  | ⎛ ⎜
 ⎝
 | −15 | √ |  | −33 | ⎞ ⎟
 ⎠
 | 
 |  |  |  | 10 | 
 | + | | | ⎛ ⎜
 ⎜
 ⎝
 |  | ⎞ ⎟
 ⎟
 ⎠
 |  |  | ⎛ ⎜
 ⎝
 | 15 | √ |  | −33 | ⎞ ⎟
 ⎠
 | 
 |  |  |  | 10 | 
 | − |  | , | 
 |  |  |  |  |  |  |  |  |  |  | y | | = | | | ⎛ ⎜
 ⎜
 ⎝
 |  | ⎞ ⎟
 ⎟
 ⎠
 |  |  | ⎛ ⎜
 ⎝
 | −3 | √ |  | −6 | ⎞ ⎟
 ⎠
 | 
 |  |  |  | 5 | 
 | + | | | ⎛ ⎜
 ⎜
 ⎝
 |  | ⎞ ⎟
 ⎟
 ⎠
 |  |  | ⎛ ⎜
 ⎝
 | 3 | √ |  | −6 | ⎞ ⎟
 ⎠
 | 
 |  |  |  | 5 | 
 | − |  | ]] | 
 |  |  |  |  |  |  |  |  |  | 
 | 
| isolve(8x^2-24x*y+18y^2+5x+7y+16=0) | 
|  | | |  | | ⎡ ⎢
 ⎣
 | | x=−174 _Z12+17_Z1−2, | y=−116 _Z12+21_Z1−2 |  | x=−174 _Z12+41_Z1−4, | y=−116 _Z12+37_Z1−4 | 
 | ⎤ ⎥
 ⎦
 | 
 | 
 |  |  |  |  |  |  |  |  |  |  | 
 | 
Integral zeros of ternary quadratic forms can be found.
| isolve(x^2+11y^2+6x*y-3z^2=0,a,b,c) | 
|  | | |  | ⎡ ⎣
 | x=c | ⎛ ⎝
 | −44 a2+12 b2 | ⎞ ⎠
 | ,y=c | ⎛ ⎝
 | 13 a2−3 b2−6 a b | ⎞ ⎠
 | ,z=c | ⎛ ⎝
 | −11 a2−3 b2+2 a b | ⎞ ⎠
 | ⎤ ⎦
 | 
 |  |  |  |  |  |  |  |  |  |  | 
 | 
The components of the above solution can be divided by the GCD of −44 a2+12 b2, 13 a2−3 b2−6 a b, and −11 a2−3 b2+2 a b, thus producing a parametrization for the pairwise-coprime solutions given c=1.
Certain polynomial equations of the type f(x)=g(y) can be fully solved, as in the following example.
| isolve(x^2-3x+5=y^8-y^7+9y^6-7y^5+4y^4-y^3) | 
|  | | |  | | ⎡ ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎢
 ⎣
 | | x=−3, | y=−1 |  | x=6, | y=−1 |  | x=0, | y=1 |  | x=3, | y=1 |  | x=660, | y=5 |  | x=−657, | y=5 | 
 | ⎤ ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎥
 ⎦
 | 
 | 
 |  |  |  |  |  |  |  |  |  |  | 
 | 
The above list contains all integer solutions to the given equation.
 
 
