Iteration

 BBS: Inland Empire Archive
Date: 10-08-92 (08:28)             Number: 353
From: HYLTON PEIMER                Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Iteration                      Conf: (2) Quik_Bas
                         ---(cut)---

'Save this file to "iter.bas" then execute with QBASIC,QB/X.

'This small program will allow you to work out simultaneous
'equations by means of iteration. That is taking a number,
'plugging it into an equation and then using the output of
'that stage as the input for the next, until an answer is
'found. The lines EQUATION.ONE and EQUATION.TWO have the
'equation following. Remeber to express y in terms of x and
'vice-a-versa. The first x value of the iterate must be
'entered. Guessing any number will do.

DIM a, b, x, y AS SINGLE
OPEN "scrn:" FOR OUTPUT AS #1
INPUT "Initial x value:= ", x: CLS
PRINT #1, "Initial value for x is = "; x: PRINT #1,
PRINT #1, "Equation One";
PRINT #1, TAB(40); "Equation Two"

'###############################
EQUATION.ONE: y = 8 - x
'###############################

PRINT #1, "("; x; ","; y; ")  ";

'###############################
EQUATION.TWO: x = (23 - y) / 4
'###############################

s = 1
PRINT #1, TAB(40); "("; x; ","; y; ")"
IF a = x AND y = b THEN GOTO Found
g = g + 1: a = x:  b = y
GOTO EQUATION.ONE
Found:  PRINT #1, : PRINT #1, "Times to repeat : "; g
CLOSE #1

'The results can be used to sketch the situation. Simply
'connect a line the top left (X,Y) to the top right (X,Y)
'then to the second line (left) then right.

'Simultaneous equations where each x value has the identical
'coefficient do not work. One combination of y in terms of
'x will work. The other will not.

                            ---(end)---
... My other computer is an 80643437647386
--- Blue Wave/Max v2.01 [NR]
 * Origin: QuickSHARE's Australian HQ (03) 752-3949 (3:633/371.0)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET