home *** CD-ROM | disk | FTP | other *** search
-
- ~ SOLVE.MSE 12/12/84 Mouse House Software
- ~
- ~ This program solves a system of 3 equations
- ~ in 3 unknowns.
- ~
- ~ Fixed bug in $G macro on 10/29/85
-
- 2 s: ~ Number of seconds for pause.
-
- 125 N: ~ N = number of cycles in 1 second, where 1 cycle is
- ~ equal to the time it takes to execute w. 1 - w: w. ^
-
- #S,s.; 26 !' ~ Pause s seconds to allow interpreter
- ~ time to announce itself, then blank out
- ~ the screen.
-
- "!!SOLVE.MSE (10/29/85)!!" ~ Announce self
-
- #P,6,1;
-
- "a x + b y + c z = d!!"
- "e x + f y + g z = h!!"
- "i x + j y + k z = l!!!"
-
- "Cramer's Rule is used. Please use small integers.!!!"
-
- 'y r :
-
- "First run ? " ?' T :
-
- T. 'n - 0 = T. 'N - 0 = + ~ Check for n or N response
-
- [8 !' "No.!!" "Change a-l ? " ?' r :]
-
- r. 'y - 0 = r. 'Y - 0 = + ~ Check for y or Y response
-
- [ ~ If yes ...
-
- 8 !' "Yes." #S,s.; 26 !' ~ Complete response, wait s seconds
- ~ and then clear the screen.
-
- ~ Format the data entry screen
-
- #P,20,1;
-
- #P,17,25; "Enter Data "'!!'
- #P,20,7; "SPACE means use old value (re-run) or 0 (first run)."
-
-
- #P,3,15; "a=" #P,3,25; "b=" #P,3,35; "c=" #P,3,45; "d="
- #P,8,15; "e=" #P,8,25; "f=" #P,8,35; "g=" #P,8,45; "h="
- #P,13,15;"i=" #P,13,25;"j=" #P,13,35;"k=" #P,13,45;"l="
-
- ~ Get and display the coefficients and right hand side values
-
- #P,3,17; #G,a; a: #P,3,27; #G,b; b: #P,3,37; #G,c; c: #P,3,47; #G,d; d:
- #P,8,17; #G,e; e: #P,8,27; #G,f; f: #P,8,37; #G,g; g: #P,8,47; #G,h; h:
- #P,13,17; #G,i; i: #P,13,27; #G,j; j: #P,13,37; #G,k; k: #P,13,47; #G,l; l:
-
- ]
-
- r. 'n - 0 = r. 'N - 0 = + ~ Check for n or N response
-
- [ ~ If no ...
-
- 8 !' "No."]
-
- #S,s.; 26 !' ~ Pause and clear.
-
- ~ Load m with the deter m inant of the system
-
- #D ,a,b,c,
- e,f,g,
- i,j,k;
- m :
-
- m. 0 > m. 0 < + ~ If determinant is not 0
-
- [
- ~ Compute x's numerator
-
- #D ,d,b,c,
- h,f,g,
- l,j,k;
- x :
-
- ~ Compute y's numerator
-
- #D ,a,d,c,
- e,h,g,
- i,l,k;
- y :
-
- ~ Now z's
-
- #D ,a,b,d,
- e,f,h,
- i,j,l;
- z :
-
- "!!"
-
- ~ Show the answer
-
- "x = 0" 8!'#A,x. m. /;[x. m. / !" "]#A,x. m. \; [x. m. \ ! "/" #A,m.;!]
-
- 12!'"!!"
-
- "y = 0" 8!'#A,y. m. /;[y. m. / !" "]#A,y. m. \; [y. m. \ ! "/" #A,m.;!]
-
- 12!'"!!"
-
- "z = 0" 8!'#A,z. m. /;[z. m. / !" "]#A,z. m. \; [z. m. \ ! "/" #A,m.;!]
-
- 12!'"!!"
-
- "!"
- ]
-
- m. 0 = ["!!Determinant is 0. Method fails.!"]
-
- $D
-
- ~ Evaluate determinant
-
- ~ | 1%. 2%. 3%.|
- ~ | 4%. 5%. 6%.|
- ~ | 7%. 8%. 9%.|
-
- 5%. 9%. * 6%. 8%. * - 1%. *
- 4%. 9%. * 6%. 7%. * - 2%. * -
- 4%. 8%. * 5%. 7%. * - 3%. * +
-
- @
-
- $S ~ Pause 1% second(s)
- N. 1% * w: ( w. 1 - w: w. ^ )
-
- @
-
- $P ~ Position cursor at (1%,2%)
- 27 !' "=" 1% 1 - 32 + !' 2% 1 - 32 + !'
-
- @
-
- $G ~ Get a signed number
- ?' h: ~ Save leading character
-
- ~ Use old if SPACE and re-run.
- T. 'n - 0 = T. 'N - 0 = + [h. 32 = [1%. ! 1%. @]]
-
- ~ Use 0 if SPACE and first run.
- T. 'y - 0 = T. 'Y - 0 = + [h. 32 = [0 ! 0 @]]
-
- h. '- - 0 = [ ? l: 0 l. - @] ~ Support negative number entry.
-
- ~ loop til carriage return detected, adding in appropriate multiples
- ~ of 10
-
- h. 48 - l: (?' h: h. 13 - ^ l. 10 * h. 48 - + l:) l. @ ~ 10/29/85 fix
-
- $A ~ Absolute value of 1%
- 1% n : 0 n. - [ 0 n. - n : ] n.
-
- @
- h. 13 - ^ l. 10 * h. 48 - + l:) l. @ ~ 10/29/85 fix
-
- $A ~ A