[GAP Forum] Need help: Solution to a simultaneous equation

David Joyner wdjoyner at gmail.com
Wed Apr 11 18:19:35 BST 2007


On 4/11/07, muniru asiru <maasiru at yahoo.com> wrote:
>
>
> a:=100;;
> y1=1+  401/a*10^-14*b+  118/a*10^-14*c+
> 260/a*10^-14*d+  331/a*10^-27*e
> y1=1+  457/a*10^-14*b+  127/a*10^-14*c+
> 330/a*10^-14*d+  255/a*10^-27*e
> y1=1+  765/a*10^-14*b+  383/a*10^-14*c+
> 595/a*10^-14*d+  380/a*10^-27*e
> y1=1+  101/a*10^-14*b+  266/a*10^-14*c+
> 797/a*10^-14*d+  428/a*10^-27*e
> y1=1+  135/a*10^-14*b+  354/a*10^-14*c+
> 106/a*10^-14*d+  586/a*10^-27*e
>
>
> I need help.  I like to solve the above simultaneous
> equations to determine the
> values y1, b,c,d, and e.


I can't tell what you mean: in 401/a*10^-14*b, is b in
the numerator?

If so, solve the 5x5 system in y1,b,c,d,e.
You can use TriangulizeMat on the augmented matrix associated to the
system. For example,
gap> M:=[[1,2,3,4],[1,2,1,2],[1,1,0,0]];
[ [ 1, 2, 3, 4 ], [ 1, 2, 1, 2 ], [ 1, 1, 0, 0 ] ]
gap> TriangulizeMat(M);
gap> M;
[ [ 1, 0, 0, -1 ], [ 0, 1, 0, 1 ], [ 0, 0, 1, 1 ] ]
says the soln to
x+2y+3z=4, x+2y+z=2, x+y=0 is x=-1, y=1, z=1.
Or, you can write the system as a matrix equation Ax=b and compute
A^(-1)*b.

If the system is non-linear, you might try clearling denominators and
using Grobner bases,
http://www.gap-system.org/Manuals/doc/htm/ref/CHAP064.htm#SSEC017.1


You may need to use Maxima instead (which has function for solving non-linear
systems) but some comments on your code are given below:



> I can write some simple codes in Gap, but this doesn't
> appear to help.
>
> I wiil be grateful if you will help me out.  My
> program is shown below.
>
> k0:=[-2^25,(-2^25-1)..2^25];;  a:=100;;
> k1:=[];;
> for y1 in k0 do for b in k0 do for c in k0 do for d in
> k0 do for e in k0 do if
> [[y1],[y1],[y1],[y1],[y1]]=[
> 10^30*[1+  401/a*10^-14*b+  118/a*10^-14*c+
> 260/a*10^-14*d+  331/a*10^-27*e],
> 10^30+[1+  457/a*10^-14*b+  127/a*10^-14*c+
> 330/a*10^-14*d+  255/a*10^-27*e],
> 10^30+[1+  765/a*10^-14*b+  383/a*10^-14*c+
> 595/a*10^-14*d+  380/a*10^-27*e],
> 10^30+[1+  101/a*10^-14*b+  266/a*10^-14*c+
> 797/a*10^-14*d+  428/a*10^-27*e],
> 10^30+[1+  135/a*10^-14*b+  354/a*10^-14*c+
> 106/a*10^-14*d+  586/a*10^-27*e]]
> then  Add(k1,[Int(y1),Int(b),Int(c),Int(d),Int(e)]);
> fi; od; od; od; od; od; k1;
>
> Gap cannot give me the value of k1.  How do I overcome
> this problem.


1) the range k0 is actually an empty list:

gap> k0:=[-2^25,(-2^25-1)..2^25];
[  ]

so it is not surprising that this code finishes with an empty list in
a moment. Using single semicolon instead of double one would
help to spot this bug.

2) Even if you fixed the range of k0, you should realize that
such approach will search only for INTEGER solutions within a certain
range, so, roughly speaking, it does not guarantee anything.

3) Also you are taking y1, b,c,d, and e from the range k0
(so they already are integers) but then applies Int to them.
First, this would not change them. Second, GAP can
operate with rationals with arbitrary large numerators and denominators,
so applying Int in case of rational solutions would be their very
rough approximation.

4) If you are going to loop over big lists, then 10^30 in the
numerator and a=100 multiplied by 10^(-something) in the denominator
may be reduced to avoid additional operations repeated each time inside
the loop.

There might be more remarks regarding the code, but the four
remarks above seems to be the most informative ones that you can
use to further your work with GAP. We refer to the GAP Tutorial
(http://www.gap-system.org/Manuals/doc/htm/tut/chapters.htm)
as a source of examples teaching good programming style in GAP.


- David Joyner and Alexander Konovalov



>
> Thanks
>
>
> sincerely,
> maa
>
>
>
> ____________________________________________________________________________________
> 8:00? 8:25? 8:40? Find a flick in no time
> with the Yahoo! Search movie showtime shortcut.
> http://tools.search.yahoo.com/shortcuts/#news
>
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum
>



More information about the Forum mailing list