ZX Review #1-2
31 декабря 1996

Spectrum in School - an article on numerical methods, "Seidel method for solving the linear.

<b>Spectrum in School</b> - an article on numerical methods,
                          SPECTRUM SCHOOL


         IFC.: Andrei Pugachev from g.Kovrov, Vladimir region
invites readers to court ZX REVIEW his material on the numerical
methods.

         REPORTER: In ZX REVIEW 1993 was published several 
articles on numerical methods. But then, this is a very 
interesting topic has been forgotten. To as a return to 
justice, especially for the magazine, I wrote three programs in 
BASIC for numerical methods. This is a program for solving the 
linear "method Seidel (a very useful thing - is a modification 
of the method of simple iterations), and two programs for 
finding the minimum of functions: the method of golden section 
and the method of dichotomy. 


                  Seidel method for solving the linear.


         Allows us to obtain solution with a given error in
limited number of iterations. Method converges provided that
diagonal coefficients of absolute value equal to or greater
any other factor in its row.

A11 A12 A13 ... A1n B1
A21 A22 A23 ... A2n B2
A31 A32 A33 ... A3n B3
... ... ... ... ... ..
An1 An2 An3 ... Ann Bn


         Program in BASIC:

5 REM Input
10 DIM A (30,30): DIM B (30): DIM Z (30): DIM D (30): DIM X (30)
20 INPUT "Number of (<= 30)"; KOLUR
40 INPUT "error of method"; EPS
50 FOR I = 1 TO KOLUR
60 FOR J = 1 TO KOLUR
70 INPUT "Enter the A [i, j]"; A (I, J)
80 PRINT "A ["; I ;","; J ;"]="; A (I, J)
90 NEXT J
100 INPUT "Type B [i]"; B (I)
110 LET Z (I) = B (I) / A (I, I)
120 PRINT "B ["; I ;"]="; B (I)
130 NEXT I
135 REM Analiz
140 FOR I = 1 TO KOLUR
150 FOR J = 1 NJ KOLUR
160 IF ABS (A (I, I))  EPS THEN LET K = 1: REM accuracy 
is not reached 270 LET X (I) = Z (I)-D (I) / A (I, I): REM 
Correction solutions 280 LET Z (I) = X (I): REM Filling for use 
at a given iteration 290 NEXT I

300 LET S = S +1
310 PRINT "Iteration number"; S
320 FOR I = 1 TO KOLUR
330 PRINT "X ["; I ;"]="; X (I); "delta_X =";-D (I) / D (I, I)
340 NEXT I
350 PRINT "To continue press Enter"
355 PAUSE 0
360 IF K <> 0 THEN GO TO 200: REM accuracy achieved
365 REM Result
380 PRINT "Results:
390 PRINT "Number of iteration ="; S
400 FOR I = 1 TO KOLUR
410 PRINT "X ["; I ;"]="; X (I)
420 NEXT I



                       The method of "golden section" search

                           minimum of the function y = F (x)


10 LET C = 0.618: LET D = 0.382
13 INPUT "Start segment ="; A: INPUT "Cut End ="; B: IF A> = B 
THEN 

   GO TO 13
15 INPUT "margin of error ="; EPS: GOSUB 58: GOSUB 70
1921 IF Y1> Y2 THEN GO TO 36
26 LET B = X2: LET X2 = X1: LET Y2 = Y1
27 GOSUB 58: GO TO 43
36 LET A = X1: LET X1 = X2: LET Y1 = Y2
37 GOSUB 70
1943 IF ABS (B-A)> EPS THEN GO TO 21
50 PRINT "Result:"
52 LET X = (A + B) / 2: PRINT "X_min ="; X: STOP
58 LET X1 = C * A + D * B: LET X = X1: GOSUB 82: LET Y1 = Y: 
RETURN 70 LET X2 = D * A + C * B: LET X = X2: GOSUB 82: LET Y2 
= Y: RETURN 82 LET Y =......................... : REM Enter the 
equation under study 



                      Search for the minimum one-dimensional 
function 

                             method of "dichotomy"

10 DEF FN F (X )=................ : REM Enter the function
20 INPUT "Start segment"; A
30 INPUT "Cut End"; B
40 INPUT "Tolerance"; EPS
50 REM Metod
60 LET I = 0
70 LET C = (A + B) / 2
80 IF FN F (C-EPS/10) <FN F (C + EPS/10) THEN GO TO 100
90 LET A = C-EPS/10: GO TO 110
100 LET B = C + EPS/10
110 LET I = I +1
120 PRINT "C ="; C; "Iteration number:"; I
130 IF (B-A)> EPS THEN GO TO 70
140 PRINT "Result:"
150 PRINT "X_min ="; C; "Number of iteration ="; I





Other articles:

Business Card - an overview of electronic journals for the ZX Spectrum.

Computer novella - In the game "The Saga"

Computers, we choose - Finalization of the computer "ATM-TURBO".

Spectrum in School - an article on numerical methods, "Seidel method for solving the linear.

Entry - greetings from the Editor.

New Programs - copier ABCDcopy and utility for formatting floppy disks Floppy Format.

Forum - questions and answers on games: Jungle Warrior, Buratino, Streaker, Paris Dakar, Bloodwych, Hero Quest, Apollo, Cliff Hanger, Cyber Hordes, Paradise Valley, Star Drive, Laser Platoon, Movie, Where Time Stood Still, The Sceptre, Carrier Command, etc.

Expert Tips - the strategic game Wellingsto at Waterloo.

Expert Tips - the strategic game of Napoleon.

Expert Tips - for the game Star Fox.

Crossing Dragon - Dungeons & Dragons (the first chapter of a book on adventyurnyh games).

TR-DOS for beginners - 5 th chapter of the book "General information on the disk system TP DOS.

Returning to the printed - the last file dizzasemblera TR-DOS.

reader-reader - On the hardware, software and Other Computer Profi ...

reader-reader - Recover lost data.

reader-reader - Spectrum and expert systems.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Miscellaneous - Amiga: questions and answers.
Enlight'96 - members and guests of the festival (by B. MATERIAL Mednonogova).
WANTED - Searching software ...

В этот день...   21 November