home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / misc / mouse.lbr / SOLVE.MZE / SOLVE.MSE
Encoding:
Text File  |  1988-07-12  |  3.4 KB  |  169 lines

  1.  
  2. ~  SOLVE.MSE  12/12/84   Mouse House Software
  3. ~
  4. ~  This program solves a system of 3 equations
  5. ~  in 3 unknowns.
  6. ~
  7. ~  Fixed bug in $G macro on 10/29/85  
  8.  
  9. 2 s:      ~ Number of seconds for pause.
  10.  
  11. 125 N:    ~ N = number of cycles in 1 second, where 1 cycle is
  12.           ~ equal to the time it takes to execute w. 1 - w: w. ^
  13.  
  14. #S,s.; 26 !' ~ Pause s seconds to allow interpreter
  15.              ~ time to announce itself, then blank out
  16.              ~ the screen.
  17.  
  18. "!!SOLVE.MSE (10/29/85)!!"  ~ Announce self
  19.  
  20. #P,6,1;
  21.  
  22. "a x  +  b y  +  c z   =   d!!"
  23. "e x  +  f y  +  g z   =   h!!"
  24. "i x  +  j y  +  k z   =   l!!!"
  25.  
  26. "Cramer's Rule is used.  Please use small integers.!!!"
  27.  
  28. 'y r :
  29.  
  30. "First run ? " ?' T :
  31.  
  32. T. 'n - 0 = T. 'N - 0 = +        ~ Check for n or N response
  33.  
  34. [8 !' "No.!!" "Change a-l ? " ?' r :]
  35.  
  36. r. 'y - 0 = r. 'Y - 0 = +        ~ Check for y or Y response
  37.  
  38. [ ~ If yes ...
  39.  
  40. 8 !' "Yes." #S,s.; 26 !'  ~ Complete response, wait s seconds
  41.                           ~ and then clear the screen.
  42.  
  43. ~ Format the data entry screen
  44.  
  45. #P,20,1;
  46.  
  47. #P,17,25; "Enter Data "'!!'
  48. #P,20,7; "SPACE means use old value (re-run) or 0 (first run)."
  49.  
  50.  
  51. #P,3,15; "a=" #P,3,25; "b=" #P,3,35; "c=" #P,3,45; "d="
  52. #P,8,15; "e=" #P,8,25; "f=" #P,8,35; "g=" #P,8,45; "h="
  53. #P,13,15;"i=" #P,13,25;"j=" #P,13,35;"k=" #P,13,45;"l="
  54.  
  55. ~ Get and display the coefficients and right hand side values
  56.  
  57. #P,3,17;  #G,a; a:  #P,3,27;  #G,b; b: #P,3,37;  #G,c; c:  #P,3,47;  #G,d; d:
  58. #P,8,17;  #G,e; e:  #P,8,27;  #G,f; f: #P,8,37;  #G,g; g:  #P,8,47;  #G,h; h:
  59. #P,13,17; #G,i; i:  #P,13,27; #G,j; j: #P,13,37; #G,k; k:  #P,13,47; #G,l; l:
  60.  
  61. ]
  62.  
  63. r. 'n - 0 = r. 'N - 0 = +        ~ Check for n or N response
  64.  
  65. [ ~ If no ...
  66.  
  67. 8 !' "No."]
  68.  
  69. #S,s.; 26 !'  ~ Pause and clear.
  70.  
  71. ~  Load m with the deter m inant of the system
  72.  
  73. #D ,a,b,c,
  74.     e,f,g,
  75.     i,j,k;
  76. m :
  77.  
  78. m. 0 > m. 0 < +   ~ If determinant is not 0
  79.  
  80. [
  81. ~  Compute x's numerator
  82.  
  83. #D ,d,b,c,
  84.     h,f,g,
  85.     l,j,k;
  86. x :
  87.  
  88. ~  Compute y's numerator
  89.  
  90. #D ,a,d,c,
  91.     e,h,g,
  92.     i,l,k;
  93. y :
  94.  
  95. ~  Now z's
  96.  
  97. #D ,a,b,d,
  98.     e,f,h,
  99.     i,j,l;
  100. z :
  101.  
  102. "!!"
  103.  
  104. ~  Show the answer
  105.  
  106. "x = 0" 8!'#A,x. m. /;[x. m. / !" "]#A,x. m. \; [x. m. \ ! "/" #A,m.;!]
  107.  
  108. 12!'"!!"
  109.  
  110. "y = 0" 8!'#A,y. m. /;[y. m. / !" "]#A,y. m. \; [y. m. \ ! "/" #A,m.;!]
  111.  
  112. 12!'"!!"
  113.  
  114. "z = 0" 8!'#A,z. m. /;[z. m. / !" "]#A,z. m. \; [z. m. \ ! "/" #A,m.;!]
  115.  
  116. 12!'"!!"
  117.  
  118. "!"
  119. ]
  120.  
  121. m. 0 = ["!!Determinant is 0.  Method fails.!"]
  122.  
  123. $D
  124.  
  125. ~ Evaluate determinant
  126.  
  127. ~     | 1%.  2%.  3%.|
  128. ~     | 4%.  5%.  6%.|
  129. ~     | 7%.  8%.  9%.|
  130.  
  131. 5%. 9%. * 6%. 8%. * - 1%. *
  132. 4%. 9%. * 6%. 7%. * - 2%. * -
  133. 4%. 8%. * 5%. 7%. * - 3%. * +
  134.  
  135. @
  136.  
  137. $S ~ Pause 1% second(s)
  138. N. 1% * w: ( w. 1 - w: w. ^ )
  139.  
  140. @
  141.  
  142. $P   ~ Position cursor at (1%,2%)
  143. 27 !' "=" 1% 1 - 32 + !' 2% 1 - 32 + !'
  144.  
  145. @
  146.  
  147. $G              ~ Get a signed number
  148. ?' h:           ~ Save leading character
  149.  
  150. ~ Use old if SPACE and re-run.
  151. T. 'n - 0 = T. 'N - 0 = + [h. 32 = [1%. ! 1%. @]]
  152.  
  153. ~ Use 0 if SPACE and first run.
  154. T. 'y - 0 = T. 'Y - 0 = + [h. 32 = [0 ! 0 @]]
  155.  
  156. h. '- -  0 = [ ? l: 0 l. - @]     ~ Support negative number entry.
  157.  
  158. ~ loop til carriage return detected, adding in appropriate multiples
  159. ~ of 10
  160.  
  161. h. 48 - l: (?' h: h. 13 - ^ l. 10 * h. 48 - + l:) l. @  ~  10/29/85 fix
  162.  
  163. $A     ~ Absolute value of 1%
  164. 1% n : 0 n. - [ 0 n. - n : ] n.
  165.  
  166. @
  167.  h. 13 - ^ l. 10 * h. 48 - + l:) l. @  ~  10/29/85 fix
  168.  
  169. $A     ~ A