Bill Allombert on Sat, 07 Jan 2023 10:32:39 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Solve an non-homogeneous system of equations mod Z.


On Sat, Jan 07, 2023 at 09:14:04AM +0800, Hongyi Zhao wrote:
> 
> I tried the following method, but failed:
> 
> ? mat1 = [ -210, -210, -220; -221, -222, -232; 410, 411, 430 ]
> %1 =
> [-210 -210 -220]
> 
> [-221 -222 -232]
> 
> [ 410  411  430]
> 
> ? vec1 = [ -27, -28, 105/2 ]~
> %2 = [-27, -28, 105/2]~
> ? matsolvemod(mat1,[1,1,1]~, 2 * vec1~,1)
>   ***   at top-level: matsolvemod(mat1,[1,1,1]~,2*vec1~,1)
>   ***                 ^------------------------------------
>   *** matsolvemod: incorrect type in matsolvemod (Y) (t_VEC).

There are three issues:
1/ The error is that you applied ~ to vec1.
2/ You need to multiply everything by 2 to compensate, not just vec1.
3/ matsolvemod looks for integral solutions. Obviously there are none,
so you will get the empty set.

One possible solution
Take w = [0,0,1/4]~
then  mat1*w-vec1 = [-28,-30,55]~ is integral
? matsolvemod(mat1,1,mat1*w-vec1,1)
%20 = [[0,0,0]~,[1,0,0;0,1,0;0,0,1]]

so the set of solution is w + Z^3

Cheers,
Bill