Hongyi Zhao on Sat, 07 Jan 2023 14:31:14 +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 7, 2023 at 5:31 PM Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> wrote: > > 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. But based on my testing with your code snippet below, you still used vec1 like this: vec1 = [ -27, -28, 105/2 ]~ > 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]~ This solution is not given in advance. We need to find such things first. How did you find such a solution? > 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]] Here is the complete test using your above code example: ? mat1 = [ -210, -210, -220; -221, -222, -232; 410, 411, 430 ] %9 = [-210 -210 -220] [-221 -222 -232] [ 410 411 430] ? vec1 = [ -27, -28, 105/2 ]~ %10 = [-27, -28, 105/2]~ ? w = [0,0,1/4]~ %11 = [0, 0, 1/4]~ ? mat1*w-vec1 %12 = [-28, -30, 55]~ ? matsolvemod(mat1,1,mat1*w-vec1,1) %13 = [[0, 0, 0]~, [1, 0, 0; 0, 1, 0; 0, 0, 1]] > so the set of solution is w + Z^3 > > Cheers, > Bill Best, Zhao