Jsun Yui Wong
"Solving systems of nonlinear equations is perhaps the most difficult problem in all of numerical computation," Rice [1, 1993, p. 355].
Modelled on the computer program in the June 30 post of the present blog, the computer program below tries to find multiple integer solutions of the following nonlinear system from Bellido [2, p. 348; 3, p. I-14]. These equations are used in line 1142 through line 1225 below.
X(1)^2+X(2)^2+X(3)^2-12*X(1)-68=0
X(4)^2+X(5)^2+X(6)^2-12*X(5)-68=0
X(7)^2+X(8)^2+X(9)^2-24*X(8)-12*X(9)+100=0
X(1)*X(4)+X(2)*X(5)+X(3)*X(6)-6*X(1)-6*X(5)-52=0
X(1)*X(7)+X(2)*X(8)+X(3)*X(9)-6*X(1)-12*X(8)-6*X(9)+64=0
X(4)*X(7)+X(5)*X(8)+X(6)*X(9)-6*X(5)-12*X(8)-6*X(9)+32=0
2*X(2)+2*X(3)-X(4)-X(5)-2*X(6)-X(7)-X(9)+18=0
X(1)+X(2)+2*X(3)+2*X(4)+2*X(6)-2*X(7)+X(8)-X(9)-38=0
X(1)+X(3)-2*X(4)+X(5)-X(6)+2*X(7)-2*X(8)+8=0
0 DEFDBL A-Z
3 DEFINT I,J,K
4 DIM X(42),A(42),L(33),K(33)
5 FOR JJJJ=-32000 TO 32000
14 RANDOMIZE JJJJ
16 M=-1D+17
91 FOR KK=1 TO 9
94 A(KK)=-100+FIX(RND*201)
95 NEXT KK
126 IMAR=10+FIX(RND*10000)
128 FOR I=1 TO IMAR
129 FOR K=1 TO 9
131 X(K)=A(K)
132 NEXT K
181 J=1+FIX(RND*9)
182 X(J)=-100+FIX(RND*201)
1142 L1=X(1)^2+X(2)^2+X(3)^2-12*X(1)-68
1143 L2=X(4)^2+X(5)^2+X(6)^2-12*X(5)-68
1144 L3=X(7)^2+X(8)^2+X(9)^2-24*X(8)-12*X(9)+100
1145 L4=X(1)*X(4)+X(2)*X(5)+X(3)*X(6)-6*X(1)-6*X(5)-52
1146 L5=X(1)*X(7)+X(2)*X(8)+X(3)*X(9)-6*X(1)-12*X(8)-6*X(9)+64
1147 L6=X(4)*X(7)+X(5)*X(8)+X(6)*X(9)-6*X(5)-12*X(8)-6*X(9)+32
1221 L7=2*X(2)+2*X(3)-X(4)-X(5)-2*X(6)-X(7)-X(9)+18
1223 L8=X(1)+X(2)+2*X(3)+2*X(4)+2*X(6)-2*X(7)+X(8)-X(9)-38
1225 L9=X(1)+X(3)-2*X(4)+X(5)-X(6)+2*X(7)-2*X(8)+8
1230 P1NEWMAY=-ABS(L1)-ABS(L2)-ABS(L3)-ABS(L4)-ABS(L5)-ABS(L6)-ABS(L7)-ABS(L8)-ABS(L9)
1448 P=P1NEWMAY
1451 IF P<=M THEN 1670
1657 FOR KEW=1 TO 9
1658 A(KEW)=X(KEW)
1659 NEXT KEW
1661 M=P
1663 LL1=L1:LL2=L2:LL3=L3:LL4=L4:LL5=L5:LL6=L6:LL7=L7:LL8=L8:LL9=L9
1666 GOTO 128
1670 NEXT I
1890 IF M>-1 THEN 1912 ELSE 1999
1912 PRINT A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9)
1913 PRINT M,JJJJ
1914 PRINT LL1,LL2,LL3,LL4,LL5,LL6,LL7,LL8,LL9,M
1999 NEXT JJJJ
The BASIC computer program above was run with Microsoft's GW BASIC 3.11 interpreter, which is not a compiler. Its complete output through
JJJJ=-19985 is presented below. What immediately follows is a manual copy from the computer screen.
4 0 10 0 4
10 0 8 14
0 -27393
0 0 0 0 0
0 0 0 0 0
4 0 10 0 4
10 0 8 14
0 -25657
0 0 0 0 0
0 0 0 0 0
4 0 10 0 4
10 0 8 14
0 -24235
0 0 0 0 0
0 0 0 0 0
12 8 2 8 12
2 8 16 6
0 -19985
0 0 0 0 0
0 0 0 0 0
Interpreted in accordance with line 1912 through line 1914, the output above was obtained in four hours on a personal computer with an Intel 2.66 GHz. chip and the IBM basica/D interpreter.
References
[1] J. Rice. Numerical methods, software, and analysis, second ed. Academic Press, 1993.
[2] A.-M. Bellido. Construction of iteration functions for the simultaneous computation of the solutions of equations and algebraic systems. Numerical Algorithms 6 (1994) 317-351.
[3] A.-M. Bellido. "Construction of iteration functions for the simultaneous computation of the solutions of equations and algebraic systems," Seminaire d'ANALYSE NUMERIQUE, Annee 1991-1992, pp. I-1 to I-16. Universite Paul Sabatier de Toulouse, U.F.R. Mathematiques, Informatique, Gestion.
[4] W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery. Numerical recipes: the art of scientific computing, third ed. Cambridge University Press, 2007.
[5] Microsoft Corp. BASIC, second edition (May 1982), Version 1.10. Boca Raton, Florida: IBM Corp., Personal Computer, P. O. Box 1328-C, Boca Raton, Florida 33432, 1981.