r38_0100.html 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700
  1. <a name=r38_0100>
  2. <title>RAD2DMS</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>RAD2DMS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  7. <P>
  8. <P>
  9. <P>
  10. <P> <H3>
  11. syntax: </H3>
  12. <em>rad2dms</em>(&lt;expression&gt;)
  13. <P>
  14. <P>
  15. <P>
  16. In
  17. <a href=r38_0300.html#r38_0330>rounded</a> mode, if &lt;expression&gt; is a real
  18. number, the
  19. operator <em>rad2dms</em> will interpret it as radians, and convert it to a
  20. list containing the equivalent degrees, minutes and seconds. In all other
  21. cases, an expression in terms of the original operator is returned.
  22. <P>
  23. <P>
  24. <P> <H3>
  25. examples: </H3>
  26. <p><pre><tt>
  27. rad2dms 1;
  28. RAD2DMS(1)
  29. on rounded;
  30. ws;
  31. {57,17,44.8062470964}
  32. rad2dms a;
  33. RAD2DMS(A)
  34. </tt></pre><p>
  35. <a name=r38_0101>
  36. <title>RECIP</title></a>
  37. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  38. E"></p>
  39. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  40. <b>RECIP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  41. <P>
  42. <em>recip</em> is the alphabetical name for the division operator <em>/</em>
  43. or
  44. <a href=r38_0001.html#r38_0030>slash</a> used as a unary operator. The use of
  45. <em>/</em> is preferred.
  46. <P>
  47. <P>
  48. <P> <H3>
  49. examples: </H3>
  50. <p><pre><tt>
  51. recip a;
  52. 1
  53. -
  54. A
  55. recip 2;
  56. 1
  57. --
  58. 2
  59. </tt></pre><p>
  60. <a name=r38_0102>
  61. <title>REMAINDER</title></a>
  62. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  63. E"></p>
  64. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  65. <b>REMAINDER</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  66. <P>
  67. <P>
  68. <P>
  69. The <em>remainder</em> operator returns the remainder after its first
  70. argument is divided by its second argument.
  71. <P>
  72. <P>
  73. <P> <H3>
  74. syntax: </H3>
  75. <em>remainder</em>(&lt;expression&gt;,&lt;expression&gt;)
  76. <P>
  77. <P>
  78. <P>
  79. &lt;expression&gt; can be any valid REDUCE polynomial, and is not limited
  80. to numeric values.
  81. <P>
  82. <P>
  83. <P> <H3>
  84. examples: </H3>
  85. <p><pre><tt>
  86. remainder(13,6);
  87. 1
  88. remainder(x**2 + 3*x + 2,x+1);
  89. 0
  90. remainder(x**3 + 12*x + 4,x**2 + 1);
  91. 11*X + 4
  92. remainder(sin(2*x),x*y);
  93. SIN(2*X)
  94. </tt></pre><p>In the default case, remainders are calculated over the integers.
  95. If you
  96. need the remainder with respect to another domain, it must be declared
  97. explicitly.
  98. <P>
  99. <P>
  100. If the first argument to <em>remainder</em> contains a denominator not equal to
  101. 1, an error occurs.
  102. <P>
  103. <P>
  104. <P>
  105. <a name=r38_0103>
  106. <title>ROUND</title></a>
  107. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  108. E"></p>
  109. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  110. <b>ROUND</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  111. <P>
  112. <P>
  113. <P>
  114. <P> <H3>
  115. syntax: </H3>
  116. <em>round</em>(&lt;expression&gt;)
  117. <P>
  118. <P>
  119. <P>
  120. If its argument has a numerical value, <em>round</em> rounds it to the
  121. nearest integer. For non-numeric arguments, the value is an expression in
  122. the original operator.
  123. <P>
  124. <P>
  125. <P> <H3>
  126. examples: </H3>
  127. <p><pre><tt>
  128. round 3.4;
  129. 3
  130. round 3.5;
  131. 4
  132. round a;
  133. ROUND(A)
  134. </tt></pre><p>
  135. <a name=r38_0104>
  136. <title>SETMOD</title></a>
  137. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  138. E"></p>
  139. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  140. <b>SETMOD</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  141. <P>
  142. <P>
  143. <P>
  144. The <em>setmod</em> command sets the modulus value for subsequent
  145. <a href=r38_0300.html#r38_0305>modular</a>
  146. arithmetic.
  147. <P> <H3>
  148. syntax: </H3>
  149. <P>
  150. <P>
  151. <em>setmod</em>&lt;integer&gt;
  152. <P>
  153. <P>
  154. <P>
  155. &lt;integer&gt; must be positive, and greater than 1. It need not be a prime
  156. number.
  157. <P>
  158. <P>
  159. <P> <H3>
  160. examples: </H3>
  161. <p><pre><tt>
  162. setmod 6;
  163. 1
  164. on modular;
  165. 16;
  166. 4
  167. x^2 + 5x + 7;
  168. 2
  169. X + 5*X + 1
  170. x/3;
  171. X
  172. -
  173. 3
  174. setmod 2;
  175. 6
  176. (x+1)^4;
  177. 4
  178. X + 1
  179. x/3;
  180. X
  181. </tt></pre><p><em>setmod</em>returns the previous modulus, or 1 if none has been
  182. set
  183. before. <em>setmod</em> only has effect when
  184. <a href=r38_0300.html#r38_0305>modular</a> is on.
  185. <P>
  186. <P>
  187. Modular operations are done only on numbers such as coefficients of
  188. polynomials, not on the exponents. The modulus need not be prime.
  189. Attempts to divide by a power of the modulus produces an error message, since th
  190. e
  191. operation is equivalent to dividing by 0. However, dividing by a factor
  192. of a non-prime modulus does not produce an error message.
  193. <P>
  194. <P>
  195. <P>
  196. <a name=r38_0105>
  197. <title>SIGN</title></a>
  198. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  199. E"></p>
  200. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  201. <b>SIGN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  202. <P>
  203. <P>
  204. <P>
  205. <P> <H3>
  206. syntax: </H3>
  207. <em>sign</em>&lt;expression&gt;
  208. <P>
  209. <P>
  210. <P>
  211. <em>sign</em>tries to evaluate the sign of its argument. If this
  212. is possible <em>sign</em> returns one of 1, 0 or -1. Otherwise, the result
  213. is the original form or a simplified variant.
  214. <P>
  215. <P>
  216. <P> <H3>
  217. examples: </H3>
  218. <p><pre><tt>
  219. sign(-5)
  220. -1
  221. sign(-a^2*b)
  222. -SIGN(B)
  223. </tt></pre><p>Even powers of formal expressions are assumed to be positive only
  224. as long
  225. as the switch
  226. <a href=r38_0250.html#r38_0274>complex</a> is off.
  227. <P>
  228. <P>
  229. <P>
  230. <a name=r38_0106>
  231. <title>SQRT</title></a>
  232. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  233. E"></p>
  234. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  235. <b>SQRT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  236. <P>
  237. <P>
  238. <P>
  239. The <em>sqrt</em> operator returns the square root of its argument.
  240. <P> <H3>
  241. syntax: </H3>
  242. <P>
  243. <P>
  244. <em>sqrt</em>(&lt;expression&gt;)
  245. <P>
  246. <P>
  247. <P>
  248. &lt;expression&gt; can be any REDUCE scalar expression.
  249. <P>
  250. <P>
  251. <P> <H3>
  252. examples: </H3>
  253. <p><pre><tt>
  254. sqrt(16*a^3);
  255. 4*SQRT(A)*A
  256. sqrt(17);
  257. SQRT(17)
  258. on rounded;
  259. sqrt(17);
  260. 4.12310562562
  261. off rounded;
  262. sqrt(a*b*c^5*d^3*27);
  263. 2
  264. 3*SQRT(D)*SQRT(C)*SQRT(B)*SQRT(A)*SQRT(3)*C *D
  265. </tt></pre><p><em>sqrt</em>checks its argument for squared factors and removes t
  266. hem.
  267. <P>
  268. <P>
  269. Numeric values for square roots that are not exact integers are given only
  270. when
  271. <a href=r38_0300.html#r38_0330>rounded</a> is on.
  272. <P>
  273. <P>
  274. Please note that <em>sqrt(a**2)</em> is given as <em>a</em>, which may be
  275. incorrect if <em>a</em> eventually has a negative value. If you are
  276. programming a calculation in which this is a concern, you can turn on the
  277. <a href=r38_0300.html#r38_0317>precise</a> switch, which causes the absolute val
  278. ue of the square root
  279. to be returned.
  280. <P>
  281. <P>
  282. <P>
  283. <a name=r38_0107>
  284. <title>TIMES</title></a>
  285. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  286. E"></p>
  287. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  288. <b>TIMES</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  289. <P>
  290. The <em>times</em> operator is an infix or prefix n-ary multiplication
  291. operator. It is identical to <em>*</em>.
  292. <P> <H3>
  293. syntax: </H3>
  294. <P>
  295. <P>
  296. &lt;expression&gt; <em>times</em> &lt;expression&gt; {<em>times</em> &lt;express
  297. ion&gt;}*
  298. <P>
  299. <P>
  300. or <em>times</em>(&lt;expression&gt;,&lt;expression&gt; {,&lt;expression&gt;}*)
  301. <P>
  302. <P>
  303. <P>
  304. &lt;expression&gt; can be any valid REDUCE scalar or matrix expression.
  305. Matrix expressions must be of the correct dimensions. Compatible scalar
  306. and matrix expressions can be mixed.
  307. <P>
  308. <P>
  309. <P> <H3>
  310. examples: </H3>
  311. <p><pre><tt>
  312. var1 times var2;
  313. VAR1*VAR2
  314. times(6,5);
  315. 30
  316. matrix aa,bb;
  317. aa := mat((1),(2),(x))$
  318. bb := mat((0,3,1))$
  319. aa times bb times 5;
  320. [0 15 5 ]
  321. [ ]
  322. [0 30 10 ]
  323. [ ]
  324. [0 15*X 5*X]
  325. </tt></pre><p>
  326. <a name=r38_0108>
  327. <title>Arithmetic Operations</title></a>
  328. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  329. E"></p>
  330. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  331. <b>Arithmetic Operations</b><menu>
  332. <li><a href=r38_0050.html#r38_0069>ARITHMETIC\_OPERATIONS introduction</a><P>
  333. <li><a href=r38_0050.html#r38_0070>ABS operator</a><P>
  334. <li><a href=r38_0050.html#r38_0071>ADJPREC switch</a><P>
  335. <li><a href=r38_0050.html#r38_0072>ARG operator</a><P>
  336. <li><a href=r38_0050.html#r38_0073>CEILING operator</a><P>
  337. <li><a href=r38_0050.html#r38_0074>CHOOSE operator</a><P>
  338. <li><a href=r38_0050.html#r38_0075>DEG2DMS operator</a><P>
  339. <li><a href=r38_0050.html#r38_0076>DEG2RAD operator</a><P>
  340. <li><a href=r38_0050.html#r38_0077>DIFFERENCE operator</a><P>
  341. <li><a href=r38_0050.html#r38_0078>DILOG operator</a><P>
  342. <li><a href=r38_0050.html#r38_0079>DMS2DEG operator</a><P>
  343. <li><a href=r38_0050.html#r38_0080>DMS2RAD operator</a><P>
  344. <li><a href=r38_0050.html#r38_0081>FACTORIAL operator</a><P>
  345. <li><a href=r38_0050.html#r38_0082>FIX operator</a><P>
  346. <li><a href=r38_0050.html#r38_0083>FIXP operator</a><P>
  347. <li><a href=r38_0050.html#r38_0084>FLOOR operator</a><P>
  348. <li><a href=r38_0050.html#r38_0085>EXPT operator</a><P>
  349. <li><a href=r38_0050.html#r38_0086>GCD operator</a><P>
  350. <li><a href=r38_0050.html#r38_0087>LN operator</a><P>
  351. <li><a href=r38_0050.html#r38_0088>LOG operator</a><P>
  352. <li><a href=r38_0050.html#r38_0089>LOGB operator</a><P>
  353. <li><a href=r38_0050.html#r38_0090>MAX operator</a><P>
  354. <li><a href=r38_0050.html#r38_0091>MIN operator</a><P>
  355. <li><a href=r38_0050.html#r38_0092>MINUS operator</a><P>
  356. <li><a href=r38_0050.html#r38_0093>NEXTPRIME operator</a><P>
  357. <li><a href=r38_0050.html#r38_0094>NOCONVERT switch</a><P>
  358. <li><a href=r38_0050.html#r38_0095>NORM operator</a><P>
  359. <li><a href=r38_0050.html#r38_0096>PERM operator</a><P>
  360. <li><a href=r38_0050.html#r38_0097>PLUS operator</a><P>
  361. <li><a href=r38_0050.html#r38_0098>QUOTIENT operator</a><P>
  362. <li><a href=r38_0050.html#r38_0099>RAD2DEG operator</a><P>
  363. <li><a href=r38_0100.html#r38_0100>RAD2DMS operator</a><P>
  364. <li><a href=r38_0100.html#r38_0101>RECIP operator</a><P>
  365. <li><a href=r38_0100.html#r38_0102>REMAINDER operator</a><P>
  366. <li><a href=r38_0100.html#r38_0103>ROUND operator</a><P>
  367. <li><a href=r38_0100.html#r38_0104>SETMOD command</a><P>
  368. <li><a href=r38_0100.html#r38_0105>SIGN operator</a><P>
  369. <li><a href=r38_0100.html#r38_0106>SQRT operator</a><P>
  370. <li><a href=r38_0100.html#r38_0107>TIMES operator</a><P>
  371. </menu>
  372. <a name=r38_0109>
  373. <title>boolean_value</title></a>
  374. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  375. E"></p>
  376. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  377. <b>BOOLEAN VALUE</b><P>
  378. <P>
  379. There are no extra symbols for the truth values true
  380. and false. Instead,
  381. <a href=r38_0001.html#r38_0014>nil</a> and the number zero
  382. are interpreted as truth value false in algebraic
  383. programs (see
  384. <a href=r38_0001.html#r38_0014>false</a>), while any different
  385. value is considered as true (see
  386. <a href=r38_0100.html#r38_0122>true</a>).
  387. <P>
  388. <P>
  389. <a name=r38_0110>
  390. <title>EQUAL</title></a>
  391. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  392. E"></p>
  393. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  394. <b>EQUAL</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  395. <P>
  396. <P>
  397. <P>
  398. The operator <em>equal</em> is an infix binary comparison
  399. operator. It is identical with <em>=</em>. It returns
  400. <a href=r38_0100.html#r38_0122>true</a> if its two
  401. arguments are equal.
  402. <P>
  403. <P>
  404. <P> <H3>
  405. syntax: </H3>
  406. &lt;expression&gt; <em>equal</em> &lt;expression&gt;
  407. <P>
  408. <P>
  409. <P>
  410. Equality is given between floating point numbers and integers that have
  411. the same value.
  412. <P>
  413. <P>
  414. <P> <H3>
  415. examples: </H3>
  416. <p><pre><tt>
  417. on rounded;
  418. a := 4;
  419. A := 4
  420. b := 4.0;
  421. B := 4.0
  422. if a equal b then write &quot;true&quot; else write &quot;false&quot;;
  423. true
  424. if a equal 5 then write &quot;true&quot; else write &quot;false&quot;;
  425. false
  426. if a equal sqrt(16) then write &quot;true&quot; else write &quot;false&quot;;
  427. true
  428. </tt></pre><p>Comparison operators can only be used as conditions in conditional
  429. commands
  430. such as <em>if</em>...<em>then</em> and <em>repeat</em>...<em>until</em>.
  431. &lt;equal&gt; can also be used as a prefix operator. However, this use
  432. is not encouraged.
  433. <P>
  434. <P>
  435. <P>
  436. <a name=r38_0111>
  437. <title>EVENP</title></a>
  438. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  439. E"></p>
  440. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  441. <b>EVENP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  442. <P>
  443. The <em>evenp</em> logical operator returns
  444. <a href=r38_0100.html#r38_0122>true</a> if its argument is an
  445. even integer, and
  446. <a href=r38_0001.html#r38_0014>nil</a> if its argument is an odd integer. An err
  447. or
  448. message is returned if its argument is not an integer.
  449. <P>
  450. <P>
  451. <P> <H3>
  452. syntax: </H3>
  453. <em>evenp</em>(&lt;integer&gt;) or <em>evenp</em> &lt;integer&gt;
  454. <P>
  455. <P>
  456. <P>
  457. &lt;integer&gt; must evaluate to an integer.
  458. <P>
  459. <P>
  460. <P> <H3>
  461. examples: </H3>
  462. <p><pre><tt>
  463. aa := 1782;
  464. AA := 1782
  465. if evenp aa then yes else no;
  466. YES
  467. if evenp(-3) then yes else no;
  468. NO
  469. </tt></pre><p>Although you would not ordinarily enter an expression such as the
  470. last
  471. example above, note that the negative term must be enclosed in parentheses
  472. to be correctly parsed. The <em>evenp</em> operator can only be used in
  473. conditional statements such as <em>if</em>...<em>then</em>...<em>else</em>
  474. or <em>while</em>...<em>do</em>.
  475. <P>
  476. <P>
  477. <P>
  478. <a name=r38_0112>
  479. <title>false</title></a>
  480. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  481. E"></p>
  482. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  483. <b>FALSE</b><P>
  484. <P>
  485. The symbol
  486. <a href=r38_0001.html#r38_0014>nil</a> and the number zero are considered
  487. as
  488. <a href=r38_0100.html#r38_0109>boolean value</a> false if used in a place where
  489. a boolean value is required. Most builtin operators return
  490. <a href=r38_0001.html#r38_0014>nil</a> as false value. Algebraic programs use be
  491. tter zero.
  492. Note that <em>nil</em> is not printed when returned as result to
  493. a top level evaluation.
  494. <P>
  495. <P>
  496. <a name=r38_0113>
  497. <title>FREEOF</title></a>
  498. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  499. E"></p>
  500. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  501. <b>FREEOF</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  502. <P>
  503. The <em>freeof</em> logical operator returns
  504. <a href=r38_0100.html#r38_0122>true</a> if its first argument does
  505. not contain its second argument anywhere in its structure.
  506. <P> <H3>
  507. syntax: </H3>
  508. <P>
  509. <P>
  510. <em>freeof</em>(&lt;expression&gt;,&lt;kernel&gt;) or
  511. &lt;expression&gt; <em>freeof</em> &lt;kernel&gt;
  512. <P>
  513. <P>
  514. <P>
  515. &lt;expression&gt; can be any valid scalar REDUCE expression, &lt;kernel&gt; mus
  516. t
  517. be a kernel expression (see <em>kernel</em>).
  518. <P>
  519. <P>
  520. <P> <H3>
  521. examples: </H3>
  522. <p><pre><tt>
  523. a := x + sin(y)**2 + log sin z;
  524. 2
  525. A := LOG(SIN(Z)) + SIN(Y) + X
  526. if freeof(a,sin(y)) then write &quot;free&quot; else write &quot;not free&quot;;
  527. not free
  528. if freeof(a,sin(x)) then write &quot;free&quot; else write &quot;not free&quot;;
  529. free
  530. if a freeof sin z then write &quot;free&quot; else write &quot;not free&quot;;
  531. not free
  532. </tt></pre><p>Logical operators can only be used in conditional expressions such
  533. as
  534. <P>
  535. <P>
  536. <em>if</em>...<em>then</em> or <em>while</em>...<em>do</em>.
  537. <P>
  538. <P>
  539. <P>
  540. <a name=r38_0114>
  541. <title>LEQ</title></a>
  542. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  543. E"></p>
  544. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  545. <b>LEQ</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  546. <P>
  547. The <em>leq</em> operator is a binary infix or prefix logical operator. It
  548. returns
  549. <a href=r38_0100.html#r38_0122>true</a> if its first argument is less than or eq
  550. ual to its second
  551. argument. As an infix operator it is identical with <em>&lt;=</em>.
  552. <P> <H3>
  553. syntax: </H3>
  554. <P>
  555. <P>
  556. <em>leq</em>(&lt;expression&gt;,&lt;expression&gt;) or &lt;expression&gt;
  557. <em>leq</em> &lt;expression&gt;
  558. <P>
  559. <P>
  560. <P>
  561. <P>
  562. &lt;expression&gt; can be any valid REDUCE expression that evaluates to a
  563. number.
  564. <P>
  565. <P>
  566. <P> <H3>
  567. examples: </H3>
  568. <p><pre><tt>
  569. a := 15;
  570. A := 15
  571. if leq(a,25) then write &quot;yes&quot; else write &quot;no&quot;;
  572. yes
  573. if leq(a,15) then write &quot;yes&quot; else write &quot;no&quot;;
  574. yes
  575. if leq(a,5) then write &quot;yes&quot; else write &quot;no&quot;;
  576. no
  577. </tt></pre><p>Logical operators can only be used in conditional statements such
  578. as
  579. <P>
  580. <P>
  581. <em>if</em>...<em>then</em>...<em>else</em> or <em>while</em>...<em>do</em>.
  582. <P>
  583. <P>
  584. <P>
  585. <a name=r38_0115>
  586. <title>LESSP</title></a>
  587. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  588. E"></p>
  589. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  590. <b>LESSP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  591. <P>
  592. The <em>lessp</em> operator is a binary infix or prefix logical operator. It
  593. returns
  594. <a href=r38_0100.html#r38_0122>true</a> if its first argument is strictly less t
  595. han its second
  596. argument. As an infix operator it is identical with <em>&lt;</em>.
  597. <P> <H3>
  598. syntax: </H3>
  599. <P>
  600. <P>
  601. <em>lessp</em>(&lt;expression&gt;,&lt;expression&gt;)
  602. or &lt;expression&gt; <em>lessp</em> &lt;expression&gt;
  603. <P>
  604. <P>
  605. <P>
  606. <P>
  607. &lt;expression&gt; can be any valid REDUCE expression that evaluates to a
  608. number.
  609. <P>
  610. <P>
  611. <P> <H3>
  612. examples: </H3>
  613. <p><pre><tt>
  614. a := 15;
  615. A := 15
  616. if lessp(a,25) then write &quot;yes&quot; else write &quot;no&quot;;
  617. yes
  618. if lessp(a,15) then write &quot;yes&quot; else write &quot;no&quot;;
  619. no
  620. if lessp(a,5) then write &quot;yes&quot; else write &quot;no&quot;;
  621. no
  622. </tt></pre><p>Logical operators can only be used in conditional statements such
  623. as
  624. <P>
  625. <P>
  626. <em>if</em>...<em>then</em>...<em>else</em> or <em>while</em>...<em>do</em>.
  627. <P>
  628. <P>
  629. <P>
  630. <a name=r38_0116>
  631. <title>MEMBER</title></a>
  632. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  633. E"></p>
  634. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  635. <b>MEMBER</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  636. <P>
  637. <P>
  638. <P>
  639. <P> <H3>
  640. syntax: </H3>
  641. &lt;expression&gt; <em>member</em> &lt;list&gt;
  642. <P>
  643. <P>
  644. <P>
  645. <em>member</em>is an infix binary comparison operator that evaluates to
  646. <a href=r38_0100.html#r38_0122>true</a> if &lt;expression&gt; is
  647. <a href=r38_0100.html#r38_0110>equal</a> to a member of
  648. the
  649. <a href=r38_0050.html#r38_0053>list</a> &lt;list&gt;.
  650. <P>
  651. <P>
  652. <P> <H3>
  653. examples: </H3>
  654. <p><pre><tt>
  655. if a member {a,b} then 1 else 0;
  656. 1
  657. if 1 member(1,2,3) then a else b;
  658. a
  659. if 1 member(1.0,2) then a else b;
  660. b
  661. </tt></pre><p>Logical operators can only be used in conditional statements such
  662. as
  663. <P>
  664. <P>
  665. <em>if</em>...<em>then</em>...<em>else</em> or <em>while</em>...<em>do</em>.
  666. &lt;member&gt; can also be used as a prefix operator. However, this use
  667. is not encouraged. Finally,
  668. <a href=r38_0100.html#r38_0110>equal</a> (<em>=</em>) is used for the test
  669. within the list, so expressions must be of the same type to match.
  670. <P>
  671. <P>
  672. <P>
  673. <a name=r38_0117>
  674. <title>NEQ</title></a>
  675. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  676. E"></p>
  677. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  678. <b>NEQ</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  679. <P>
  680. The operator <em>neq</em> is an infix binary comparison
  681. operator. It returns
  682. <a href=r38_0100.html#r38_0122>true</a> if its two
  683. arguments are not
  684. <a href=r38_0100.html#r38_0110>equal</a>.
  685. <P>
  686. <P>
  687. <P> <H3>
  688. syntax: </H3>
  689. &lt;expression&gt; <em>neq</em> &lt;expression&gt;
  690. <P>
  691. <P>
  692. <P>
  693. An inequality is satisfied between floating point numbers and integers
  694. that have the same value.
  695. <P>
  696. <P>
  697. <P> <H3>
  698. examples: </H3>
  699. <p><pre><tt>
  700. on rounded;
  701. a := 4;
  702. A := 4
  703. b := 4.0;
  704. B := 4.0
  705. if a neq b then write &quot;true&quot; else write &quot;false&quot;;
  706. false
  707. if a neq 5 then write &quot;true&quot; else write &quot;false&quot;;
  708. true
  709. </tt></pre><p>Comparison operators can only be used as conditions in conditional
  710. commands
  711. such as <em>if</em>...<em>then</em> and <em>repeat</em>...<em>until</em>.
  712. &lt;neq&gt; can also be used as a prefix operator. However, this use
  713. is not encouraged.
  714. <P>
  715. <P>
  716. <P>
  717. <a name=r38_0118>
  718. <title>NOT</title></a>
  719. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  720. E"></p>
  721. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  722. <b>NOT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  723. <P>
  724. The <em>not</em> operator returns
  725. <a href=r38_0100.html#r38_0122>true</a> if its argument evaluates to
  726. <a href=r38_0001.html#r38_0014>nil</a>, and <em>nil</em> if its argument is <em>
  727. true</em>.
  728. <P> <H3>
  729. syntax: </H3>
  730. <P>
  731. <P>
  732. <em>not</em>(&lt;logical expression&gt;)
  733. <P>
  734. <P>
  735. <P>
  736. <P> <H3>
  737. examples: </H3>
  738. <p><pre><tt>
  739. if not numberp(a) then write &quot;indeterminate&quot; else write a;
  740. indeterminate;
  741. a := 10;
  742. A := 10
  743. if not numberp(a) then write &quot;indeterminate&quot; else write a;
  744. 10
  745. if not(numberp(a) and a &lt; 0) then write &quot;positive number&quot;;
  746. positive number
  747. </tt></pre><p>Logical operators can only be used in conditional statements such
  748. as
  749. <P>
  750. <P>
  751. <em>if</em>...<em>then</em>...<em>else</em> or <em>while</em>...<em>do</em>.
  752. <P>
  753. <P>
  754. <P>
  755. <a name=r38_0119>
  756. <title>NUMBERP</title></a>
  757. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  758. E"></p>
  759. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  760. <b>NUMBERP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  761. <P>
  762. The <em>numberp</em> operator returns
  763. <a href=r38_0100.html#r38_0122>true</a> if its argument is a number,
  764. and
  765. <a href=r38_0001.html#r38_0014>nil</a> otherwise.
  766. <P> <H3>
  767. syntax: </H3>
  768. <P>
  769. <P>
  770. <em>numberp</em>(&lt;expression&gt;) or <em>numberp</em> &lt;expression&gt;
  771. <P>
  772. <P>
  773. <P>
  774. &lt;expression&gt; can be any REDUCE scalar expression.
  775. <P>
  776. <P>
  777. <P> <H3>
  778. examples: </H3>
  779. <p><pre><tt>
  780. cc := 15.3;
  781. CC := 15.3
  782. if numberp(cc) then write &quot;number&quot; else write &quot;nonnumber&quot;;
  783. number
  784. if numberp(cb) then write &quot;number&quot; else write &quot;nonnumber&quot;;
  785. nonnumber
  786. </tt></pre><p>Logical operators can only be used in conditional expressions, suc
  787. h as
  788. <P>
  789. <P>
  790. <em>if</em>...<em>then</em>...<em>else</em> and <em>while</em>...<em>do</em>.
  791. <P>
  792. <P>
  793. <P>
  794. <a name=r38_0120>
  795. <title>ORDP</title></a>
  796. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  797. E"></p>
  798. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  799. <b>ORDP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  800. <P>
  801. <P>
  802. <P>
  803. The <em>ordp</em> logical operator returns
  804. <a href=r38_0100.html#r38_0122>true</a> if its first argument is
  805. ordered ahead of its second argument in canonical internal ordering, or is
  806. identical to it.
  807. <P> <H3>
  808. syntax: </H3>
  809. <P>
  810. <P>
  811. <em>ordp</em>(&lt;expression1&gt;,&lt;expression2&gt;)
  812. <P>
  813. <P>
  814. <P>
  815. <P>
  816. &lt;expression1&gt; and &lt;expression2&gt; can be any valid REDUCE scalar
  817. expression.
  818. <P>
  819. <P>
  820. <P> <H3>
  821. examples: </H3>
  822. <p><pre><tt>
  823. if ordp(x**2 + 1,x**3 + 3) then write &quot;yes&quot; else write &quot;no&quot;;
  824. no
  825. if ordp(101,100) then write &quot;yes&quot; else write &quot;no&quot;;
  826. yes
  827. if ordp(x,x) then write &quot;yes&quot; else write &quot;no&quot;;
  828. yes
  829. </tt></pre><p>Logical operators can only be used in conditional expressions, suc
  830. h as
  831. <P>
  832. <P>
  833. <em>if</em>...<em>then</em>...<em>else</em> and <em>while</em>...<em>do</em>.
  834. <P>
  835. <P>
  836. <P>
  837. <a name=r38_0121>
  838. <title>PRIMEP</title></a>
  839. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  840. E"></p>
  841. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  842. <b>PRIMEP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  843. <P>
  844. <P>
  845. <P>
  846. <P> <H3>
  847. syntax: </H3>
  848. <em>primep</em>(&lt;expression&gt;) or <em>primep</em> &lt;simple\_expression
  849. &gt;
  850. <P>
  851. <P>
  852. <P>
  853. If &lt;expression&gt; evaluates to a integer, <em>primep</em> returns
  854. <a href=r38_0100.html#r38_0122>true</a> <P>
  855. <P>
  856. if &lt;expression&gt; is a prime number (i.e., a number other than 0 and
  857. plus or minus 1 which is only exactly divisible by itself or a unit)
  858. and
  859. <a href=r38_0001.html#r38_0014>nil</a> otherwise.
  860. If &lt;expression&gt; does not have an integer value, a type error occurs.
  861. <P>
  862. <P>
  863. <P> <H3>
  864. examples: </H3>
  865. <p><pre><tt>
  866. if primep 3 then write &quot;yes&quot; else write &quot;no&quot;;
  867. YES
  868. if primep a then 1;
  869. ***** A invalid as integer
  870. </tt></pre><p>
  871. <a name=r38_0122>
  872. <title>TRUE</title></a>
  873. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  874. E"></p>
  875. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  876. <b>TRUE</b><P>
  877. <P>
  878. <P>
  879. <P>
  880. Any value of the boolean part of a logical expression which is neither
  881. <a href=r38_0001.html#r38_0014>nil</a> nor <em>0</em> is considered as <em>true
  882. </em>. Most
  883. builtin test and compare functions return
  884. <a href=r38_0001.html#r38_0018>t</a> for <em>true</em>
  885. and
  886. <a href=r38_0001.html#r38_0014>nil</a> for <em>false</em>.
  887. <P>
  888. <P>
  889. <P> <H3>
  890. examples: </H3>
  891. <p><pre><tt>
  892. if member(3,{1,2,3}) then 1 else -1;
  893. 1
  894. if floor(1.7) then 1 else -1;
  895. 1
  896. if floor(0.7) then 1 else -1;
  897. -1
  898. </tt></pre><p>
  899. <a name=r38_0123>
  900. <title>Boolean Operators</title></a>
  901. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  902. E"></p>
  903. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  904. <b>Boolean Operators</b><menu>
  905. <li><a href=r38_0100.html#r38_0109>boolean value concept</a><P>
  906. <li><a href=r38_0100.html#r38_0110>EQUAL operator</a><P>
  907. <li><a href=r38_0100.html#r38_0111>EVENP operator</a><P>
  908. <li><a href=r38_0100.html#r38_0122>false concept</a><P>
  909. <li><a href=r38_0100.html#r38_0113>FREEOF operator</a><P>
  910. <li><a href=r38_0100.html#r38_0114>LEQ operator</a><P>
  911. <li><a href=r38_0100.html#r38_0115>LESSP operator</a><P>
  912. <li><a href=r38_0100.html#r38_0116>MEMBER operator</a><P>
  913. <li><a href=r38_0100.html#r38_0117>NEQ operator</a><P>
  914. <li><a href=r38_0100.html#r38_0118>NOT operator</a><P>
  915. <li><a href=r38_0100.html#r38_0119>NUMBERP operator</a><P>
  916. <li><a href=r38_0100.html#r38_0120>ORDP operator</a><P>
  917. <li><a href=r38_0100.html#r38_0121>PRIMEP operator</a><P>
  918. <li><a href=r38_0100.html#r38_0122>TRUE concept</a><P>
  919. </menu>
  920. <a name=r38_0124>
  921. <title>BYE</title></a>
  922. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  923. E"></p>
  924. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  925. <b>BYE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  926. <P>
  927. The <em>bye</em> command ends the REDUCE session, returning control to the
  928. program (e.g., the operating system) that called REDUCE. When you are at
  929. the top level, the <em>bye</em> command exits REDUCE. <em>quit</em> is a
  930. synonym for <em>bye</em>.
  931. <P>
  932. <P>
  933. <a name=r38_0125>
  934. <title>CONT</title></a>
  935. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  936. E"></p>
  937. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  938. <b>CONT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  939. <P>
  940. The command <em>cont</em> returns control to an interactive file after a
  941. <a href=r38_0100.html#r38_0128>pause</a> command that has been answered with
  942. <em>n</em>.
  943. <P>
  944. <P>
  945. <P> <H3>
  946. examples: </H3>
  947. <p><pre><tt></tt></pre><p>Suppose you are in the middle of an interactive file.
  948. <p><pre><tt>
  949. factorize(x**2 + 17*x + 60);
  950. {{X + 12,1},{X + 5,1}}
  951. pause;
  952. Cont? (Y or N)
  953. n
  954. saveas results;
  955. factor1 := first results;
  956. FACTOR1 := {X + 12,1}
  957. factor2 := second results;
  958. FACTOR2 := {X + 5,1}
  959. cont; </tt></pre><p> the file resumes<p><pre><tt>
  960. </tt></pre><p>
  961. <P>
  962. <P>
  963. A
  964. <a href=r38_0100.html#r38_0128>pause</a> allows you to enter your own REDUCE com
  965. mands, change
  966. switch values, inquire about results, or other such activities. When you
  967. wish to resume operation of the interactive file, use <em>cont</em>.
  968. <P>
  969. <P>
  970. <P>
  971. <P>
  972. <a name=r38_0126>
  973. <title>DISPLAY</title></a>
  974. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  975. E"></p>
  976. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  977. <b>DISPLAY</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  978. <P>
  979. <P>
  980. <P>
  981. When given a numeric argument &lt;n&gt;, <em>display</em> prints the &lt;n&gt;
  982. most recent input statements, identified by prompt numbers. If an empty
  983. pair of parentheses is given, or if &lt;n&gt; is greater than the current
  984. number of statements, all the input statements since the beginning of
  985. the session are printed.
  986. <P>
  987. <P>
  988. <P> <H3>
  989. syntax: </H3>
  990. <em>display</em>(&lt;n&gt;) or <em>display</em>()
  991. <P>
  992. <P>
  993. <P>
  994. &lt;n&gt; should be a positive integer. However, if it is a real number, the
  995. truncated integer value is used, and if a non-numeric argument is used, all
  996. the input statements are printed.
  997. <P>
  998. <P>
  999. The statements are displayed in upper case, with lines split at semicolons or
  1000. dollar signs, as they are in editing. If long files have been input during
  1001. the session, the <em>display</em> command is slow to format these for
  1002. printing.
  1003. <P>
  1004. <P>
  1005. <P>
  1006. <a name=r38_0127>
  1007. <title>LOAD_PACKAGE</title></a>
  1008. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1009. E"></p>
  1010. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1011. <b>LOAD\_PACKAGE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1012. <P>
  1013. <P>
  1014. <P>
  1015. The <em>load_package</em> command is used to load REDUCE packages, such as
  1016. <em>gentran</em> that are not automatically loaded by the system.
  1017. <P> <H3>
  1018. syntax: </H3>
  1019. <P>
  1020. <P>
  1021. <em>load_package &quot;</em>&lt;package\_name&gt;<em>&quot;</em>
  1022. <P>
  1023. <P>
  1024. <P>
  1025. A package is only loaded once; subsequent calls of <em>load_package</em>
  1026. for the same package name are ignored.
  1027. <P>
  1028. <P>
  1029. <a name=r38_0128>
  1030. <title>PAUSE</title></a>
  1031. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1032. E"></p>
  1033. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1034. <b>PAUSE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1035. <P>
  1036. <P>
  1037. <P>
  1038. The <em>pause</em> command, given in an interactive file, stops operation and
  1039. asks if you want to continue or not.
  1040. <P>
  1041. <P>
  1042. <P> <H3>
  1043. examples: </H3>
  1044. <p><pre><tt></tt></pre><p>An interactive file is running, and at some point you
  1045. see the
  1046. question<p><pre><tt>
  1047. Cont? (Y or N)
  1048. </tt></pre><p>If you type<p><pre><tt>
  1049. ykey{Return}
  1050. </tt></pre><p>the file continues to run until the next pause or the end.<p><pre>
  1051. <tt>
  1052. </tt></pre><p>If you type <p><pre><tt>
  1053. nkey{Return}
  1054. </tt></pre><p>you will get a numbered REDUCE prompt, and be allowed to
  1055. enter and execute any REDUCE statements. If you later wish to continue with
  1056. the file, type<p><pre><tt>
  1057. cont;
  1058. </tt></pre><p>and the file resumes.<p><pre><tt></tt></pre><p>
  1059. <P>
  1060. <P>
  1061. To use <em>pause</em> in your own interactive files, type
  1062. <P>
  1063. <P>
  1064. <em>pause;</em>in the file wherever you want it.
  1065. <P>
  1066. <P>
  1067. <em>pause</em>does not allow you to continue without typing either <em>y</em>
  1068. or <em>n</em>. Its use is to slow down scrolling of interactive files, or to
  1069. let you change parameters or switch settings for the calculations.
  1070. <P>
  1071. <P>
  1072. If you have stopped an interactive file at a <em>pause,</em> and do not wish to
  1073. resume the file, type <em>end;</em>. This does not end the REDUCE session, but
  1074. stops input from the file. A second <em>end;</em> ends the REDUCE session.
  1075. However, if you have pauses from more than one file stacked up, an <em>end;</em>
  1076. brings you back to the top level, not the file directly above.
  1077. <P>
  1078. <P>
  1079. A <em>pause</em> typed from the terminal has no effect.
  1080. <P>
  1081. <P>
  1082. <P>
  1083. <a name=r38_0129>
  1084. <title>QUIT</title></a>
  1085. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1086. E"></p>
  1087. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1088. <b>QUIT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1089. <P>
  1090. The <em>quit</em> command ends the REDUCE session, returning control to the
  1091. program (e.g., the operating system) that called REDUCE. When you are at
  1092. the top level, the <em>quit</em> command exits REDUCE.
  1093. <a href=r38_0100.html#r38_0124>bye</a> is a
  1094. synonym for <em>quit</em>.
  1095. <P>
  1096. <P>
  1097. <a name=r38_0130>
  1098. <title>RECLAIM</title></a>
  1099. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1100. E"></p>
  1101. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1102. <b>RECLAIM</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1103. <P>
  1104. <P>
  1105. <P>
  1106. REDUCE's memory is in a storage structure called a heap. As REDUCE
  1107. statements execute, chunks of memory are used up. When these chunks are no
  1108. longer needed, they remain idle. When the memory is almost full,
  1109. the system executes a garbage collection, reclaiming space that is no
  1110. longer needed, and putting all the free space at one end. Depending on
  1111. the size of the image REDUCE is using,
  1112. garbage collection needs to be done more or less often. A
  1113. larger image means fewer but longer garbage collections.
  1114. Regardless of memory size,
  1115. if you ask REDUCE to do something ridiculous, like <em>factorial(2000)</em>, it
  1116. may
  1117. garbage collect many times.
  1118. <P>
  1119. <P>
  1120. <P>
  1121. <a name=r38_0131>
  1122. <title>REDERR</title></a>
  1123. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1124. E"></p>
  1125. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1126. <b>REDERR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1127. <P>
  1128. <P>
  1129. <P>
  1130. The <em>rederr</em> command allows you to print an error message from inside
  1131. a
  1132. <a href=r38_0050.html#r38_0055>procedure</a> or a
  1133. <a href=r38_0001.html#r38_0041>block</a> statement.
  1134. The calculation is gracefully terminated.
  1135. <P> <H3>
  1136. syntax: </H3>
  1137. <P>
  1138. <P>
  1139. <em>rederr</em>&lt;message&gt;
  1140. <P>
  1141. <P>
  1142. <P>
  1143. &lt;message&gt; is an error message, usually inside double quotation marks
  1144. (a
  1145. <a href=r38_0001.html#r38_0003>string</a>).
  1146. <P>
  1147. <P>
  1148. <P> <H3>
  1149. examples: </H3>
  1150. <p><pre><tt>
  1151. procedure fac(n);
  1152. if not (fixp(n) and n&gt;=0)
  1153. then rederr &quot;Choose nonneg. integer only&quot;
  1154. else for i := 0:n-1 product i+1;
  1155. fac
  1156. fac a;
  1157. ***** Choose nonneg. integer only
  1158. fac 5;
  1159. 120
  1160. </tt></pre><p>The above procedure finds the factorial of its argument.
  1161. If n is not a positive integer or 0, an error message is returned.
  1162. <P>
  1163. <P>
  1164. If your procedure is executed in a file, the usual error message is
  1165. printed, followed by <em>Cont? (Y or N)</em>, just as any other error does from
  1166. a file. Although the procedure is gracefully terminated, any switch settings or
  1167. variable assignments you made before the error occurred are not undone. If you
  1168. need to clean up such items before exiting, use a group statement, with the
  1169. <em>rederr</em> command as its last statement.
  1170. <P>
  1171. <P>
  1172. <P>
  1173. <a name=r38_0132>
  1174. <title>RETRY</title></a>
  1175. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1176. E"></p>
  1177. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1178. <b>RETRY</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1179. <P>
  1180. <P>
  1181. <P>
  1182. The <em>retry</em> command allows you to retry the latest statement that resulte
  1183. d
  1184. in an error message.
  1185. <P>
  1186. <P>
  1187. <P> <H3>
  1188. examples: </H3>
  1189. <p><pre><tt>
  1190. matrix a;
  1191. det a;
  1192. ***** Matrix A not set
  1193. a := mat((1,2),(3,4));
  1194. A(1,1) := 1
  1195. A(1,2) := 2
  1196. A(2,1) := 3
  1197. A(2,2) := 4
  1198. retry;
  1199. -2
  1200. </tt></pre><p><em>retry</em>remembers only the most recent statement that result
  1201. ed in an
  1202. error message. It allows you to stop and fix something obvious, then
  1203. continue on your way without retyping the original command.
  1204. <P>
  1205. <P>
  1206. <P>
  1207. <a name=r38_0133>
  1208. <title>SAVEAS</title></a>
  1209. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1210. E"></p>
  1211. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1212. <b>SAVEAS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1213. <P>
  1214. The <em>saveas</em> command saves the current workspace under the name of its
  1215. argument.
  1216. <P> <H3>
  1217. syntax: </H3>
  1218. <P>
  1219. <P>
  1220. <em>saveas</em>&lt;identifier&gt;
  1221. <P>
  1222. <P>
  1223. <P>
  1224. &lt;identifier&gt; can be any valid REDUCE identifier.
  1225. <P>
  1226. <P>
  1227. <P> <H3>
  1228. examples: </H3>
  1229. <p><pre><tt></tt></pre><p>(The numbered prompts are shown below, unlike in most
  1230. examples)<p><pre><tt>
  1231. 1: solve(x^2-3);
  1232. {x=sqrt(3),x= - sqrt(3)}
  1233. 2: saveas rts(0)$
  1234. 3: rts(0);
  1235. {x=sqrt(3),x= - sqrt(3)}
  1236. </tt></pre><p>
  1237. <P>
  1238. <P>
  1239. <em>saveas</em>works only for the current workspace, the last algebraic
  1240. expression produced by REDUCE. This allows you to save a result that you
  1241. did not assign to an identifier when you originally typed the input.
  1242. For access to previous output use
  1243. <a href=r38_0150.html#r38_0184>ws</a>.
  1244. <P>
  1245. <P>
  1246. <P>
  1247. <a name=r38_0134>
  1248. <title>SHOWTIME</title></a>
  1249. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1250. E"></p>
  1251. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1252. <b>SHOWTIME</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1253. <P>
  1254. <P>
  1255. <P>
  1256. The <em>showtime</em> command prints the elapsed system time since the last
  1257. call of this command or since the beginning of the session, if it has not
  1258. been called before.
  1259. <P>
  1260. <P>
  1261. <P> <H3>
  1262. examples: </H3>
  1263. <p><pre><tt>
  1264. showtime;
  1265. Time: 1020 ms
  1266. factorize(x^4 - 8x^4 + 8x^2 - 136x - 153);
  1267. 2
  1268. {X - 9,X + 17,X + 1}
  1269. showtime;
  1270. Time: 920 ms
  1271. </tt></pre><p>The time printed is either the elapsed cpu time or the elapsed wal
  1272. l clock
  1273. time, depending on your system. <em>showtime</em> allows you to see the
  1274. system time resources REDUCE uses in its calculations. Your time readings
  1275. will of course vary from this example according to the system you use.
  1276. <P>
  1277. <P>
  1278. <P>
  1279. <a name=r38_0135>
  1280. <title>WRITE</title></a>
  1281. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1282. E"></p>
  1283. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1284. <b>WRITE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  1285. <P>
  1286. <P>
  1287. <P>
  1288. The <em>write</em> command explicitly writes its arguments to the output device
  1289. (terminal or file).
  1290. <P> <H3>
  1291. syntax: </H3>
  1292. <P>
  1293. <P>
  1294. <em>write</em>&lt;item&gt;{,&lt;item&gt;}*
  1295. <P>
  1296. <P>
  1297. <P>
  1298. &lt;item&gt; can be an expression, an assignment or a
  1299. <a href=r38_0001.html#r38_0003>string</a>
  1300. enclosed in double quotation marks (<em>&quot;</em>).
  1301. <P>
  1302. <P>
  1303. <P> <H3>
  1304. examples: </H3>
  1305. <p><pre><tt>
  1306. write a, sin x, &quot;this is a string&quot;;
  1307. ASIN(X)this is a string
  1308. write a,&quot; &quot;,sin x,&quot; this is a string&quot;;
  1309. A SIN(X) this is a string
  1310. if not numberp(a) then write &quot;the symbol &quot;,a;
  1311. the symbol A
  1312. array m(10);
  1313. for i := 1:5 do write m(i) := 2*i;
  1314. M(1) := 2
  1315. M(2) := 4
  1316. M(3) := 6
  1317. M(4) := 8
  1318. M(5) := 10
  1319. m(4);
  1320. 8
  1321. </tt></pre><p>The items specified by a single <em>write</em> statement print on
  1322. a single line
  1323. unless they are too long. A printed line is always ended with a carriage
  1324. return, so the next item printed starts a new line.
  1325. <P>
  1326. <P>
  1327. When an assignment statement is printed, the assignment is also made. This
  1328. allows you to get feedback on filling slots in an array with a
  1329. <a href=r38_0001.html#r38_0047>for</a>
  1330. statement, as shown in the last example above.
  1331. <P>
  1332. <P>
  1333. <P>
  1334. <a name=r38_0136>
  1335. <title>General Commands</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>General Commands</b><menu>
  1340. <li><a href=r38_0100.html#r38_0124>BYE command</a><P>
  1341. <li><a href=r38_0100.html#r38_0125>CONT command</a><P>
  1342. <li><a href=r38_0100.html#r38_0126>DISPLAY command</a><P>
  1343. <li><a href=r38_0100.html#r38_0127>LOAD\_PACKAGE command</a><P>
  1344. <li><a href=r38_0100.html#r38_0128>PAUSE command</a><P>
  1345. <li><a href=r38_0100.html#r38_0129>QUIT command</a><P>
  1346. <li><a href=r38_0100.html#r38_0130>RECLAIM operator</a><P>
  1347. <li><a href=r38_0100.html#r38_0131>REDERR command</a><P>
  1348. <li><a href=r38_0100.html#r38_0132>RETRY command</a><P>
  1349. <li><a href=r38_0100.html#r38_0133>SAVEAS command</a><P>
  1350. <li><a href=r38_0100.html#r38_0134>SHOWTIME command</a><P>
  1351. <li><a href=r38_0100.html#r38_0135>WRITE command</a><P>
  1352. </menu>
  1353. <a name=r38_0137>
  1354. <title>APPEND</title></a>
  1355. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1356. E"></p>
  1357. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1358. <b>APPEND</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1359. <P>
  1360. <P>
  1361. <P>
  1362. The <em>append</em> operator constructs a new
  1363. <a href=r38_0050.html#r38_0053>list</a>
  1364. from the elements of its two arguments (which must be lists).
  1365. <P>
  1366. <P>
  1367. <P> <H3>
  1368. syntax: </H3>
  1369. <em>append</em>(&lt;list&gt;,&lt;list&gt;)
  1370. <P>
  1371. <P>
  1372. <P>
  1373. &lt;list&gt; must be a list, though it may be the empty list (<em>{}</em>).
  1374. Any arguments beyond the first two are ignored.
  1375. <P>
  1376. <P>
  1377. <P> <H3>
  1378. examples: </H3>
  1379. <p><pre><tt>
  1380. alist := {1,2,{a,b}};
  1381. ALIST := {1,2,{A,B}}
  1382. blist := {3,4,5,sin(y)};
  1383. BLIST := {3,4,5,SIN(Y)}
  1384. append(alist,blist);
  1385. {1,2,{A,B},3,4,5,SIN(Y)}
  1386. append(alist,{});
  1387. {1,2,{A,B}}
  1388. append(list z,blist);
  1389. {Z,3,4,5,SIN(Y)}
  1390. </tt></pre><p>The new list consists of the elements of the second list appended
  1391. to the
  1392. elements of the first list. You can <em>append</em> new elements to the
  1393. beginning or end of an existing list by putting the new element in a
  1394. list (use curly braces or the operator <em>list</em>). This is
  1395. particularly helpful in an iterative loop.
  1396. <P>
  1397. <P>
  1398. <P>
  1399. <a name=r38_0138>
  1400. <title>ARBINT</title></a>
  1401. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1402. E"></p>
  1403. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1404. <b>ARBINT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1405. <P>
  1406. <P>
  1407. <P>
  1408. The operator <em>arbint</em> is used to express arbitrary integer parts
  1409. of an expression, e.g. in the result of
  1410. <a href=r38_0150.html#r38_0179>solve</a> when
  1411. <a href=r38_0250.html#r38_0266>allbranch</a> is on.
  1412. <P> <H3>
  1413. examples: </H3>
  1414. <p><pre><tt>
  1415. solve(log(sin(x+3)),x);
  1416. {X=2*ARBINT(1)*PI - ASIN(1) - 3,
  1417. X=2*ARBINT(1)*PI + ASIN(1) + PI - 3}
  1418. </tt></pre><p><P>
  1419. <P>
  1420. <a name=r38_0139>
  1421. <title>ARBCOMPLEX</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>ARBCOMPLEX</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1426. <P>
  1427. <P>
  1428. <P>
  1429. The operator <em>arbcomplex</em> is used to express arbitrary scalar parts
  1430. of an expression, e.g. in the result of
  1431. <a href=r38_0150.html#r38_0179>solve</a> when
  1432. the solution is parametric in one of the variable.
  1433. <P> <H3>
  1434. examples: </H3>
  1435. <p><pre><tt>
  1436. solve({x+3=y-2z,y-3x=0},{x,y,z});
  1437. 2*ARBCOMPLEX(1) + 3
  1438. {X=-------------------,
  1439. 2
  1440. 3*ARBCOMPLEX(1) + 3
  1441. Y=-------------------,
  1442. 2
  1443. Z=ARBCOMPLEX(1)}
  1444. </tt></pre><p><P>
  1445. <P>
  1446. <a name=r38_0140>
  1447. <title>ARGLENGTH</title></a>
  1448. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1449. E"></p>
  1450. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1451. <b>ARGLENGTH</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1452. <P>
  1453. <P>
  1454. <P>
  1455. The operator <em>arglength</em> returns the number of arguments of the top-level
  1456. operator in its argument.
  1457. <P>
  1458. <P>
  1459. <P> <H3>
  1460. syntax: </H3>
  1461. <em>arglength</em>(&lt;expression&gt;)
  1462. <P>
  1463. <P>
  1464. <P>
  1465. &lt;expression&gt; can be any valid REDUCE algebraic expression.
  1466. <P>
  1467. <P>
  1468. <P> <H3>
  1469. examples: </H3>
  1470. <p><pre><tt>
  1471. arglength(a + b + c + d);
  1472. 4
  1473. arglength(a/b/c);
  1474. 2
  1475. arglength(log(sin(df(r**3*x,x))));
  1476. 1
  1477. </tt></pre><p>In the first example, <em>+</em> is an n-ary operator, so the numb
  1478. er of terms
  1479. is returned. In the second example, since <em>/</em> is a binary operator, the
  1480. argument is actually (a/b)/c, so there are two terms at the top level. In
  1481. the last example, no matter how deeply the operators are nested, there is
  1482. still only one argument at the top level.
  1483. <P>
  1484. <P>
  1485. <P>
  1486. <a name=r38_0141>
  1487. <title>COEFF</title></a>
  1488. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1489. E"></p>
  1490. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1491. <b>COEFF</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1492. <P>
  1493. <P>
  1494. <P>
  1495. The <em>coeff</em> operator returns the coefficients of the powers of the
  1496. specified variable in the given expression, in a
  1497. <a href=r38_0050.html#r38_0053>list</a>.
  1498. <P>
  1499. <P>
  1500. <P> <H3>
  1501. syntax: </H3>
  1502. <em>coeff</em>(&lt;expression&gt;<em>,</em>&lt;variable&gt;)
  1503. <P>
  1504. <P>
  1505. <P>
  1506. &lt;expression&gt; is expected to be a polynomial expression, not a rational
  1507. expression. Rational expressions are accepted when the switch
  1508. <a href=r38_0300.html#r38_0322>ratarg</a> is on. &lt;variable&gt; must be a kern
  1509. el. The results are
  1510. returned in a list.
  1511. <P>
  1512. <P>
  1513. <P> <H3>
  1514. examples: </H3>
  1515. <p><pre><tt>
  1516. coeff((x+y)**3,x);
  1517. 3 2
  1518. {Y ,3*Y ,3*Y,1}
  1519. coeff((x+2)**4 + sin(x),x);
  1520. {SIN(X) + 16,32,24,8,1}
  1521. high_pow;
  1522. 4
  1523. low_pow;
  1524. 0
  1525. ab := x**9 + sin(x)*x**7 + sqrt(y);
  1526. 7 9
  1527. AB := SQRT(Y) + SIN(X)*X + X
  1528. coeff(ab,x);
  1529. {SQRT(Y),0,0,0,0,0,0,SIN(X),0,1}
  1530. </tt></pre><p>The variables
  1531. <a href=r38_0001.html#r38_0010>high_pow</a> and
  1532. <a href=r38_0001.html#r38_0013>low_pow</a> are set to the
  1533. highest and lowest powers of the variable, respectively, appearing in the
  1534. expression.
  1535. <P>
  1536. <P>
  1537. The coefficients are put into a list, with the coefficient of the lowest
  1538. (constant) term first. You can use the usual list access methods
  1539. (<em>first</em>, <em>second</em>, <em>third</em>, <em>rest</em>, <em>length</em>
  1540. , and
  1541. <em>part</em>) to extract them. If a power does not appear in the
  1542. expression, the corresponding element of the list is zero. Terms involving
  1543. functions of the specified variable but not including powers of it (for
  1544. example in the expression <em>x**4 + 3*x**2 + tan(x)</em>) are placed in the
  1545. constant term.
  1546. <P>
  1547. <P>
  1548. Since the <em>coeff</em> command deals with the expanded form of the expression,
  1549. you may get unexpected results when
  1550. <a href=r38_0250.html#r38_0284>exp</a> is off, or when
  1551. <a href=r38_0250.html#r38_0287>factor</a> or
  1552. <a href=r38_0250.html#r38_0296>ifactor</a> are on.
  1553. <P>
  1554. <P>
  1555. If you want only a specific coefficient rather than all of them, use the
  1556. <a href=r38_0100.html#r38_0142>coeffn</a> operator.
  1557. <P>
  1558. <P>
  1559. <P>
  1560. <P>
  1561. <a name=r38_0142>
  1562. <title>COEFFN</title></a>
  1563. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1564. E"></p>
  1565. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1566. <b>COEFFN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1567. <P>
  1568. <P>
  1569. <P>
  1570. The <em>coeffn</em> operator takes three arguments: an expression, a kernel, and
  1571. a non-negative integer. It returns the coefficient of the kernel to that
  1572. integer power, appearing in the expression.
  1573. <P>
  1574. <P>
  1575. <P> <H3>
  1576. syntax: </H3>
  1577. <em>coeffn</em>(&lt;expression&gt;,&lt;kernel&gt;,&lt;integer&gt;)
  1578. <P>
  1579. <P>
  1580. <P>
  1581. &lt;expression&gt; must be a polynomial, unless
  1582. <a href=r38_0300.html#r38_0322>ratarg</a> is on which
  1583. allows rational expressions. &lt;kernel&gt; must be a kernel, and
  1584. &lt;integer&gt; must be a non-negative integer.
  1585. <P>
  1586. <P>
  1587. <P> <H3>
  1588. examples: </H3>
  1589. <p><pre><tt>
  1590. ff := x**7 + sin(y)*x**5 + y**4 + x + 7;
  1591. 5 7 4
  1592. FF := SIN(Y)*X + X + X + Y + 7
  1593. coeffn(ff,x,5);
  1594. SIN(Y)
  1595. coeffn(ff,z,3);
  1596. 0
  1597. coeffn(ff,y,0);
  1598. 5 7
  1599. SIN(Y)*X + X + X + 7
  1600. rr := 1/y**2+y**3+sin(y);
  1601. 2 5
  1602. SIN(Y)*Y + Y + 1
  1603. RR := --------------------
  1604. 2
  1605. Y
  1606. on ratarg;
  1607. coeffn(rr,y,-2);
  1608. ***** -2 invalid as COEFFN index
  1609. coeffn(rr,y,5);
  1610. 1
  1611. ---
  1612. 2
  1613. Y
  1614. </tt></pre><p>If the given power of the kernel does not appear in the expression
  1615. ,
  1616. <em>coeffn</em> returns 0. Negative powers are never detected, even if
  1617. they appear in the expression and
  1618. <a href=r38_0300.html#r38_0322>ratarg</a> are on. <em>coeffn</em>
  1619. with an integer argument of 0 returns any terms in the expression that
  1620. do not contain the given kernel.
  1621. <P>
  1622. <P>
  1623. <P>
  1624. <a name=r38_0143>
  1625. <title>CONJ</title></a>
  1626. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1627. E"></p>
  1628. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1629. <b>CONJ</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1630. <P>
  1631. <P>
  1632. <P>
  1633. <P> <H3>
  1634. syntax: </H3>
  1635. <em>conj</em>(&lt;expression&gt;) or <em>conj</em> &lt;simple\_expression&gt;
  1636. <P>
  1637. <P>
  1638. <P>
  1639. This operator returns the complex conjugate of an expression, if that
  1640. argument has an numerical value. A non-numerical argument is returned as
  1641. an expression in the operators
  1642. <a href=r38_0150.html#r38_0173>repart</a> and
  1643. <a href=r38_0150.html#r38_0153>impart</a>.
  1644. <P>
  1645. <P>
  1646. <P> <H3>
  1647. examples: </H3>
  1648. <p><pre><tt>
  1649. conj(1+i);
  1650. 1-I
  1651. conj(a+i*b);
  1652. REPART(A) - REPART(B)*I - IMPART(A)*I - IMPART(B)
  1653. </tt></pre><p>
  1654. <a name=r38_0144>
  1655. <title>CONTINUED_FRACTION</title></a>
  1656. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1657. E"></p>
  1658. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1659. <b>CONTINUED_FRACTION</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1660. <P>
  1661. <P>
  1662. <P>
  1663. <P> <H3>
  1664. syntax: </H3>
  1665. <em>continued_fraction</em>(&lt;num&gt;)
  1666. or <em>continued_fraction</em>( &lt;num&gt;,&lt;size&gt;)
  1667. <P>
  1668. <P>
  1669. <P>
  1670. This operator approximates the real number &lt;num&gt;
  1671. (
  1672. <a href=r38_0300.html#r38_0323>rational</a> number,
  1673. <a href=r38_0300.html#r38_0330>rounded</a> number)
  1674. into a continued fraction. The result is a list of two elements: the
  1675. first one is the rational value of the approximation, the second one
  1676. is the list of terms of the continued fraction which represents the
  1677. same value according to the definition <em>t0 +1/(t1 + 1/(t2 + ...))</em>.
  1678. Precision: the second optional parameter &lt;size&gt; is an upper bound
  1679. for the absolute value of the result denominator. If omitted, the
  1680. approximation is performed up to the current system precision.
  1681. <P>
  1682. <P>
  1683. <P> <H3>
  1684. examples: </H3>
  1685. <p><pre><tt>
  1686. continued_fraction pi;
  1687. 1146408
  1688. {-------,{3,7,15,1,292,1,1,1,2,1}}
  1689. 364913
  1690. continued_fraction(pi,100);
  1691. 22
  1692. {--,{3,7}}
  1693. 7
  1694. </tt></pre><p>
  1695. <a name=r38_0145>
  1696. <title>DECOMPOSE</title></a>
  1697. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1698. E"></p>
  1699. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1700. <b>DECOMPOSE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1701. <P>
  1702. <P>
  1703. <P>
  1704. The <em>decompose</em> operator takes a multivariate polynomial as argument,
  1705. and returns an expression and a
  1706. <a href=r38_0050.html#r38_0053>list</a> of
  1707. <a href=r38_0001.html#r38_0045>equation</a>s from which the
  1708. original polynomial can be found by composition.
  1709. <P>
  1710. <P>
  1711. <P> <H3>
  1712. syntax: </H3>
  1713. <em>decompose</em>(&lt;expression&gt;) or <em>decompose</em>
  1714. &lt;simple\_expression&gt;
  1715. <P>
  1716. <P>
  1717. <P>
  1718. <P> <H3>
  1719. examples: </H3>
  1720. <p><pre><tt>
  1721. decompose(x^8-88*x^7+2924*x^6-43912*x^5+263431*x^4-
  1722. 218900*x^3+65690*x^2-7700*x+234)
  1723. 2 2 2
  1724. U + 35*U + 234, U=V + 10*V, V=X - 22*X
  1725. decompose(u^2+v^2+2u*v+1)
  1726. 2
  1727. W + 1, W=U + V
  1728. </tt></pre><p>Unlike factorization, this decomposition is not unique. Further
  1729. details can be found in V.S. Alagar, M.Tanh, &lt;Fast Polynomial
  1730. Decomposition&gt;, Proc. EUROCAL 1985, pp 150-153 (Springer) and J. von zur
  1731. Gathen, &lt;Functional&gt;
  1732. &lt;Decomposition of Polynomials: the Tame Case&gt;, J.
  1733. Symbolic Computation (1990) 9, 281-299.
  1734. <P>
  1735. <P>
  1736. <P>
  1737. <a name=r38_0146>
  1738. <title>DEG</title></a>
  1739. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1740. E"></p>
  1741. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1742. <b>DEG</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1743. <P>
  1744. <P>
  1745. <P>
  1746. The operator <em>deg</em> returns the highest degree of its variable argument
  1747. found in its expression argument.
  1748. <P>
  1749. <P>
  1750. <P> <H3>
  1751. syntax: </H3>
  1752. <em>deg</em>(&lt;expression&gt;,&lt;kernel&gt;)
  1753. <P>
  1754. <P>
  1755. <P>
  1756. &lt;expression&gt; is expected to be a polynomial expression, not a rational
  1757. expression. Rational expressions are accepted when the switch
  1758. <a href=r38_0300.html#r38_0322>ratarg</a> is on. &lt;variable&gt; must be a
  1759. <a href=r38_0001.html#r38_0002>kernel</a>. The
  1760. results are returned in a list.
  1761. <P>
  1762. <P>
  1763. <P> <H3>
  1764. examples: </H3>
  1765. <p><pre><tt>
  1766. deg((x+y)**5,x);
  1767. 5
  1768. deg((a+b)*(c+2*d)**2,d);
  1769. 2
  1770. deg(x**2 + cos(y),sin(x));
  1771. deg((x**2 + sin(x))**5,sin(x));
  1772. 5
  1773. </tt></pre><p>
  1774. <a name=r38_0147>
  1775. <title>DEN</title></a>
  1776. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1777. E"></p>
  1778. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1779. <b>DEN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1780. <P>
  1781. <P>
  1782. <P>
  1783. The <em>den</em> operator returns the denominator of its argument.
  1784. <P>
  1785. <P>
  1786. <P> <H3>
  1787. syntax: </H3>
  1788. <em>den</em>(&lt;expression&gt;)
  1789. <P>
  1790. <P>
  1791. <P>
  1792. &lt;expression&gt; is ordinarily a rational expression, but may be any valid
  1793. scalar REDUCE expression.
  1794. <P>
  1795. <P>
  1796. <P> <H3>
  1797. examples: </H3>
  1798. <p><pre><tt>
  1799. a := x**3 + 3*x**2 + 12*x;
  1800. 2
  1801. A := X*(X + 3*X + 12)
  1802. b := 4*x*y + x*sin(x);
  1803. B := X*(SIN(X) + 4*Y)
  1804. den(a/b);
  1805. SIN(X) + 4*Y
  1806. den(aa/4 + bb/5);
  1807. 20
  1808. den(100/6);
  1809. 3
  1810. den(sin(x));
  1811. 1
  1812. </tt></pre><p><em>den</em>returns the denominator of the expression after it has
  1813. been
  1814. simplified by REDUCE. As seen in the examples, this includes putting
  1815. sums of rational expressions over a common denominator, and reducing
  1816. common factors where possible. If the expression does not have any
  1817. other denominator, 1 is returned.
  1818. <P>
  1819. <P>
  1820. Switch settings, such as
  1821. <a href=r38_0300.html#r38_0304>mcd</a> or
  1822. <a href=r38_0300.html#r38_0323>rational</a>, have an
  1823. effect on the denominator of an expression.
  1824. <P>
  1825. <P>
  1826. <P>
  1827. <a name=r38_0148>
  1828. <title>DF</title></a>
  1829. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1830. E"></p>
  1831. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1832. <b>DF</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1833. <P>
  1834. <P>
  1835. <P>
  1836. The <em>df</em> operator finds partial derivatives with respect to one or
  1837. more variables.
  1838. <P>
  1839. <P>
  1840. <P> <H3>
  1841. syntax: </H3>
  1842. <em>df</em>(&lt;expression&gt;<em>,</em>&lt;var&gt;
  1843. [<em>,</em>&lt;number&gt;]
  1844. {<em>,</em>&lt;var&gt; [ <em>,</em>&lt;number&gt;] } )
  1845. <P>
  1846. <P>
  1847. <P>
  1848. &lt;expression&gt; can be any valid REDUCE algebraic expression. &lt;var&gt;
  1849. must be a
  1850. <a href=r38_0001.html#r38_0002>kernel</a>, and is the differentiation variable.
  1851. &lt;number&gt; must be a non-negative integer.
  1852. <P>
  1853. <P>
  1854. <P> <H3>
  1855. examples: </H3>
  1856. <p><pre><tt>
  1857. df(x**2,x);
  1858. 2*X
  1859. df(x**2*y + sin(y),y);
  1860. 2
  1861. COS(Y) + X
  1862. df((x+y)**10,z);
  1863. 0
  1864. df(1/x**2,x,2);
  1865. 6
  1866. ---
  1867. 4
  1868. X
  1869. df(x**4*y + sin(y),y,x,3);
  1870. 24*X
  1871. for all x let df(tan(x),x) = sec(x)**2;
  1872. df(tan(3*x),x);
  1873. 2
  1874. 3*SEC(3*X)
  1875. </tt></pre><p>An error message results if a non-kernel is entered as a different
  1876. iation
  1877. operator. If the optional number is omitted, it is assumed to be 1.
  1878. See the declaration
  1879. <a href=r38_0150.html#r38_0192>depend</a> to establish dependencies for implicit
  1880. differentiation.
  1881. <P>
  1882. <P>
  1883. You can define your own differentiation rules, expanding REDUCE's
  1884. capabilities, using the
  1885. <a href=r38_0150.html#r38_0199>let</a> command as shown in the last example
  1886. above. Note that once you add your own rule for differentiating a
  1887. function, it supersedes REDUCE's normal handling of that function for the
  1888. duration of the REDUCE session. If you clear the rule
  1889. (
  1890. <a href=r38_0150.html#r38_0190>clearrules</a>), you don't get back
  1891. to the previous rule.
  1892. <P>
  1893. <P>
  1894. <P>
  1895. <a name=r38_0149>
  1896. <title>EXPAND_CASES</title></a>
  1897. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1898. E"></p>
  1899. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1900. <b>EXPAND\_CASES</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1901. <P>
  1902. <P>
  1903. <P>
  1904. When a
  1905. <a href=r38_0150.html#r38_0176>root_of</a> form in a result of
  1906. <a href=r38_0150.html#r38_0179>solve</a>
  1907. has been converted to a
  1908. <a href=r38_0150.html#r38_0168>one_of</a> form, <em>expand_cases</em>
  1909. can be used to convert this into form corresponding to the
  1910. normal explicit results of
  1911. <a href=r38_0150.html#r38_0179>solve</a>. See
  1912. <a href=r38_0150.html#r38_0176>root_of</a>.
  1913. <P>
  1914. <P>