r38_0001.html 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603
  1. <a name=r38_0001>
  2. <title>IDENTIFIER</title></a>
  3. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  4. E"></p>
  5. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  6. <b>IDENTIFIER</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>type</b><P>
  7. <P>
  8. Identifiers in REDUCE consist of one or more alphanumeric characters, of
  9. which the first must be alphabetical. The maximum number of characters
  10. allowed is system dependent, but is usually over 100. However, printing
  11. is simplified if they are kept under 25 characters.
  12. <P>
  13. <P>
  14. You can also use special characters in your identifiers, but each must be
  15. preceded by an exclamation point <em>!</em> as an escape character. Useful
  16. special characters are <em> # $ % ^ &amp; * - + = ? &lt; &gt; ~ | / !</em> and
  17. the space. Note that the use of the exclamation point as a special
  18. character requires a second exclamation point as an escape character.
  19. The underscore <em>_</em> is special in this regard. It must be preceded
  20. by an escape character in the first position in an identifier, but is
  21. treated like a normal letter within an identifier.
  22. <P>
  23. <P>
  24. Other characters, such as <em>( ) # ; ` ' &quot;</em> can also be used if
  25. preceded by a <em>!</em>, but as they have special meanings to the Lisp
  26. reader it is best to avoid them to avoid confusion.
  27. <P>
  28. <P>
  29. Many system identifiers have * before or after their names, or - between
  30. words. If you accidentally pick one of these names for your own identifier,
  31. it could have disastrous effects. For this reason it is wise not to include
  32. * or - anywhere in your identifiers.
  33. <P>
  34. <P>
  35. You will notice that REDUCE does not use the escape characters when it prints
  36. identifiers containing special characters; however, you still must use them
  37. when you refer to these identifiers. Be careful when editing statements
  38. containing escaped special characters to treat the character and its escape
  39. as an inseparable pair.
  40. <P>
  41. <P>
  42. Identifiers are used for variable names, labels for <em>go to</em> statements,
  43. and names of arrays, matrices, operators, and procedures. Once an identifier is
  44. used as a matrix, array, scalar or operator identifier, it may not be used
  45. again as a matrix, array or operator. An operator or array identifier may
  46. later be used as a scalar without problems, but a matrix identifier cannot be
  47. used as a scalar. All procedures are entered into the system as operators, so
  48. the name of a procedure may not be used as a matrix, array, or operator
  49. identifier either.
  50. <P>
  51. <P>
  52. <a name=r38_0002>
  53. <title>KERNEL</title></a>
  54. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  55. E"></p>
  56. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  57. <b>KERNEL</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>type</b><P>
  58. <P>
  59. A <em>kernel</em> is a form that cannot be modified further by the REDUCE
  60. canonical simplifier. Scalar variables are always kernels. The
  61. other important class of kernels are operators with their arguments.
  62. Some examples should help clarify this concept:
  63. <P>
  64. <P>
  65. <p><pre><tt>
  66. Expression Kernel?
  67. x Yes
  68. varname Yes
  69. cos(a) Yes
  70. log(sin(x**2)) Yes
  71. a*b No
  72. (x+y)**4 No
  73. matrix-identifier No
  74. </tt></pre><p>Many REDUCE operators expect kernels among their arguments. Error
  75. messages
  76. result from attempts to use non-kernel expressions for these arguments.
  77. <P>
  78. <P>
  79. <a name=r38_0003>
  80. <title>STRING</title></a>
  81. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  82. E"></p>
  83. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  84. <b>STRING</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>type</b><P>
  85. <P>
  86. A <em>string</em> is any collection of characters enclosed in double quotation
  87. marks (<em>&quot;</em>). It may be used as an argument for a variety of commands
  88. and operators, such as <em>in</em>, <em>rederr</em> and <em>write</em>.
  89. <P> <H3>
  90. examples: </H3>
  91. <p><pre><tt>
  92. write &quot;this is a string&quot;;
  93. this is a string
  94. write a, &quot; &quot;, b, &quot; &quot;,c,&quot;!&quot;;
  95. A B C!
  96. </tt></pre><p><P>
  97. <P>
  98. <a name=r38_0004>
  99. <title>Concepts</title></a>
  100. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  101. E"></p>
  102. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  103. <b>Concepts</b><menu>
  104. <li><a href=r38_0001.html#r38_0001>IDENTIFIER type</a><P>
  105. <li><a href=r38_0001.html#r38_0002>KERNEL type</a><P>
  106. <li><a href=r38_0001.html#r38_0003>STRING type</a><P>
  107. </menu>
  108. <a name=r38_0005>
  109. <title>assumptions</title></a>
  110. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  111. E"></p>
  112. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  113. <b>ASSUMPTIONS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>variable</b><P>
  114. <P>
  115. <P>
  116. <P>
  117. After solving a linear or polynomial equation system
  118. with parameters, the variable <em>assumptions</em> contains a list
  119. of side relations for the parameters. The solution is valid only
  120. as long as none of these expression is zero.
  121. <P> <H3>
  122. examples: </H3>
  123. <p><pre><tt>
  124. solve({a*x-b*y+x,y-c},{x,y});
  125. b*c
  126. {{x=-----,y=c}}
  127. a + 1
  128. assumptions;
  129. {a + 1}
  130. </tt></pre><p><P>
  131. <P>
  132. <a name=r38_0006>
  133. <title>CARD_NO</title></a>
  134. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  135. E"></p>
  136. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  137. <b>CARD\_NO</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>variable</b><P>
  138. <P>
  139. <P>
  140. <P>
  141. <em>card_no</em>sets the total number of cards allowed in a Fortran
  142. output statement when <em>fort</em> is on. Default is 20.
  143. <P>
  144. <P>
  145. <P> <H3>
  146. examples: </H3>
  147. <p><pre><tt>
  148. on fort;
  149. card_no := 4;
  150. CARD_NO=4.
  151. z := (x + y)**15;
  152. ANS1=5005.*X**6*Y**9+3003.*X**5*Y**10+1365.*X**4*Y**
  153. . 11+455.*X**3*Y**12+105.*X**2*Y**13+15.*X*Y**14+Y**15
  154. Z=X**15+15.*X**14*Y+105.*X**13*Y**2+455.*X**12*Y**3+
  155. . 1365.*X**11*Y**4+3003.*X**10*Y**5+5005.*X**9*Y**6+
  156. . 6435.*X**8*Y**7+6435.*X**7*Y**8+ANS1
  157. </tt></pre><p>Twenty total cards means 19 continuation cards. You may set it for
  158. more
  159. if your Fortran system allows more. Expressions are broken apart in a
  160. Fortran-compatible way if they extend for more than <em>card_no</em>
  161. continuation cards.
  162. <P>
  163. <P>
  164. <P>
  165. <a name=r38_0007>
  166. <title>E</title></a>
  167. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  168. E"></p>
  169. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  170. <b>E</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>constant</b><P>
  171. <P>
  172. The constant <em>e</em> is reserved for use as the base of the natural
  173. logarithm. Its value is approximately 2.71828284590, which REDUCE gives
  174. to the current decimal precision when the switch
  175. <a href=r38_0300.html#r38_0330>rounded</a> is on.
  176. <P>
  177. <P>
  178. <em>e</em>may be used as an iterative variable in a
  179. <a href=r38_0001.html#r38_0047>for</a> statement,
  180. or as a local variable or a
  181. <a href=r38_0050.html#r38_0055>procedure</a>. If <em>e</em> is defined
  182. as a local
  183. variable inside the procedure, the normal definition as the base of the
  184. natural logarithm would be suspended inside the procedure.
  185. <P>
  186. <P>
  187. <P>
  188. <a name=r38_0008>
  189. <title>EVAL_MODE</title></a>
  190. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  191. E"></p>
  192. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  193. <b>EVAL\_MODE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>variable</b><P>
  194. <P>
  195. <P>
  196. <P>
  197. The system variable <em>eval_mode</em> contains the current mode, either
  198. <a href=r38_0150.html#r38_0186>algebraic</a> or
  199. <a href=r38_0200.html#r38_0221>symbolic</a>.
  200. <P>
  201. <P>
  202. <P> <H3>
  203. examples: </H3>
  204. <p><pre><tt>
  205. EVAL_MODE;
  206. ALGEBRAIC
  207. </tt></pre><p>Some commands do not behave the same way in algebraic and symbolic
  208. modes.
  209. <P>
  210. <P>
  211. <P>
  212. <a name=r38_0009>
  213. <title>FORT_WIDTH</title></a>
  214. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  215. E"></p>
  216. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  217. <b>FORT\_WIDTH</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>variable</b><P>
  218. <P>
  219. <P>
  220. <P>
  221. The <em>fort_width</em> variable sets the number of characters in a line of
  222. Fortran-compatible output produced when the
  223. <a href=r38_0250.html#r38_0289>fort</a> switch is on.
  224. Default is 70.
  225. <P>
  226. <P>
  227. <P> <H3>
  228. examples: </H3>
  229. <p><pre><tt>
  230. fort_width := 30;
  231. FORT_WIDTH := 30
  232. on fort;
  233. df(sin(x**3*y),x);
  234. ANS=3.*COS(X
  235. . **3*Y)*X**2*
  236. . Y
  237. </tt></pre><p><em>fort_width</em>includes the usually blank characters at the be
  238. ginning
  239. of the card. As you may notice above, it is conservative and makes the
  240. lines even shorter than it was told.
  241. <P>
  242. <P>
  243. <P>
  244. <a name=r38_0010>
  245. <title>HIGH_POW</title></a>
  246. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  247. E"></p>
  248. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  249. <b>HIGH\_POW</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>variable</b><P>
  250. <P>
  251. <P>
  252. <P>
  253. The variable <em>high_pow</em> is set by
  254. <a href=r38_0100.html#r38_0141>coeff</a> to the highest power
  255. of the variable of interest in the given expression. You can access this
  256. variable for use in further computation or display.
  257. <P>
  258. <P>
  259. <P> <H3>
  260. examples: </H3>
  261. <p><pre><tt>
  262. coeff((x+1)^5*(x*(y+3)^2)^2,x);
  263. {0,
  264. 0,
  265. 4 3 2
  266. Y + 12*Y + 54*Y + 108*Y + 81,
  267. 4 3 2
  268. 5*(Y + 12*Y + 54*Y + 108*Y + 81),
  269. 4 3 2
  270. 10*(Y + 12*Y + 54*Y + 108*Y + 81),
  271. 4 3 2
  272. 10*(Y + 12*Y + 54*Y + 108*Y + 81),
  273. 4 3 2
  274. 5*(Y + 12*Y + 54*Y + 108*Y + 81),
  275. 4 3 2
  276. Y + 12*Y + 54*Y + 108*Y + 81}
  277. high_pow;
  278. 7
  279. </tt></pre><p>
  280. <a name=r38_0011>
  281. <title>I</title></a>
  282. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  283. E"></p>
  284. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  285. <b>I</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>constant</b><P>
  286. <P>
  287. <P>
  288. <P>
  289. REDUCE knows <em>i</em> is the square root of -1,
  290. and that i^2 = -1.
  291. <P>
  292. <P>
  293. <P> <H3>
  294. examples: </H3>
  295. <p><pre><tt>
  296. (a + b*i)*(c + d*i);
  297. A*C + A*D*I + B*C*I - B*D
  298. i**2;
  299. -1
  300. </tt></pre><p><em>i</em>cannot be used as an identifier. It is all right to use
  301. <em>i</em>
  302. as an index variable in a <em>for</em> loop, or as a local (<em>scalar</em>)
  303. variable inside a <em>begin...end</em> block, but it loses its definition as
  304. the square root of -1 inside the block in that case.
  305. <P>
  306. <P>
  307. Only the simplest properties of i are known by REDUCE unless
  308. the switch
  309. <a href=r38_0250.html#r38_0274>complex</a> is turned on, which implements full c
  310. omplex
  311. arithmetic in factoring, simplification, and functional values.
  312. <em>complex</em> is ordinarily off.
  313. <P>
  314. <P>
  315. <P>
  316. <a name=r38_0012>
  317. <title>INFINITY</title></a>
  318. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  319. E"></p>
  320. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  321. <b>INFINITY</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>constant</b><P>
  322. <P>
  323. The name <em>infinity</em> is used to represent the infinite positive number.
  324. However, at the present time, arithmetic in terms of this operator reflects
  325. finite arithmetic, rather than true operations on infinity.
  326. <P>
  327. <P>
  328. <a name=r38_0013>
  329. <title>LOW_POW</title></a>
  330. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  331. E"></p>
  332. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  333. <b>LOW\_POW</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>variable</b><P>
  334. <P>
  335. <P>
  336. <P>
  337. The variable <em>low_pow</em> is set by
  338. <a href=r38_0100.html#r38_0141>coeff</a> to the lowest power
  339. of the variable of interest in the given expression. You can access this
  340. variable for use in further computation or display.
  341. <P>
  342. <P>
  343. <P> <H3>
  344. examples: </H3>
  345. <p><pre><tt>
  346. coeff((x+2*y)**6,y);
  347. 6
  348. {X ,
  349. 5
  350. 12*X ,
  351. 4
  352. 60*X ,
  353. 3
  354. 160*X ,
  355. 2
  356. 240*X ,
  357. 192*X,
  358. 64}
  359. low_pow;
  360. 0
  361. coeff(x**2*(x*sin(y) + 1),x);
  362. {0,0,1,SIN(Y)}
  363. low_pow;
  364. 2
  365. </tt></pre><p>
  366. <a name=r38_0014>
  367. <title>NIL</title></a>
  368. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  369. E"></p>
  370. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  371. <b>NIL</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>constant</b><P>
  372. <P>
  373. <P>
  374. <P>
  375. <em>nil</em>represents the truth value false in symbolic mode, and is
  376. a synonym for 0 in algebraic mode. It cannot be used for any other
  377. purpose, even inside procedures or
  378. <a href=r38_0001.html#r38_0047>for</a> loops.
  379. <P>
  380. <P>
  381. <a name=r38_0015>
  382. <title>PI</title></a>
  383. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  384. E"></p>
  385. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  386. <b>PI</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>constant</b><P>
  387. <P>
  388. The identifier <em>pi</em> is reserved for use as the circular constant.
  389. Its value is given by 3.14159265358..., which REDUCE gives to the current
  390. decimal precision when REDUCE is in a floating-point mode.
  391. <P>
  392. <P>
  393. <em>pi</em>may be used as a looping variable in a
  394. <a href=r38_0001.html#r38_0047>for</a> statement,
  395. or as a local variable in a
  396. <a href=r38_0050.html#r38_0055>procedure</a>. Its value in such cases
  397. will be taken from the local environment.
  398. <P>
  399. <P>
  400. <P>
  401. <a name=r38_0016>
  402. <title>requirements</title></a>
  403. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  404. E"></p>
  405. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  406. <b>REQUIREMENTS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>variable</b><P>
  407. <P>
  408. <P>
  409. <P>
  410. After an attempt to solve an inconsistent equation system
  411. with parameters, the variable <em>requirements</em> contains a list
  412. of expressions. These expressions define a set of conditions implicitly
  413. equated with zero. Any solution to this system defines a setting for
  414. the parameters sufficient to make the original system consistent.
  415. <P> <H3>
  416. examples: </H3>
  417. <p><pre><tt>
  418. solve({x-a,x-y,y-1},{x,y});
  419. {}
  420. requirements;
  421. {a - 1}
  422. </tt></pre><p><P>
  423. <P>
  424. <a name=r38_0017>
  425. <title>ROOT_MULTIPLICITIES</title></a>
  426. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  427. E"></p>
  428. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  429. <b>ROOT\_MULTIPLICITIES</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>variable</b><P>
  430. <P>
  431. <P>
  432. <P>
  433. The <em>root_multiplicities</em> variable is set to the list of the
  434. multiplicities of the roots of an equation by the
  435. <a href=r38_0150.html#r38_0179>solve</a> operator.
  436. <P>
  437. <P>
  438. <a href=r38_0150.html#r38_0179>solve</a>returns its solutions in a list. The mul
  439. tiplicities of
  440. each solution are put in the corresponding locations of the list
  441. <em>root_multiplicities</em>.
  442. <P>
  443. <P>
  444. <P>
  445. <a name=r38_0018>
  446. <title>T</title></a>
  447. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  448. E"></p>
  449. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  450. <b>T</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>constant</b><P>
  451. <P>
  452. The constant <em>t</em> stands for the truth value true. It cannot be used
  453. as a scalar variable in a
  454. <a href=r38_0001.html#r38_0041>block</a>, as a looping variable in a
  455. <a href=r38_0001.html#r38_0047>for</a> statement or as an
  456. <a href=r38_0200.html#r38_0211>operator</a> name.
  457. <P>
  458. <P>
  459. <a name=r38_0019>
  460. <title>Variables</title></a>
  461. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  462. E"></p>
  463. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  464. <b>Variables</b><menu>
  465. <li><a href=r38_0001.html#r38_0005>assumptions variable</a><P>
  466. <li><a href=r38_0001.html#r38_0006>CARD\_NO variable</a><P>
  467. <li><a href=r38_0001.html#r38_0007>E constant</a><P>
  468. <li><a href=r38_0001.html#r38_0008>EVAL\_MODE variable</a><P>
  469. <li><a href=r38_0001.html#r38_0009>FORT\_WIDTH variable</a><P>
  470. <li><a href=r38_0001.html#r38_0010>HIGH\_POW variable</a><P>
  471. <li><a href=r38_0001.html#r38_0011>I constant</a><P>
  472. <li><a href=r38_0001.html#r38_0012>INFINITY constant</a><P>
  473. <li><a href=r38_0001.html#r38_0013>LOW\_POW variable</a><P>
  474. <li><a href=r38_0001.html#r38_0014>NIL constant</a><P>
  475. <li><a href=r38_0001.html#r38_0015>PI constant</a><P>
  476. <li><a href=r38_0001.html#r38_0016>requirements variable</a><P>
  477. <li><a href=r38_0001.html#r38_0017>ROOT\_MULTIPLICITIES variable</a><P>
  478. <li><a href=r38_0001.html#r38_0018>T constant</a><P>
  479. </menu>
  480. <a name=r38_0020>
  481. <title>semicolon</title></a>
  482. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  483. E"></p>
  484. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  485. <b>;</b> _ _ _ <b>SEMICOLON</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  486. <P>
  487. The semicolon is a statement delimiter, indicating results are to be printed
  488. when used in interactive mode.
  489. <P>
  490. <P>
  491. <P> <H3>
  492. examples: </H3>
  493. <p><pre><tt>
  494. (x+1)**2;
  495. 2
  496. X + 2*X + 1
  497. df(x**2 + 1,x);
  498. 2*X
  499. </tt></pre><p>Entering a <em>Return</em> without a semicolon or dollar sign resu
  500. lts in a
  501. prompt on the following line. A semicolon or dollar sign can be
  502. added at this point to execute the statement. In interactive mode, a
  503. statement that is ended with a semicolon and <em>Return</em> has its results
  504. printed on the screen.
  505. <P>
  506. <P>
  507. Inside a group statement <em>&lt;&lt;</em>...<em>&gt;&gt;</em>
  508. or a <em>begin</em>...<em>end</em> block, a
  509. semicolon or dollar sign separates individual REDUCE statements. Since
  510. results are not printed from a block without a specific <em>return</em>
  511. statement, there is no difference between using the semicolon or dollar
  512. sign. In a group statement, the last value produced is the value
  513. returned by the group statement. Thus, if a semicolon or dollar sign is
  514. placed between the last statement and the ending brackets, the group
  515. statement returns the value 0 or nil, rather than the value of the
  516. last statement.
  517. <P>
  518. <P>
  519. <P>
  520. <a name=r38_0021>
  521. <title>dollar</title></a>
  522. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  523. E"></p>
  524. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  525. <b>$</b> _ _ _ <b>DOLLAR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  526. <P>
  527. The dollar sign is a statement delimiter, indicating results are not to be
  528. printed when used in interactive mode.
  529. <P>
  530. <P>
  531. <P> <H3>
  532. examples: </H3>
  533. <p><pre><tt>
  534. (x+1)**2$ </tt></pre><p>The workspace is set to x^2 + 2x + 1
  535. but nothing shows on the screen<p><pre><tt>
  536. ws;
  537. 2
  538. X + 2*X + 1
  539. </tt></pre><p>
  540. <P>
  541. <P>
  542. Entering a <em>Return</em> without a semicolon or dollar sign results in a
  543. prompt on the following line. A semicolon or dollar sign can
  544. be added at this point to execute the statement. In interactive mode, a
  545. statement that ends with a dollar sign <em>$</em> and a <em>Return</em> is
  546. executed, but the results not printed.
  547. <P>
  548. <P>
  549. Inside a
  550. <a href=r38_0001.html#r38_0038>group</a> statement <em>&lt;&lt;</em>...<em>&gt;
  551. &gt;</em>
  552. or a <em>begin</em>...<em>end</em>
  553. <a href=r38_0001.html#r38_0041>block</a>, a
  554. semicolon or dollar sign separates individual REDUCE statements. Since
  555. results are not printed from a
  556. <a href=r38_0001.html#r38_0041>block</a> without a specific
  557. <a href=r38_0050.html#r38_0058>return</a><P>
  558. <P>
  559. statement, there is no difference between using the semicolon or dollar
  560. sign.
  561. <P>
  562. <P>
  563. In a group statement, the last value produced is the value returned by the
  564. group statement. Thus, if a semicolon or dollar sign is placed between the
  565. last statement and the ending brackets, the group statement returns the
  566. value 0 or nil, rather than the value of the last statement.
  567. <P>
  568. <P>
  569. <P>
  570. <P>
  571. <a name=r38_0022>
  572. <title>percent</title></a>
  573. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  574. E"></p>
  575. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  576. <b>%</b> _ _ _ <b>PERCENT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  577. <P>
  578. The percent sign is used to precede comments; everything from a percent
  579. to the end of the line is ignored.
  580. <P>
  581. <P>
  582. <P> <H3>
  583. examples: </H3>
  584. <p><pre><tt>
  585. df(x**3 + y,x);% This is a comment key{Return}
  586. 2
  587. 3*X
  588. int(3*x**2,x) %This is a comment; key{Return}
  589. </tt></pre><p>A prompt is given, waiting for the semicolon that was not
  590. detected in the comment<p><pre><tt></tt></pre><p>
  591. <P>
  592. <P>
  593. Statement delimiters <em>;</em> and <em>$</em> are not detected between a
  594. percent sign and the end of the line.
  595. <P>
  596. <P>
  597. <P>
  598. <a name=r38_0023>
  599. <title>dot</title></a>
  600. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  601. E"></p>
  602. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  603. <b>.</b> _ _ _ <b>DOT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  604. <P>
  605. <P>
  606. <P>
  607. The . (dot) infix binary operator adds a new item to the beginning of an
  608. existing
  609. <a href=r38_0300.html#r38_0302>list</a>. In high energy physics expressions,
  610. it can also be used
  611. to represent the scalar product of two Lorentz four-vectors.
  612. <P>
  613. <P>
  614. <P> <H3>
  615. syntax: </H3>
  616. &lt;item&gt; <em>.</em> &lt;list&gt;
  617. <P>
  618. <P>
  619. <P>
  620. &lt;item&gt; can be any REDUCE scalar expression, including a list;
  621. &lt;list&gt; must be a
  622. <a href=r38_0300.html#r38_0302>list</a> to avoid producing an error message.
  623. The dot operator is right associative.
  624. <P>
  625. <P>
  626. <P> <H3>
  627. examples: </H3>
  628. <p><pre><tt>
  629. liss := a . {};
  630. LISS := {A}
  631. liss := b . liss;
  632. LISS := {B,A}
  633. newliss := liss . liss;
  634. NEWLISS := {{B,A},B,A}
  635. firstlis := a . b . {c};
  636. FIRSTLIS := {A,B,C}
  637. secondlis := x . y . {z};
  638. SECONDLIS := {X,Y,Z}
  639. for i := 1:3 sum part(firstlis,i)*part(secondlis,i);
  640. A*X + B*Y + C*Z
  641. </tt></pre><p>
  642. <a name=r38_0024>
  643. <title>assign</title></a>
  644. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  645. E"></p>
  646. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  647. <b>:=</b> _ _ _ <b>ASSIGN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  648. <P>
  649. <P>
  650. <P>
  651. The <em>:=</em> is the assignment operator, assigning the value on the right-han
  652. d
  653. side to the identifier or other valid expression on the left-hand side.
  654. <P>
  655. <P>
  656. <P> <H3>
  657. syntax: </H3>
  658. &lt;restricted\_expression&gt; <em>:=</em> &lt;expression&gt;
  659. <P>
  660. <P>
  661. <P>
  662. &lt;restricted\_expression&gt; is ordinarily a single identifier, though simple
  663. expressions may be used (see Comments below). &lt;expression&gt; is any
  664. valid REDUCE expression. If &lt;expression&gt; is a
  665. <a href=r38_0300.html#r38_0345>matrix</a>
  666. identifier, then
  667. &lt;restricted\_expression&gt; can be a matrix identifier (redimensioned if
  668. necessary) which has each element set to the corresponding elements
  669. of the identifier on the right-hand side.
  670. <P>
  671. <P>
  672. <P> <H3>
  673. examples: </H3>
  674. <p><pre><tt>
  675. a := x**2 + 1;
  676. 2
  677. A := X + 1
  678. a;
  679. 2
  680. X + 1
  681. first := second := third;
  682. FIRST := SECOND := THIRD
  683. first;
  684. THIRD
  685. second;
  686. THIRD
  687. b := for i := 1:5 product i;
  688. B := 120
  689. b;
  690. 120
  691. w + (c := x + 3) + z;
  692. W + X + Z + 3
  693. c;
  694. X + 3
  695. y + b := c;
  696. Y + B := C
  697. y;
  698. - (B - C)
  699. </tt></pre><p>The assignment operator is right associative, as shown in the seco
  700. nd and
  701. third examples. A string of such assignments has all but the last
  702. item set to the value of the last item. Embedding an assignment statement
  703. in another expression has the side effect of making the assignment, as well
  704. as causing the given replacement in the expression.
  705. <P>
  706. <P>
  707. Assignments of values to expressions rather than simple identifiers (such as in
  708. the last example above) can also be done, subject to the following remarks:
  709. <P>
  710. <P>
  711. _ _ _ (i)
  712. If the left-hand side is an identifier, an operator, or a power, the
  713. substitution rule is added to the rule table.
  714. <P>
  715. <P>
  716. _ _ _ (ii)
  717. If the operators <em>- + /</em> appear on the left-hand side, all but the first
  718. term of the expression is moved to the right-hand side.
  719. <P>
  720. <P>
  721. _ _ _ (iii)
  722. If the operator <em>*</em> appears on the left-hand side, any constant terms are
  723. moved to the right-hand side, but the symbolic factors remain.
  724. <P>
  725. <P>
  726. Assignment is valid for
  727. <a href=r38_0150.html#r38_0188>array</a> elements, but not for entire arrays.
  728. The assignment operator can also be used to attach functionality to operators.
  729. <P>
  730. <P>
  731. A recursive construction such as <em>a := a + b</em> is allowed, but when
  732. <em>a</em> is referenced again, the process of resubstitution continues
  733. until the expression stack overflows (you get an error message).
  734. Recursive assignments can be done safely inside controlled loop
  735. expressions, such as
  736. <a href=r38_0001.html#r38_0047>for</a>... or
  737. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em>.
  738. <P>
  739. <P>
  740. <P>
  741. <P>
  742. <a name=r38_0025>
  743. <title>equalsign</title></a>
  744. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  745. E"></p>
  746. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  747. <b>=</b> _ _ _ <b>EQUALSIGN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  748. <P>
  749. The <em>=</em> operator is a prefix or infix equality comparison operator.
  750. <P>
  751. <P>
  752. <P> <H3>
  753. syntax: </H3>
  754. <em>=</em>(&lt;expression&gt;<em>,</em>&lt;expression&gt;)
  755. or
  756. &lt;expression&gt; <em>=</em> &lt;expression&gt;
  757. <P>
  758. <P>
  759. <P>
  760. &lt;expression&gt; can be any REDUCE scalar expression.
  761. <P>
  762. <P>
  763. <P> <H3>
  764. examples: </H3>
  765. <p><pre><tt>
  766. a := 4;
  767. A := 4
  768. if =(a,10) then write &quot;yes&quot; else write &quot;no&quot;;
  769. no
  770. b := c;
  771. B := C
  772. if b = c then write &quot;yes&quot; else write &quot;no&quot;;
  773. yes
  774. on rounded;
  775. if 4.0 = 4 then write &quot;yes&quot; else write &quot;no&quot;;
  776. yes
  777. </tt></pre><p>This logical equality operator can only be used inside a condition
  778. al
  779. statement, such as
  780. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em>
  781. or
  782. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em>. In other places the
  783. equal
  784. sign establishes an algebraic object of type
  785. <a href=r38_0001.html#r38_0045>equation</a>.
  786. <P>
  787. <P>
  788. <P>
  789. <P>
  790. <a name=r38_0026>
  791. <title>replace</title></a>
  792. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  793. E"></p>
  794. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  795. <b>=></b> _ _ _ <b>REPLACE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  796. <P>
  797. <P>
  798. <P>
  799. The <em>=&gt;</em> operator is a binary operator used in
  800. <a href=r38_0050.html#r38_0060>rule</a> lists to
  801. denote replacements.
  802. <P>
  803. <P>
  804. <P> <H3>
  805. examples: </H3>
  806. <p><pre><tt>
  807. operator f;
  808. let f(x) =&gt; x^2;
  809. f(x);
  810. 2
  811. x
  812. </tt></pre><p>
  813. <a name=r38_0027>
  814. <title>plussign</title></a>
  815. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  816. E"></p>
  817. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  818. <b>+</b> _ _ _ <b>PLUSSIGN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  819. <P>
  820. The <em>+</em> operator is a prefix or infix n-ary addition operator.
  821. <P>
  822. <P>
  823. <P> <H3>
  824. syntax: </H3>
  825. &lt;expression&gt; { <em>+</em>&lt;expression&gt;}+
  826. <P>
  827. <P>
  828. or <em>+</em>(&lt;expression&gt; {,&lt;expression&gt;}+)
  829. <P>
  830. <P>
  831. <P>
  832. &lt;expression&gt; may be any valid REDUCE expression.
  833. <P>
  834. <P>
  835. <P> <H3>
  836. examples: </H3>
  837. <p><pre><tt>
  838. x**4 + 4*x**2 + 17*x + 1;
  839. 4 2
  840. X + 4*X + 17*X + 1
  841. 14 + 15 + x;
  842. X + 29
  843. +(1,2,3,4,5);
  844. 15
  845. </tt></pre><p><em>+</em>is also valid as an addition operator for
  846. <a href=r38_0300.html#r38_0345>matrix</a> variables
  847. that are of the same dimensions and for
  848. <a href=r38_0001.html#r38_0045>equation</a>s.
  849. <P>
  850. <P>
  851. <P>
  852. <a name=r38_0028>
  853. <title>minussign</title></a>
  854. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  855. E"></p>
  856. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  857. <b>-</b> _ _ _ <b>MINUSSIGN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  858. <P>
  859. The <em>-</em> operator is a prefix or infix binary subtraction operator, as wel
  860. l
  861. as the unary minus operator.
  862. <P>
  863. <P>
  864. <P> <H3>
  865. syntax: </H3>
  866. &lt;expression&gt; <em>-</em> &lt;expression&gt;
  867. or <em>-</em>(&lt;expression&gt;,&lt;expression&gt;)
  868. <P>
  869. <P>
  870. <P>
  871. &lt;expression&gt; may be any valid REDUCE expression.
  872. <P>
  873. <P>
  874. <P> <H3>
  875. examples: </H3>
  876. <p><pre><tt>
  877. 15 - 4;
  878. 11
  879. x*(-5);
  880. - 5*X
  881. a - b - 15;
  882. A - B - 15
  883. -(a,4);
  884. A - 4
  885. </tt></pre><p>The subtraction operator is left associative, so that a - b - c is
  886. equivalent
  887. to (a - b) - c, as shown in the third example. The subtraction operator is
  888. also valid with
  889. <a href=r38_0300.html#r38_0345>matrix</a> expressions of the correct dimensions
  890. and with
  891. <a href=r38_0001.html#r38_0045>equation</a>s.
  892. <P>
  893. <P>
  894. <P>
  895. <a name=r38_0029>
  896. <title>asterisk</title></a>
  897. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  898. E"></p>
  899. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  900. <b>*</b> _ _ _ <b>ASTERISK</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  901. <P>
  902. The <em>*</em> operator is a prefix or infix n-ary multiplication operator.
  903. <P>
  904. <P>
  905. <P> <H3>
  906. syntax: </H3>
  907. &lt;expression&gt; { <em>*</em> &lt;expression&gt;}+
  908. <P>
  909. <P>
  910. or <em>*</em>(&lt;expression&gt; {,&lt;expression&gt;}+)
  911. <P>
  912. <P>
  913. <P>
  914. &lt;expression&gt; may be any valid REDUCE expression.
  915. <P>
  916. <P>
  917. <P> <H3>
  918. examples: </H3>
  919. <p><pre><tt>
  920. 15*3;
  921. 45
  922. 24*x*yvalue*2;
  923. 48*X*YVALUE
  924. *(6,x);
  925. 6*X
  926. on rounded;
  927. 3*1.5*x*x*x;
  928. 3
  929. 4.5*X
  930. off rounded;
  931. 2x**2;
  932. 2
  933. 2*X
  934. </tt></pre><p>REDUCE assumes you are using an implicit multiplication operator w
  935. hen an
  936. identifier is preceded by a number, as shown in the last line above. Since
  937. no valid identifiers can begin with numbers, there is no ambiguity in
  938. making this assumption.
  939. <P>
  940. <P>
  941. The multiplication operator is also valid with
  942. <a href=r38_0300.html#r38_0345>matrix</a> expressions
  943. of the
  944. proper dimensions: matrices A and B
  945. can be multiplied if
  946. A is n x m and B is
  947. m x p. Matrices and
  948. <a href=r38_0001.html#r38_0045>equation</a>s can also be
  949. multiplied by scalars: the
  950. result is as if each element was multiplied by the scalar.
  951. <P>
  952. <P>
  953. <P>
  954. <a name=r38_0030>
  955. <title>slash</title></a>
  956. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  957. E"></p>
  958. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  959. <b>/</b> _ _ _ <b>SLASH</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  960. <P>
  961. The <em>/</em> operator is a prefix or infix binary division operator or
  962. prefix unary
  963. <a href=r38_0100.html#r38_0101>recip</a>rocal operator.
  964. <P>
  965. <P>
  966. <P> <H3>
  967. syntax: </H3>
  968. &lt;expression&gt;<em>/</em>&lt;expression&gt; or
  969. <em>/</em>&lt;expression&gt;
  970. <P>
  971. <P>
  972. or <em>/</em>(&lt;expression&gt;,&lt;expression&gt;)
  973. <P>
  974. <P>
  975. <P>
  976. &lt;expression&gt; may be any valid REDUCE expression.
  977. <P>
  978. <P>
  979. <P> <H3>
  980. examples: </H3>
  981. <p><pre><tt>
  982. 20/5;
  983. 4
  984. 100/6;
  985. 50
  986. --
  987. 3
  988. 16/2/x;
  989. 8
  990. -
  991. X
  992. /b;
  993. 1
  994. -
  995. B
  996. /(y,5);
  997. Y
  998. -
  999. 5
  1000. on rounded;
  1001. 35/4;
  1002. 8.75
  1003. /20;
  1004. 0.05
  1005. </tt></pre><p>The division operator is left associative, so that <em>a/b/c</em>
  1006. is equivalent
  1007. to <em>(a/b)/c</em>. The division operator is also valid with square
  1008. <a href=r38_0300.html#r38_0345>matrix</a> expressions of the same dimensions: Wi
  1009. th A and
  1010. B both n x n matrices and B
  1011. invertible, A/B is
  1012. given by A*B^-1.
  1013. Division of a matrix by a scalar is defined, with the results being the
  1014. division of each element of the matrix by the scalar. Division of a
  1015. scalar by a matrix is defined if the matrix is invertible, and has the
  1016. effect of multiplying the scalar by the inverse of the matrix. When
  1017. <em>/</em> is used as a reciprocal operator for a matrix, the inverse of
  1018. the matrix is returned if it exists.
  1019. <P>
  1020. <P>
  1021. <P>
  1022. <a name=r38_0031>
  1023. <title>power</title></a>
  1024. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1025. E"></p>
  1026. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1027. <b>**</b> _ _ _ <b>POWER</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1028. <P>
  1029. The <em>**</em> operator is a prefix or infix binary exponentiation operator.
  1030. <P>
  1031. <P>
  1032. <P> <H3>
  1033. syntax: </H3>
  1034. &lt;expression&gt; <em>**</em>&lt;expression&gt;
  1035. or <em>**</em>(&lt;expression&gt;,&lt;expression&gt;)
  1036. <P>
  1037. <P>
  1038. <P>
  1039. &lt;expression&gt; may be any valid REDUCE expression.
  1040. <P>
  1041. <P>
  1042. <P> <H3>
  1043. examples: </H3>
  1044. <p><pre><tt>
  1045. x**15;
  1046. 15
  1047. X
  1048. x**y**z;
  1049. Y*Z
  1050. X
  1051. x**(y**z);
  1052. Z
  1053. Y
  1054. X
  1055. **(y,4);
  1056. 4
  1057. Y
  1058. on rounded;
  1059. 2**pi;
  1060. 8.82497782708
  1061. </tt></pre><p>The exponentiation operator is left associative, so that <em>a**b*
  1062. *c</em> is
  1063. equivalent to <em>(a**b)**c</em>, as shown in the second example. Note
  1064. that this is not <em>a**(b**c)</em>, which would be right associative.
  1065. <P>
  1066. <P>
  1067. When
  1068. <a href=r38_0300.html#r38_0308>nat</a> is on (the default), REDUCE output produc
  1069. es raised
  1070. exponents, as shown. The symbol <em>^</em>, which is the upper-case 6 on
  1071. most keyboards, may be used in the place of <em>**</em>.
  1072. <P>
  1073. <P>
  1074. A square
  1075. <a href=r38_0300.html#r38_0345>matrix</a> may also be raised to positive and neg
  1076. ative powers
  1077. with the exponentiation operator (negative powers require the matrix to be
  1078. invertible). Scalar expressions and
  1079. <a href=r38_0001.html#r38_0045>equation</a>s may be raised to
  1080. fractional and floating-point powers.
  1081. <P>
  1082. <P>
  1083. <P>
  1084. <a name=r38_0032>
  1085. <title>caret</title></a>
  1086. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1087. E"></p>
  1088. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1089. <b>^</b> _ _ _ <b>CARET</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1090. <P>
  1091. The <em>^</em> operator is a prefix or infix binary exponentiation operator.
  1092. It is equivalent to
  1093. <a href=r38_0001.html#r38_0031>power</a> or **.
  1094. <P>
  1095. <P>
  1096. <P> <H3>
  1097. syntax: </H3>
  1098. &lt;expression&gt; <em>^</em>&lt;expression&gt;
  1099. or <em>^</em>(&lt;expression&gt;,&lt;expression&gt;)
  1100. <P>
  1101. <P>
  1102. <P>
  1103. &lt;expression&gt; may be any valid REDUCE expression.
  1104. <P>
  1105. <P>
  1106. <P> <H3>
  1107. examples: </H3>
  1108. <p><pre><tt>
  1109. x^15;
  1110. 15
  1111. X
  1112. x^y^z;
  1113. Y*Z
  1114. X
  1115. x^(y^z);
  1116. Z
  1117. Y
  1118. X
  1119. ^(y,4);
  1120. 4
  1121. Y
  1122. on rounded;
  1123. 2^pi;
  1124. 8.82497782708
  1125. </tt></pre><p>The exponentiation operator is left associative, so that <em>a^b^c
  1126. </em> is
  1127. equivalent to <em>(a^b)^c</em>, as shown in the second example. Note
  1128. that this is &lt;not&gt; <em>a^(b^c)</em>, which would be right associative.
  1129. <P>
  1130. <P>
  1131. When
  1132. <a href=r38_0300.html#r38_0308>nat</a> is on (the default), REDUCE output produc
  1133. es raised
  1134. exponents, as shown.
  1135. <P>
  1136. <P>
  1137. A square
  1138. <a href=r38_0300.html#r38_0345>matrix</a> may also be raised to positive
  1139. and negative powers with
  1140. the exponentiation operator (negative powers require the matrix to be
  1141. invertible). Scalar expressions and
  1142. <a href=r38_0001.html#r38_0045>equation</a>s
  1143. may be raised to fractional and floating-point powers.
  1144. <P>
  1145. <P>
  1146. <P>
  1147. <a name=r38_0033>
  1148. <title>geqsign</title></a>
  1149. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1150. E"></p>
  1151. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1152. <b>>=</b> _ _ _ <b>GEQSIGN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1153. <P>
  1154. <em>&gt;=</em> is an infix binary comparison operator, which returns true if
  1155. its first argument is greater than or equal to its second argument.
  1156. <P>
  1157. <P>
  1158. <P> <H3>
  1159. syntax: </H3>
  1160. &lt;expression&gt; <em>&gt;=</em> &lt;expression&gt;
  1161. <P>
  1162. <P>
  1163. <P>
  1164. &lt;expression&gt; must evaluate to an integer or floating-point number.
  1165. <P>
  1166. <P>
  1167. <P> <H3>
  1168. examples: </H3>
  1169. <p><pre><tt>
  1170. if (3 &gt;= 2) then yes;
  1171. yes
  1172. a := 15;
  1173. A := 15
  1174. if a &gt;= 20 then big else small;
  1175. small
  1176. </tt></pre><p>The binary comparison operators can only be used for comparisons b
  1177. etween
  1178. numbers or variables that evaluate to numbers. The truth values returned
  1179. by such a comparison can only be used inside programming constructs, such
  1180. as
  1181. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em>
  1182. or
  1183. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or
  1184. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em>.
  1185. <P>
  1186. <P>
  1187. <P>
  1188. <a name=r38_0034>
  1189. <title>greater</title></a>
  1190. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1191. E"></p>
  1192. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1193. <b>></b> _ _ _ <b>GREATER</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1194. <P>
  1195. The <em>&gt;</em> is an infix binary comparison operator that returns
  1196. true if its first argument is strictly greater than its second.
  1197. <P>
  1198. <P>
  1199. <P> <H3>
  1200. syntax: </H3>
  1201. &lt;expression&gt; <em>&gt;</em> &lt;expression&gt;
  1202. <P>
  1203. <P>
  1204. <P>
  1205. &lt;expression&gt; must evaluate to a number, e.g., integer, rational or
  1206. floating point number.
  1207. <P>
  1208. <P>
  1209. <P> <H3>
  1210. examples: </H3>
  1211. <p><pre><tt>
  1212. on rounded;
  1213. if 3.0 &gt; 3 then write &quot;different&quot; else write &quot;same&quot;;
  1214. same
  1215. off rounded;
  1216. a := 20;
  1217. A := 20
  1218. if a &gt; 20 then write &quot;bigger&quot; else write &quot;not bigger&quot;;
  1219. not bigger
  1220. </tt></pre><p>The binary comparison operators can only be used for comparisons b
  1221. etween
  1222. numbers or variables that evaluate to numbers. The truth values returned
  1223. by such a comparison can only be used inside programming constructs, such
  1224. as
  1225. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> or
  1226. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or
  1227. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em>.
  1228. <P>
  1229. <P>
  1230. <P>
  1231. <a name=r38_0035>
  1232. <title>leqsign</title></a>
  1233. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1234. E"></p>
  1235. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1236. <b><=</b> _ _ _ <b>LEQSIGN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1237. <P>
  1238. <em>&lt;=</em> is an infix binary comparison operator that returns
  1239. true if its first argument is less than or equal to its second argument.
  1240. <P>
  1241. <P>
  1242. <P> <H3>
  1243. syntax: </H3>
  1244. &lt;expression&gt; <em>&lt;=</em> &lt;expression&gt;
  1245. <P>
  1246. <P>
  1247. <P>
  1248. &lt;expression&gt; must evaluate to a number, e.g., integer, rational or
  1249. floating point number.
  1250. <P>
  1251. <P>
  1252. <P> <H3>
  1253. examples: </H3>
  1254. <p><pre><tt>
  1255. a := 10;
  1256. A := 10
  1257. if a &lt;= 10 then true;
  1258. true
  1259. </tt></pre><p>The binary comparison operators can only be used for comparisons b
  1260. etween
  1261. numbers or variables that evaluate to numbers. The truth values returned
  1262. by such a comparison can only be used inside programming constructs, such
  1263. as
  1264. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> or
  1265. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or
  1266. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em>.
  1267. <P>
  1268. <P>
  1269. <P>
  1270. <a name=r38_0036>
  1271. <title>less</title></a>
  1272. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1273. E"></p>
  1274. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1275. <b><</b> _ _ _ <b>LESS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1276. <P>
  1277. <em>&lt;</em> is an infix binary logical comparison operator that
  1278. returns true if its first argument is strictly less than its second
  1279. argument.
  1280. <P>
  1281. <P>
  1282. <P> <H3>
  1283. syntax: </H3>
  1284. &lt;expression&gt; <em>&lt;</em> &lt;expression&gt;
  1285. <P>
  1286. <P>
  1287. <P>
  1288. &lt;expression&gt; must evaluate to a number, e.g., integer, rational or
  1289. floating point number.
  1290. <P>
  1291. <P>
  1292. <P> <H3>
  1293. examples: </H3>
  1294. <p><pre><tt>
  1295. f := -3;
  1296. F := -3
  1297. if f &lt; -3 then write &quot;yes&quot; else write &quot;no&quot;;
  1298. no
  1299. </tt></pre><p>The binary comparison operators can only be used for comparisons b
  1300. etween
  1301. numbers or variables that evaluate to numbers. The truth values returned
  1302. by such a comparison can only be used inside programming constructs, such
  1303. as
  1304. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em>
  1305. or
  1306. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or
  1307. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em>.
  1308. <P>
  1309. <P>
  1310. <P>
  1311. <a name=r38_0037>
  1312. <title>tilde</title></a>
  1313. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1314. E"></p>
  1315. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1316. <b>~</b> _ _ _ <b>TILDE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1317. <P>
  1318. The <em>~</em> is used as a unary prefix operator in the left-hand
  1319. sides of
  1320. <a href=r38_0050.html#r38_0060>rule</a>s to mark
  1321. <a href=r38_0050.html#r38_0061>free variable</a>s. A double tilde
  1322. marks an optional
  1323. <a href=r38_0050.html#r38_0061>free variable</a>.
  1324. <P>
  1325. <P>
  1326. <a name=r38_0038>
  1327. <title>group</title></a>
  1328. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1329. E"></p>
  1330. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1331. <b><<</b> _ _ _ <b>GROUP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1332. <P>
  1333. The <em>&lt;&lt;</em>...<em>&gt;&gt;</em> command is a group statement,
  1334. used to group statements
  1335. together where REDUCE expects a single statement.
  1336. <P>
  1337. <P>
  1338. <P> <H3>
  1339. syntax: </H3>
  1340. <em>&lt;&lt;</em>&lt;statement&gt;{; &lt;statement&gt; <em>or</em>
  1341. &lt;statement&gt;}* <em>&gt;&gt;</em>
  1342. <P>
  1343. <P>
  1344. <P>
  1345. &lt;statement&gt; may be any valid REDUCE statement or expression.
  1346. <P>
  1347. <P>
  1348. <P> <H3>
  1349. examples: </H3>
  1350. <p><pre><tt>
  1351. a := 2;
  1352. A := 2
  1353. if a &lt; 5 then &lt;&lt;b := a + 10; write b&gt;&gt;;
  1354. 12
  1355. &lt;&lt;d := c/15; f := d + 3; f**2&gt;&gt;;
  1356. 2
  1357. C + 90*C + 202
  1358. ----------------
  1359. 225
  1360. </tt></pre><p>The value returned from a group statement is the value of the last
  1361. individual statement executed inside it. Note that when a semicolon is
  1362. placed between the last statement and the closing brackets, 0 or
  1363. nil is returned. Group statements are often used in the
  1364. consequence portions of
  1365. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>,
  1366. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em>, and
  1367. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em>
  1368. clauses. They may also be used in interactive
  1369. operation to execute several statements at one time. Statements inside
  1370. the group statement are separated by semicolons or dollar signs.
  1371. <P>
  1372. <P>
  1373. <P>
  1374. <P>
  1375. <a name=r38_0039>
  1376. <title>AND</title></a>
  1377. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1378. E"></p>
  1379. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1380. <b>AND</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1381. <P>
  1382. The <em>and</em> binary logical operator returns true if both of its
  1383. arguments are true.
  1384. <P>
  1385. <P>
  1386. <P> <H3>
  1387. syntax: </H3>
  1388. &lt;logical\_expression&gt; <em>and</em> &lt;logical\_expression&gt;
  1389. <P>
  1390. <P>
  1391. <P>
  1392. &lt;logical\_expression&gt; must evaluate to true or nil.
  1393. <P>
  1394. <P>
  1395. <P> <H3>
  1396. examples: </H3>
  1397. <p><pre><tt>
  1398. a := 12;
  1399. A := 12
  1400. if numberp a and a &lt; 15 then write a**2 else write &quot;no&quot;;
  1401. 144
  1402. clear a;
  1403. if numberp a and a &lt; 15 then write a**2 else write &quot;no&quot;;
  1404. no
  1405. </tt></pre><p>Logical operators can only be used inside conditional statements,
  1406. such as
  1407. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em> or
  1408. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em>. <em>and
  1409. </em> examines each of
  1410. its arguments in order, and quits, returning nil, on finding an
  1411. argument that is not true. An error results if it is used in other
  1412. contexts.
  1413. <P>
  1414. <P>
  1415. <em>and</em>is left associative: <em>x and y and z</em> is equivalent to
  1416. <em>(x and y) and z</em>.
  1417. <P>
  1418. <P>
  1419. <P>
  1420. <a name=r38_0040>
  1421. <title>BEGIN</title></a>
  1422. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1423. E"></p>
  1424. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1425. <b>BEGIN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1426. <P>
  1427. <em>begin</em> is used to start a
  1428. <a href=r38_0001.html#r38_0041>block</a> statement, which is closed with
  1429. <em>end</em>.
  1430. <P>
  1431. <P>
  1432. <P> <H3>
  1433. syntax: </H3>
  1434. <em>begin</em>&lt;statement&gt;{<em>;</em> &lt;statement&gt;}* <em>end</em>
  1435. <P>
  1436. <P>
  1437. <P>
  1438. &lt;statement&gt; is any valid REDUCE statement.
  1439. <P>
  1440. <P>
  1441. <P> <H3>
  1442. examples: </H3>
  1443. <p><pre><tt>
  1444. begin for i := 1:3 do write i end;
  1445. 1
  1446. 2
  1447. 3
  1448. begin scalar n;n:=1;b:=for i:=1:4 product(x-i);return n end;
  1449. 1
  1450. b;
  1451. 4 3 2
  1452. X - 10*X + 35*X - 50*X + 24
  1453. </tt></pre><p>A <em>begin</em>...<em>end</em> block can do actions (such as <em>
  1454. write</em>), but
  1455. does not
  1456. return a value unless instructed to by a
  1457. <a href=r38_0050.html#r38_0058>return</a> statement, which must
  1458. be the last statement executed in the block. It is unnecessary to insert
  1459. a semicolon before the <em>end</em>.
  1460. <P>
  1461. <P>
  1462. Local variables, if any, are declared in the first statement immediately
  1463. after <em>begin</em>, and may be defined as <em>scalar, integer,</em> or
  1464. <em>real</em>.
  1465. <a href=r38_0150.html#r38_0188>array</a> variables declared
  1466. within a <em>begin</em>...<em>end</em> block
  1467. are global in every case, and
  1468. <a href=r38_0150.html#r38_0199>let</a> statements have global
  1469. effects. A
  1470. <a href=r38_0150.html#r38_0199>let</a> statement involving a formal parameter af
  1471. fects
  1472. the calling parameter that corresponds to it.
  1473. <a href=r38_0150.html#r38_0199>let</a> statements
  1474. involving local variables make global assignments, overwriting outside
  1475. variables by the same name or creating them if they do not exist. You
  1476. can use this feature to affect global variables from procedures, but be
  1477. careful that you do not do it inadvertently.
  1478. <P>
  1479. <P>
  1480. <P>
  1481. <P>
  1482. <a name=r38_0041>
  1483. <title>block</title></a>
  1484. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1485. E"></p>
  1486. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1487. <b>BLOCK</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1488. <P>
  1489. A <em>block</em> is a sequence of statements enclosed by
  1490. commands
  1491. <a href=r38_0001.html#r38_0040>begin</a> and
  1492. <a href=r38_0001.html#r38_0044>end</a>.
  1493. <P>
  1494. <P>
  1495. <P> <H3>
  1496. syntax: </H3>
  1497. <em>begin</em>&lt;statement&gt;{<em>;</em> &lt;statement&gt;}* <em>end</em>
  1498. <P>
  1499. <P>
  1500. <P>
  1501. For more details see
  1502. <a href=r38_0001.html#r38_0040>begin</a>.
  1503. <P>
  1504. <P>
  1505. <a name=r38_0042>
  1506. <title>COMMENT</title></a>
  1507. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1508. E"></p>
  1509. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1510. <b>COMMENT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1511. <P>
  1512. Beginning with the word <em>comment</em>, all text until the next statement
  1513. terminator (<em>;</em> or <em>$</em>) is ignored.
  1514. <P>
  1515. <P>
  1516. <P> <H3>
  1517. examples: </H3>
  1518. <p><pre><tt>
  1519. x := a**2 comment--a is the velocity of the particle;;
  1520. 2
  1521. X := A
  1522. </tt></pre><p>Note that the first semicolon ends the comment and the second one
  1523. terminates the original REDUCE statement.
  1524. <P>
  1525. <P>
  1526. Multiple-line comments are often needed in interactive files. The
  1527. <em>comment</em> command allows a normal-looking text to accompany the
  1528. REDUCE statements in the file.
  1529. <P>
  1530. <P>
  1531. <P>
  1532. <a name=r38_0043>
  1533. <title>CONS</title></a>
  1534. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1535. E"></p>
  1536. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1537. <b>CONS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1538. <P>
  1539. The <em>cons</em> operator adds a new element to the beginning of a
  1540. <a href=r38_0300.html#r38_0302>list</a>. Its
  1541. operation is identical to the symbol
  1542. <a href=r38_0001.html#r38_0023>dot</a> (dot). It can be used
  1543. infix or prefix.
  1544. <P>
  1545. <P>
  1546. <P> <H3>
  1547. syntax: </H3>
  1548. <em>cons</em>(&lt;item&gt;,&lt;list&gt;) or &lt;item&gt; <em>cons</em> &lt;list
  1549. &gt;
  1550. <P>
  1551. <P>
  1552. <P>
  1553. &lt;item&gt; can be any REDUCE scalar expression, including a list; &lt;list&gt;
  1554. must be a list.
  1555. <P>
  1556. <P>
  1557. <P> <H3>
  1558. examples: </H3>
  1559. <p><pre><tt>
  1560. liss := cons(a,{b});
  1561. {A,B}
  1562. liss := c cons liss;
  1563. {C,A,B}
  1564. newliss := for each y in liss collect cons(y,list x);
  1565. NEWLISS := {{C,X},{A,X},{B,X}}
  1566. for each y in newliss sum (first y)*(second y);
  1567. X*(A + B + C)
  1568. </tt></pre><p>If you want to use <em>cons</em> to put together two elements into
  1569. a new list,
  1570. you must make the second one into a list with curly brackets or the <em>list
  1571. </em>
  1572. command. You can also start with an empty list created by <em>{}</em>.
  1573. <P>
  1574. <P>
  1575. The <em>cons</em> operator is right associative: <em>a cons b cons c</em> is val
  1576. id
  1577. if <em>c</em> is a list; <em>b</em> need not be a list. The list produced is
  1578. <em>{a,b,c}</em>.
  1579. <P>
  1580. <P>
  1581. <P>
  1582. <P>
  1583. <a name=r38_0044>
  1584. <title>END</title></a>
  1585. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1586. E"></p>
  1587. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1588. <b>END</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1589. <P>
  1590. The command <em>end</em> has two main uses:
  1591. <P>
  1592. <P>
  1593. _ _ _ (i)
  1594. as the ending of a
  1595. <a href=r38_0001.html#r38_0040>begin</a>...<em>end</em>
  1596. <a href=r38_0001.html#r38_0041>block</a>; and
  1597. <P>
  1598. _ _ _ (ii)
  1599. to end input from a file.
  1600. <P>
  1601. <P>
  1602. In a <em>begin</em>...<em>end</em>
  1603. <a href=r38_0001.html#r38_0041>block</a>, there need not be a delimiter
  1604. (<em>;</em> or <em>$</em>) before the <em>end</em>, though there must be one
  1605. after it, or a right bracket matching an earlier left bracket.
  1606. <P>
  1607. <P>
  1608. Files to be read into REDUCE should end with <em>end;</em>, which must be
  1609. preceded by a semicolon (usually the last character of the previous line).
  1610. The additional semicolon avoids problems with mistakes in the files. If
  1611. you have suspended file operation by answering <em>n</em> to a <em>pause</em>
  1612. command, you are still, technically speaking, ``in&quot; the file. Use
  1613. <em>end</em> to exit the file.
  1614. <P>
  1615. <P>
  1616. An <em>end</em> at the top level of a program is ignored.
  1617. <P>
  1618. <P>
  1619. <P>
  1620. <a name=r38_0045>
  1621. <title>EQUATION</title></a>
  1622. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1623. E"></p>
  1624. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1625. <b>EQUATION</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>type</b><P>
  1626. <P>
  1627. <P>
  1628. <P>
  1629. An <em>equation</em> is an expression where two algebraic expressions
  1630. are connected by the (infix) operator
  1631. <a href=r38_0100.html#r38_0110>equal</a> or by <em>=</em>.
  1632. For access to the components of an <em>equation</em> the operators
  1633. <a href=r38_0150.html#r38_0158>lhs</a>,
  1634. <a href=r38_0150.html#r38_0175>rhs</a> or
  1635. <a href=r38_0150.html#r38_0169>part</a> can be used. The
  1636. evaluation of the left-hand side of an <em>equation</em> is controlled
  1637. by the switch
  1638. <a href=r38_0250.html#r38_0283>evallhseqp</a>, while the right-hand side is
  1639. evaluated unconditionally. When an <em>equation</em> is part of a
  1640. logical expression, e.g. in a
  1641. <a href=r38_0050.html#r38_0052>if</a> or
  1642. <a href=r38_0200.html#r38_0228>while</a> statement,
  1643. the equation is evaluated by subtracting both sides can comparing
  1644. the result with zero.
  1645. <P>
  1646. <P>
  1647. Equations occur in many contexts, e.g. as arguments of the
  1648. <a href=r38_0150.html#r38_0182>sub</a>
  1649. operator and in the arguments and the results
  1650. of the operator
  1651. <a href=r38_0150.html#r38_0179>solve</a>. An equation can be member of a
  1652. <a href=r38_0300.html#r38_0302>list</a>
  1653. and you may assign an equation to a variable. Elementary arithmetic is supported
  1654. for equations: if
  1655. <a href=r38_0250.html#r38_0283>evallhseqp</a> is on, you may add and subtract
  1656. equations, and you can combine an equation with a scalar expression by
  1657. addition, subtraction, multiplication, division and raise an equation
  1658. to a power.
  1659. <P> <H3>
  1660. examples: </H3>
  1661. <p><pre><tt>
  1662. on evallhseqp;
  1663. u:=x+y=1$
  1664. v:=2x-y=0$
  1665. 2*u-v;
  1666. - 3*y=-2
  1667. ws/3;
  1668. 2
  1669. y=--
  1670. 3
  1671. </tt></pre><p><P>
  1672. <P>
  1673. Important: the equation must occur in the leftmost term of such an expression.
  1674. For other operations, e.g. taking function values of both sides, use the
  1675. <a href=r38_0150.html#r38_0163>map</a> operator.
  1676. <P>
  1677. <P>
  1678. <a name=r38_0046>
  1679. <title>FIRST</title></a>
  1680. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1681. E"></p>
  1682. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1683. <b>FIRST</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1684. <P>
  1685. <P>
  1686. <P>
  1687. The <em>first</em> operator returns the first element of a
  1688. <a href=r38_0300.html#r38_0302>list</a>.
  1689. <P> <H3>
  1690. syntax: </H3>
  1691. <P>
  1692. <P>
  1693. <em>first</em>(&lt;list&gt;) or <em>first</em> &lt;list&gt;
  1694. <P>
  1695. <P>
  1696. <P>
  1697. &lt;list&gt; must be a non-empty list to avoid an error message.
  1698. <P>
  1699. <P>
  1700. <P> <H3>
  1701. examples: </H3>
  1702. <p><pre><tt>
  1703. alist := {a,b,c,d};
  1704. ALIST := {A,B,C,D}
  1705. first alist;
  1706. A
  1707. blist := {x,y,{ww,aa,qq},z};
  1708. BLIST := {X,Y,{WW,AA,QQ},Z}
  1709. first third blist;
  1710. WW
  1711. </tt></pre><p>
  1712. <a name=r38_0047>
  1713. <title>FOR</title></a>
  1714. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1715. E"></p>
  1716. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1717. <b>FOR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1718. <P>
  1719. <P>
  1720. <P>
  1721. The <em>for</em> command is used for iterative loops. There are many
  1722. possible forms it can take.
  1723. <P>
  1724. <P>
  1725. <p><pre><tt>
  1726. /
  1727. / |STEP &lt;number&gt; UNTIL|
  1728. |&lt;var&gt;:=&lt;number&gt;| |&lt;number&gt;|
  1729. FOR| | : | |&lt;action&gt; &lt;exprn&gt;
  1730. | / |
  1731. |EACH &lt;var&gt; IN &lt;list&gt; |
  1732. /
  1733. where &lt;action&gt; ::= DO|PRODUCT|SUM|COLLECT|JOIN.
  1734. </tt></pre><p>&lt;var&gt; can be any valid REDUCE identifier except <em>t</em> o
  1735. r
  1736. <em>nil</em>, &lt;inc&gt;, &lt;start&gt; and &lt;stop&gt; can be any expression
  1737. that evaluates to a positive or negative integer. &lt;list&gt; must be a
  1738. valid
  1739. <a href=r38_0300.html#r38_0302>list</a> structure.
  1740. The action taken must be one of the actions shown
  1741. above, each of which is followed by a single REDUCE expression, statement
  1742. or a
  1743. <a href=r38_0001.html#r38_0038>group</a> (<em>&lt;&lt;</em>...<em>&gt;&gt;</em>)
  1744. or
  1745. <a href=r38_0001.html#r38_0041>block</a>
  1746. (
  1747. <a href=r38_0001.html#r38_0040>begin</a>...
  1748. <a href=r38_0001.html#r38_0044>end</a>) statement.
  1749. <P>
  1750. <P>
  1751. <P> <H3>
  1752. examples: </H3>
  1753. <p><pre><tt>
  1754. for i := 1:10 sum i;
  1755. 55
  1756. for a := -2 step 3 until 6 product a;
  1757. -8
  1758. a := 3;
  1759. A := 3
  1760. for iter := 4:a do write iter;
  1761. m := 0;
  1762. M := 0
  1763. for s := 10 step -1 until 3 do &lt;&lt;d := 10*s;m := m + d&gt;&gt;;
  1764. m;
  1765. 520
  1766. for each x in {q,r,s} sum x**2;
  1767. 2 2 2
  1768. Q + R + S
  1769. for i := 1:4 collect 1/i;
  1770. 1 1 1
  1771. {1,-,-,-}
  1772. 2 3 4
  1773. for i := 1:3 join list solve(x**2 + i*x + 1,x);
  1774. SQRT(3)*I + 1
  1775. {{X= --------------,
  1776. 2
  1777. SQRT(3)*I - 1
  1778. X= --------------}
  1779. 2
  1780. {X=-1},
  1781. SQRT(5) + 3 SQRT(5) - 3
  1782. {X= - -----------,X=-----------}}
  1783. 2 2
  1784. </tt></pre><p>The behavior of each of the five action words follows:
  1785. <P>
  1786. <P>
  1787. <p><pre><tt>
  1788. Action Word Behavior
  1789. Keyword Argument Type Action
  1790. do statement, command, group Evaluates its argument once
  1791. or block for each iteration of the loop,
  1792. not saving results
  1793. collect expression, statement, Evaluates its argument once for
  1794. command, group, block, list each iteration of the loop,
  1795. storing the results in a list
  1796. which is returned by the for
  1797. statement when done
  1798. join list or an operator which Evaluates its argument once for
  1799. produces a list each iteration of the loop,
  1800. appending the elements in each
  1801. individual result list onto the
  1802. overall result list
  1803. product expression, statement, Evaluates its argument once for
  1804. command, group or block each iteration of the loop,
  1805. multiplying the results together
  1806. and returning the overall product
  1807. sum expression, statement, Evaluates its argument once for
  1808. command, group or block each iteration of the loop,
  1809. adding the results together and
  1810. returning the overall sum
  1811. </tt></pre><p>For number-driven <em>for</em> statements, if the ending limit is
  1812. smaller
  1813. than the beginning limit (larger in the case of negative steps) the action
  1814. statement is not executed at all. The iterative variable is local to the
  1815. <em>for</em> statement, and does not affect the value of an identifier with
  1816. the same name. For list-driven <em>for</em> statements, if the list is
  1817. empty, the action statement is not executed, but no error occurs.
  1818. <P>
  1819. <P>
  1820. You can use nested <em>for</em> statements, with the inner <em>for</em>
  1821. statement after the action keyword. You must make sure that your inner
  1822. statement returns an expression that the outer statement can handle.
  1823. <P>
  1824. <P>
  1825. <P>
  1826. <a name=r38_0048>
  1827. <title>FOREACH</title></a>
  1828. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1829. E"></p>
  1830. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1831. <b>FOREACH</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1832. <P>
  1833. <P>
  1834. <P>
  1835. <em>foreach</em>is a synonym for the <em>for each</em> variant of the
  1836. <a href=r38_0001.html#r38_0047>for</a> construct. It is designed to iterate down
  1837. a list, and an
  1838. error will occur if a list is not used. The use of <em>for each</em> is
  1839. preferred to <em>foreach</em>.
  1840. <P>
  1841. <P>
  1842. <P> <H3>
  1843. syntax: </H3>
  1844. <em>foreach</em>&lt;variable&gt; in &lt;list&gt; &lt;action&gt; &lt;expression
  1845. &gt;
  1846. <P>
  1847. <P>
  1848. where &lt;action&gt; ::= <em>do | product | sum | collect | join</em>
  1849. <P>
  1850. <P>
  1851. <P>
  1852. <P> <H3>
  1853. examples: </H3>
  1854. <p><pre><tt>
  1855. foreach x in {q,r,s} sum x**2;
  1856. 2 2 2
  1857. Q + R + S
  1858. </tt></pre><p>
  1859. <a name=r38_0049>
  1860. <title>GEQ</title></a>
  1861. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1862. E"></p>
  1863. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1864. <b>GEQ</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1865. <P>
  1866. The <em>geq</em> operator is a binary infix or prefix logical operator. It
  1867. returns true if its first argument is greater than or equal to its second
  1868. argument. As an infix operator it is identical with <em>&gt;=</em>.
  1869. <P> <H3>
  1870. syntax: </H3>
  1871. <P>
  1872. <P>
  1873. <em>geq</em>(&lt;expression&gt;,&lt;expression&gt;) or &lt;expression&gt;
  1874. <em>geq</em> &lt;expression&gt;
  1875. <P>
  1876. <P>
  1877. <P>
  1878. &lt;expression&gt; can be any valid REDUCE expression that evaluates to a
  1879. number.
  1880. <P>
  1881. <P>
  1882. <P> <H3>
  1883. examples: </H3>
  1884. <p><pre><tt>
  1885. a := 20;
  1886. A := 20
  1887. if geq(a,25) then write &quot;big&quot; else write &quot;small&quot;;
  1888. small
  1889. if a geq 20 then write &quot;big&quot; else write &quot;small&quot;;
  1890. big
  1891. if (a geq 18) then write &quot;big&quot; else write &quot;small&quot;;
  1892. big
  1893. </tt></pre><p>Logical operators can only be used in conditional statements such
  1894. as
  1895. <P>
  1896. <P>
  1897. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> or
  1898. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em>.
  1899. <P>
  1900. <P>
  1901. <P>