The following computer program seeks to solve the following system of nine equations; see Morgan [3, page 15] and Floudas [1, page 660]. The problem is to solve simultaneously
X(1) * X(2) * X(3) * X(4) * X(5) * X(6) * X(7) * X(8) * X(9) - 1 = 0
2 * X(1) + X(2) + X(3) + X(4) + X(5) + X(6) + X(7) + X(8) + X(9) - 10 = 0
X(1) +2 * X(2) + X(3) + X(4) + X(5) + X(6) + X(7) + X(8) + X(9) - 10 = 0
X(1) + X(2) + 2 * X(3) + X(4) + X(5) + X(6) + X(7) + X(8) + X(9) - 10 = 0
X(1) + X(2) + X(3) + 2 * X(4) + X(5) + X(6) + X(7) + X(8) + X(9) - 10 = 0
X(1) + X(2) + X(3) + X(4) + 2 * X(5) + X(6) + X(7) + X(8) + X(9) - 10 = 0
X(1) + X(2) + X(3) + X(4) + X(5) + 2 * X(6) + X(7) + X(8) + X(9) - 10 = 0
X(1) + X(2) + X(3) + X(4) + X(5) + X(6) + 2 * X(7) + X(8) + X(9) - 10 = 0
X(1) + X(2) + X(3) + X(4) + X(5) + X(6) + X(7) + 2 * X(8) + X(9) - 10 = 0
The following computer program uses qb64v1000-win [5, 6].
0 DEFDBL A-Z
3 DEFINT 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) = -10 + RND * 20
95 NEXT KK
128 FOR I = 1 TO 60000 STEP 1
129 FOR K = 1 TO 9
131 X(K) = A(K)
132 NEXT K
155 FOR IPP = 1 TO FIX(1 + RND * 3)
181 B = 1 + FIX(RND * 9)
183 R = (1 - RND * 2) * A(B)
187 IF RND < .25 THEN X(B) = A(B) + RND * R ELSE IF RND < .333 THEN X(B) = A(B) + RND ^ 4 * R ELSE IF RND < .5 THEN X(B) = A(B) + RND ^ 7 * R ELSE X(B) = CINT(A(B))
191 NEXT IPP
195 X(1) = -2## * X(2) - X(3) - X(4) - X(5) - X(6) - X(7) - X(8) - X(9) + 10##
222 N1 = 2## * X(1) + X(2) + X(3) + X(4) + X(5) + X(6) + X(7) + X(8) + X(9) - 10##
224 N3 = X(1) + X(2) + 2## * X(3) + X(4) + X(5) + X(6) + X(7) + X(8) + X(9) - 10##
225 N4 = X(1) + X(2) + X(3) + 2## * X(4) + X(5) + X(6) + X(7) + X(8) + X(9) - 10##
226 N8 = X(1) + X(2) + X(3) + X(4) + 2## * X(5) + X(6) + X(7) + X(8) + X(9) - 10##
228 N9 = X(1) + X(2) + X(3) + X(4) + X(5) + 2## * X(6) + X(7) + X(8) + X(9) - 10##
231 NZ = X(1) + X(2) + X(3) + X(4) + X(5) + X(6) + 2## * X(7) + X(8) + X(9) - 10##
232 NL = X(1) + X(2) + X(3) + X(4) + X(5) + X(6) + X(7) + 2## * X(8) + X(9) - 10##
233 N5 = X(1) * X(2) * X(3) * X(4) * X(5) * X(6) * X(7) * X(8) * X(9) - 1##
1230 P = -ABS(N1) - ABS(N3) - ABS(N4) - ABS(N5) - ABS(N8) - ABS(N9) - ABS(NZ) - ABS(NL)
1451 IF P <= M THEN 1670
1657 FOR KEW = 1 TO 9
1658 A(KEW) = X(KEW)
1659 NEXT KEW
1661 M = P
1670 NEXT I
1890 IF M < -.005 THEN 1999
1912 PRINT A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), M, JJJJ
1999 NEXT JJJJ
This computer program was run with qb64v1000-win [5, 6]. Copied by hand from the screen, the computer program’s complete output through
JJJJ= 32000 is shown below:
1 1 1 1 1
1 1 1 1 0
-27528
.9743386025850583 .9743386027383917 .9743385977227542
.9743385967110256 .9743386070307317 .974338600657202
.9743386223574053 .9743386013943338. 1.230952566064706
-1.82853374971903D-04 -10040
1 1 1 1 1
1 1 1 1 0
-1391
.9998829513994836 .9998829434625747 .9998821558466593
.9998828594920054 .9998829356715228 .999883026305355
.9998826220110612 .9998730372727007 1.001064525076063
-1.276387574025548D-04 6828
Above there is no rounding by hand; it is just straight copying by hand from the screen.
On a personal computer with a Pentium Dual-Core CPU E5200 @2.50GHz, 2.50 GHz, 960 MB of RAM and with qb64v1000-win [5, 6], the wall-clock time for obtaining the output through JJJJ= 32000 was one hour and fifty minutes.
Acknowledgment
I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.
References
[1] C. A. Floudas, Deterministic Global Optimization. Kluwer Academic Publishers, 2000.
[2] 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.
[3] Alexander P. Morgan, A Method for Computing All Solutions to Systems of Polynomial Equations, ACM Transactions on Mathematical Software, Vol. 9, No. 1, March 1983, Pages 1-17. https://folk.uib.no/ssu029/pdf_file/Morgan83.pdf
[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] E.K. Virtanen (2008-05-26). “Interview With Galleon”.
http://www.basicprogramming.org/PCOPY! issue70/#galleoninterview
[6] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64
No comments:
Post a Comment