r38_0050.html 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088
  1. <a name=r38_0050>
  2. <title>GOTO</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>GOTO</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  7. <P>
  8. Inside a <em>begin</em>...<em>end</em>
  9. <a href=r38_0001.html#r38_0041>block</a>, <em>goto</em>, or
  10. preferably, <em>go to</em>, transfers flow of control to a labeled statement.
  11. <P> <H3>
  12. syntax: </H3>
  13. <P>
  14. <P>
  15. <em>go to</em>&lt;labeled_statement&gt; or <em>goto</em> &lt;labeled_statement
  16. &gt;
  17. <P>
  18. <P>
  19. <P>
  20. &lt;labeled_statement&gt; is of the form &lt;label&gt; <em>:</em>&lt;statement
  21. &gt;
  22. <P>
  23. <P>
  24. <P> <H3>
  25. examples: </H3>
  26. <p><pre><tt>
  27. procedure dumb(a);
  28. begin scalar q;
  29. go to lab;
  30. q := df(a**2 - sin(a),a);
  31. write q;
  32. lab: return a
  33. end;
  34. DUMB
  35. dumb(17);
  36. 17
  37. </tt></pre><p><em>go to</em>can only be used inside a <em>begin</em>...<em>end
  38. </em>
  39. <a href=r38_0001.html#r38_0041>block</a>, and inside
  40. the block only statements at the top level can be labeled, not ones inside
  41. <em>&lt;&lt;</em>...<em>&gt;&gt;</em>,
  42. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em>, etc.
  43. <P>
  44. <P>
  45. <P>
  46. <a name=r38_0051>
  47. <title>GREATERP</title></a>
  48. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  49. E"></p>
  50. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  51. <b>GREATERP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  52. <P>
  53. The <em>greaterp</em> logical operator returns true if its first argument is
  54. strictly greater than its second argument. As an infix operator it is
  55. identical with <em>&gt;</em>.
  56. <P> <H3>
  57. syntax: </H3>
  58. <P>
  59. <P>
  60. <em>greaterp</em>(&lt;expression&gt;,&lt;expression&gt;) or &lt;expression&gt;
  61. <em>greaterp</em> &lt;expression&gt;
  62. <P>
  63. <P>
  64. <P>
  65. &lt;expression&gt; can be any valid REDUCE expression that evaluates to a
  66. number.
  67. <P>
  68. <P>
  69. <P> <H3>
  70. examples: </H3>
  71. <p><pre><tt>
  72. a := 20;
  73. A := 20
  74. if greaterp(a,25) then write &quot;big&quot; else write &quot;small&quot;;
  75. small
  76. if a greaterp 20 then write &quot;big&quot; else write &quot;small&quot;;
  77. small
  78. if (a greaterp 18) then write &quot;big&quot; else write &quot;small&quot;;
  79. big
  80. </tt></pre><p>Logical operators can only be used in conditional statements such
  81. as
  82. <P>
  83. <P>
  84. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em>
  85. or
  86. <a href=r38_0050.html#r38_0056>repeat</a>...
  87. <a href=r38_0200.html#r38_0228>while</a>.
  88. <P>
  89. <P>
  90. <P>
  91. <a name=r38_0052>
  92. <title>IF</title></a>
  93. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  94. E"></p>
  95. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  96. <b>IF</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  97. <P>
  98. The <em>if</em> command is a conditional statement that executes a statement
  99. if a condition is true, and optionally another statement if it is not.
  100. <P> <H3>
  101. syntax: </H3>
  102. <P>
  103. <P>
  104. <em>if</em>&lt;condition&gt; <em>then</em> &lt;statement&gt;
  105. _ _ _ option(<em>else</em> &lt;statement&gt;)
  106. <P>
  107. <P>
  108. <P>
  109. &lt;condition&gt; must be a logical or comparison operator that evaluates to
  110. a
  111. <a href=r38_0100.html#r38_0109>boolean value</a>.
  112. &lt;statement&gt; must be a single REDUCE statement or a
  113. <a href=r38_0001.html#r38_0038>group</a> (<em>&lt;&lt;</em>...<em>&gt;&gt;</em>)
  114. or
  115. <a href=r38_0001.html#r38_0041>block</a> (<em>begin</em>...<em>end</em>) stateme
  116. nt.
  117. <P>
  118. <P>
  119. <P> <H3>
  120. examples: </H3>
  121. <p><pre><tt>
  122. if x = 5 then a := b+c else a := d+f;
  123. D + F
  124. x := 9;
  125. X := 9
  126. if numberp x and x&lt;20 then y := sqrt(x) else write &quot;illegal&quot;;
  127. 3
  128. clear x;
  129. if numberp x and x&lt;20 then y := sqrt(x) else write &quot;illegal&quot;;
  130. illegal
  131. x := 12;
  132. X := 12
  133. a := if x &lt; 5 then 100 else 150;
  134. A := 150
  135. b := u**(if x &lt; 10 then 2);
  136. B := 1
  137. bb := u**(if x &gt; 10 then 2);
  138. 2
  139. BB := U
  140. </tt></pre><p>An <em>if</em> statement may be used inside an assignment statemen
  141. t and sets
  142. its value depending on the conditions, or used anywhere else an
  143. expression would be valid, as shown in the last example. If there is no
  144. <em>else</em> clause, the value is 0 if a number is expected, and nothing
  145. otherwise.
  146. <P>
  147. <P>
  148. The <em>else</em> clause may be left out if no action is to be taken if the
  149. condition is false.
  150. <P>
  151. <P>
  152. The condition may be a compound conditional statement using
  153. <a href=r38_0001.html#r38_0039>and</a> or
  154. <a href=r38_0050.html#r38_0054>or</a>. If a non-conditional statement, such as a
  155. constant, is used by
  156. accident, it is assumed to have value true.
  157. <P>
  158. <P>
  159. Be sure to use
  160. <a href=r38_0001.html#r38_0038>group</a> or
  161. <a href=r38_0001.html#r38_0041>block</a> statements after
  162. <em>then</em> or <em>else</em>.
  163. <P>
  164. <P>
  165. The <em>if</em> operator is right associative. The following constructions are
  166. examples:
  167. <P>
  168. <P>
  169. _ _ _ (1)
  170. <P> <H3>
  171. syntax: </H3>
  172. <P>
  173. <P>
  174. <em>if</em>&lt;condition&gt; <em>then</em> <em>if</em> &lt;condition&gt; <em>the
  175. n</em>
  176. &lt;action&gt; <em>else</em> &lt;action&gt;
  177. <P>
  178. <P>
  179. <P>
  180. which is equivalent to
  181. <P> <H3>
  182. syntax: </H3>
  183. <P>
  184. <P>
  185. <em>if</em>&lt;condition&gt; <em>then</em> (<em>if</em> &lt;condition&gt;
  186. <em>then</em> &lt;action&gt; <em>else</em> &lt;action&gt;);
  187. <P>
  188. <P>
  189. <P>
  190. _ _ _ (2)
  191. <P> <H3>
  192. syntax: </H3>
  193. <P>
  194. <P>
  195. <em>if</em>&lt;condition&gt; <em>then</em> &lt;action&gt; <em>else if</em>
  196. &lt;condition&gt; <em>then</em> &lt;action&gt; <em>else</em> &lt;action&gt;
  197. <P>
  198. <P>
  199. <P>
  200. which is equivalent to
  201. <P> <H3>
  202. syntax: </H3>
  203. <P>
  204. <P>
  205. <em>if</em>&lt;condition&gt; <em>then</em> &lt;action&gt; <em>else</em>
  206. <P>
  207. <P>
  208. (<em>if</em> &lt;condition&gt; <em>then</em> &lt;action&gt;
  209. <em>else</em> &lt;action&gt;).
  210. <P>
  211. <P>
  212. <P>
  213. <P>
  214. <P>
  215. <P>
  216. <a name=r38_0053>
  217. <title>LIST</title></a>
  218. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  219. E"></p>
  220. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  221. <b>LIST</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  222. <P>
  223. <P>
  224. <P>
  225. The <em>list</em> operator constructs a list from its arguments.
  226. <P> <H3>
  227. syntax: </H3>
  228. <P>
  229. <P>
  230. <em>list</em>(&lt;item&gt; {,&lt;item&gt;}*) or
  231. <em>list</em>() to construct an empty list.
  232. <P>
  233. <P>
  234. <P>
  235. &lt;item&gt; can be any REDUCE scalar expression, including another list.
  236. Left and right curly brackets can also be used instead of the operator
  237. <em>list</em> to construct a list.
  238. <P>
  239. <P>
  240. <P> <H3>
  241. examples: </H3>
  242. <p><pre><tt>
  243. liss := list(c,b,c,{xx,yy},3x**2+7x+3,df(sin(2*x),x));
  244. 2
  245. LISS := {C,B,C,{XX,YY},3*X + 7*X + 3,2*COS(2*X)}
  246. length liss;
  247. 6
  248. liss := {c,b,c,{xx,yy},3x**2+7x+3,df(sin(2*x),x)};
  249. 2
  250. LISS := {C,B,C,{XX,YY},3*X + 7*X + 3,2*COS(2*X)}
  251. emptylis := list();
  252. EMPTYLIS := {}
  253. a . emptylis;
  254. {A}
  255. </tt></pre><p>Lists are ordered, hierarchical structures. The elements stay wher
  256. e you
  257. put them, and only change position in the list if you specifically change
  258. them. Lists can have nested sublists to any (reasonable) level. The
  259. <a href=r38_0150.html#r38_0169>part</a> operator can be used to access elements
  260. anywhere within a list
  261. hierarchy. The
  262. <a href=r38_0150.html#r38_0157>length</a> operator counts the
  263. number of top-level elements
  264. of its list argument; elements that are themselves lists still only
  265. count as one element.
  266. <P>
  267. <P>
  268. <P>
  269. <a name=r38_0054>
  270. <title>OR</title></a>
  271. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  272. E"></p>
  273. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  274. <b>OR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  275. <P>
  276. The <em>or</em> binary logical operator returns true if either one or
  277. both of its arguments is true.
  278. <P> <H3>
  279. syntax: </H3>
  280. <P>
  281. <P>
  282. &lt;logical expression&gt; <em>or</em> &lt;logical expression&gt;
  283. <P>
  284. <P>
  285. <P>
  286. &lt;logical expression&gt; must evaluate to true or nil.
  287. <P>
  288. <P>
  289. <P> <H3>
  290. examples: </H3>
  291. <p><pre><tt>
  292. a := 10;
  293. A := 10
  294. if a&lt;0 or a&gt;140 then write &quot;not a valid human age&quot; else
  295. write &quot;age = &quot;,a;
  296. age = 10
  297. a := 200;
  298. A := 200
  299. if a &lt; 0 or a &gt; 140 then write &quot;not a valid human age&quot;;
  300. not a valid human age
  301. </tt></pre><p>The <em>or</em> operator is left associative: <em>x or y or z</em>
  302. is equivalent to
  303. <em>(x or y)</em> <em>or z</em>.
  304. <P>
  305. <P>
  306. Logical operators can only be used in conditional expressions, such as
  307. <P>
  308. <P>
  309. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em>
  310. and
  311. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em>.
  312. <em>or</em> evaluates its arguments in order and quits, returning true,
  313. on finding the first true statement.
  314. <P>
  315. <P>
  316. <P>
  317. <a name=r38_0055>
  318. <title>PROCEDURE</title></a>
  319. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  320. E"></p>
  321. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  322. <b>PROCEDURE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  323. <P>
  324. The <em>procedure</em> command allows you to define a mathematical operation as
  325. a
  326. function with arguments.
  327. <P> <H3>
  328. syntax: </H3>
  329. <P>
  330. <P>
  331. _ _ _ &lt;option&gt; <em>procedure</em> &lt;identifier&gt;
  332. (&lt;arg&gt;{,&lt;arg&gt;}+)<em>;</em>&lt;body&gt;
  333. <P>
  334. <P>
  335. <P>
  336. The &lt;option&gt; may be
  337. <a href=r38_0150.html#r38_0186>algebraic</a> or
  338. <a href=r38_0200.html#r38_0221>symbolic</a>,
  339. indicating the
  340. mode under which the procedure is executed, or
  341. <a href=r38_0200.html#r38_0216>real</a> or
  342. <a href=r38_0150.html#r38_0197>integer</a>, indicating the type of answer expect
  343. ed. The default is
  344. algebraic. Real or integer procedures are subtypes of algebraic
  345. procedures; type-checking is done on the results of integer procedures, but
  346. not on real procedures (in the current REDUCE release). &lt;identifier&gt;
  347. may be any valid REDUCE identifier that is not already a procedure name,
  348. operator,
  349. <a href=r38_0150.html#r38_0188>array</a> or
  350. <a href=r38_0300.html#r38_0345>matrix</a>.
  351. &lt;arg&gt; is a formal parameter that may be any
  352. valid REDUCE identifier. &lt;body&gt; is a single statement (a
  353. <a href=r38_0001.html#r38_0038>group</a>
  354. or
  355. <a href=r38_0001.html#r38_0041>block</a> statement may be used) with the desired
  356. activities in it.
  357. <P>
  358. <P>
  359. <P> <H3>
  360. examples: </H3>
  361. <p><pre><tt>
  362. procedure fac(n);
  363. if not (fixp(n) and n&gt;=0)
  364. then rederr &quot;Choose nonneg. integer only&quot;
  365. else for i := 0:n-1 product i+1;
  366. FAC
  367. fac(0);
  368. 1
  369. fac(5);
  370. 120
  371. fac(-5);
  372. ***** choose nonneg. integer only
  373. </tt></pre><p>Procedures are automatically declared as operators upon definition
  374. . When
  375. REDUCE has parsed the procedure definition and successfully converted it to
  376. a form for its own use, it prints the name of the procedure. Procedure
  377. definitions cannot be nested. Procedures can call other procedures, or can
  378. recursively call themselves. Procedure identifiers can be cleared as you
  379. would clear an operator. Unlike
  380. <a href=r38_0150.html#r38_0199>let</a> statements, new definitions
  381. under the same procedure name replace the previous definitions completely.
  382. <P>
  383. <P>
  384. Be careful not to use the name of a system operator for your own procedure.
  385. REDUCE may or may not give you a warning message. If you redefine a system
  386. operator in your own procedure, the original function of the system operator
  387. is lost for the remainder of the REDUCE session.
  388. <P>
  389. <P>
  390. Procedures may have none, one, or more than one parameter. A REDUCE
  391. parameter is a formal parameter only; the use of x as a parameter in
  392. a <em>procedure</em> definition has no connection with a value of x in
  393. the REDUCE session, and the results of calling a procedure have no effect
  394. on the value of x. If a procedure is called with x as a
  395. parameter, the current value of x is used as specified in the
  396. computation, but is not changed outside the procedure.
  397. Making an assignment statement by <em>:=</em> with a
  398. formal parameter on the left-hand side only changes the value of the
  399. calling parameter within the procedure.
  400. <P>
  401. <P>
  402. Using a
  403. <a href=r38_0150.html#r38_0199>let</a> statement inside a procedure always chang
  404. es the value
  405. globally: a <em>let</em> with a formal parameter makes the change to the calling
  406. parameter. <em>let</em> statements cannot be made on local variables inside
  407. <a href=r38_0001.html#r38_0040>begin</a>...<em>end</em>
  408. <a href=r38_0001.html#r38_0041>block</a><em>s</em>.
  409. When
  410. <a href=r38_0150.html#r38_0189>clear</a> statements are used on formal
  411. parameters, the calling variables associated with them are cleared globally too.
  412. The use of <em>let</em> or <em>clear</em> statements inside procedures
  413. should be done with extreme caution.
  414. <P>
  415. <P>
  416. Arrays and operators may be used as parameters to procedures. The body of the
  417. procedure can contain statements that appropriately manipulate these
  418. arguments. Changes are made to values of the calling arrays or operators.
  419. Simple expressions can also be used as arguments, in the place of scalar
  420. variables. Matrices may not be used as arguments to procedures.
  421. <P>
  422. <P>
  423. A procedure that has no parameters is called by the procedure name,
  424. immediately followed by empty parentheses. The empty parentheses may be left
  425. out when writing a procedure with no parameters, but must appear in a call of
  426. the procedure. If this is a nuisance to you, use a
  427. <a href=r38_0150.html#r38_0199>let</a> statement on
  428. the name of the procedure (i.e., <em>let noargs = noargs()</em>) after which
  429. you can call the procedure by just its name.
  430. <P>
  431. <P>
  432. Procedures that have a single argument can leave out the parentheses around
  433. it both in the definition and procedure call. (You can use the parentheses if
  434. you wish.) Procedures with more than one argument must use parentheses, with
  435. the arguments separated by commas.
  436. <P>
  437. <P>
  438. Procedures often have a <em>begin</em>...<em>end</em> block in them. Inside the
  439. block, local variables are declared using <em>scalar</em>, <em>real</em> or
  440. <em>integer</em> declarations.
  441. The declarations must be made immediately after the word
  442. <em>begin</em>, and if more than one type of declaration is made, they are
  443. separated by semicolons. REDUCE currently does no type checking on local
  444. variables; <em>real</em> and <em>integer</em> are treated just like <em>scalar
  445. </em>.
  446. Actions take place as specified in the statements inside the block statement.
  447. Any identifiers that are not formal parameters or local variables are treated
  448. as global variables, and activities involving these identifiers are global in
  449. effect.
  450. <P>
  451. <P>
  452. If a return value is desired from a procedure call, a specific
  453. <a href=r38_0050.html#r38_0058>return</a> command must be the last statement exe
  454. cuted before exiting
  455. from the procedure. If no <em>return</em> is used, a procedure returns a
  456. zero or no value.
  457. <P>
  458. <P>
  459. Procedures are often written in a file using an editor, then the file
  460. is input using the command
  461. <a href=r38_0200.html#r38_0231>in</a>. This method allows easy changes in
  462. development, and also allows you to load the named procedures whenever
  463. you like, by loading the files that contain them.
  464. <P>
  465. <P>
  466. <P>
  467. <a name=r38_0056>
  468. <title>REPEAT</title></a>
  469. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  470. E"></p>
  471. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  472. <b>REPEAT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  473. <P>
  474. <P>
  475. <P>
  476. The
  477. <a href=r38_0050.html#r38_0056>repeat</a> command causes repeated execution of a
  478. statement
  479. <em>until</em><P>
  480. <P>
  481. the given condition is found to be true. The statement is always executed
  482. at least once.
  483. <P> <H3>
  484. syntax: </H3>
  485. <P>
  486. <P>
  487. <em>repeat</em>&lt;statement&gt; <em>until</em> &lt;condition&gt;
  488. <P>
  489. <P>
  490. <P>
  491. &lt;statement&gt; can be a single statement,
  492. <a href=r38_0001.html#r38_0038>group</a> statement, or
  493. a <em>begin</em>...<em>end</em>
  494. <a href=r38_0001.html#r38_0041>block</a>. &lt;condition&gt; must be
  495. a logical operator that evaluates to true or nil.
  496. <P>
  497. <P>
  498. <P> <H3>
  499. examples: </H3>
  500. <p><pre><tt>
  501. &lt;&lt;m := 4; repeat &lt;&lt;write 100*x*m;m := m-1&gt;&gt; until m = 0&gt;
  502. &gt;;
  503. 400*X
  504. 300*X
  505. 200*X
  506. 100*X
  507. &lt;&lt;m := -1; repeat &lt;&lt;write m; m := m-1&gt;&gt; until m &lt;= 0&gt;
  508. &gt;;
  509. -1
  510. </tt></pre><p><em>repeat</em>must always be followed by an <em>until</em> with a
  511. condition.
  512. Be careful not to generate an infinite loop with a condition that is never
  513. true. In the second example, if the condition had been <em>m = 0</em>, it
  514. would never have been true since <em>m</em> already had value -2 when the
  515. condition was first evaluated.
  516. <P>
  517. <P>
  518. <P>
  519. <a name=r38_0057>
  520. <title>REST</title></a>
  521. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  522. E"></p>
  523. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  524. <b>REST</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  525. <P>
  526. <P>
  527. <P>
  528. The <em>rest</em> operator returns a
  529. <a href=r38_0050.html#r38_0053>list</a> containing all but the first
  530. element of the list it is given.
  531. <P> <H3>
  532. syntax: </H3>
  533. <P>
  534. <P>
  535. <em>rest</em>(&lt;list&gt;) or <em>rest</em> &lt;list&gt;
  536. <P>
  537. <P>
  538. <P>
  539. <P>
  540. &lt;list&gt; must be a non-empty list, but need not have more than one element.
  541. <P>
  542. <P>
  543. <P> <H3>
  544. examples: </H3>
  545. <p><pre><tt>
  546. alist := {a,b,c,d};
  547. ALIST := {A,B,C,D};
  548. rest alist;
  549. {B,C,D}
  550. blist := {x,y,{aa,bb,cc},z};
  551. BLIST := {X,Y,{AA,BB,CC},Z}
  552. second rest blist;
  553. {AA,BB,CC}
  554. clist := {c};
  555. CLIST := C
  556. rest clist;
  557. {}
  558. </tt></pre><p>
  559. <a name=r38_0058>
  560. <title>RETURN</title></a>
  561. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  562. E"></p>
  563. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  564. <b>RETURN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  565. <P>
  566. The <em>return</em> command causes a value to be returned from inside a
  567. <em>begin</em>...<em>end</em>
  568. <a href=r38_0001.html#r38_0041>block</a>.
  569. <P>
  570. <P>
  571. <P> <H3>
  572. syntax: </H3>
  573. <em>begin</em>&lt;statements&gt; <em>return</em> &lt;(expression)&gt;
  574. <em>end</em><P>
  575. <P>
  576. <P>
  577. <P>
  578. &lt;statements&gt; can be any valid REDUCE statements. The value of
  579. &lt;expression&gt; is returned.
  580. <P>
  581. <P>
  582. <P> <H3>
  583. examples: </H3>
  584. <p><pre><tt>
  585. begin write &quot;yes&quot;; return a end;
  586. yes
  587. A
  588. procedure dumb(a);
  589. begin if numberp(a) then return a else return 10 end;
  590. DUMB
  591. dumb(x);
  592. 10
  593. dumb(-5);
  594. -5
  595. procedure dumb2(a);
  596. begin c := a**2 + 2*a + 1; d := 17; c*d; return end;
  597. DUMB2
  598. dumb2(4);
  599. c;
  600. 25
  601. d;
  602. 17
  603. </tt></pre><p>Note in <em>dumb2</em> above that the assignments were made as req
  604. uested, but
  605. the product <em>c*d</em> cannot be accessed. Changing the procedure to read
  606. <em>return c*d</em> would remedy this problem.
  607. <P>
  608. <P>
  609. The <em>return</em> statement is always the last statement executed before
  610. leaving the block. If <em>return</em> has no argument, the block is exited but
  611. no value is returned. A block statement does not need a <em>return</em> ;
  612. the statements inside terminate in their normal fashion without one.
  613. In that case no value is returned, although the specified actions inside the
  614. block take place.
  615. <P>
  616. <P>
  617. The <em>return</em> command can be used inside <em>&lt;&lt;</em>...<em>&gt;&gt;
  618. </em>
  619. <a href=r38_0001.html#r38_0038>group</a> statements and
  620. <a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> commands t
  621. hat
  622. are inside <em>begin</em>...<em>end</em>
  623. <a href=r38_0001.html#r38_0041>block</a>s.
  624. It is not valid in these constructions that are not inside
  625. a <em>begin</em>...<em>end</em>
  626. block. It is not valid inside
  627. <a href=r38_0001.html#r38_0047>for</a>,
  628. <a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or
  629. <a href=r38_0200.html#r38_0228>while</a>...<em>do</em>
  630. loops in any construction. To force early termination from loops, the
  631. <em>go to</em>(
  632. <a href=r38_0050.html#r38_0050>goto</a>) command must be used.
  633. When you use nested block statements, a
  634. <em>return</em> from an inner block exits returning a value to the next-outermos
  635. t
  636. block, rather than all the way to the outside.
  637. <P>
  638. <P>
  639. <P>
  640. <a name=r38_0059>
  641. <title>REVERSE</title></a>
  642. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  643. E"></p>
  644. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  645. <b>REVERSE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  646. <P>
  647. <P>
  648. <P>
  649. The <em>reverse</em> operator returns a
  650. <a href=r38_0050.html#r38_0053>list</a> that is the reverse of the
  651. list it is given.
  652. <P> <H3>
  653. syntax: </H3>
  654. <P>
  655. <P>
  656. <em>reverse</em>(&lt;list&gt;) or <em>reverse</em> &lt;list&gt;
  657. <P>
  658. <P>
  659. <P>
  660. &lt;list&gt; must be a
  661. <a href=r38_0050.html#r38_0053>list</a>.
  662. <P>
  663. <P>
  664. <P> <H3>
  665. examples: </H3>
  666. <p><pre><tt>
  667. aa := {c,b,a,{x**2,z**3},y};
  668. 2 3
  669. AA := {C,B,A,{X ,Z },Y}
  670. reverse aa;
  671. 2 3
  672. {Y,{X ,Z },A,B,C}
  673. reverse(q . reverse aa);
  674. 2 3
  675. {C,B,A,{X ,Z },Y,Q}
  676. </tt></pre><p><em>reverse</em>and
  677. <a href=r38_0001.html#r38_0043>cons</a> can be used together to add a new elemen
  678. t to
  679. the end of a list (<em>.</em> adds its new element to the beginning). The
  680. <em>reverse</em> operator uses a noticeable amount of system resources,
  681. especially if the list is long. If you are doing much heavy-duty list
  682. manipulation, you should probably design your algorithms to avoid much
  683. reversing of lists. A moderate amount of list reversing is no problem.
  684. <P>
  685. <P>
  686. <P>
  687. <a name=r38_0060>
  688. <title>RULE</title></a>
  689. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  690. E"></p>
  691. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  692. <b>RULE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>type</b><P>
  693. <P>
  694. <P>
  695. <P>
  696. A <em>rule</em> is an instruction to replace an algebraic expression
  697. or a part of an expression by another one.
  698. <P> <H3>
  699. syntax: </H3>
  700. <P>
  701. <P>
  702. &lt;lhs&gt; =&gt; &lt;rhs&gt; or
  703. &lt;lhs&gt; =&gt; &lt;rhs&gt; <em>when</em> &lt;cond&gt;
  704. <P>
  705. <P>
  706. <P>
  707. &lt;lhs&gt; is an algebraic expression used as search pattern and
  708. &lt;rhs&gt; is an algebraic expression which replaces matches of
  709. &lt;rhs&gt;. <em>=&gt;</em> is the operator
  710. <a href=r38_0001.html#r38_0026>replace</a>.
  711. <P>
  712. <P>
  713. &lt;lhs&gt; can contain
  714. <a href=r38_0050.html#r38_0061>free variable</a>s which are
  715. symbols preceded by a tilde <em>~</em> in their leftmost position
  716. in &lt;lhs&gt;.
  717. A double tilde marks an
  718. <a href=r38_0050.html#r38_0062>optional free variable</a>.
  719. If a rule has a <em>when</em> &lt;cond&gt;
  720. part it will fire only if the evaluation of &lt;cond&gt; has a
  721. result
  722. <a href=r38_0100.html#r38_0122>true</a>. &lt;cond&gt; may contain references to
  723. free variables of &lt;lhs&gt;.
  724. <P>
  725. <P>
  726. Rules can be collected in a
  727. <a href=r38_0050.html#r38_0053>list</a> which then forms a
  728. <em>rule list</em>. <em>Rule lists</em> can be used to collect
  729. algebraic knowledge for a specific evaluation context.
  730. <P>
  731. <P>
  732. <em>Rules</em>and <em>rule lists</em> are globally activated and
  733. deactivated by
  734. <a href=r38_0150.html#r38_0199>let</a>,
  735. <a href=r38_0150.html#r38_0195>forall</a>,
  736. <a href=r38_0150.html#r38_0190>clearrules</a>.
  737. For a single evaluation they can be locally activate by
  738. <a href=r38_0200.html#r38_0227>where</a>.
  739. The active rules for an operator can be visualized by
  740. <a href=r38_0150.html#r38_0178>showrules</a>.
  741. <P>
  742. <P>
  743. <P> <H3>
  744. examples: </H3>
  745. <p><pre><tt>
  746. operator f,g,h;
  747. let f(x) =&gt; x^2;
  748. f(x);
  749. 2
  750. x
  751. g_rules:={g(~n,~x)=&gt;h(n/2,x) when evenp n,
  752. g(~n,~x)=&gt;h((1-n)/2,x) when not evenp n}$
  753. let g_rules;
  754. g(3,x);
  755. h(-1,x)
  756. </tt></pre><p>
  757. <a name=r38_0061>
  758. <title>Free_Variable</title></a>
  759. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  760. E"></p>
  761. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  762. <b>FREE VARIABLE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>type</b><P>
  763. <P>
  764. <P>
  765. <P>
  766. A variable preceded by a tilde is considered as <em>free variable</em>
  767. and stands for an arbitrary part in an algebraic form during
  768. pattern matching. Free variables occur in the left-hand sides
  769. of
  770. <a href=r38_0050.html#r38_0060>rule</a>s, in the side relations for
  771. <a href=r38_0600.html#r38_0642>compact</a>
  772. and in the first arguments of
  773. <a href=r38_0150.html#r38_0163>map</a> and
  774. <a href=r38_0150.html#r38_0177>select</a>
  775. calls. See
  776. <a href=r38_0050.html#r38_0060>rule</a> for examples.
  777. <P>
  778. <P>
  779. In rules also
  780. <a href=r38_0050.html#r38_0062>optional free variable</a>s may occur.
  781. <P>
  782. <P>
  783. <a name=r38_0062>
  784. <title>Optional_Free_Variable</title></a>
  785. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  786. E"></p>
  787. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  788. <b>OPTIONAL FREE VARIABLE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>type</b><P>
  789. <P>
  790. <P>
  791. <P>
  792. A variable preceded by a double tilde is considered as
  793. <em>optional free variable</em><P>
  794. <P>
  795. and stands for an arbitrary part part in an algebraic form during
  796. pattern matching. In contrast to ordinary
  797. <a href=r38_0050.html#r38_0061>free variable</a>s
  798. an operator pattern with an <em>optional free variable</em>
  799. matches also if the operand for the variable is missing. In such
  800. a case the variable is bound to a neutral value.
  801. Optional free variables can be used as
  802. <P>
  803. <P>
  804. term in a sum: set to 0 if missing,
  805. <P>
  806. <P>
  807. factor in a product: set to 1 if missing,
  808. <P>
  809. <P>
  810. exponent: set to 1 if missing
  811. <P>
  812. <P>
  813. <P> <H3>
  814. examples: </H3>
  815. <p><pre><tt></tt></pre><p>Optional free variables are allowed only in the left-h
  816. and sides
  817. of
  818. <a href=r38_0050.html#r38_0060>rule</a>s.
  819. <P>
  820. <P>
  821. <a name=r38_0063>
  822. <title>SECOND</title></a>
  823. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  824. E"></p>
  825. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  826. <b>SECOND</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  827. <P>
  828. <P>
  829. <P>
  830. The <em>second</em> operator returns the second element of a list.
  831. <P> <H3>
  832. syntax: </H3>
  833. <P>
  834. <P>
  835. <em>second</em>(&lt;list&gt;) or <em>second</em> &lt;list&gt;
  836. <P>
  837. <P>
  838. <P>
  839. <P>
  840. &lt;list&gt; must be a list with at least two elements, to avoid an error
  841. message.
  842. <P>
  843. <P>
  844. <P> <H3>
  845. examples: </H3>
  846. <p><pre><tt>
  847. alist := {a,b,c,d};
  848. ALIST := {A,B,C,D}
  849. second alist;
  850. B
  851. blist := {x,{aa,bb,cc},z};
  852. BLIST := {X,{AA,BB,CC},Z}
  853. second second blist;
  854. BB
  855. </tt></pre><p>
  856. <a name=r38_0064>
  857. <title>SET</title></a>
  858. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  859. E"></p>
  860. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  861. <b>SET</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  862. <P>
  863. <P>
  864. <P>
  865. The <em>set</em> operator is used for assignments when you want both sides of
  866. the assignment statement to be evaluated.
  867. <P> <H3>
  868. syntax: </H3>
  869. <P>
  870. <P>
  871. <em>set</em>(&lt;restricted\_expression&gt;,&lt;expression&gt;)
  872. <P>
  873. <P>
  874. <P>
  875. &lt;expression&gt; can be any REDUCE expression; &lt;restricted\_expression&gt;
  876. must be an identifier or an expression that evaluates to an identifier.
  877. <P>
  878. <P>
  879. <P> <H3>
  880. examples: </H3>
  881. <p><pre><tt>
  882. a := y;
  883. A := Y
  884. set(a,sin(x^2));
  885. 2
  886. SIN(X )
  887. a;
  888. 2
  889. SIN(X )
  890. y;
  891. 2
  892. SIN(X )
  893. a := b + c;
  894. A := B + C
  895. set(a-c,z);
  896. Z
  897. b;
  898. Z
  899. </tt></pre><p>Using an
  900. <a href=r38_0150.html#r38_0188>array</a> or
  901. <a href=r38_0300.html#r38_0345>matrix</a> reference as the first
  902. argument to <em>set</em> has
  903. the result of setting the contents of the designated element to
  904. <em>set</em>'s second argument. You should be careful to avoid unwanted
  905. side effects when you use this facility.
  906. <P>
  907. <P>
  908. <P>
  909. <a name=r38_0065>
  910. <title>SETQ</title></a>
  911. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  912. E"></p>
  913. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  914. <b>SETQ</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  915. <P>
  916. <P>
  917. <P>
  918. The <em>setq</em> operator is an infix or prefix binary assignment operator.
  919. It is identical to <em>:=</em>.
  920. <P> <H3>
  921. syntax: </H3>
  922. <P>
  923. <P>
  924. <em>setq</em>(&lt;restricted\_expression&gt;,&lt;expression&gt;) or
  925. <P>
  926. <P>
  927. &lt;restricted\_expression&gt; <em>setq</em> &lt;expression&gt;
  928. <P>
  929. <P>
  930. <P>
  931. &lt;restricted expression&gt; is ordinarily a single identifier, though
  932. simple expressions may be used (see Comments below). &lt;expression&gt; can
  933. be any valid REDUCE expression. If &lt;expression&gt; is a
  934. <a href=r38_0300.html#r38_0345>matrix</a>
  935. identifier, then &lt;restricted\_expression&gt; can be a matrix identifier
  936. (redimensioned if necessary), which has each element set to the
  937. corresponding elements of the identifier on the right-hand side.
  938. <P>
  939. <P>
  940. <P> <H3>
  941. examples: </H3>
  942. <p><pre><tt>
  943. setq(b,6);
  944. B := 6
  945. c setq sin(x);
  946. C := SIN(X)
  947. w + setq(c,x+3) + z;
  948. W + X + Z + 3
  949. c;
  950. X + 3
  951. setq(a1 + a2,25);
  952. A1 + A2 := 25
  953. a1;
  954. - (A2 - 25)
  955. </tt></pre><p>Embedding a <em>setq</em> statement in an expression has the side
  956. effect of making
  957. the assignment, as shown in the third example above.
  958. <P>
  959. <P>
  960. Assignments are generally done for identifiers, but may be done for simple
  961. expressions as well, subject to the following remarks:
  962. <P>
  963. <P>
  964. _ _ _ (i)
  965. If the left-hand side is an identifier, an operator, or a power, the rule
  966. is added to the rule table.
  967. <P>
  968. <P>
  969. _ _ _ (ii)
  970. If the operators <em>- + /</em> appear on the left-hand side, all but the first
  971. term of the expression is moved to the right-hand side.
  972. <P>
  973. <P>
  974. _ _ _ (iii)
  975. If the operator <em>*</em> appears on the left-hand side, any constant terms are
  976. moved to the right-hand side, but the symbolic factors remain.
  977. <P>
  978. <P>
  979. Be careful not to make a recursive <em>setq</em> assignment that is not
  980. controlled inside a loop statement. The process of resubstitution
  981. continues until you get a stack overflow message. <em>setq</em> can be used
  982. to attach functionality to operators, as the <em>:=</em> does.
  983. <P>
  984. <P>
  985. <P>
  986. <a name=r38_0066>
  987. <title>THIRD</title></a>
  988. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  989. E"></p>
  990. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  991. <b>THIRD</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  992. <P>
  993. <P>
  994. <P>
  995. The <em>third</em> operator returns the third item of a
  996. <a href=r38_0050.html#r38_0053>list</a>.
  997. <P> <H3>
  998. syntax: </H3>
  999. <P>
  1000. <P>
  1001. <em>third</em>(&lt;list&gt;) or <em>third</em> &lt;list&gt;
  1002. <P>
  1003. <P>
  1004. <P>
  1005. <P>
  1006. &lt;list&gt; must be a list containing at least three items to avoid an error
  1007. message.
  1008. <P>
  1009. <P>
  1010. <P> <H3>
  1011. examples: </H3>
  1012. <p><pre><tt>
  1013. alist := {a,b,c,d};
  1014. ALIST := {A,B,C,D}
  1015. third alist;
  1016. C
  1017. blist := {x,{aa,bb,cc},y,z};
  1018. BLIST := {X,{AA,BB,CC},Y,Z};
  1019. third second blist;
  1020. CC
  1021. third blist;
  1022. Y
  1023. </tt></pre><p>
  1024. <a name=r38_0067>
  1025. <title>WHEN</title></a>
  1026. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1027. E"></p>
  1028. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1029. <b>WHEN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1030. <P>
  1031. <P>
  1032. <P>
  1033. The <em>when</em> operator is used inside a <em>rule</em> to make the
  1034. execution of the rule depend on a boolean condition which is
  1035. evaluated at execution time. For the use see
  1036. <a href=r38_0050.html#r38_0060>rule</a>.
  1037. <P>
  1038. <P>
  1039. <a name=r38_0068>
  1040. <title>Syntax</title></a>
  1041. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1042. E"></p>
  1043. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1044. <b>Syntax</b><menu>
  1045. <li><a href=r38_0001.html#r38_0020>semicolon command</a>alias= (;)<P>
  1046. <li><a href=r38_0001.html#r38_0021>dollar command</a>alias= ($)<P>
  1047. <li><a href=r38_0001.html#r38_0022>percent command</a>alias= (%)<P>
  1048. <li><a href=r38_0001.html#r38_0023>dot operator</a>alias= (.)<P>
  1049. <li><a href=r38_0050.html#r38_0065>assign operator</a>alias= (: =)<P>
  1050. <li><a href=r38_0001.html#r38_0025>equalsign operator</a>alias= (=)<P>
  1051. <li><a href=r38_0001.html#r38_0026>replace operator</a>alias= (= >)<P>
  1052. <li><a href=r38_0001.html#r38_0027>plussign operator</a>alias= (+)<P>
  1053. <li><a href=r38_0001.html#r38_0028>minussign operator</a>alias= (-)<P>
  1054. <li><a href=r38_0001.html#r38_0029>asterisk operator</a>alias= (*)<P>
  1055. <li><a href=r38_0001.html#r38_0030>slash operator</a>alias= (/)<P>
  1056. <li><a href=r38_0001.html#r38_0031>power operator</a>alias= (* *)<P>
  1057. <li><a href=r38_0001.html#r38_0032>caret operator</a>alias= (^)<P>
  1058. <li><a href=r38_0001.html#r38_0033>geqsign operator</a>alias= (> =)<P>
  1059. <li><a href=r38_0001.html#r38_0034>greater operator</a>alias= (>)<P>
  1060. <li><a href=r38_0001.html#r38_0035>leqsign operator</a>alias= (< =)<P>
  1061. <li><a href=r38_0001.html#r38_0036>less operator</a>alias= (<)<P>
  1062. <li><a href=r38_0001.html#r38_0037>tilde operator</a>alias= (~)<P>
  1063. <li><a href=r38_0001.html#r38_0038>group command</a>alias= (< <)<P>
  1064. <li><a href=r38_0001.html#r38_0039>AND operator</a><P>
  1065. <li><a href=r38_0001.html#r38_0040>BEGIN command</a><P>
  1066. <li><a href=r38_0001.html#r38_0041>block command</a><P>
  1067. <li><a href=r38_0001.html#r38_0042>COMMENT command</a><P>
  1068. <li><a href=r38_0001.html#r38_0043>CONS operator</a><P>
  1069. <li><a href=r38_0001.html#r38_0044>END command</a><P>
  1070. <li><a href=r38_0001.html#r38_0045>EQUATION type</a><P>
  1071. <li><a href=r38_0001.html#r38_0046>FIRST operator</a><P>
  1072. <li><a href=r38_0001.html#r38_0047>FOR command</a><P>
  1073. <li><a href=r38_0001.html#r38_0048>FOREACH command</a><P>
  1074. <li><a href=r38_0001.html#r38_0049>GEQ operator</a><P>
  1075. <li><a href=r38_0050.html#r38_0050>GOTO command</a><P>
  1076. <li><a href=r38_0050.html#r38_0051>GREATERP operator</a><P>
  1077. <li><a href=r38_0050.html#r38_0052>IF command</a><P>
  1078. <li><a href=r38_0050.html#r38_0053>LIST operator</a><P>
  1079. <li><a href=r38_0050.html#r38_0054>OR operator</a><P>
  1080. <li><a href=r38_0050.html#r38_0055>PROCEDURE command</a><P>
  1081. <li><a href=r38_0050.html#r38_0056>REPEAT command</a><P>
  1082. <li><a href=r38_0050.html#r38_0057>REST operator</a><P>
  1083. <li><a href=r38_0050.html#r38_0058>RETURN command</a><P>
  1084. <li><a href=r38_0050.html#r38_0059>REVERSE operator</a><P>
  1085. <li><a href=r38_0050.html#r38_0060>RULE type</a><P>
  1086. <li><a href=r38_0050.html#r38_0061>Free Variable type</a><P>
  1087. <li><a href=r38_0050.html#r38_0062>Optional Free Variable type</a><P>
  1088. <li><a href=r38_0050.html#r38_0063>SECOND operator</a><P>
  1089. <li><a href=r38_0050.html#r38_0064>SET operator</a><P>
  1090. <li><a href=r38_0050.html#r38_0065>SETQ operator</a><P>
  1091. <li><a href=r38_0050.html#r38_0066>THIRD operator</a><P>
  1092. <li><a href=r38_0050.html#r38_0067>WHEN operator</a><P>
  1093. </menu>
  1094. <a name=r38_0069>
  1095. <title>ARITHMETIC_OPERATIONS</title></a>
  1096. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1097. E"></p>
  1098. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1099. <b>ARITHMETIC\_OPERATIONS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>introduction</b><P>
  1100. <P>
  1101. This section considers operations defined in REDUCE that concern numbers,
  1102. or operators that can operate on numbers in addition, in most cases, to
  1103. more general expressions.
  1104. <P>
  1105. <P>
  1106. <a name=r38_0070>
  1107. <title>ABS</title></a>
  1108. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1109. E"></p>
  1110. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1111. <b>ABS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1112. <P>
  1113. <P>
  1114. <P>
  1115. The <em>abs</em> operator returns the absolute value of its argument.
  1116. <P>
  1117. <P>
  1118. <P> <H3>
  1119. syntax: </H3>
  1120. <em>abs</em>(&lt;expression&gt;)
  1121. <P>
  1122. <P>
  1123. <P>
  1124. &lt;expression&gt; can be any REDUCE scalar expression.
  1125. <P>
  1126. <P>
  1127. <P> <H3>
  1128. examples: </H3>
  1129. <p><pre><tt>
  1130. abs(-a);
  1131. ABS(A)
  1132. abs(-5);
  1133. 5
  1134. a := -10;
  1135. A := -10
  1136. abs(a);
  1137. 10
  1138. abs(-a);
  1139. 10
  1140. </tt></pre><p>If the argument has had no numeric value assigned to it, such as a
  1141. n
  1142. identifier or polynomial, <em>abs</em> returns an expression involving
  1143. <em>abs</em> of its argument, doing as much simplification of the argument
  1144. as it can, such as dropping any preceding minus sign.
  1145. <P>
  1146. <P>
  1147. <P>
  1148. <a name=r38_0071>
  1149. <title>ADJPREC</title></a>
  1150. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1151. E"></p>
  1152. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1153. <b>ADJPREC</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>switch</b><P>
  1154. <P>
  1155. <P>
  1156. <P>
  1157. When a real number is input, it is normally truncated to the
  1158. <a href=r38_0200.html#r38_0214>precision</a> in
  1159. effect at the time the number is read. If it is desired to keep the full
  1160. precision of all numbers input, the switch <em>adjprec</em>
  1161. (for &lt;adjust precision&gt;) can be turned on. While on, <em>adjprec</em>
  1162. will automatically increase the precision, when necessary, to match that
  1163. of any integer or real input, and a message printed to inform the user of
  1164. the precision increase.
  1165. <P>
  1166. <P>
  1167. <P> <H3>
  1168. examples: </H3>
  1169. <p><pre><tt>
  1170. on rounded;
  1171. 1.23456789012345;
  1172. 1.23456789012
  1173. on adjprec;
  1174. 1.23456789012345;
  1175. *** precision increased to 15
  1176. </tt></pre><p>
  1177. <a name=r38_0072>
  1178. <title>ARG</title></a>
  1179. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1180. E"></p>
  1181. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1182. <b>ARG</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1183. <P>
  1184. <P>
  1185. <P>
  1186. If
  1187. <a href=r38_0250.html#r38_0274>complex</a> and
  1188. <a href=r38_0300.html#r38_0330>rounded</a> are on, and arg
  1189. evaluates to a complex number, <em>arg</em> returns the polar angle of
  1190. arg, measured in radians. Otherwise an expression in arg is
  1191. returned.
  1192. <P>
  1193. <P>
  1194. <P> <H3>
  1195. examples: </H3>
  1196. <p><pre><tt>
  1197. arg(3+4i)
  1198. ARG(3 + 4*I)
  1199. on rounded, complex;
  1200. ws;
  1201. 0.927295218002
  1202. arg a;
  1203. ARG(A)
  1204. </tt></pre><p>
  1205. <a name=r38_0073>
  1206. <title>CEILING</title></a>
  1207. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1208. E"></p>
  1209. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1210. <b>CEILING</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1211. <P>
  1212. <P>
  1213. <P>
  1214. <P> <H3>
  1215. syntax: </H3>
  1216. <em>ceiling</em>(&lt;expression&gt;)
  1217. <P>
  1218. <P>
  1219. <P>
  1220. This operator returns the ceiling (i.e., the least integer greater than or
  1221. equal to its argument) if its argument has a numerical value. For
  1222. negative numbers, this is equivalent to
  1223. <a href=r38_0050.html#r38_0082>fix</a>. For non-numeric
  1224. arguments, the value is an expression in the original operator.
  1225. <P>
  1226. <P>
  1227. <P> <H3>
  1228. examples: </H3>
  1229. <p><pre><tt>
  1230. ceiling 3.4;
  1231. 4
  1232. fix 3.4;
  1233. 3
  1234. ceiling(-5.2);
  1235. -5
  1236. fix(-5.2);
  1237. -5
  1238. ceiling a;
  1239. CEILING(A)
  1240. </tt></pre><p>
  1241. <a name=r38_0074>
  1242. <title>CHOOSE</title></a>
  1243. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1244. E"></p>
  1245. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1246. <b>CHOOSE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1247. <P>
  1248. <em>choose</em>(&lt;m&gt;,&lt;m&gt;) returns the number of ways of choosing
  1249. &lt;m&gt; objects from a collection of &lt;n&gt; distinct objects --- in other
  1250. words the binomial coefficient. If &lt;m&gt; and &lt;n&gt; are not positive
  1251. integers, or m &gt;n, the expression is returned unchanged.
  1252. than or equal to
  1253. <P> <H3>
  1254. examples: </H3>
  1255. <p><pre><tt>
  1256. choose(2,3);
  1257. 3
  1258. choose(3,2);
  1259. CHOOSE(3,2)
  1260. choose(a,b);
  1261. CHOOSE(A,B)
  1262. </tt></pre><p><P>
  1263. <P>
  1264. <a name=r38_0075>
  1265. <title>DEG2DMS</title></a>
  1266. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1267. E"></p>
  1268. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1269. <b>DEG2DMS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1270. <P>
  1271. <P>
  1272. <P>
  1273. <P> <H3>
  1274. syntax: </H3>
  1275. <em>deg2dms</em>(&lt;expression&gt;)
  1276. <P>
  1277. <P>
  1278. <P>
  1279. In
  1280. <a href=r38_0300.html#r38_0330>rounded</a> mode, if &lt;expression&gt; is a real
  1281. number, the
  1282. operator <em>deg2dms</em> will interpret it as degrees, and convert it to a
  1283. list containing the equivalent degrees, minutes and seconds. In all other
  1284. cases, an expression in terms of the original operator is returned.
  1285. <P>
  1286. <P>
  1287. <P> <H3>
  1288. examples: </H3>
  1289. <p><pre><tt>
  1290. deg2dms 60;
  1291. DEG2DMS(60)
  1292. on rounded;
  1293. ws;
  1294. {60,0,0}
  1295. deg2dms 42.4;
  1296. {42,23,60.0}
  1297. deg2dms a;
  1298. DEG2DMS(A)
  1299. </tt></pre><p>
  1300. <a name=r38_0076>
  1301. <title>DEG2RAD</title></a>
  1302. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1303. E"></p>
  1304. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1305. <b>DEG2RAD</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1306. <P>
  1307. <P>
  1308. <P>
  1309. <P> <H3>
  1310. syntax: </H3>
  1311. <em>deg2rad</em>(&lt;expression&gt;)
  1312. <P>
  1313. <P>
  1314. <P>
  1315. In
  1316. <a href=r38_0300.html#r38_0330>rounded</a> mode, if &lt;expression&gt; is a real
  1317. number, the
  1318. operator <em>deg2rad</em> will interpret it as degrees, and convert it to
  1319. the equivalent radians. In all other cases, an expression in terms of the
  1320. original operator is returned.
  1321. <P>
  1322. <P>
  1323. <P> <H3>
  1324. examples: </H3>
  1325. <p><pre><tt>
  1326. deg2rad 60;
  1327. DEG2RAD(60)
  1328. on rounded;
  1329. ws;
  1330. 1.0471975512
  1331. deg2rad a;
  1332. DEG2RAD(A)
  1333. </tt></pre><p>
  1334. <a name=r38_0077>
  1335. <title>DIFFERENCE</title></a>
  1336. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1337. E"></p>
  1338. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1339. <b>DIFFERENCE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1340. <P>
  1341. The <em>difference</em> operator may be used as either an infix or prefix binary
  1342. subtraction operator. It is identical to <em>-</em> as a binary operator.
  1343. <P>
  1344. <P>
  1345. <P> <H3>
  1346. syntax: </H3>
  1347. <em>difference</em>(&lt;expression&gt;,&lt;expression&gt;) or
  1348. <P>
  1349. <P>
  1350. &lt;expression&gt; <em>difference</em> &lt;expression&gt;
  1351. {<em>difference</em> &lt;expression&gt;}*
  1352. <P>
  1353. <P>
  1354. <P>
  1355. &lt;expression&gt; can be a number or any other valid REDUCE expression. Matrix
  1356. expressions are allowed if they are of the same dimensions.
  1357. <P>
  1358. <P>
  1359. <P> <H3>
  1360. examples: </H3>
  1361. <p><pre><tt>
  1362. difference(10,4);
  1363. 6
  1364. 15 difference 5 difference 2;
  1365. 8
  1366. a difference b;
  1367. A - B
  1368. </tt></pre><p>The <em>difference</em> operator is left associative, as shown in
  1369. the second
  1370. example above.
  1371. <P>
  1372. <P>
  1373. <P>
  1374. <P>
  1375. <a name=r38_0078>
  1376. <title>DILOG</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>DILOG</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1381. <P>
  1382. <P>
  1383. <P>
  1384. The <em>dilog</em> operator is known to the differentiation and integration
  1385. operators, but has numeric value attached only at <em>dilog(0)</em>. Dilog is
  1386. defined by
  1387. <P>
  1388. <P>
  1389. dilog(x) = -int(log(x),x)/(x-1)
  1390. <P>
  1391. <P>
  1392. <P> <H3>
  1393. examples: </H3>
  1394. <p><pre><tt>
  1395. df(dilog(x**2),x);
  1396. 2
  1397. 2*LOG(X )*X
  1398. - ------------
  1399. 2
  1400. X - 1
  1401. int(dilog(x),x);
  1402. DILOG(X)*X - DILOG(X) + LOG(X)*X - X
  1403. dilog(0);
  1404. 2
  1405. PI
  1406. ----
  1407. 6
  1408. </tt></pre><p>
  1409. <a name=r38_0079>
  1410. <title>DMS2DEG</title></a>
  1411. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1412. E"></p>
  1413. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1414. <b>DMS2DEG</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1415. <P>
  1416. <P>
  1417. <P>
  1418. <P> <H3>
  1419. syntax: </H3>
  1420. <em>dms2deg</em>(&lt;list&gt;)
  1421. <P>
  1422. <P>
  1423. <P>
  1424. In
  1425. <a href=r38_0300.html#r38_0330>rounded</a> mode, if &lt;list&gt; is a list of th
  1426. ree real numbers,
  1427. the operator <em>dms2deg</em> will interpret the list as degrees, minutes
  1428. and seconds and convert it to the equivalent degrees. In all other cases,
  1429. an expression in terms of the original operator is returned.
  1430. <P>
  1431. <P>
  1432. <P> <H3>
  1433. examples: </H3>
  1434. <p><pre><tt>
  1435. dms2deg {42,3,7};
  1436. DMS2DEG({42,3,7})
  1437. on rounded;
  1438. ws;
  1439. 42.0519444444
  1440. dms2deg a;
  1441. DMS2DEG(A)
  1442. </tt></pre><p>
  1443. <a name=r38_0080>
  1444. <title>DMS2RAD</title></a>
  1445. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1446. E"></p>
  1447. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1448. <b>DMS2RAD</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1449. <P>
  1450. <P>
  1451. <P>
  1452. <P> <H3>
  1453. syntax: </H3>
  1454. <em>dms2rad</em>(&lt;list&gt;)
  1455. <P>
  1456. <P>
  1457. <P>
  1458. In
  1459. <a href=r38_0300.html#r38_0330>rounded</a> mode, if &lt;list&gt; is a list of th
  1460. ree real numbers,
  1461. the operator <em>dms2rad</em> will interpret the list as degrees, minutes
  1462. and seconds and convert it to the equivalent radians. In all other cases,
  1463. an expression in terms of the original operator is returned.
  1464. <P>
  1465. <P>
  1466. <P> <H3>
  1467. examples: </H3>
  1468. <p><pre><tt>
  1469. dms2rad {42,3,7};
  1470. DMS2RAD({42,3,7})
  1471. on rounded;
  1472. ws;
  1473. 0.733944887421
  1474. dms2rad a;
  1475. DMS2RAD(A)
  1476. </tt></pre><p>
  1477. <a name=r38_0081>
  1478. <title>FACTORIAL</title></a>
  1479. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1480. E"></p>
  1481. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1482. <b>FACTORIAL</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1483. <P>
  1484. <P>
  1485. <P>
  1486. <P> <H3>
  1487. syntax: </H3>
  1488. <em>factorial</em>(&lt;expression&gt;)
  1489. <P>
  1490. <P>
  1491. <P>
  1492. If the argument of <em>factorial</em> is a positive integer or zero, its
  1493. factorial is returned. Otherwise the result is expressed in terms of the
  1494. original operator. For more general operations, the
  1495. <a href=r38_0450.html#r38_0492>gamma</a> operator
  1496. is available in the
  1497. <a href=r38_0400.html#r38_0444>Special Function Package</a>.
  1498. <P>
  1499. <P>
  1500. <P> <H3>
  1501. examples: </H3>
  1502. <p><pre><tt>
  1503. factorial 4;
  1504. 24
  1505. factorial 30 ;
  1506. 265252859812191058636308480000000
  1507. </tt></pre><p>
  1508. <a name=r38_0082>
  1509. <title>FIX</title></a>
  1510. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1511. E"></p>
  1512. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1513. <b>FIX</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1514. <P>
  1515. <P>
  1516. <P>
  1517. <P> <H3>
  1518. syntax: </H3>
  1519. <em>fix</em>(&lt;expression&gt;)
  1520. <P>
  1521. <P>
  1522. <P>
  1523. The operator <em>fix</em> returns the integer part of its argument, if that
  1524. argument has a numerical value. For positive numbers, this is equivalent
  1525. to
  1526. <a href=r38_0050.html#r38_0084>floor</a>, and, for negative numbers,
  1527. <a href=r38_0050.html#r38_0073>ceiling</a>. For
  1528. non-numeric arguments, the value is an expression in the original operator.
  1529. <P>
  1530. <P>
  1531. <P> <H3>
  1532. examples: </H3>
  1533. <p><pre><tt>
  1534. fix 3.4;
  1535. 3
  1536. floor 3.4;
  1537. 3
  1538. ceiling 3.4;
  1539. 4
  1540. fix(-5.2);
  1541. -5
  1542. floor(-5.2);
  1543. -6
  1544. ceiling(-5.2);
  1545. -5
  1546. fix(a);
  1547. FIX(A)
  1548. </tt></pre><p>
  1549. <a name=r38_0083>
  1550. <title>FIXP</title></a>
  1551. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1552. E"></p>
  1553. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1554. <b>FIXP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1555. <P>
  1556. <P>
  1557. <P>
  1558. The <em>fixp</em> logical operator returns true if its argument is an integer.
  1559. <P> <H3>
  1560. syntax: </H3>
  1561. <P>
  1562. <P>
  1563. <em>fixp</em>(&lt;expression&gt;) or <em>fixp</em> &lt;simple\_expression&gt;
  1564. <P>
  1565. <P>
  1566. <P>
  1567. &lt;expression&gt; can be any valid REDUCE expression, &lt;simple\_expression
  1568. &gt;
  1569. must be a single identifier or begin with a prefix operator.
  1570. <P>
  1571. <P>
  1572. <P> <H3>
  1573. examples: </H3>
  1574. <p><pre><tt>
  1575. if fixp 1.5 then write &quot;ok&quot; else write &quot;not&quot;;
  1576. not
  1577. if fixp(a) then write &quot;ok&quot; else write &quot;not&quot;;
  1578. not
  1579. a := 15;
  1580. A := 15
  1581. if fixp(a) then write &quot;ok&quot; else write &quot;not&quot;;
  1582. ok
  1583. </tt></pre><p>Logical operators can only be used inside conditional expressions
  1584. such as
  1585. <em>if</em>...<em>then</em> or <em>while</em>...<em>do</em>.
  1586. <P>
  1587. <P>
  1588. <P>
  1589. <a name=r38_0084>
  1590. <title>FLOOR</title></a>
  1591. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1592. E"></p>
  1593. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1594. <b>FLOOR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1595. <P>
  1596. <P>
  1597. <P>
  1598. <P> <H3>
  1599. syntax: </H3>
  1600. <em>floor</em>(&lt;expression&gt;)
  1601. <P>
  1602. <P>
  1603. <P>
  1604. This operator returns the floor (i.e., the greatest integer less than or
  1605. equal to its argument) if its argument has a numerical value. For
  1606. positive numbers, this is equivalent to
  1607. <a href=r38_0050.html#r38_0082>fix</a>. For non-numeric
  1608. arguments, the value is an expression in the original operator.
  1609. <P>
  1610. <P>
  1611. <P> <H3>
  1612. examples: </H3>
  1613. <p><pre><tt>
  1614. floor 3.4;
  1615. 3
  1616. fix 3.4;
  1617. 3
  1618. floor(-5.2);
  1619. -6
  1620. fix(-5.2);
  1621. -5
  1622. floor a;
  1623. FLOOR(A)
  1624. </tt></pre><p>
  1625. <a name=r38_0085>
  1626. <title>EXPT</title></a>
  1627. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1628. E"></p>
  1629. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1630. <b>EXPT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1631. <P>
  1632. The <em>expt</em> operator is both an infix and prefix binary exponentiation
  1633. operator. It is identical to <em>^</em> or <em>**</em>.
  1634. <P> <H3>
  1635. syntax: </H3>
  1636. <P>
  1637. <P>
  1638. <em>expt</em>(&lt;expression&gt;,&lt;expression&gt;)
  1639. or &lt;expression&gt; <em>expt</em> &lt;expression&gt;
  1640. <P>
  1641. <P>
  1642. <P>
  1643. <P> <H3>
  1644. examples: </H3>
  1645. <p><pre><tt>
  1646. a expt b;
  1647. B
  1648. A
  1649. expt(a,b);
  1650. B
  1651. A
  1652. (x+y) expt 4;
  1653. 4 3 2 2 3 4
  1654. X + 4*X *Y + 6*X *Y + 4*X*Y + Y
  1655. </tt></pre><p>Scalar expressions may be raised to fractional and floating-point
  1656. powers.
  1657. Square matrix expressions may be raised to positive powers, and also to
  1658. negative powers if non-singular.
  1659. <P>
  1660. <P>
  1661. <em>expt</em>is left associative. In other words, <em>a expt b expt c</em> is
  1662. equivalent to <em>a expt (b*c)</em>, not <em>a expt (b expt c)</em>, which
  1663. would be right associative.
  1664. <P>
  1665. <P>
  1666. <P>
  1667. <a name=r38_0086>
  1668. <title>GCD</title></a>
  1669. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1670. E"></p>
  1671. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1672. <b>GCD</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1673. <P>
  1674. <P>
  1675. <P>
  1676. The <em>gcd</em> operator returns the greatest common divisor of two
  1677. polynomials.
  1678. <P> <H3>
  1679. syntax: </H3>
  1680. <P>
  1681. <P>
  1682. <em>gcd</em>(&lt;expression&gt;,&lt;expression&gt;)
  1683. <P>
  1684. <P>
  1685. <P>
  1686. &lt;expression&gt; must be a polynomial (or integer), otherwise an error
  1687. occurs.
  1688. <P>
  1689. <P>
  1690. <P> <H3>
  1691. examples: </H3>
  1692. <p><pre><tt>
  1693. gcd(2*x**2 - 2*y**2,4*x + 4*y);
  1694. 2*(X + Y)
  1695. gcd(sin(x),x**2 + 1);
  1696. 1
  1697. gcd(765,68);
  1698. 17
  1699. </tt></pre><p>The operator <em>gcd</em> described here provides an explicit mean
  1700. s to find the
  1701. gcd of two expressions. The switch <em>gcd</em> described below simplifies
  1702. expressions by finding and canceling gcd's at every opportunity. When
  1703. the switch
  1704. <a href=r38_0250.html#r38_0286>ezgcd</a> is also on, gcd's are figured using the
  1705. EZ GCD
  1706. algorithm, which is usually faster.
  1707. <P>
  1708. <P>
  1709. <P>
  1710. <a name=r38_0087>
  1711. <title>LN</title></a>
  1712. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1713. E"></p>
  1714. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1715. <b>LN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1716. <P>
  1717. <P>
  1718. <P>
  1719. <P> <H3>
  1720. syntax: </H3>
  1721. <em>ln</em>(&lt;expression&gt;)
  1722. <P>
  1723. <P>
  1724. <P>
  1725. &lt;expression&gt; can be any valid scalar REDUCE expression.
  1726. <P>
  1727. <P>
  1728. The <em>ln</em> operator returns the natural logarithm of its argument.
  1729. However, unlike
  1730. <a href=r38_0050.html#r38_0088>log</a>, there are no algebraic rules associated
  1731. with it; it will only evaluate when
  1732. <a href=r38_0300.html#r38_0330>rounded</a> is on, and the
  1733. argument is a real number.
  1734. <P>
  1735. <P>
  1736. <P> <H3>
  1737. examples: </H3>
  1738. <p><pre><tt>
  1739. ln(x);
  1740. LN(X)
  1741. ln 4;
  1742. LN(4)
  1743. ln(e);
  1744. LN(E)
  1745. df(ln(x),x);
  1746. DF(LN(X),X)
  1747. on rounded;
  1748. ln 4;
  1749. 1.38629436112
  1750. ln e;
  1751. 1
  1752. </tt></pre><p>Because of the restricted algebraic properties of <em>ln</em>, use
  1753. rs are
  1754. advised to use
  1755. <a href=r38_0050.html#r38_0088>log</a> whenever possible.
  1756. <P>
  1757. <P>
  1758. <P>
  1759. <a name=r38_0088>
  1760. <title>LOG</title></a>
  1761. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1762. E"></p>
  1763. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1764. <b>LOG</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1765. <P>
  1766. <P>
  1767. <P>
  1768. The <em>log</em> operator returns the natural logarithm of its argument.
  1769. <P> <H3>
  1770. syntax: </H3>
  1771. <P>
  1772. <P>
  1773. <em>log</em>(&lt;expression&gt;) or <em>log</em> &lt;expression&gt;
  1774. <P>
  1775. <P>
  1776. <P>
  1777. &lt;expression&gt; can be any valid scalar REDUCE expression.
  1778. <P>
  1779. <P>
  1780. <P> <H3>
  1781. examples: </H3>
  1782. <p><pre><tt>
  1783. log(x);
  1784. LOG(X)
  1785. log 4;
  1786. LOG(4)
  1787. log(e);
  1788. 1
  1789. on rounded;
  1790. log 4;
  1791. 1.38629436112
  1792. </tt></pre><p><em>log</em>returns a numeric value only when
  1793. <a href=r38_0300.html#r38_0330>rounded</a> is on. In that
  1794. case, use of a negative argument for <em>log</em> results in an error
  1795. message. No error is given on a negative argument when REDUCE is not in
  1796. that mode.
  1797. <P>
  1798. <P>
  1799. <P>
  1800. <a name=r38_0089>
  1801. <title>LOGB</title></a>
  1802. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1803. E"></p>
  1804. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1805. <b>LOGB</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1806. <P>
  1807. <P>
  1808. <P>
  1809. <P> <H3>
  1810. syntax: </H3>
  1811. <em>logb</em>(&lt;expression&gt;,&lt;integer&gt;)
  1812. <P>
  1813. <P>
  1814. <P>
  1815. &lt;expression&gt; can be any valid scalar REDUCE expression.
  1816. <P>
  1817. <P>
  1818. The <em>logb</em> operator returns the logarithm of its first argument using
  1819. the second argument as base. However, unlike
  1820. <a href=r38_0050.html#r38_0088>log</a>, there are no
  1821. algebraic rules associated with it; it will only evaluate when
  1822. <a href=r38_0300.html#r38_0330>rounded</a> is on, and the first argument is a re
  1823. al number.
  1824. <P>
  1825. <P>
  1826. <P> <H3>
  1827. examples: </H3>
  1828. <p><pre><tt>
  1829. logb(x,2);
  1830. LOGB(X,2)
  1831. logb(4,3);
  1832. LOGB(4,3)
  1833. logb(2,2);
  1834. LOGB(2,2)
  1835. df(logb(x,3),x);
  1836. DF(LOGB(X,3),X)
  1837. on rounded;
  1838. logb(4,3);
  1839. 1.26185950714
  1840. logb(2,2);
  1841. 1
  1842. </tt></pre><p>
  1843. <a name=r38_0090>
  1844. <title>MAX</title></a>
  1845. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1846. E"></p>
  1847. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1848. <b>MAX</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1849. <P>
  1850. <P>
  1851. <P>
  1852. The operator <em>max</em> is an n-ary prefix operator, which returns the largest
  1853. value in its arguments.
  1854. <P> <H3>
  1855. syntax: </H3>
  1856. <P>
  1857. <P>
  1858. <em>max</em>(&lt;expression&gt;{,&lt;expression&gt;}*)
  1859. <P>
  1860. <P>
  1861. <P>
  1862. <P>
  1863. &lt;expression&gt; must evaluate to a number. <em>max</em> of an empty list
  1864. returns 0.
  1865. <P>
  1866. <P>
  1867. <P> <H3>
  1868. examples: </H3>
  1869. <p><pre><tt>
  1870. max(4,6,10,-1);
  1871. 10
  1872. &lt;&lt;a := 23;b := 2*a;c := 4**2;max(a,b,c)&gt;&gt;;
  1873. 46
  1874. max(-5,-10,-a);
  1875. -5
  1876. </tt></pre><p>
  1877. <a name=r38_0091>
  1878. <title>MIN</title></a>
  1879. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1880. E"></p>
  1881. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1882. <b>MIN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1883. <P>
  1884. <P>
  1885. <P>
  1886. The operator <em>min</em> is an n-ary prefix operator, which returns the
  1887. smallest value in its arguments.
  1888. <P> <H3>
  1889. syntax: </H3>
  1890. <P>
  1891. <P>
  1892. <em>min</em>(&lt;expression&gt;{,&lt;expression&gt;}*)
  1893. <P>
  1894. <P>
  1895. <P>
  1896. &lt;expression&gt; must evaluate to a number. <em>min</em> of an empty list
  1897. returns 0.
  1898. <P> <H3>
  1899. examples: </H3>
  1900. <p><pre><tt>
  1901. min(-3,0,17,2);
  1902. -3
  1903. &lt;&lt;a := 23;b := 2*a;c := 4**2;min(a,b,c)&gt;&gt;;
  1904. 16
  1905. min(5,10,a);
  1906. 5
  1907. </tt></pre><p><P>
  1908. <P>
  1909. <a name=r38_0092>
  1910. <title>MINUS</title></a>
  1911. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1912. E"></p>
  1913. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1914. <b>MINUS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1915. <P>
  1916. The <em>minus</em> operator is a unary minus, returning the negative of its
  1917. argument. It is equivalent to the unary <em>-</em>.
  1918. <P> <H3>
  1919. syntax: </H3>
  1920. <P>
  1921. <P>
  1922. <em>minus</em>(&lt;expression&gt;)
  1923. <P>
  1924. <P>
  1925. <P>
  1926. <P>
  1927. &lt;expression&gt; may be any scalar REDUCE expression.
  1928. <P>
  1929. <P>
  1930. <P> <H3>
  1931. examples: </H3>
  1932. <p><pre><tt>
  1933. minus(a);
  1934. - A
  1935. minus(-1);
  1936. 1
  1937. minus((x+1)**4);
  1938. 4 3 2
  1939. - (X + 4*X + 6*X + 4*X + 1)
  1940. </tt></pre><p>
  1941. <a name=r38_0093>
  1942. <title>NEXTPRIME</title></a>
  1943. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1944. E"></p>
  1945. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1946. <b>NEXTPRIME</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1947. <P>
  1948. <P>
  1949. <P>
  1950. <P> <H3>
  1951. syntax: </H3>
  1952. <em>nextprime</em>(&lt;expression&gt;)
  1953. <P>
  1954. <P>
  1955. <P>
  1956. If the argument of <em>nextprime</em> is an integer, the least prime greater
  1957. than that argument is returned. Otherwise, a type error results.
  1958. <P>
  1959. <P>
  1960. <P> <H3>
  1961. examples: </H3>
  1962. <p><pre><tt>
  1963. nextprime 5001;
  1964. 5003
  1965. nextprime(10^30);
  1966. 1000000000000000000000000000057
  1967. nextprime a;
  1968. ***** A invalid as integer
  1969. </tt></pre><p>
  1970. <a name=r38_0094>
  1971. <title>NOCONVERT</title></a>
  1972. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1973. E"></p>
  1974. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1975. <b>NOCONVERT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>switch</b><P>
  1976. <P>
  1977. Under normal circumstances when <em>rounded</em> is on, REDUCE converts the
  1978. number 1.0 to the integer 1. If this is not desired, the switch
  1979. <em>noconvert</em> can be turned on.
  1980. <P> <H3>
  1981. examples: </H3>
  1982. <p><pre><tt>
  1983. on rounded;
  1984. 1.0000000000001;
  1985. 1
  1986. on noconvert;
  1987. 1.0000000000001;
  1988. 1.0
  1989. </tt></pre><p><P>
  1990. <P>
  1991. <a name=r38_0095>
  1992. <title>NORM</title></a>
  1993. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1994. E"></p>
  1995. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1996. <b>NORM</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1997. <P>
  1998. <P>
  1999. <P>
  2000. <P> <H3>
  2001. syntax: </H3>
  2002. <em>norm</em>(&lt;expression&gt;)
  2003. <P>
  2004. <P>
  2005. <P>
  2006. If <em>rounded</em> is on, and the argument is a real number, &lt;norm&gt;
  2007. returns its absolute value. If <em>complex</em> is also on, &lt;norm&gt;
  2008. returns the square root of the sum of squares of the real and imaginary
  2009. parts of the argument. In all other cases, a result is returned in
  2010. terms of the original operator.
  2011. <P>
  2012. <P>
  2013. <P> <H3>
  2014. examples: </H3>
  2015. <p><pre><tt>
  2016. norm (-2);
  2017. NORM(-2)
  2018. on rounded;
  2019. ws;
  2020. 2.0
  2021. norm(3+4i);
  2022. NORM(4*I+3)
  2023. on complex;
  2024. ws;
  2025. 5.0
  2026. </tt></pre><p>
  2027. <a name=r38_0096>
  2028. <title>PERM</title></a>
  2029. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2030. E"></p>
  2031. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2032. <b>PERM</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  2033. <P>
  2034. <P>
  2035. <P>
  2036. <P> <H3>
  2037. syntax: </H3>
  2038. perm(&lt;expression1&gt;,&lt;expression2&gt;)
  2039. <P>
  2040. <P>
  2041. <P>
  2042. If &lt;expression1&gt; and &lt;expression2&gt; evaluate to positive integers,
  2043. <em>perm</em> returns the number of permutations possible in selecting
  2044. &lt;expression1&gt; objects from &lt;expression2&gt; objects.
  2045. In other cases, an expression in the original operator is returned.
  2046. <P>
  2047. <P>
  2048. <P> <H3>
  2049. examples: </H3>
  2050. <p><pre><tt>
  2051. perm(1,1);
  2052. 1
  2053. perm(3,5);
  2054. 60
  2055. perm(-3,5);
  2056. PERM(-3,5)
  2057. perm(a,b);
  2058. PERM(A,B)
  2059. </tt></pre><p>
  2060. <a name=r38_0097>
  2061. <title>PLUS</title></a>
  2062. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2063. E"></p>
  2064. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2065. <b>PLUS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  2066. <P>
  2067. The <em>plus</em> operator is both an infix and prefix n-ary addition
  2068. operator. It exists because of the way in which REDUCE handles such
  2069. operators internally, and is not recommended for use in algebraic mode
  2070. programming.
  2071. <a href=r38_0001.html#r38_0027>plussign</a>, which has the identical effect, sho
  2072. uld be
  2073. used instead.
  2074. <P> <H3>
  2075. syntax: </H3>
  2076. <P>
  2077. <P>
  2078. <em>plus</em>(&lt;expression&gt;,&lt;expression&gt;{,&lt;expression&gt;}
  2079. *) or
  2080. <P>
  2081. <P>
  2082. &lt;expression&gt; <em>plus</em> &lt;expression&gt; {<em>plus</em> &lt;expressio
  2083. n&gt;}*
  2084. <P>
  2085. <P>
  2086. <P>
  2087. &lt;expression&gt; can be any valid REDUCE expression, including matrix
  2088. expressions of the same dimensions.
  2089. <P>
  2090. <P>
  2091. <P> <H3>
  2092. examples: </H3>
  2093. <p><pre><tt>
  2094. a plus b plus c plus d;
  2095. A + B + C + D
  2096. 4.5 plus 10;
  2097. 29
  2098. --
  2099. 2
  2100. plus(x**2,y**2);
  2101. 2 2
  2102. X + Y
  2103. </tt></pre><p>
  2104. <a name=r38_0098>
  2105. <title>QUOTIENT</title></a>
  2106. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2107. E"></p>
  2108. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2109. <b>QUOTIENT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  2110. <P>
  2111. The <em>quotient</em> operator is both an infix and prefix binary operator that
  2112. returns the quotient of its first argument divided by its second. It is
  2113. also a unary
  2114. <a href=r38_0100.html#r38_0101>recip</a>rocal operator. It is identical to <em>/
  2115. </em> and
  2116. <a href=r38_0001.html#r38_0030>slash</a>.
  2117. <P> <H3>
  2118. syntax: </H3>
  2119. <P>
  2120. <P>
  2121. <em>quotient</em>(&lt;expression&gt;,&lt;expression&gt;) or
  2122. &lt;expression&gt; <em>quotient</em> &lt;expression&gt; or
  2123. <em>quotient</em>(&lt;expression&gt;) or
  2124. <em>quotient</em> &lt;expression&gt;
  2125. <P>
  2126. <P>
  2127. <P>
  2128. &lt;expression&gt; can be any valid REDUCE scalar expression. Matrix
  2129. expressions can also be used if the second expression is invertible and the
  2130. matrices are of the correct dimensions.
  2131. <P> <H3>
  2132. examples: </H3>
  2133. <p><pre><tt>
  2134. quotient(a,x+1);
  2135. A
  2136. -----
  2137. X + 1
  2138. 7 quotient 17;
  2139. 7
  2140. --
  2141. 17
  2142. on rounded;
  2143. 4.5 quotient 2;
  2144. 2.25
  2145. quotient(x**2 + 3*x + 2,x+1);
  2146. X + 2
  2147. matrix m,inverse;
  2148. m := mat((a,b),(c,d));
  2149. M(1,1) := A;
  2150. M(1,2) := B;
  2151. M(2,1) := C
  2152. M(2,2) := D
  2153. inverse := quotient m;
  2154. D
  2155. INVERSE(1,1) := ----------
  2156. A*D - B*C
  2157. B
  2158. INVERSE(1,2) := - ----------
  2159. A*D - B*C
  2160. C
  2161. INVERSE(2,1) := - ----------
  2162. A*D - B*C
  2163. A
  2164. INVERSE(2,2) := ----------
  2165. A*D - B*C
  2166. </tt></pre><p><P>
  2167. <P>
  2168. The <em>quotient</em> operator is left associative: <em>a quotient b quotient c
  2169. </em>
  2170. is equivalent to <em>(a quotient b) quotient c</em>.
  2171. <P>
  2172. <P>
  2173. If a matrix argument to the unary <em>quotient</em> is not invertible, or if the
  2174. second matrix argument to the binary quotient is not invertible, an error
  2175. message is given.
  2176. <P>
  2177. <P>
  2178. <P>
  2179. <a name=r38_0099>
  2180. <title>RAD2DEG</title></a>
  2181. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2182. E"></p>
  2183. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2184. <b>RAD2DEG</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  2185. <P>
  2186. <P>
  2187. <P>
  2188. <P> <H3>
  2189. syntax: </H3>
  2190. <em>rad2deg</em>(&lt;expression&gt;)
  2191. <P>
  2192. <P>
  2193. <P>
  2194. In
  2195. <a href=r38_0300.html#r38_0330>rounded</a> mode, if &lt;expression&gt; is a real
  2196. number, the
  2197. operator <em>rad2deg</em> will interpret it as radians, and convert it to
  2198. the equivalent degrees. In all other cases, an expression in terms of the
  2199. original operator is returned.
  2200. <P>
  2201. <P>
  2202. <P> <H3>
  2203. examples: </H3>
  2204. <p><pre><tt>
  2205. rad2deg 1;
  2206. RAD2DEG(1)
  2207. on rounded;
  2208. ws;
  2209. 57.2957795131
  2210. rad2deg a;
  2211. RAD2DEG(A)
  2212. </tt></pre><p>