The Domino Method for Solving Nonlinear Systems of Equations, QB64 Edition

Jsun Yui Wong

Based on the computer program in Wong [6], the computer program listed below seeks to solve simultaneously the following system of four nonlinear equations in Greenspan and Casulli [2, p. 44].

– 10*X(1) +5*X(2) – EXP(X(1) ) = 0

5* X(1) -10*X(2) +5*X(3) -EXP(X(2) ) = 0

5* X(2) -10*X(3) +5*X(4) -EXP(X(3) ) = 0

5*X(3) – 10*X(4) -EXP(X(4) ) ) = 0.

The following computer program uses qb64v1000-win [4, 5].

0 DEFDBL A-Z
1 DEFINT I, J, K
2 DIM B(99), N(99), A(2002), H(99), L(99), U(99), X(2002), D(111), P(111), PS(33), J(99), AA(99), HR(32), HHR(32), LHS(44), PLHS(44), LB(22), UB(22), PX(44), J44(44)
88 FOR JJJJ = -32000 TO 32000
89 RANDOMIZE JJJJ
90 M = -3D+30
100 FOR KLQ = 1 TO 4

101 A(KLQ) = FIX(-25 + RND * 50)

102 NEXT KLQ

128 FOR I = 1 TO 1000

129 FOR KKQQ = 1 TO 4
130 X(KKQQ) = A(KKQQ)
131 NEXT KKQQ
149 FOR IPP = 1 TO FIX(1 + RND * 3)
150 B = 1 + FIX(RND * 4)
155 R = (1 – RND * 2) * A(B)
167 X(B) = A(B) + (RND ^ (RND * 10)) * R
169 NEXT IPP
171 IF X(1) > 80 THEN 1670
174 IF X(4) > 80 THEN 1670
181 X(2) = (10 * X(1) + EXP(X(1))) / 5
183 X(3) = (10 * X(4) + EXP(X(4))) / 5
184 IF X(2) > 80 THEN 1670
185 IF X(3) > 80 THEN 1670
186 X(5) = 5 * X(1) – 10 * X(2) + 5 * X(3) – EXP(X(2))
188 X(6) = 5 * X(2) – 10 * X(3) + 5 * X(4) – EXP(X(3))
340 P = -ABS(X(5)) – ABS(X(6))
1111 IF P <= M THEN 1670
1452 M = P
1454 FOR KLX = 1 TO 6

1455 A(KLX) = X(KLX)
1456 NEXT KLX
1557 GOTO 128
1670 NEXT I
1889 IF M < -.0000001 THEN 1999

1904 PRINT A(1), A(2), A(3)
1907 PRINT A(4), A(5), A(6)
1989 PRINT M, JJJJ
1999 NEXT JJJJ

This computer program was run with qb64v1000-win [4, 5]. Copied by hand from the screen, the computer program’s complete output through
JJJJ= -31997 is shown below:

-.282813847989135          -.4148956819502774              -.41489568194162
-.2828138479851097          1.40658928948767D-10          2.520739172950925D-11
-1.658663206782762D-10          -31998
-.2828138479756393          -.4148956819212518                -.4148956819213826
-.2828138479757001          -1.008082506359642D-13          1.644295810621088D-12
-1.745104061257052D-12          -31997

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= -31997 was about two seconds–counting from “Starting program…”.

Acknowledgment

I would like to acknowledge the encouragement of Roberta Clark and Tom Clark.

References

[1] Richard L. Burden, J. Douglas Faires, Numerical Analysis, Eighth Edition. Publisher: Brooks/Cole, 2005.
.
[2] Donald Greenspan, Vincenzo Casulli, Numerical Analysis for Applied Mathematics, Science, and Engineering. Addison-Wesley Publishing Company, 1988.

[3] 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.

[4] E.K. Virtanen (2008-05-26). “Interview With Galleon”.
http://www.basicprogramming.org/PCOPY!issue70/#galleoninterview

[5] Wikipedia, QB64, https://en.wikipedia.org/wiki/QB64

[6] Jsun Yui Wong (May 2, 2011). The Domino Method for Solving Nonlinear Systems of Equations.
https://computationalresultsfromcomputerprograms.wordpress.com/2011/05/02/the-domino-method-for-solving-nonlinear-systems-of equations/