r38_0150.html 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893
  1. <a name=r38_0150>
  2. <title>EXPREAD</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>EXPREAD</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  7. <P>
  8. <P>
  9. <P>
  10. <P> <H3>
  11. syntax: </H3>
  12. <em>expread</em>()
  13. <P>
  14. <P>
  15. <P>
  16. <em>expread</em>reads one well-formed expression from the current input
  17. buffer and returns its value.
  18. <P>
  19. <P>
  20. <P> <H3>
  21. examples: </H3>
  22. <p><pre><tt>
  23. expread(); a+b;
  24. A + B
  25. </tt></pre><p>
  26. <a name=r38_0151>
  27. <title>FACTORIZE</title></a>
  28. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  29. E"></p>
  30. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  31. <b>FACTORIZE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  32. <P>
  33. <P>
  34. <P>
  35. The <em>factorize</em> operator factors a given expression into a list of
  36. {factor,power} pairs.
  37. <P> <H3>
  38. syntax: </H3>
  39. <P>
  40. <P>
  41. <em>factorize</em>(&lt;expression&gt;)
  42. <P>
  43. <P>
  44. <P>
  45. &lt;expression&gt; should be a polynomial, otherwise an error will result.
  46. <P>
  47. <P>
  48. <P> <H3>
  49. examples: </H3>
  50. <p><pre><tt>
  51. fff := factorize(x^3 - y^3);
  52. 2 2
  53. {{X + X*Y + Y ,1},{X - Y,1}}
  54. fac1 := first fff;
  55. 2 2
  56. FAC1 := {{X + X*Y + Y ,1}
  57. factorize(x^15 - 1);
  58. 8 7 6 5 4
  59. {{ X - X + X - X + X - X + 1,1},
  60. 4 3 2
  61. {X + X + X + X + 1,1},
  62. 2
  63. {X + X + 1,1},
  64. {X - 1,1}}
  65. lastone := part(ws,length ws);
  66. LASTONE := {X - 1,1}
  67. setmod 2;
  68. 1
  69. on modular;
  70. factorize(x^15 - 1);
  71. 4 3 2
  72. {{X + X + X + X + 1,1},
  73. 4 3
  74. {X + X + 1,1},
  75. 4
  76. {X + X + 1,1},
  77. 2
  78. { X + X + 1,1},
  79. {X + 1,1}}
  80. </tt></pre><p>The <em>factorize</em> command returns the factor,power pairs as a
  81. <a href=r38_0050.html#r38_0053>list</a>.
  82. You can therefore use the usual list access methods (
  83. <a href=r38_0001.html#r38_0046>first</a>,
  84. <a href=r38_0050.html#r38_0063>second</a>,
  85. <a href=r38_0050.html#r38_0066>third</a>,
  86. <a href=r38_0050.html#r38_0057>rest</a>,
  87. <a href=r38_0150.html#r38_0157>length</a> and
  88. <a href=r38_0150.html#r38_0169>part</a>) to extract these pairs.
  89. <P>
  90. <P>
  91. If the &lt;expression&gt; given to <em>factorize</em> is an integer, it will be
  92. factored into its prime components. To factor any integer factor of a
  93. non-numerical expression, the switch
  94. <a href=r38_0250.html#r38_0296>ifactor</a> should be turned on.
  95. Its default is off.
  96. <a href=r38_0250.html#r38_0296>ifactor</a> has effect only when factoring is
  97. explicitly done by <em>factorize</em>, not when factoring is automatically
  98. done with the
  99. <a href=r38_0250.html#r38_0287>factor</a> switch. If full factorization is not
  100. needed the switch
  101. <a href=r38_0300.html#r38_0301>limitedfactors</a> allows you to reduce the
  102. computing time of calls to <em>factorize</em>.
  103. <P>
  104. <P>
  105. Factoring can be done in a modular domain by calling <em>factorize</em> when
  106. <a href=r38_0300.html#r38_0305>modular</a> is on. You can set the modulus with t
  107. he
  108. <a href=r38_0100.html#r38_0104>setmod</a>
  109. command. The last example above shows factoring modulo 2.
  110. <P>
  111. <P>
  112. For general comments on factoring, see comments under the switch
  113. <a href=r38_0250.html#r38_0287>factor</a>.
  114. <P>
  115. <P>
  116. <P>
  117. <a name=r38_0152>
  118. <title>HYPOT</title></a>
  119. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  120. E"></p>
  121. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  122. <b>HYPOT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  123. <P>
  124. <P>
  125. <P>
  126. <P> <H3>
  127. syntax: </H3>
  128. hypot(&lt;expression&gt;,&lt;expression&gt;)
  129. <P>
  130. <P>
  131. <P>
  132. If <em>rounded</em> is on, and the two arguments evaluate to numbers, this
  133. operator returns the square root of the sums of the squares of the
  134. arguments in a manner that avoids intermediate overflow. In other cases,
  135. an expression in the original operator is returned.
  136. <P>
  137. <P>
  138. <P> <H3>
  139. examples: </H3>
  140. <p><pre><tt>
  141. hypot(3,4);
  142. HYPOT(3,4)
  143. on rounded;
  144. ws;
  145. 5.0
  146. hypot(a,b);
  147. HYPOT(A,B)
  148. </tt></pre><p>
  149. <a name=r38_0153>
  150. <title>IMPART</title></a>
  151. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  152. E"></p>
  153. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  154. <b>IMPART</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  155. <P>
  156. <P>
  157. <P>
  158. <P> <H3>
  159. syntax: </H3>
  160. <em>impart</em>(&lt;expression&gt;) or <em>impart</em> &lt;simple\_expression
  161. &gt;
  162. <P>
  163. <P>
  164. <P>
  165. This operator returns the imaginary part of an expression, if that
  166. argument has an numerical value. A non-numerical argument is returned as
  167. an expression in the operators
  168. <a href=r38_0150.html#r38_0173>repart</a> and <em>impart</em>.
  169. <P> <H3>
  170. examples: </H3>
  171. <p><pre><tt>
  172. impart(1+i);
  173. 1
  174. impart(a+i*b);
  175. REPART(B) + IMPART(A)
  176. </tt></pre><p><P>
  177. <P>
  178. <a name=r38_0154>
  179. <title>INT</title></a>
  180. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  181. E"></p>
  182. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  183. <b>INT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  184. <P>
  185. <P>
  186. <P>
  187. The <em>int</em> operator performs analytic integration on a variety of
  188. functions.
  189. <P>
  190. <P>
  191. <P> <H3>
  192. syntax: </H3>
  193. <em>int</em>(&lt;expression&gt;,&lt;kernel&gt;)
  194. <P>
  195. <P>
  196. <P>
  197. &lt;expression&gt; can be any scalar expression. involving polynomials, log
  198. functions, exponential functions, or tangent or arctangent expressions.
  199. <em>int</em> attempts expressions involving error functions, dilogarithms
  200. and other trigonometric expressions. Integrals involving algebraic
  201. extensions (such as square roots) may not succeed. &lt;kernel&gt; must be a
  202. REDUCE
  203. <a href=r38_0001.html#r38_0002>kernel</a>.
  204. <P>
  205. <P>
  206. <P> <H3>
  207. examples: </H3>
  208. <p><pre><tt>
  209. int(x**3 + 3,x);
  210. 3
  211. X*(X + 12)
  212. -----------
  213. 4
  214. int(sin(x)*exp(2*x),x);
  215. 2*X
  216. E *(COS(X) - 2*SIN(X))
  217. - ------------------------
  218. 5
  219. int(1/(x^2-2),x);
  220. SQRT(2)*(LOG( - SQRT(2) + X) - LOG(SQRT(2) + X))
  221. ------------------------------------------------
  222. 4
  223. int(sin(x)/(4 + cos(x)**2),x);
  224. COS(X)
  225. ATAN(------)
  226. 2
  227. - ------------
  228. 2
  229. int(1/sqrt(x^2-x),x);
  230. SQRT(X)*SQRT(X - 1)
  231. INT(-------------------,X)
  232. 2
  233. X -X
  234. </tt></pre><p>Note that REDUCE couldn't handle the last integral with its defaul
  235. t
  236. integrator, since the integrand involves a square root. However,
  237. the integral can be found using the
  238. <a href=r38_0250.html#r38_0265>algint</a> package.
  239. Alternatively, you could add a rule using the
  240. <a href=r38_0150.html#r38_0199>let</a> statement
  241. to evaluate this integral.
  242. <P>
  243. <P>
  244. The arbitrary constant of integration is not shown. Definite integrals can
  245. be found by evaluating the result at the limits of integration (use
  246. <a href=r38_0300.html#r38_0330>rounded</a>) and subtracting the lower from the h
  247. igher. Evaluation can
  248. be easily done by the
  249. <a href=r38_0150.html#r38_0182>sub</a> operator.
  250. <P>
  251. <P>
  252. When <em>int</em> cannot find an integral it returns an expression
  253. involving formal <em>int</em> expressions unless the switch
  254. <a href=r38_0250.html#r38_0288>failhard</a> has been set. If not all of the expr
  255. ession
  256. can be integrated, the switch
  257. <a href=r38_0300.html#r38_0311>nolnr</a> controls whether a partially
  258. integrated result should be returned or not.
  259. <P>
  260. <P>
  261. <P>
  262. <P>
  263. <a name=r38_0155>
  264. <title>INTERPOL</title></a>
  265. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  266. E"></p>
  267. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  268. <b>INTERPOL</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  269. <P>
  270. <P>
  271. <P>
  272. <em>interpol</em>generates an interpolation polynomial.
  273. <P> <H3>
  274. syntax: </H3>
  275. <P>
  276. <P>
  277. interpol(&lt;values&gt;,&lt;variable&gt;,&lt;points&gt;)
  278. <P>
  279. <P>
  280. <P>
  281. &lt;values&gt; and &lt;points&gt; are
  282. <a href=r38_0050.html#r38_0053>list</a>s of equal length and
  283. &lt;variable&gt; is an algebraic expression (preferably a
  284. <a href=r38_0001.html#r38_0002>kernel</a>).
  285. The interpolation polynomial is generated in the given variable of degree
  286. length(&lt;values&gt;)-1. The unique polynomial <em>f</em> is defined by the
  287. property that for corresponding elements <em>v</em> of &lt;values&gt; and
  288. <em>p</em> of &lt;points&gt; the relation <em>f(p)=v</em> holds.
  289. <P>
  290. <P>
  291. <P> <H3>
  292. examples: </H3>
  293. <p><pre><tt>
  294. f := for i:=1:4 collect(i**3-1);
  295. F := 0,7,26,63
  296. p := {1,2,3,4};
  297. P := 1,2,3,4
  298. interpol(f,x,p);
  299. 3
  300. X - 1
  301. </tt></pre><p>The Aitken-Neville interpolation algorithm is used which guarantee
  302. s a
  303. stable result even with rounded numbers and an ill-conditioned problem.
  304. <P>
  305. <P>
  306. <P>
  307. <a name=r38_0156>
  308. <title>LCOF</title></a>
  309. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  310. E"></p>
  311. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  312. <b>LCOF</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  313. <P>
  314. <P>
  315. <P>
  316. The <em>lcof</em> operator returns the leading coefficient of a given expression
  317. with respect to a given variable.
  318. <P> <H3>
  319. syntax: </H3>
  320. <P>
  321. <P>
  322. <em>lcof</em>(&lt;expression&gt;,&lt;kernel&gt;)
  323. <P>
  324. <P>
  325. <P>
  326. &lt;expression&gt; is ordinarily a polynomial. If
  327. <a href=r38_0300.html#r38_0322>ratarg</a> is on,
  328. a rational expression may also be used, otherwise an error results.
  329. &lt;kernel&gt; must be a
  330. <a href=r38_0001.html#r38_0002>kernel</a>.
  331. <P>
  332. <P>
  333. <P> <H3>
  334. examples: </H3>
  335. <p><pre><tt>
  336. lcof((x+2*y)**5,y);
  337. 32
  338. lcof((x + y*sin(x))**2 + cos(x)*sin(x)**2,sin(x));
  339. 2
  340. COS(X) + Y
  341. lcof(x**2 + 3*x + 17,y);
  342. 2
  343. X + 3*X + 17
  344. </tt></pre><p>If the kernel does not appear in the expression, <em>lcof</em> ret
  345. urns the
  346. expression.
  347. <P>
  348. <P>
  349. <P>
  350. <a name=r38_0157>
  351. <title>LENGTH</title></a>
  352. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  353. E"></p>
  354. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  355. <b>LENGTH</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  356. <P>
  357. <P>
  358. <P>
  359. The <em>length</em> operator returns the number of items in a
  360. <a href=r38_0050.html#r38_0053>list</a>, the
  361. number of
  362. terms in an expression, or the dimensions of an array or matrix.
  363. <P> <H3>
  364. syntax: </H3>
  365. <P>
  366. <P>
  367. <em>length</em>(&lt;expr&gt;) or <em>length</em> &lt;expr&gt;
  368. <P>
  369. <P>
  370. <P>
  371. &lt;expr&gt; can be a list structure, an array, a matrix, or a scalar expression
  372. .
  373. <P>
  374. <P>
  375. <P> <H3>
  376. examples: </H3>
  377. <p><pre><tt>
  378. alist := {a,b,{ww,xx,yy,zz}};
  379. ALIST := {A,B,{WW,XX,YY,ZZ}}
  380. length alist;
  381. 3
  382. length third alist;
  383. 4
  384. dlist := {d};
  385. DLIST := {D}
  386. length rest dlist;
  387. 0
  388. matrix mmm(4,5);
  389. length mmm;
  390. {4,5}
  391. array aaa(5,3,2);
  392. length aaa;
  393. {6,4,3}
  394. eex := (x+3)**2/(x-y);
  395. 2
  396. X + 6*X + 9
  397. EEX := ------------
  398. X - Y
  399. length eex;
  400. 5
  401. </tt></pre><p>An item in a list that is itself a list only counts as one item. A
  402. n error
  403. message will be printed if <em>length</em> is called on a matrix which has
  404. not had its dimensions set. The <em>length</em> of an array includes the
  405. zeroth element of each dimension, showing the full number of elements
  406. allocated. (Declaring an array A with n elements
  407. allocates A(0),A(1),...,A(n).) The
  408. <em>length</em> of an expression is the total number of additive terms
  409. appearing in the numerator and denominator of the expression. Note that
  410. subtraction of a term is represented internally as addition of a negative
  411. term.
  412. <P>
  413. <P>
  414. <P>
  415. <a name=r38_0158>
  416. <title>LHS</title></a>
  417. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  418. E"></p>
  419. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  420. <b>LHS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  421. <P>
  422. <P>
  423. <P>
  424. The <em>lhs</em> operator returns the left-hand side of an
  425. <a href=r38_0001.html#r38_0045>equation</a>,
  426. such as those
  427. returned in a list by
  428. <a href=r38_0150.html#r38_0179>solve</a>.
  429. <P> <H3>
  430. syntax: </H3>
  431. <P>
  432. <P>
  433. <em>lhs</em>(&lt;equation&gt;) or <em>lhs</em> &lt;equation&gt;
  434. <P>
  435. <P>
  436. <P>
  437. <P>
  438. &lt;equation&gt; must be an equation of the form
  439. <P>
  440. <P>
  441. <em>left-hand side</em><em>=</em><em>right-hand side</em>.
  442. <P>
  443. <P>
  444. <P> <H3>
  445. examples: </H3>
  446. <p><pre><tt>
  447. polly := (x+3)*(x^4+2x+1);
  448. 5 4 2
  449. POLLY := X + 3*X + 2*X + 7*X + 3
  450. pollyroots := solve(polly,x);
  451. POLLYROOTS := {X=ROOT F(X3 - X2 + X + 1,X ,
  452. O )
  453. X=-1,
  454. X=-3}
  455. variable := lhs first pollyroots;
  456. VARIABLE := X
  457. </tt></pre><p>
  458. <a name=r38_0159>
  459. <title>LIMIT</title></a>
  460. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  461. E"></p>
  462. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  463. <b>LIMIT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  464. <P>
  465. <P>
  466. <P>
  467. LIMITS is a fast limit package for REDUCE for functions which are
  468. continuous except for computable poles and singularities, based on
  469. some earlier work by Ian Cohen and John P. Fitch. The Truncated
  470. Power Series package is used for non-critical points, at which
  471. the value of the function is the constant term in the expansion
  472. around that point. l'Hopital's rule is used in critical cases,
  473. with preprocessing of 1-1 forms and reformatting of product forms
  474. in order to apply l'Hopital's rule. A limited amount of bounded
  475. arithmetic is also employed where applicable.
  476. <P>
  477. <P>
  478. <P> <H3>
  479. syntax: </H3>
  480. <em>limit</em>(&lt;expr&gt;,&lt;var&gt;,&lt;limpoint&gt;) or
  481. <P>
  482. <P>
  483. <em>limit!+</em>(&lt;expr&gt;,&lt;var&gt;,&lt;limpoint&gt;) or
  484. <P>
  485. <P>
  486. <em>limit!-</em>(&lt;expr&gt;,&lt;var&gt;,&lt;limpoint&gt;)
  487. <P>
  488. <P>
  489. <P>
  490. where &lt;expr&gt; is an expression depending of the variable &lt;var&gt;
  491. (a
  492. <a href=r38_0001.html#r38_0002>kernel</a>) and &lt;limpoint&gt; is the limit poi
  493. nt.
  494. If the limit depends upon the direction of approach to the &lt;limpoint&gt;,
  495. the operators <em>limit!+</em> and <em>limit!-</em> may be used.
  496. <P>
  497. <P>
  498. <P> <H3>
  499. examples: </H3>
  500. <p><pre><tt>
  501. limit(x*cot(x),x,0);
  502. 0
  503. limit((2x+5)/(3x-2),x,infinity);
  504. 2
  505. --
  506. 3
  507. </tt></pre><p>
  508. <a name=r38_0160>
  509. <title>LPOWER</title></a>
  510. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  511. E"></p>
  512. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  513. <b>LPOWER</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  514. <P>
  515. <P>
  516. <P>
  517. The <em>lpower</em> operator returns the leading power of an expression with
  518. respect to a kernel. 1 is returned if the expression does not depend on
  519. the kernel.
  520. <P> <H3>
  521. syntax: </H3>
  522. <P>
  523. <P>
  524. <em>lpower</em>(&lt;expression&gt;,&lt;kernel&gt;)
  525. <P>
  526. <P>
  527. <P>
  528. &lt;expression&gt; is ordinarily a polynomial. If
  529. <a href=r38_0300.html#r38_0322>ratarg</a> is on,
  530. a rational expression may also be used, otherwise an error results.
  531. &lt;kernel&gt; must be a
  532. <a href=r38_0001.html#r38_0002>kernel</a>.
  533. <P>
  534. <P>
  535. <P> <H3>
  536. examples: </H3>
  537. <p><pre><tt>
  538. lpower((x+2*y)**6,y);
  539. 6
  540. Y
  541. lpower((x + cos(x))**8 + df(x**2,x),cos(x));
  542. 8
  543. COS(X)
  544. lpower(x**3 + 3*x,y);
  545. 1
  546. </tt></pre><p>
  547. <a name=r38_0161>
  548. <title>LTERM</title></a>
  549. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  550. E"></p>
  551. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  552. <b>LTERM</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  553. <P>
  554. <P>
  555. <P>
  556. The <em>lterm</em> operator returns the leading term of an expression with
  557. respect to a kernel. The expression is returned if it does not depend on
  558. the kernel.
  559. <P> <H3>
  560. syntax: </H3>
  561. <P>
  562. <P>
  563. <em>lterm</em>(&lt;expression&gt;,&lt;kernel&gt;)
  564. <P>
  565. <P>
  566. <P>
  567. &lt;expression&gt; is ordinarily a polynomial. If
  568. <a href=r38_0300.html#r38_0322>ratarg</a> is on,
  569. a rational expression may also be used, otherwise an error results.
  570. &lt;kernel&gt; must be a
  571. <a href=r38_0001.html#r38_0002>kernel</a>.
  572. <P>
  573. <P>
  574. <P> <H3>
  575. examples: </H3>
  576. <p><pre><tt>
  577. lterm((x+2*y)**6,y);
  578. 6
  579. 64*Y
  580. lterm((x + cos(x))**8 + df(x**2,x),cos(x));
  581. 8
  582. COS(X)
  583. lterm(x**3 + 3*x,y);
  584. 3
  585. X + 3X
  586. </tt></pre><p>
  587. <a name=r38_0162>
  588. <title>MAINVAR</title></a>
  589. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  590. E"></p>
  591. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  592. <b>MAINVAR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  593. <P>
  594. <P>
  595. <P>
  596. The <em>mainvar</em> operator returns the main variable (in the system's
  597. internal representation) of its argument.
  598. <P> <H3>
  599. syntax: </H3>
  600. <P>
  601. <P>
  602. <em>mainvar</em>(&lt;expression&gt;)
  603. <P>
  604. <P>
  605. <P>
  606. <P>
  607. &lt;expression&gt; is usually a polynomial, but may be any valid REDUCE
  608. scalar expression. In the case of a rational function, the main variable
  609. of the numerator is returned. The main variable returned is a
  610. <a href=r38_0001.html#r38_0002>kernel</a>.
  611. <P>
  612. <P>
  613. <P> <H3>
  614. examples: </H3>
  615. <p><pre><tt>
  616. test := (a + b + c)**2;
  617. 2 2 2
  618. TEST := A + 2*A*B + 2*A*C + B + 2*B*C + C
  619. mainvar(test);
  620. A
  621. korder c,b,a;
  622. mainvar(test);
  623. C
  624. mainvar(2*cos(x)**2);
  625. COS(X)
  626. mainvar(17);
  627. 0
  628. </tt></pre><p>The main variable is the first variable in the canonical ordering
  629. of
  630. kernels. Generally, alphabetically ordered functions come first, then
  631. alphabetically ordered identifiers (variables). Numbers come last, and as
  632. far as <em>mainvar</em> is concerned belong in the family <em>0</em>. The
  633. canonical ordering can be changed by the declaration
  634. <a href=r38_0150.html#r38_0198>korder</a>, as
  635. shown above.
  636. <P>
  637. <P>
  638. <P>
  639. <a name=r38_0163>
  640. <title>MAP</title></a>
  641. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  642. E"></p>
  643. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  644. <b>MAP</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  645. <P>
  646. <P>
  647. <P>
  648. The <em>map</em> operator applies a uniform evaluation pattern
  649. to all members of a composite structure: a
  650. <a href=r38_0300.html#r38_0345>matrix</a>,
  651. a
  652. <a href=r38_0050.html#r38_0053>list</a> or the arguments of an
  653. <a href=r38_0200.html#r38_0211>operator</a> expression.
  654. The evaluation pattern can be a
  655. unary procedure, an operator, or an algebraic expression with
  656. one free variable.
  657. <P> <H3>
  658. syntax: </H3>
  659. <P>
  660. <P>
  661. <em>map</em>(&lt;function&gt;,&lt;object&gt;)
  662. <P>
  663. <P>
  664. <P>
  665. &lt;object&gt; is a list, a matrix or an operator expression.
  666. <P>
  667. <P>
  668. &lt;function&gt; is
  669. the name of an operator for a single argument: the operator
  670. is evaluated once with each element of &lt;object&gt; as its single argument,
  671. <P>
  672. <P>
  673. or an algebraic expression with exactly one
  674. <a href=r38_0050.html#r38_0061>free variable</a>, that is
  675. a variable preceded by the tilde symbol: the expression
  676. is evaluated for each element of &lt;object&gt; where the element is
  677. substituted for the free variable,
  678. <P>
  679. <P>
  680. or a replacement
  681. <a href=r38_0050.html#r38_0060>rule</a> of the form
  682. <P> <H3>
  683. syntax: </H3>
  684. <P>
  685. <P>
  686. <em>var</em>=&gt; <em>rep</em>
  687. <P>
  688. <P>
  689. <P>
  690. where &lt;var&gt; is a variable (a &lt;kernel&gt; without subscript)
  691. and &lt;rep&gt; is an expression which contains &lt;var&gt;.
  692. Here <em>rep</em> is evaluated for each element of &lt;object&gt; where
  693. the element is substituted for <em>var</em>. <em>var</em> may be
  694. optionally preceded by a tilde.
  695. <P>
  696. <P>
  697. The rule form for &lt;function&gt; is needed when more than
  698. one free variable occurs.
  699. <P>
  700. <P>
  701. <P> <H3>
  702. examples: </H3>
  703. <p><pre><tt>
  704. map(abs,{1,-2,a,-a});
  705. 1,2,abs(a),abs(a)
  706. map(int(~w,x), mat((x^2,x^5),(x^4,x^5)));
  707. [ 3 6 ]
  708. [ x x ]
  709. [---- ----]
  710. [ 3 6 ]
  711. [ ]
  712. [ 5 6 ]
  713. [ x x ]
  714. [---- ----]
  715. [ 5 6 ]
  716. map(~w*6, x^2/3 = y^3/2 -1);
  717. 2 3
  718. 2*x =3*(y -2)
  719. </tt></pre><p>You can use <em>map</em> in nested expressions. It is not allowed
  720. to
  721. apply <em>map</em> for a non-composed object, e.g. an identifier or a number.
  722. <P>
  723. <P>
  724. <P>
  725. <a name=r38_0164>
  726. <title>MKID</title></a>
  727. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  728. E"></p>
  729. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  730. <b>MKID</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  731. <P>
  732. <P>
  733. <P>
  734. The <em>mkid</em> command constructs an identifier, given a stem and an identifi
  735. er
  736. or an integer.
  737. <P> <H3>
  738. syntax: </H3>
  739. <P>
  740. <P>
  741. <em>mkid</em>(&lt;stem&gt;,&lt;leaf&gt;)
  742. <P>
  743. <P>
  744. <P>
  745. &lt;stem&gt; can be any valid REDUCE identifier that does not include escaped
  746. special characters. &lt;leaf&gt; may be an integer, including one given by a
  747. local variable in a
  748. <a href=r38_0001.html#r38_0047>for</a> loop, or any other legal group of
  749. characters.
  750. <P>
  751. <P>
  752. <P> <H3>
  753. examples: </H3>
  754. <p><pre><tt>
  755. mkid(x,3);
  756. X3
  757. factorize(x^15 - 1);
  758. {X - 1,
  759. 2
  760. X + X + 1,
  761. 4 3 2
  762. X + X + X + X + 1,
  763. 8 7 5 4 3
  764. X - X + X - X + X - X + 1}
  765. for i := 1:length ws do write set(mkid(f,i),part(ws,i));
  766. 8 7 5 4 3
  767. X - X + X - X + X - X + 1
  768. 4 3 2
  769. X + X + X + X + 1
  770. 2
  771. X + X + 1
  772. X - 1
  773. </tt></pre><p>You can use <em>mkid</em> to construct identifiers from inside pro
  774. cedures. This
  775. allows you to handle an unknown number of factors, or deal with variable
  776. amounts of data. It is particularly helpful to attach identifiers to the
  777. answers returned by <em>factorize</em> and <em>solve</em>.
  778. <P>
  779. <P>
  780. <P>
  781. <a name=r38_0165>
  782. <title>NPRIMITIVE</title></a>
  783. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  784. E"></p>
  785. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  786. <b>NPRIMITIVE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  787. <P>
  788. <P>
  789. <P>
  790. <P> <H3>
  791. syntax: </H3>
  792. <em>nprimitive</em>(&lt;expression&gt;) or <em>nprimitive</em>
  793. &lt;simple\_expression&gt;
  794. <P>
  795. <P>
  796. <P>
  797. This operator returns the numerically-primitive part of any scalar
  798. expression. In other words, any overall integer factors in the expression
  799. are removed.
  800. <P>
  801. <P>
  802. <P> <H3>
  803. examples: </H3>
  804. <p><pre><tt>
  805. nprimitive((2x+2y)^2);
  806. 2 2
  807. X + 2*X*Y + Y
  808. nprimitive(3*a*b*c);
  809. 3*A*B*C
  810. </tt></pre><p>
  811. <a name=r38_0166>
  812. <title>NUM</title></a>
  813. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  814. E"></p>
  815. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  816. <b>NUM</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  817. <P>
  818. <P>
  819. <P>
  820. The <em>num</em> operator returns the numerator of its argument.
  821. <P> <H3>
  822. syntax: </H3>
  823. <P>
  824. <P>
  825. <em>num</em>(&lt;expression&gt;) or <em>num</em> &lt;simple\_expression&gt;
  826. <P>
  827. <P>
  828. <P>
  829. &lt;expression&gt; can be any valid REDUCE scalar expression.
  830. <P>
  831. <P>
  832. <P> <H3>
  833. examples: </H3>
  834. <p><pre><tt>
  835. num(100/6);
  836. 50
  837. num(a/5 + b/6);
  838. 6*A + 5*B
  839. num(sin(x));
  840. SIN(X)
  841. </tt></pre><p><em>num</em>returns the numerator of the expression after it has b
  842. een simplified
  843. by REDUCE. As seen in the examples, this includes putting sums of rational
  844. expressions over a common denominator, and reducing common factors where
  845. possible. If the expression is not a rational expression, it is returned
  846. unchanged.
  847. <P>
  848. <P>
  849. <P>
  850. <a name=r38_0167>
  851. <title>ODESOLVE</title></a>
  852. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  853. E"></p>
  854. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  855. <b>ODESOLVE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  856. <P>
  857. <P>
  858. <P>
  859. The <em>odesolve</em> package is a solver for ordinary differential
  860. equations. At the present time it has still limited capabilities:
  861. <P>
  862. <P>
  863. 1. it can handle only a single scalar equation presented as an
  864. algebraic expression or equation, and
  865. <P>
  866. <P>
  867. 2. it can solve only first-order equations of simple types, linear
  868. equations with constant coefficients and Euler equations.
  869. <P>
  870. <P>
  871. These solvable types are exactly those for which Lie symmetry
  872. techniques give no useful information.
  873. <P>
  874. <P>
  875. <P> <H3>
  876. syntax: </H3>
  877. <em>odesolve</em>(&lt;expr&gt;,&lt;var1&gt;,&lt;var2&gt;)
  878. <P>
  879. <P>
  880. <P>
  881. <P>
  882. &lt;expr&gt; is a single scalar expression such that &lt;expr&gt;=0
  883. is the ordinary differential equation (ODE for short) to be solved, or
  884. is an equivalent
  885. <a href=r38_0001.html#r38_0045>equation</a>.
  886. <P>
  887. <P>
  888. &lt;var1&gt; is the name of the dependent variable,
  889. &lt;var2&gt; is the name of the independent variable.
  890. <P>
  891. <P>
  892. A differential in &lt;expr&gt; is expressed using the
  893. <a href=r38_0100.html#r38_0148>df</a>
  894. operator. Note that in most cases you must declare explicitly
  895. &lt;var1&gt; to depend of &lt;var2&gt; using a
  896. <a href=r38_0150.html#r38_0192>depend</a>
  897. declaration -- otherwise the derivative might be evaluated to
  898. zero on input to <em>odesolve</em>.
  899. <P>
  900. <P>
  901. The returned value is a list containing the equation giving the general
  902. solution of the ODE (for simultaneous equations this will be a
  903. list of equations eventually). It will contain occurrences of
  904. the operator <em>arbconst</em> for the arbitrary constants in the general
  905. solution. The arguments of <em>arbconst</em> should be new.
  906. A counter <em>!!arbconst</em> is used to arrange this.
  907. <P>
  908. <P>
  909. <P> <H3>
  910. examples: </H3>
  911. <p><pre><tt>
  912. depend y,x;
  913. % A first-order linear equation, with an initial condition
  914. ode:=df(y,x) + y * sin x/cos x - 1/cos x$
  915. odesolve(ode,y,x);
  916. {y=arbconst(1)*cos(x) + sin(x)}
  917. </tt></pre><p>
  918. <a name=r38_0168>
  919. <title>ONE_OF</title></a>
  920. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  921. E"></p>
  922. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  923. <b>ONE\_OF</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>type</b><P>
  924. <P>
  925. The operator <em>one_of</em> is used to represent an indefinite choice
  926. of one element from a finite set of objects.
  927. <P> <H3>
  928. examples: </H3>
  929. <p><pre><tt>
  930. x=one_of{1,2,5}
  931. </tt></pre><p>this equation encodes that x can take one of the values
  932. 1,2 or 5<p><pre><tt>
  933. </tt></pre><p>
  934. REDUCE generates a <em>one_of</em> form in cases when an implicit
  935. <em>root_of</em> expression could be converted to an explicit solution set.
  936. A <em>one_of</em> form can be converted to a <em>solve</em> solution using
  937. <a href=r38_0100.html#r38_0149>expand_cases</a>. See
  938. <a href=r38_0150.html#r38_0176>root_of</a>.
  939. <P>
  940. <P>
  941. <a name=r38_0169>
  942. <title>PART</title></a>
  943. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  944. E"></p>
  945. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  946. <b>PART</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  947. <P>
  948. <P>
  949. <P>
  950. The operator <em>part</em> permits the extraction of various parts or
  951. operators of expressions and
  952. <a href=r38_0050.html#r38_0053>list</a><em>s</em>.
  953. <P> <H3>
  954. syntax: </H3>
  955. <P>
  956. <P>
  957. <em>part</em>(&lt;expression,integer&gt;{,&lt;integer&gt;}*)
  958. <P>
  959. <P>
  960. <P>
  961. &lt;expression&gt; can be any valid REDUCE expression or a list,
  962. integer may be an expression that evaluates to a positive or negative
  963. integer or 0. A positive integer &lt;n&gt; picks up the n th term,
  964. counting from the first term toward the end. A negative integer n
  965. picks up the n th term, counting from the back toward the front. The
  966. integer 0 picks up the operator (which is <em>LIST</em> when the expression
  967. is a
  968. <a href=r38_0050.html#r38_0053>list</a>).
  969. <P>
  970. <P>
  971. <P> <H3>
  972. examples: </H3>
  973. <p><pre><tt>
  974. part((x + y)**5,4);
  975. 2 3
  976. 10*X *Y
  977. part((x + y)**5,4,2);
  978. 2
  979. X
  980. part((x + y)**5,4,2,1);
  981. X
  982. part((x + y)**5,0);
  983. PLUS
  984. part((x + y)**5,-5);
  985. 4
  986. 5*X *Y
  987. part((x + y)**5,4) := sin(x);
  988. 5 4 3 2 4 5
  989. X + 5*X *Y + 10*X *Y + SIN(X) + 5*X*Y + Y
  990. alist := {x,y,{aa,bb,cc},x**2*sqrt(y)};
  991. 2
  992. ALIST := {X,Y,{AA,BB,CC},SQRT(Y)*X }
  993. part(alist,3,2);
  994. BB
  995. part(alist,4,0);
  996. TIMES
  997. </tt></pre><p>Additional integer arguments after the first one examine the
  998. terms recursively, as shown above. In the third line, the fourth term
  999. is picked from the original polynomial, 10x^2y^3,
  1000. then the second term from that, x^2, and finally the first
  1001. component, x. If an integer's absolute value is too large for
  1002. the appropriate expression, a message is given.
  1003. <P>
  1004. <P>
  1005. <em>part</em>works on the form of the expression as printed, or as it would
  1006. have been printed at that point of the calculation, bearing in mind the
  1007. current switch settings. It is important to realize that the switch settings
  1008. change the operation of <em>part</em>.
  1009. <a href=r38_0300.html#r38_0319>pri</a> must be on when
  1010. <em>part</em> is used.
  1011. <P>
  1012. <P>
  1013. When <em>part</em> is used on a polynomial expression that has minus signs, the
  1014. <em>+</em> is always returned as the top-level operator. The minus is found
  1015. as a unary operator attached to the negative term.
  1016. <P>
  1017. <P>
  1018. <em>part</em>can also be used to change the relevant part of the expression or
  1019. list as shown in the sixth example line. The <em>part</em> operator returns the
  1020. changed expression, though original expression is not changed. You can
  1021. also use <em>part</em> to change the operator.
  1022. <P>
  1023. <P>
  1024. <P>
  1025. <a name=r38_0170>
  1026. <title>PF</title></a>
  1027. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1028. E"></p>
  1029. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1030. <b>PF</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1031. <P>
  1032. <P>
  1033. <P>
  1034. <P> <H3>
  1035. syntax: </H3>
  1036. pf(&lt;expression&gt;,&lt;variable&gt;)
  1037. <P>
  1038. <P>
  1039. <P>
  1040. <em>pf</em>transforms &lt;expression&gt; into a
  1041. <a href=r38_0050.html#r38_0053>list</a> of partial fraction
  1042. s
  1043. with respect to the main variable, &lt;variable&gt;. <em>pf</em> does a
  1044. complete partial fraction decomposition, and as the algorithms used are
  1045. fairly unsophisticated (factorization and the extended Euclidean
  1046. algorithm), the code may be unacceptably slow in complicated cases.
  1047. <P> <H3>
  1048. examples: </H3>
  1049. <p><pre><tt>
  1050. pf(2/((x+1)^2*(x+2)),x);
  1051. 2 -2 2
  1052. {-----,-----,------------}
  1053. X + 2 X + 1 2
  1054. X + 2*X + 1
  1055. off exp;
  1056. pf(2/((x+1)^2*(x+2)),x);
  1057. 2 - 2 2
  1058. {-----,-----,--------}
  1059. X + 2 X + 1 2
  1060. (X + 1)
  1061. for each j in ws sum j;
  1062. 2
  1063. ----------------
  1064. 2
  1065. ( + 2)*(X + 1)
  1066. </tt></pre><p><P>
  1067. <P>
  1068. If you want the denominators in factored form, turn
  1069. <a href=r38_0250.html#r38_0284>exp</a> off, as
  1070. shown in the second example above. As shown in the final example, the
  1071. <a href=r38_0001.html#r38_0047>for</a> <em>each</em> construct can be used to re
  1072. combine the terms.
  1073. Alternatively, one can use the operations on lists to extract any desired
  1074. term.
  1075. <P>
  1076. <P>
  1077. <P>
  1078. <a name=r38_0171>
  1079. <title>PROD</title></a>
  1080. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1081. E"></p>
  1082. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1083. <b>PROD</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1084. <P>
  1085. <P>
  1086. <P>
  1087. The operator <em>prod</em> returns
  1088. the indefinite or definite product of a given expression.
  1089. <P>
  1090. <P>
  1091. <P> <H3>
  1092. syntax: </H3>
  1093. <em>prod</em>(&lt;expr&gt;,&lt;k&gt;[,&lt;lolim&gt; [,&lt;uplim&gt; ]])
  1094. <P>
  1095. <P>
  1096. <P>
  1097. <P>
  1098. where &lt;expr&gt; is the expression to be multiplied, &lt;k&gt; is the
  1099. control variable (a
  1100. <a href=r38_0001.html#r38_0002>kernel</a>), and &lt;lolim&gt; and &lt;uplim&gt;
  1101. uplim are the optional lower and upper limits. If &lt;uplim&gt; is
  1102. not supplied the upper limit is taken as &lt;k&gt;. The
  1103. Gosper algorithm is used. If there is no closed form solution,
  1104. the operator returns the input unchanged.
  1105. <P>
  1106. <P>
  1107. <P> <H3>
  1108. examples: </H3>
  1109. <p><pre><tt>
  1110. prod(k/(k-2),k);
  1111. k*( - k + 1)
  1112. </tt></pre><p>
  1113. <a name=r38_0172>
  1114. <title>REDUCT</title></a>
  1115. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1116. E"></p>
  1117. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1118. <b>REDUCT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1119. <P>
  1120. <P>
  1121. <P>
  1122. The <em>reduct</em> operator returns the remainder of its expression after the
  1123. leading term with respect to the kernel in the second argument is removed.
  1124. <P> <H3>
  1125. syntax: </H3>
  1126. <P>
  1127. <P>
  1128. <em>reduct</em>(&lt;expression&gt;,&lt;kernel&gt;)
  1129. <P>
  1130. <P>
  1131. <P>
  1132. &lt;expression&gt; is ordinarily a polynomial. If
  1133. <a href=r38_0300.html#r38_0322>ratarg</a> is on,
  1134. a rational expression may also be used, otherwise an error results.
  1135. &lt;kernel&gt; must be a
  1136. <a href=r38_0001.html#r38_0002>kernel</a>.
  1137. <P>
  1138. <P>
  1139. <P> <H3>
  1140. examples: </H3>
  1141. <p><pre><tt>
  1142. reduct((x+y)**3,x);
  1143. 2 2
  1144. Y*(3*X + 3*X*Y + Y )
  1145. reduct(x + sin(x)**3,sin(x));
  1146. X
  1147. reduct(x + sin(x)**3,y);
  1148. 0
  1149. </tt></pre><p>If the expression does not contain the kernel, <em>reduct</em> ret
  1150. urns 0.
  1151. <P>
  1152. <P>
  1153. <P>
  1154. <a name=r38_0173>
  1155. <title>REPART</title></a>
  1156. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1157. E"></p>
  1158. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1159. <b>REPART</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1160. <P>
  1161. <P>
  1162. <P>
  1163. <P> <H3>
  1164. syntax: </H3>
  1165. <em>repart</em>(&lt;expression&gt;) or <em>repart</em> &lt;simple\_expression
  1166. &gt;
  1167. <P>
  1168. <P>
  1169. <P>
  1170. This operator returns the real part of an expression, if that argument has an
  1171. numerical value. A non-numerical argument is returned as an expression in
  1172. the operators <em>repart</em> and
  1173. <a href=r38_0150.html#r38_0153>impart</a>.
  1174. <P> <H3>
  1175. examples: </H3>
  1176. <p><pre><tt>
  1177. repart(1+i);
  1178. 1
  1179. repart(a+i*b);
  1180. REPART(A) - IMPART(B)
  1181. </tt></pre><p><P>
  1182. <P>
  1183. <a name=r38_0174>
  1184. <title>RESULTANT</title></a>
  1185. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1186. E"></p>
  1187. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1188. <b>RESULTANT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1189. <P>
  1190. <P>
  1191. <P>
  1192. The <em>resultant</em> operator computes the resultant of two polynomials with
  1193. respect to a given variable. If the resultant is 0, the polynomials have
  1194. a root in common.
  1195. <P> <H3>
  1196. syntax: </H3>
  1197. <P>
  1198. <P>
  1199. <em>resultant</em>(&lt;expression&gt;,&lt;expression&gt;,&lt;kernel&gt;)
  1200. <P>
  1201. <P>
  1202. <P>
  1203. &lt;expression&gt; must be a polynomial containing &lt;kernel&gt; ;
  1204. &lt;kernel&gt; must be a
  1205. <a href=r38_0001.html#r38_0002>kernel</a>.
  1206. <P>
  1207. <P>
  1208. <P> <H3>
  1209. examples: </H3>
  1210. <p><pre><tt>
  1211. resultant(x**2 + 2*x + 1,x+1,x);
  1212. 0
  1213. resultant(x**2 + 2*x + 1,x-3,x);
  1214. 16
  1215. resultant(z**3 + z**2 + 5*z + 5,
  1216. z**4 - 6*z**3 + 16*z**2 - 30*z + 55,
  1217. z);
  1218. 0
  1219. resultant(x**3*y + 4*x*y + 10,y**2 + 6*y + 4,y);
  1220. 6 5 4 3 2
  1221. Y + 18*Y + 120*Y + 360*Y + 480*Y + 288*Y + 64
  1222. </tt></pre><p>The resultant is the determinant of the Sylvester matrix, formed f
  1223. rom the
  1224. coefficients of the two polynomials in the following way:
  1225. <P>
  1226. <P>
  1227. Given two polynomials:
  1228. <P>
  1229. <P>
  1230. <p><pre><tt>
  1231. n n-1
  1232. a x + a1 x + ... + an
  1233. </tt></pre><p>and
  1234. <P>
  1235. <P>
  1236. <p><pre><tt>
  1237. m m-1
  1238. b x + b1 x + ... + bm
  1239. </tt></pre><p>form the (m+n)x(m+n-1) Sylvester matrix by the following means:
  1240. <P>
  1241. <P>
  1242. <p><pre><tt>
  1243. 0.......0 a a1 .......... an
  1244. 0....0 a a1 .......... an 0
  1245. . . . .
  1246. a0 a1 .......... an 0.......0
  1247. 0.......0 b b1 .......... bm
  1248. 0....0 b b1 .......... bm 0
  1249. . . . .
  1250. b b1 .......... bm 0.......0
  1251. </tt></pre><p>If the determinant of this matrix is 0, the two polynomials have a
  1252. common
  1253. root. Finding the resultant of large expressions is time-consuming, due
  1254. to the time needed to find a large determinant.
  1255. <P>
  1256. <P>
  1257. The sign conventions <em>resultant</em> uses are those given in the article,
  1258. ``Computing in Algebraic Extensions,'' by R. Loos, appearing in
  1259. &lt;Computer Algebra--Symbolic and Algebraic Computation&gt;, 2nd ed.,
  1260. edited by B. Buchberger, G.E. Collins and R. Loos, and published by
  1261. Springer-Verlag, 1983.
  1262. These are:
  1263. <P>
  1264. <P>
  1265. <p><pre><tt>
  1266. resultant(p(x),q(x),x) = (-1)^{deg p(x)*deg q(x)} * resultant(q(x),p(x),x),
  1267. resultant(a,p(x),x) = a^{deg p(x)},
  1268. resultant(a,b,x) = 1
  1269. </tt></pre><p>where p(x) and q(x) are polynomials which have x as a variable, an
  1270. d
  1271. a and b are free of x.
  1272. <P>
  1273. <P>
  1274. Error messages are given if <em>resultant</em> is given a non-polynomial
  1275. expression, or a non-kernel variable.
  1276. <P>
  1277. <P>
  1278. <P>
  1279. <a name=r38_0175>
  1280. <title>RHS</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>RHS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1285. <P>
  1286. <P>
  1287. <P>
  1288. The <em>rhs</em> operator returns the right-hand side of an
  1289. <a href=r38_0001.html#r38_0045>equation</a>,
  1290. such as those returned in a
  1291. <a href=r38_0050.html#r38_0053>list</a> by
  1292. <a href=r38_0150.html#r38_0179>solve</a>.
  1293. <P> <H3>
  1294. syntax: </H3>
  1295. <P>
  1296. <P>
  1297. <em>rhs</em>(&lt;equation&gt;) or <em>rhs</em> &lt;equation&gt;
  1298. <P>
  1299. <P>
  1300. <P>
  1301. &lt;equation&gt; must be an equation of the form left-hand side = right-hand
  1302. side.
  1303. <P>
  1304. <P>
  1305. <P> <H3>
  1306. examples: </H3>
  1307. <p><pre><tt>
  1308. roots := solve(x**2 + 6*x*y + 5x + 3y**2,x);
  1309. 2
  1310. SQRT(24*Y + 60*Y + 25) + 6*Y + 5
  1311. ROOTS := {X= - ---------------------------------,
  1312. 2
  1313. 2
  1314. SQRT(24*Y + 60*Y + 25) - 6*Y - 5
  1315. X= ---------------------------------}
  1316. 2
  1317. root1 := rhs first roots;
  1318. 2
  1319. SQRT(24*Y + 60*Y + 25) + 6*Y + 5
  1320. ROOT1 := - ---------------------------------
  1321. 2
  1322. root2 := rhs second roots;
  1323. 2
  1324. SQRT(24*Y + 60*Y + 25) - 6*Y - 5
  1325. ROOT2 := ----------------------------------
  1326. 2
  1327. </tt></pre><p>An error message is given if <em>rhs</em> is applied to something
  1328. other than an
  1329. equation.
  1330. <P>
  1331. <P>
  1332. <P>
  1333. <a name=r38_0176>
  1334. <title>ROOT_OF</title></a>
  1335. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1336. E"></p>
  1337. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1338. <b>ROOT\_OF</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1339. <P>
  1340. <P>
  1341. <P>
  1342. When the operator
  1343. <a href=r38_0150.html#r38_0179>solve</a> is unable to find an explicit solution
  1344. or if that solution would be too complicated, the result is presented
  1345. as formal root expression using the internal operator <em>root_of</em>
  1346. and a new local variable. An expression with a top level <em>root_of</em>
  1347. is implicitly a list with an unknown number of elements since we
  1348. can't always know how many solutions an equation has. If a
  1349. substitution is made into such an expression, closed form solutions
  1350. can emerge. If this occurs, the <em>root_of</em> construct is
  1351. replaced by an operator
  1352. <a href=r38_0150.html#r38_0168>one_of</a>. At this point it is
  1353. of course possible to transform the result if the original <em>solve</em>
  1354. operator expression into a standard <em>solve</em> solution. To
  1355. effect this, the operator
  1356. <a href=r38_0100.html#r38_0149>expand_cases</a> can be used.
  1357. <P>
  1358. <P>
  1359. <P> <H3>
  1360. examples: </H3>
  1361. <p><pre><tt>
  1362. solve(a*x^7-x^2+1,x);
  1363. 7 2
  1364. {x=root_of(a*x_ - x_ + 1,x_)}
  1365. sub(a=0,ws);
  1366. {x=one_of(1,-1)}
  1367. expand_cases ws;
  1368. x=1,x=-1
  1369. </tt></pre><p>The components of <em>root_of</em> and <em>one_of</em> expressions
  1370. can be
  1371. processed as usual with operators
  1372. <a href=r38_0100.html#r38_0140>arglength</a> and
  1373. <a href=r38_0150.html#r38_0169>part</a>.
  1374. A higher power of a <em>root_of</em> expression with a polynomial
  1375. as first argument is simplified by using the polynomial as a side relation.
  1376. <P>
  1377. <P>
  1378. <a name=r38_0177>
  1379. <title>SELECT</title></a>
  1380. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1381. E"></p>
  1382. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1383. <b>SELECT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1384. <P>
  1385. <P>
  1386. <P>
  1387. The <em>select</em> operator extracts from a list
  1388. or from the arguments of an n--ary operator elements corresponding
  1389. to a boolean predicate. The predicate pattern can be a
  1390. unary procedure, an operator or an algebraic expression with
  1391. one
  1392. <a href=r38_0050.html#r38_0061>free variable</a>.
  1393. <P> <H3>
  1394. syntax: </H3>
  1395. <P>
  1396. <P>
  1397. <em>select</em>(&lt;function&gt;,&lt;object&gt;)
  1398. <P>
  1399. <P>
  1400. <P>
  1401. &lt;object&gt; is a
  1402. <a href=r38_0050.html#r38_0053>list</a>.
  1403. <P>
  1404. <P>
  1405. &lt;function&gt; is
  1406. the name of an operator for a single argument: the operator
  1407. is evaluated once with each element of &lt;object&gt; as its single argument,
  1408. <P>
  1409. <P>
  1410. or an algebraic expression with exactly one
  1411. <a href=r38_0050.html#r38_0061>free variable</a>, that is
  1412. a variable preceded by the tilde symbol: the expression
  1413. is evaluated for each element of &lt;object&gt; where the element is
  1414. substituted for the free variable,
  1415. <P>
  1416. <P>
  1417. or a replacement
  1418. <a href=r38_0050.html#r38_0060>rule</a> of the form
  1419. <P> <H3>
  1420. syntax: </H3>
  1421. <P>
  1422. <P>
  1423. <em>var</em>=&gt; <em>rep</em>
  1424. <P>
  1425. <P>
  1426. <P>
  1427. where &lt;var&gt; is a variable (a &lt;kernel&gt; without subscript)
  1428. and &lt;rep&gt; is an expression which contains &lt;var&gt;.
  1429. Here <em>rep</em> is evaluated for each element of &lt;object&gt; where
  1430. the element is substituted for <em>var</em>. <em>var</em> may be
  1431. optionally preceded by a tilde.
  1432. <P>
  1433. <P>
  1434. The rule form for &lt;function&gt; is needed when more than
  1435. one free variable occurs. The evaluation result of &lt;function&gt; is
  1436. interpreted as
  1437. <a href=r38_0100.html#r38_0109>boolean value</a> corresponding to the convention
  1438. s of
  1439. REDUCE. The result value is built with the leading operator of the
  1440. input expression.
  1441. <P> <H3>
  1442. examples: </H3>
  1443. <p><pre><tt>
  1444. select( ~w&gt;0 , {1,-1,2,-3,3})
  1445. {1,2,3}
  1446. q:=(part((x+y)^5,0):=list)
  1447. select(evenp deg(~w,y),q);
  1448. 5 3 2 4
  1449. {x ,10*x *y ,5*x*y }
  1450. select(evenp deg(~w,x),2x^2+3x^3+4x^4);
  1451. 2 4
  1452. 2x +4x
  1453. </tt></pre><p><P>
  1454. <P>
  1455. <a name=r38_0178>
  1456. <title>SHOWRULES</title></a>
  1457. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1458. E"></p>
  1459. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1460. <b>SHOWRULES</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1461. <P>
  1462. <P>
  1463. <P>
  1464. <P> <H3>
  1465. syntax: </H3>
  1466. <em>showrules</em>(&lt;expression&gt;) or
  1467. <em>showrules</em> &lt;simple\_expression&gt;
  1468. <P>
  1469. <P>
  1470. <P>
  1471. <em>showrules</em>returns in
  1472. <a href=r38_0050.html#r38_0060>rule</a><em>-list</em> form any
  1473. <a href=r38_0200.html#r38_0211>operator</a> rules associated with its argument.
  1474. <P>
  1475. <P>
  1476. <P> <H3>
  1477. examples: </H3>
  1478. <p><pre><tt>
  1479. showrules log;
  1480. {LOG(E) =&gt; 1,
  1481. LOG(1) =&gt; 0,
  1482. ~X
  1483. LOG(E ) =&gt; ~X,
  1484. 1
  1485. DF(LOG(~X),~X) =&gt; --}
  1486. ~X
  1487. </tt></pre><p>Such rules can then be manipulated further as with any
  1488. <a href=r38_0050.html#r38_0053>list</a>. For
  1489. example
  1490. <em>rhs first ws;</em> has the value 1.
  1491. <P>
  1492. <P>
  1493. An operator may have properties that cannot be displayed in such a form,
  1494. such as the fact it is an
  1495. <a href=r38_0200.html#r38_0208>odd</a> function, or has a definition defined
  1496. as a procedure.
  1497. <P>
  1498. <P>
  1499. <P>
  1500. <a name=r38_0179>
  1501. <title>SOLVE</title></a>
  1502. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1503. E"></p>
  1504. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1505. <b>SOLVE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1506. <P>
  1507. <P>
  1508. <P>
  1509. The <em>solve</em> operator solves a single algebraic
  1510. <a href=r38_0001.html#r38_0045>equation</a> or a
  1511. system of simultaneous equations.
  1512. <P>
  1513. <P>
  1514. <P> <H3>
  1515. syntax: </H3>
  1516. <em>solve</em>(&lt;expression&gt; [ , &lt;kernel&gt;]) or
  1517. <P>
  1518. <P>
  1519. <em>solve</em>({&lt;expression&gt;,...} [ ,{ &lt;kernel&gt; ,...}] )
  1520. <P>
  1521. <P>
  1522. <P>
  1523. <P>
  1524. If the number of equations equals the number of distinct kernels, the
  1525. optional kernel argument(s) may be omitted. &lt;expression&gt; is either a
  1526. scalar expression or an
  1527. <a href=r38_0001.html#r38_0045>equation</a>.
  1528. When more than one expression is given,
  1529. the
  1530. <a href=r38_0050.html#r38_0053>list</a> of expressions is surrounded by curly br
  1531. aces.
  1532. The optional list
  1533. of
  1534. <a href=r38_0001.html#r38_0002>kernel</a>s follows, also in curly braces.
  1535. <P>
  1536. <P>
  1537. <P> <H3>
  1538. examples: </H3>
  1539. <p><pre><tt>
  1540. sss := solve(x^2 + 7);
  1541. Unknown: X
  1542. SSS := {X= - SQRT(7)*I,
  1543. X=SQRT(7)*I}
  1544. rhs first sss;
  1545. - SQRT(7)*I
  1546. solve(sin(x^2*y),y);
  1547. 2*ARBINT(1)*PI
  1548. {Y=---------------
  1549. 2
  1550. X
  1551. PI*(2*ARBINT(1) + 1)
  1552. Y=--------------------}
  1553. 2
  1554. X
  1555. off allbranch;
  1556. solve(sin(x**2*y),y);
  1557. {Y=0}
  1558. solve({3x + 5y = -4,2*x + y = -10},{x,y});
  1559. 22 46
  1560. {{X= - --,Y=--}}
  1561. 7 7
  1562. solve({x + a*y + z,2x + 5},{x,y});
  1563. 5 2*Z - 5
  1564. {{X= - -,Y= - -------}}
  1565. 2 2*A
  1566. ab := (x+2)^2*(x^6 + 17x + 1);
  1567. 8 7 6 3 2
  1568. AB := X + 4*X + 4*X + 17*X + 69*X + 72*X + 4
  1569. www := solve(ab,x);
  1570. {X=ROOT F(X6 + 17*X + 1),X=-2}
  1571. O
  1572. root_multiplicities;
  1573. {1,2}
  1574. </tt></pre><p>Results of the <em>solve</em> operator are returned as
  1575. <a href=r38_0001.html#r38_0045>equation</a><em>s</em>
  1576. in a
  1577. <a href=r38_0050.html#r38_0053>list</a>.
  1578. You can use the usual list access methods (
  1579. <a href=r38_0001.html#r38_0046>first</a>,
  1580. <a href=r38_0050.html#r38_0063>second</a>,
  1581. <a href=r38_0050.html#r38_0066>third</a>,
  1582. <a href=r38_0050.html#r38_0057>rest</a> and
  1583. <a href=r38_0150.html#r38_0169>part</a>) to
  1584. extract the desired equation, and then use the operators
  1585. <a href=r38_0150.html#r38_0175>rhs</a> and
  1586. <a href=r38_0150.html#r38_0158>lhs</a> to access the right-hand or left-hand exp
  1587. ression of the
  1588. equation. When <em>solve</em> is unable to solve an equation, it returns the
  1589. unsolved part as the argument of <em>root_of</em>, with the variable renamed
  1590. to avoid confusion, as shown in the last example above.
  1591. <P>
  1592. <P>
  1593. For one equation, <em>solve</em> uses square-free factorization, roots of
  1594. unity, and the known inverses of the
  1595. <a href=r38_0050.html#r38_0088>log</a>,
  1596. <a href=r38_0250.html#r38_0259>sin</a>,
  1597. <a href=r38_0200.html#r38_0249>cos</a>,
  1598. <a href=r38_0200.html#r38_0236>acos</a>,
  1599. <a href=r38_0200.html#r38_0244>asin</a>, and
  1600. exponentiation operators. The quadratic, cubic and quartic formulas are
  1601. used if necessary, but these are applied only when the switch
  1602. <a href=r38_0250.html#r38_0292>fullroots</a> is set on; otherwise or when no clo
  1603. sed form is available
  1604. the result is returned as
  1605. <a href=r38_0150.html#r38_0176>root_of</a> expression. The switch
  1606. <a href=r38_0300.html#r38_0336>trigform</a>
  1607. determines which type of cubic and quartic formula is used.
  1608. The multiplicity of each solution is given in a list as
  1609. the system variable
  1610. <a href=r38_0001.html#r38_0017>root_multiplicities</a>. For systems of
  1611. simultaneous linear equations, matrix inversion is used. For nonlinear
  1612. systems, the Groebner basis method is used.
  1613. <P>
  1614. <P>
  1615. Linear equation system solving is influenced by the switch
  1616. <a href=r38_0250.html#r38_0276>cramer</a>.
  1617. <P>
  1618. <P>
  1619. Singular systems can be solved when the switch
  1620. <a href=r38_0300.html#r38_0332>solvesingular</a> is
  1621. on, which is the default setting. An empty list is returned the system of
  1622. equations is inconsistent. For a linear inconsistent system with parameters
  1623. the variable
  1624. <a href=r38_0001.html#r38_0016>requirements</a> constraints
  1625. conditions for the system to become consistent.
  1626. <P>
  1627. <P>
  1628. For a solvable linear and polynomial system with parameters
  1629. the variable
  1630. <a href=r38_0001.html#r38_0005>assumptions</a>
  1631. contains a list side relations for the parameters: the solution is
  1632. valid only as long as none of these expressions is zero.
  1633. <P>
  1634. <P>
  1635. If the switch
  1636. <a href=r38_0300.html#r38_0339>varopt</a> is on (default), the system rearranges
  1637. the
  1638. variable sequence for minimal computation time. Without <em>varopt</em>
  1639. the user supplied variable sequence is maintained.
  1640. <P>
  1641. <P>
  1642. If the solution has free variables (dimension of the solution is greater
  1643. than zero), these are represented by
  1644. <a href=r38_0100.html#r38_0139>arbcomplex</a> expressions
  1645. as long as the switch
  1646. <a href=r38_0250.html#r38_0268>arbvars</a> is on (default). Without
  1647. <em>arbvars</em> no explicit equations are generated for free variables.
  1648. <P>
  1649. <P>
  1650. <P>
  1651. <P> <H3>
  1652. related: </H3>
  1653. <P>
  1654. _ _ _
  1655. <a href=r38_0250.html#r38_0266>allbranch</a>switch
  1656. <P>
  1657. _ _ _
  1658. <a href=r38_0250.html#r38_0268>arbvars</a> switch
  1659. <P>
  1660. _ _ _
  1661. <a href=r38_0001.html#r38_0005>assumptions</a> variable
  1662. <P>
  1663. _ _ _
  1664. <a href=r38_0250.html#r38_0292>fullroots</a> switch
  1665. <P>
  1666. _ _ _
  1667. <a href=r38_0001.html#r38_0016>requirements</a> variable
  1668. <P>
  1669. _ _ _
  1670. <a href=r38_0400.html#r38_0439>roots</a> operator
  1671. <P>
  1672. _ _ _
  1673. <a href=r38_0150.html#r38_0176>root_of</a> operator
  1674. <P>
  1675. _ _ _
  1676. <a href=r38_0300.html#r38_0336>trigform</a> switch
  1677. <P>
  1678. _ _ _
  1679. <a href=r38_0300.html#r38_0339>varopt</a> switch
  1680. <P>
  1681. <P>
  1682. <P>
  1683. <a name=r38_0180>
  1684. <title>SORT</title></a>
  1685. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1686. E"></p>
  1687. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1688. <b>SORT</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1689. <P>
  1690. <P>
  1691. <P>
  1692. The <em>sort</em> operator sorts the elements of a list according to
  1693. an arbitrary comparison operator.
  1694. <P> <H3>
  1695. syntax: </H3>
  1696. <P>
  1697. <P>
  1698. <em>sort</em>(&lt;lst&gt;,&lt;comp&gt;)
  1699. <P>
  1700. <P>
  1701. <P>
  1702. &lt;lst&gt; is a
  1703. <a href=r38_0050.html#r38_0053>list</a> of algebraic expressions.
  1704. &lt;comp&gt; is a comparison operator which defines a partial
  1705. ordering among the members of &lt;lst&gt;. &lt;comp&gt; may be
  1706. one of the builtin comparison operators like
  1707. <em>&lt;</em>(
  1708. <a href=r38_0100.html#r38_0115>lessp</a>), <em>&lt;=</em>(
  1709. <a href=r38_0100.html#r38_0114>leq</a>)
  1710. etc., or &lt;comp&gt; may be the name of a comparison procedure.
  1711. Such a procedure has two arguments, and it returns
  1712. <a href=r38_0100.html#r38_0122>true</a> if the first argument
  1713. ranges before the second one, and 0 or
  1714. <a href=r38_0001.html#r38_0014>nil</a> otherwise.
  1715. The result of <em>sort</em> is a new list which contains the
  1716. elements of &lt;lst&gt; in a sequence corresponding to &lt;comp&gt;.
  1717. <P> <H3>
  1718. examples: </H3>
  1719. <p><pre><tt>
  1720. procedure ce(a,b);
  1721. if evenp a and not evenp b then 1 else 0;
  1722. for i:=1:10 collect random(50)$
  1723. sort(ws,&gt;=);
  1724. {41,38,33,30,28,25,20,17,8,5}
  1725. sort(ws,&lt;);
  1726. {5,8,17,20,25,28,30,33,38,41}
  1727. sort(ws,ce);
  1728. {8,20,28,30,38,5,17,25,33,41}
  1729. procedure cd(a,b);
  1730. if deg(a,x)&gt;deg(b,x) then 1 else
  1731. if deg(a,x)&lt;deg(b,x) then 0 else
  1732. if deg(a,y)&gt;deg(b,y) then 1 else 0;
  1733. sort({x^2,y^2,x*y},cd);
  1734. 2 2
  1735. {x ,x*y,y }
  1736. </tt></pre><p><P>
  1737. <P>
  1738. <a name=r38_0181>
  1739. <title>STRUCTR</title></a>
  1740. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1741. E"></p>
  1742. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1743. <b>STRUCTR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1744. <P>
  1745. <P>
  1746. <P>
  1747. The <em>structr</em> operator breaks its argument expression into named
  1748. subexpressions.
  1749. <P>
  1750. <P>
  1751. <P> <H3>
  1752. syntax: </H3>
  1753. <em>structr</em>(&lt;expression&gt; [,&lt;identifier&gt;[,&lt;identifier&gt; ...
  1754. ]])
  1755. <P>
  1756. <P>
  1757. <P>
  1758. &lt;expression&gt; may be any valid REDUCE scalar expression.
  1759. &lt;identifier&gt; may be any valid REDUCE <em>identifier</em>. The first
  1760. identifier
  1761. is the stem for subexpression names, the second is the name to be assigned
  1762. to the structured expression.
  1763. <P>
  1764. <P>
  1765. <P> <H3>
  1766. examples: </H3>
  1767. <p><pre><tt>
  1768. structr(sqrt(x**2 + 2*x) + sin(x**2*z));
  1769. ANS1 + ANS2
  1770. where
  1771. 2
  1772. ANS2 := SIN(X *Z)
  1773. 1/2
  1774. ANS1 := ((X + 2)*X)
  1775. ans3;
  1776. ANS3
  1777. on fort;
  1778. structr((x+1)**5 + tan(x*y*z),var,aa);
  1779. VAR1=TAN(X*Y*Z)
  1780. AA=VAR1+X**5+5.*X**4+10.*X**3+10.X**2+5.*X+1
  1781. </tt></pre><p>The second argument to <em>structr</em> is optional. If it is not
  1782. given, the
  1783. default stem <em>ANS</em> is used by REDUCE to construct names for the
  1784. subexpression. The names are only for display purposes: REDUCE does not
  1785. store the names and their values unless the switch
  1786. <a href=r38_0300.html#r38_0331>savestructr</a> is
  1787. on.
  1788. <P>
  1789. <P>
  1790. If a third argument is given, the structured expression as a whole is named by
  1791. this argument, when
  1792. <a href=r38_0250.html#r38_0289>fort</a> is on. The expression is not stored
  1793. under this
  1794. name. You can send these structured Fortran expressions to a file with the
  1795. <em>out</em> command.
  1796. <P>
  1797. <P>
  1798. <P>
  1799. <a name=r38_0182>
  1800. <title>SUB</title></a>
  1801. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1802. E"></p>
  1803. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1804. <b>SUB</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1805. <P>
  1806. <P>
  1807. <P>
  1808. The <em>sub</em> operator substitutes a new expression for a kernel in an
  1809. expression.
  1810. <P> <H3>
  1811. syntax: </H3>
  1812. <P>
  1813. <P>
  1814. <em>sub</em>(&lt;kernel&gt;<em>=</em>&lt;expression&gt;
  1815. {,&lt;kernel&gt;<em>=</em>&lt;expression&gt;}*,
  1816. &lt;expression&gt;) or
  1817. <P>
  1818. <P>
  1819. <em>sub</em>({&lt;kernel&gt;<em>=</em>&lt;expression&gt;*,
  1820. &lt;kernel&gt;<em>=</em><em>expression</em>},&lt;expression&gt;)
  1821. <P>
  1822. <P>
  1823. <P>
  1824. &lt;kernel&gt; must be a
  1825. <a href=r38_0001.html#r38_0002>kernel</a>, &lt;expression&gt; can be any REDUCE
  1826. scalar expression.
  1827. <P>
  1828. <P>
  1829. <P> <H3>
  1830. examples: </H3>
  1831. <p><pre><tt>
  1832. sub(x=3,y=4,(x+y)**3);
  1833. 343
  1834. x;
  1835. X
  1836. sub({cos=sin,sin=cos},cos a+sin b)
  1837. COS(B) + SIN(A)
  1838. </tt></pre><p>Note in the second example that operators can be replaced using th
  1839. e
  1840. <em>sub</em> operator.
  1841. <P>
  1842. <P>
  1843. <P>
  1844. <a name=r38_0183>
  1845. <title>SUM</title></a>
  1846. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1847. E"></p>
  1848. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1849. <b>SUM</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1850. <P>
  1851. <P>
  1852. <P>
  1853. The operator <em>sum</em> returns
  1854. the indefinite or definite summation of a given expression.
  1855. <P>
  1856. <P>
  1857. <P> <H3>
  1858. syntax: </H3>
  1859. <em>sum</em>(&lt;expr&gt;,&lt;k&gt;[,&lt;lolim&gt; [,&lt;uplim&gt; ]])
  1860. <P>
  1861. <P>
  1862. <P>
  1863. <P>
  1864. where &lt;expr&gt; is the expression to be added, &lt;k&gt; is the
  1865. control variable (a
  1866. <a href=r38_0001.html#r38_0002>kernel</a>), and &lt;lolim&gt; and &lt;uplim&gt;
  1867. are the optional lower and upper limits. If &lt;uplim&gt; is
  1868. not supplied the upper limit is taken as &lt;k&gt;. The Gosper
  1869. algorithm is used. If there is no closed form solution, the operator
  1870. returns the input unchanged.
  1871. <P>
  1872. <P>
  1873. <P> <H3>
  1874. examples: </H3>
  1875. <p><pre><tt>
  1876. sum(4n**3,n);
  1877. 2 2
  1878. n *(n + 2*n + 1)
  1879. sum(2a+2k*r,k,0,n-1);
  1880. n*(2*a + n*r - r)
  1881. </tt></pre><p>
  1882. <a name=r38_0184>
  1883. <title>WS</title></a>
  1884. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1885. E"></p>
  1886. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1887. <b>WS</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>operator</b><P>
  1888. <P>
  1889. <P>
  1890. <P>
  1891. The <em>ws</em> operator alone returns the last result; <em>ws</em> with a
  1892. number argument returns the results of the REDUCE statement executed after
  1893. that numbered prompt.
  1894. <P> <H3>
  1895. syntax: </H3>
  1896. <P>
  1897. <P>
  1898. <em>ws</em>or <em>ws</em>(&lt;number&gt;)
  1899. <P>
  1900. <P>
  1901. <P>
  1902. &lt;number&gt; must be an integer between 1 and the current REDUCE prompt number
  1903. .
  1904. <P>
  1905. <P>
  1906. <P> <H3>
  1907. examples: </H3>
  1908. <p><pre><tt></tt></pre><p>(In the following examples, unlike most others, the nu
  1909. mbered
  1910. prompt is shown.)<p><pre><tt>
  1911. 1: df(sin y,y);
  1912. COS(Y)
  1913. 2: ws^2;
  1914. 2
  1915. COS(Y)
  1916. 3: df(ws 1,y);
  1917. -SIN(Y)
  1918. </tt></pre><p>
  1919. <P>
  1920. <P>
  1921. <em>ws</em>and <em>ws</em><em>(</em>&lt;number&gt;<em>)</em> can be used anywher
  1922. e the
  1923. expression they stand for can be used. Calling a number for which no
  1924. result was produced, such as a switch setting, will give an error message.
  1925. <P>
  1926. <P>
  1927. The current workspace always contains the results of the last REDUCE
  1928. command that produced an expression, even if several input statements
  1929. that do not produce expressions have intervened. For example, if you do
  1930. a differentiation, producing a result expression, then change several
  1931. switches, the operator <em>ws;</em> returns the results of the differentiation.
  1932. The current workspace (<em>ws</em>) can also be used inside files, though the
  1933. numbered workspace contains only the <em>in</em> command that input the file.
  1934. <P>
  1935. <P>
  1936. There are three history lists kept in your REDUCE session. The first
  1937. stores raw input, suitable for the statement editor. The second stores
  1938. parsed input, ready to execute and accessible by
  1939. <a href=r38_0200.html#r38_0232>input</a>. The
  1940. third stores results, when they are produced by statements, which are
  1941. accessible by the <em>ws</em>&lt; n&gt; operator. If your session is very
  1942. long, storage space begins to fill up with these expressions, so it is a
  1943. good idea to end the session once in a while, saving needed expressions to
  1944. files with the
  1945. <a href=r38_0100.html#r38_0133>saveas</a> and
  1946. <a href=r38_0200.html#r38_0233>out</a> commands.
  1947. <P>
  1948. <P>
  1949. An error message is given if a reference number has not yet been used.
  1950. <P>
  1951. <P>
  1952. <P>
  1953. <a name=r38_0185>
  1954. <title>Algebraic Operators</title></a>
  1955. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  1956. E"></p>
  1957. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  1958. <b>Algebraic Operators</b><menu>
  1959. <li><a href=r38_0100.html#r38_0137>APPEND operator</a><P>
  1960. <li><a href=r38_0100.html#r38_0138>ARBINT operator</a><P>
  1961. <li><a href=r38_0100.html#r38_0139>ARBCOMPLEX operator</a><P>
  1962. <li><a href=r38_0100.html#r38_0140>ARGLENGTH operator</a><P>
  1963. <li><a href=r38_0100.html#r38_0141>COEFF operator</a><P>
  1964. <li><a href=r38_0100.html#r38_0142>COEFFN operator</a><P>
  1965. <li><a href=r38_0100.html#r38_0143>CONJ operator</a><P>
  1966. <li><a href=r38_0100.html#r38_0144>CONTINUED_FRACTION operator</a><P>
  1967. <li><a href=r38_0100.html#r38_0145>DECOMPOSE operator</a><P>
  1968. <li><a href=r38_0100.html#r38_0146>DEG operator</a><P>
  1969. <li><a href=r38_0100.html#r38_0147>DEN operator</a><P>
  1970. <li><a href=r38_0100.html#r38_0148>DF operator</a><P>
  1971. <li><a href=r38_0100.html#r38_0149>EXPAND\_CASES operator</a><P>
  1972. <li><a href=r38_0150.html#r38_0150>EXPREAD operator</a><P>
  1973. <li><a href=r38_0150.html#r38_0151>FACTORIZE operator</a><P>
  1974. <li><a href=r38_0150.html#r38_0152>HYPOT operator</a><P>
  1975. <li><a href=r38_0150.html#r38_0153>IMPART operator</a><P>
  1976. <li><a href=r38_0150.html#r38_0154>INT operator</a><P>
  1977. <li><a href=r38_0150.html#r38_0155>INTERPOL operator</a><P>
  1978. <li><a href=r38_0150.html#r38_0156>LCOF operator</a><P>
  1979. <li><a href=r38_0150.html#r38_0157>LENGTH operator</a><P>
  1980. <li><a href=r38_0150.html#r38_0158>LHS operator</a><P>
  1981. <li><a href=r38_0150.html#r38_0159>LIMIT operator</a><P>
  1982. <li><a href=r38_0150.html#r38_0160>LPOWER operator</a><P>
  1983. <li><a href=r38_0150.html#r38_0161>LTERM operator</a><P>
  1984. <li><a href=r38_0150.html#r38_0162>MAINVAR operator</a><P>
  1985. <li><a href=r38_0150.html#r38_0163>MAP operator</a><P>
  1986. <li><a href=r38_0150.html#r38_0164>MKID command</a><P>
  1987. <li><a href=r38_0150.html#r38_0165>NPRIMITIVE operator</a><P>
  1988. <li><a href=r38_0150.html#r38_0166>NUM operator</a><P>
  1989. <li><a href=r38_0150.html#r38_0167>ODESOLVE operator</a><P>
  1990. <li><a href=r38_0150.html#r38_0168>ONE\_OF type</a><P>
  1991. <li><a href=r38_0150.html#r38_0169>PART operator</a><P>
  1992. <li><a href=r38_0150.html#r38_0170>PF operator</a><P>
  1993. <li><a href=r38_0150.html#r38_0171>PROD operator</a><P>
  1994. <li><a href=r38_0150.html#r38_0172>REDUCT operator</a><P>
  1995. <li><a href=r38_0150.html#r38_0173>REPART operator</a><P>
  1996. <li><a href=r38_0150.html#r38_0174>RESULTANT operator</a><P>
  1997. <li><a href=r38_0150.html#r38_0175>RHS operator</a><P>
  1998. <li><a href=r38_0150.html#r38_0176>ROOT\_OF operator</a><P>
  1999. <li><a href=r38_0150.html#r38_0177>SELECT operator</a><P>
  2000. <li><a href=r38_0150.html#r38_0178>SHOWRULES operator</a><P>
  2001. <li><a href=r38_0150.html#r38_0179>SOLVE operator</a><P>
  2002. <li><a href=r38_0150.html#r38_0180>SORT operator</a><P>
  2003. <li><a href=r38_0150.html#r38_0181>STRUCTR operator</a><P>
  2004. <li><a href=r38_0150.html#r38_0182>SUB operator</a><P>
  2005. <li><a href=r38_0150.html#r38_0183>SUM operator</a><P>
  2006. <li><a href=r38_0150.html#r38_0184>WS operator</a><P>
  2007. </menu>
  2008. <a name=r38_0186>
  2009. <title>ALGEBRAIC</title></a>
  2010. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2011. E"></p>
  2012. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2013. <b>ALGEBRAIC</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  2014. <P>
  2015. <P>
  2016. <P>
  2017. The <em>algebraic</em> command changes REDUCE's mode of operation to
  2018. algebraic. When <em>algebraic</em> is used as an operator (with an
  2019. argument inside parentheses) that argument is evaluated in algebraic
  2020. mode, but REDUCE's mode is not changed.
  2021. <P>
  2022. <P>
  2023. <P> <H3>
  2024. examples: </H3>
  2025. <p><pre><tt>
  2026. algebraic;
  2027. symbolic;
  2028. NIL
  2029. algebraic(x**2);
  2030. 2
  2031. X
  2032. x**2;
  2033. ***** The symbol X has no value.
  2034. </tt></pre><p>REDUCE's symbolic mode does not know about most algebraic commands
  2035. .
  2036. Error messages in this mode may also depend on the particular Lisp
  2037. used for the REDUCE implementation.
  2038. <P>
  2039. <P>
  2040. <P>
  2041. <a name=r38_0187>
  2042. <title>ANTISYMMETRIC</title></a>
  2043. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2044. E"></p>
  2045. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2046. <b>ANTISYMMETRIC</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>declaration</b><P>
  2047. <P>
  2048. When an operator is declared <em>antisymmetric</em>, its arguments are
  2049. reordered to conform to the internal ordering of the system. If an odd
  2050. number of argument interchanges are required to do this ordering,
  2051. the sign of the expression is changed.
  2052. <P>
  2053. <P>
  2054. <P> <H3>
  2055. syntax: </H3>
  2056. <em>antisymmetric</em>&lt;identifier&gt;{<em>,</em>&lt;identifier&gt;}*
  2057. <P>
  2058. <P>
  2059. <P>
  2060. &lt;identifier&gt; is an identifier that has been declared as an operator.
  2061. <P>
  2062. <P>
  2063. <P> <H3>
  2064. examples: </H3>
  2065. <p><pre><tt>
  2066. operator m,n;
  2067. antisymmetric m,n;
  2068. m(x,n(1,2));
  2069. - M( - N(2,1),X)
  2070. operator p;
  2071. antisymmetric p;
  2072. p(a,b,c);
  2073. P(A,B,C)
  2074. p(b,a,c);
  2075. - P(A,B,C)
  2076. </tt></pre><p>If &lt;identifier&gt; has not been declared an operator, the flag
  2077. <em>antisymmetric</em> is still attached to it. When &lt;identifier&gt; is
  2078. subsequently used as an operator, the message <em>Declare</em> &lt;identifier
  2079. &gt;
  2080. <em>operator? (Y or N)</em> is printed. If the user replies <em>y</em>, the
  2081. antisymmetric property of the operator is used.
  2082. <P>
  2083. <P>
  2084. Note in the first example, identifiers are customarily ordered
  2085. alphabetically, while numbers are ordered from largest to smallest.
  2086. The operators may have any desired number of arguments (less than 128).
  2087. <P>
  2088. <P>
  2089. <P>
  2090. <a name=r38_0188>
  2091. <title>ARRAY</title></a>
  2092. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2093. E"></p>
  2094. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2095. <b>ARRAY</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>declaration</b><P>
  2096. <P>
  2097. The <em>array</em> declaration declares a list of identifiers to be of type
  2098. <em>array</em>, and sets all their entries to 0.
  2099. <P> <H3>
  2100. syntax: </H3>
  2101. <P>
  2102. <P>
  2103. <em>array</em>&lt;identifier&gt;(&lt;dimensions&gt;)
  2104. {<em>,</em>&lt;identifier&gt;(&lt;dimensions&gt;)}*
  2105. <P>
  2106. <P>
  2107. <P>
  2108. &lt;identifier&gt; may be any valid REDUCE identifier. If the identifier
  2109. was already an array, a warning message is given that the array has been
  2110. redefined. &lt;dimensions&gt; are of form
  2111. &lt;integer&gt;{,&lt;integer&gt;}*.
  2112. <P>
  2113. <P>
  2114. <P> <H3>
  2115. examples: </H3>
  2116. <p><pre><tt>
  2117. array a(2,5),b(3,3,3),c(200);
  2118. array a(3,5);
  2119. *** ARRAY A REDEFINED
  2120. a(3,4);
  2121. 0
  2122. length a;
  2123. {4,6}
  2124. </tt></pre><p>Arrays are always global, even if defined inside a procedure or bl
  2125. ock
  2126. statement. Their status as an array remains until the variable is
  2127. reset by
  2128. <a href=r38_0150.html#r38_0189>clear</a>. Arrays may not have the same names as
  2129. operators,
  2130. procedures or scalar variables.
  2131. <P>
  2132. <P>
  2133. Array elements are referred to by the usual notation: <em>a(i,j)</em>
  2134. returns the jth element of the ith row. The
  2135. <a href=r38_0050.html#r38_0065>assign</a>ment operator
  2136. <em>:=</em> is used to put values into the array. Arrays as a whole
  2137. cannot be subject to assignment by
  2138. <a href=r38_0150.html#r38_0199>let</a> or <em>:=</em> ; the
  2139. assignment operator <em>:=</em> is only valid for individual elements.
  2140. <P>
  2141. <P>
  2142. When you use
  2143. <a href=r38_0150.html#r38_0199>let</a> on an array element, the contents of that
  2144. element become the argument to <em>let</em>. Thus, if the element
  2145. contains a number or some other expression that is not a valid argument
  2146. for this command, you get an error message. If the element contains an
  2147. identifier, the identifier has the substitution rule attached to it
  2148. globally. The same behavior occurs with
  2149. <a href=r38_0150.html#r38_0189>clear</a>. If the array
  2150. element contains an identifier or simple_expression, it is cleared. Do
  2151. &lt;not&gt; use <em>clear</em> to try to set an array element to 0. Because
  2152. of the side effects of either <em>let</em> or <em>clear</em>, it is unwise
  2153. to apply either of these to array elements.
  2154. <P>
  2155. <P>
  2156. Array indices always start with 0, so that the declaration <em>array a(5)</em>
  2157. sets aside 6 units of space, indexed from 0 through 5, and initializes
  2158. them to 0. The
  2159. <a href=r38_0150.html#r38_0157>length</a> command returns a list of the true num
  2160. ber of
  2161. elements in each dimension.
  2162. <P>
  2163. <P>
  2164. <P>
  2165. <a name=r38_0189>
  2166. <title>CLEAR</title></a>
  2167. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2168. E"></p>
  2169. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2170. <b>CLEAR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  2171. <P>
  2172. The <em>clear</em> command is used to remove assignments or remove substitution
  2173. rules from any expression.
  2174. <P>
  2175. <P>
  2176. <P> <H3>
  2177. syntax: </H3>
  2178. <em>clear</em>&lt;identifier&gt;{,&lt;identifier&gt;}+ or
  2179. <P>
  2180. <P>
  2181. &lt;let-type statement&gt; <em>clear</em> &lt;identifier&gt;
  2182. <P>
  2183. <P>
  2184. <P>
  2185. &lt;identifier&gt; can be any <em>scalar</em>,
  2186. <a href=r38_0300.html#r38_0345>matrix</a>,
  2187. or
  2188. <a href=r38_0150.html#r38_0188>array</a> variable or
  2189. <a href=r38_0050.html#r38_0055>procedure</a> name. &lt;let-type statement&gt; ca
  2190. n be any general
  2191. or specific
  2192. <a href=r38_0150.html#r38_0199>let</a> statement (see below in Comments).
  2193. <P>
  2194. <P>
  2195. <P> <H3>
  2196. examples: </H3>
  2197. <p><pre><tt>
  2198. array a(2,3);
  2199. a(2,2) := 15;
  2200. A(2,2) := 15
  2201. clear a;
  2202. a(2,2);
  2203. Declare A operator? (Y or N)
  2204. let x = y + z;
  2205. sin(x);
  2206. SIN(Y + Z)
  2207. clear x;
  2208. sin(x);
  2209. SIN(X)
  2210. let x**5 = 7;
  2211. clear x;
  2212. x**5;
  2213. 7
  2214. clear x**5;
  2215. x**5;
  2216. 5
  2217. X
  2218. </tt></pre><p>Although it is not a good idea, operators of the same name but tak
  2219. ing
  2220. different numbers of arguments can be defined. Using a <em>clear</em> statement
  2221. on any of these operators clears every one with the same name, even if the
  2222. number of arguments is different.
  2223. <P>
  2224. <P>
  2225. The <em>clear</em> command is used to ``forget&quot; matrices, arrays, operators
  2226. and scalar variables, returning their identifiers to the pristine state
  2227. to be used for other purposes. When <em>clear</em> is applied to array
  2228. elements, the contents of the array element becomes the argument for
  2229. <em>clear</em>. Thus, you get an error message if the element contains a
  2230. number, or some other expression that is not a legal argument to
  2231. <em>clear</em>. If the element contains an identifier, it is cleared.
  2232. When clear is applied to matrix elements, an error message is returned
  2233. if the element evaluates to a number, otherwise there is no effect. Do
  2234. not try to use <em>clear</em> to set array or matrix elements to 0.
  2235. You will not be pleased with the results.
  2236. <P>
  2237. <P>
  2238. If you are trying to clear power or product substitution rules made with
  2239. either
  2240. <a href=r38_0150.html#r38_0199>let</a> or
  2241. <a href=r38_0150.html#r38_0195>forall</a>...<em>let</em>, you must
  2242. reproduce the rule, exactly as you typed it with the same arguments, up to
  2243. but not including the equal sign, using the word <em>clear</em> instead of
  2244. the word <em>let</em>. This is shown in the last example. Any other type of
  2245. <em>let</em> or <em>forall</em>...<em>let</em> substitution can be cleared
  2246. with just the variable or operator name.
  2247. <a href=r38_0200.html#r38_0205>match</a> behaves the same as
  2248. <a href=r38_0150.html#r38_0199>let</a> in this situation. There is a more compli
  2249. cated example under
  2250. <a href=r38_0150.html#r38_0195>forall</a>.
  2251. <P>
  2252. <P>
  2253. <P>
  2254. <P>
  2255. <a name=r38_0190>
  2256. <title>CLEARRULES</title></a>
  2257. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2258. E"></p>
  2259. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2260. <b>CLEARRULES</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  2261. <P>
  2262. <P>
  2263. <P>
  2264. <P> <H3>
  2265. syntax: </H3>
  2266. <em>clearrules</em>&lt;list&gt;{,&lt;list&gt;}+
  2267. <P>
  2268. <P>
  2269. <P>
  2270. The operator <em>clearrules</em> is used to remove previously defined
  2271. <a href=r38_0050.html#r38_0060>rule</a> lists from the system. &lt;list&gt; can
  2272. be an explicit rule
  2273. list, or evaluate to a rule list.
  2274. <P>
  2275. <P>
  2276. <P> <H3>
  2277. examples: </H3>
  2278. <p><pre><tt>
  2279. trig1 := {cos(~x)*cos(~y) =&gt; (cos(x+y)+cos(x-y))/2,
  2280. cos(~x)*sin(~y) =&gt; (sin(x+y)-sin(x-y))/2,
  2281. sin(~x)*sin(~y) =&gt; (cos(x-y)-cos(x+y))/2,
  2282. cos(~x)^2 =&gt; (1+cos(2*x))/2,
  2283. sin(~x)^2 =&gt; (1-cos(2*x))/2}$
  2284. let trig1;
  2285. cos(a)*cos(b);
  2286. COS(A - B) + COS(A + B)
  2287. -----------------------
  2288. 2
  2289. clearrules trig1;
  2290. cos(a)*cos(b);
  2291. COS(A)*COS(B)
  2292. </tt></pre><p>
  2293. <a name=r38_0191>
  2294. <title>DEFINE</title></a>
  2295. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2296. E"></p>
  2297. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2298. <b>DEFINE</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  2299. <P>
  2300. The command <em>define</em> allows you to supply a new name for an identifier
  2301. or replace it by any valid REDUCE expression.
  2302. <P>
  2303. <P>
  2304. <P> <H3>
  2305. syntax: </H3>
  2306. <em>define</em>&lt;identifier&gt;<em>=</em>&lt;substitution&gt;
  2307. {<em>,</em>&lt;identifier&gt;<em>=</em>&lt;substitution&gt;}*
  2308. <P>
  2309. <P>
  2310. <P>
  2311. &lt;identifier&gt; is any valid REDUCE identifier, &lt;substitution&gt; can be a
  2312. number, an identifier, an operator, a reserved word, or an expression.
  2313. <P>
  2314. <P>
  2315. <P> <H3>
  2316. examples: </H3>
  2317. <p><pre><tt>
  2318. define is= :=, xx=y+z;
  2319. a is 10;
  2320. A := 10
  2321. xx**2;
  2322. 2 2
  2323. Y + 2*Y*Z + Z
  2324. xx := 10;
  2325. Y + Z := 10
  2326. </tt></pre><p>The renaming is done at the input level, and therefore takes prece
  2327. dence
  2328. over any other replacement or substitution declared for the same identifier.
  2329. It remains in effect until the end of the REDUCE session. Be careful with
  2330. it, since you cannot easily undo it without ending the session.
  2331. <P>
  2332. <P>
  2333. <P>
  2334. <a name=r38_0192>
  2335. <title>DEPEND</title></a>
  2336. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2337. E"></p>
  2338. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2339. <b>DEPEND</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>declaration</b><P>
  2340. <P>
  2341. <P>
  2342. <P>
  2343. <em>depend</em>declares that its first argument depends on the rest of its
  2344. arguments.
  2345. <P>
  2346. <P>
  2347. <P> <H3>
  2348. syntax: </H3>
  2349. <em>depend</em>&lt;kernel&gt;{<em>,</em>&lt;kernel&gt;}+
  2350. <P>
  2351. <P>
  2352. <P>
  2353. &lt;kernel&gt; must be a legal variable name or a prefix operator (see
  2354. <a href=r38_0001.html#r38_0002>kernel</a>).
  2355. <P>
  2356. <P>
  2357. <P> <H3>
  2358. examples: </H3>
  2359. <p><pre><tt>
  2360. depend y,x;
  2361. df(y**2,x);
  2362. 2*DF(Y,X)*Y
  2363. depend z,cos(x),y;
  2364. df(sin(z),cos(x));
  2365. COS(Z)*DF(Z,COS(X))
  2366. df(z**2,x);
  2367. 2*DF(Z,X)*Z
  2368. nodepend z,y;
  2369. df(z**2,x);
  2370. 2*DF(Z,X)*Z
  2371. cc := df(y**2,x);
  2372. CC := 2*DF(Y,X)*Y
  2373. y := tan x;
  2374. Y := TAN(X);
  2375. cc;
  2376. 2
  2377. 2*TAN(X)*(TAN(X) + 1)
  2378. </tt></pre><p>Dependencies can be removed by using the declaration
  2379. <a href=r38_0200.html#r38_0204>nodepend</a>.
  2380. The differentiation operator uses this information, as shown in the
  2381. examples above. Linear operators also use knowledge of dependencies
  2382. (see
  2383. <a href=r38_0200.html#r38_0200>linear</a>). Note that dependencies can be nested
  2384. : Having
  2385. declared y to depend on x, and z
  2386. to depend on y, we
  2387. see that the chain rule was applied to the derivative of a function of
  2388. z with respect to x. If the explicit function of the
  2389. dependency is later entered into the system, terms with <em>DF(Y,X)</em>,
  2390. for example, are expanded when they are displayed again, as shown in the
  2391. last example. The boolean operator
  2392. <a href=r38_0100.html#r38_0113>freeof</a> allows you to
  2393. check the dependency between two algebraic objects.
  2394. <P>
  2395. <P>
  2396. <P>
  2397. <a name=r38_0193>
  2398. <title>EVEN</title></a>
  2399. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2400. E"></p>
  2401. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2402. <b>EVEN</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>declaration</b><P>
  2403. <P>
  2404. <P> <H3>
  2405. syntax: </H3>
  2406. <P>
  2407. <P>
  2408. <em>even</em>&lt;identifier&gt;{,&lt;identifier&gt;}*
  2409. <P>
  2410. <P>
  2411. <P>
  2412. This declaration is used to declare an operator even in its first
  2413. argument. Expressions involving an operator declared in this manner are
  2414. transformed if the first argument contains a minus sign. Any other
  2415. arguments are not affected.
  2416. <P> <H3>
  2417. examples: </H3>
  2418. <p><pre><tt>
  2419. even f;
  2420. f(-a)
  2421. F(A)
  2422. f(-a,-b)
  2423. F(A,-B)
  2424. </tt></pre><p><P>
  2425. <P>
  2426. <a name=r38_0194>
  2427. <title>FACTOR_declaration</title></a>
  2428. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2429. E"></p>
  2430. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2431. <b>FACTOR</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>declaration</b><P>
  2432. <P>
  2433. <P>
  2434. <P>
  2435. When a kernel is declared by <em>factor</em>, all terms involving fixed
  2436. powers of that kernel are printed as a product of the fixed powers and
  2437. the rest of the terms.
  2438. <P> <H3>
  2439. syntax: </H3>
  2440. <P>
  2441. <P>
  2442. <em>factor</em>&lt;kernel&gt; {<em>,</em>&lt;kernel&gt;}*
  2443. <P>
  2444. <P>
  2445. <P>
  2446. &lt;kernel&gt; must be a
  2447. <a href=r38_0001.html#r38_0002>kernel</a> or a
  2448. <a href=r38_0050.html#r38_0053>list</a> of
  2449. <em>kernel</em>s.
  2450. <P>
  2451. <P>
  2452. <P> <H3>
  2453. examples: </H3>
  2454. <p><pre><tt>
  2455. a := (x + y + z)**2;
  2456. 2 2 2
  2457. A := X + 2*X*Y + 2*X*Z + Y + 2*Y*Z + Z
  2458. factor y;
  2459. a;
  2460. 2 2 2
  2461. Y + 2*Y*(X + Z) + X + 2*X*Z + Z
  2462. factor sin(x);
  2463. c := df(sin(x)**4*x**2*z,x);
  2464. 4 3 2
  2465. C := 2*SIN(X) *X*Z + 4*SIN(X) *COS(X)*X *Z
  2466. remfac sin(x);
  2467. c;
  2468. 3
  2469. 2*SIN(X) *X*Z*(2*COS(X)*X + SIN(X))
  2470. </tt></pre><p>Use the <em>factor</em> declaration to display variables of intere
  2471. st so that
  2472. you can see their powers more clearly, as shown in the example. Remove
  2473. this special treatment with the declaration
  2474. <a href=r38_0200.html#r38_0217>remfac</a>. The
  2475. <em>factor</em> declaration is only effective when the switch
  2476. <a href=r38_0300.html#r38_0319>pri</a>
  2477. is on.
  2478. <P>
  2479. <P>
  2480. The <em>factor</em> declaration is not a factoring command; to factor
  2481. expressions use the
  2482. <a href=r38_0250.html#r38_0287>factor</a> switch or the
  2483. <a href=r38_0150.html#r38_0151>factorize</a> command.
  2484. <P>
  2485. <P>
  2486. The <em>factor</em> declaration is helpful in such cases as Taylor polynomials
  2487. where the explicit powers of the variable are expected at the top level, not
  2488. buried in various factored forms.
  2489. <P>
  2490. <P>
  2491. Note that <em>factor</em> does not affect the order of its arguments. You
  2492. should also use
  2493. <a href=r38_0200.html#r38_0212>order</a> if this is important.
  2494. <P>
  2495. <P>
  2496. <P>
  2497. <a name=r38_0195>
  2498. <title>FORALL</title></a>
  2499. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2500. E"></p>
  2501. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2502. <b>FORALL</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  2503. <P>
  2504. <P>
  2505. <P>
  2506. The <em>forall</em> or (preferably) <em>for all</em> command is used as a
  2507. modifier for
  2508. <a href=r38_0150.html#r38_0199>let</a> statements, indicating the universal appl
  2509. icability
  2510. of the rule, with possible qualifications.
  2511. <P> <H3>
  2512. syntax: </H3>
  2513. <P>
  2514. <P>
  2515. <em>for all</em>&lt;identifier&gt;{,&lt;identifier&gt;}* <em>let</em>
  2516. &lt;let statement&gt;
  2517. <P>
  2518. <P>
  2519. or
  2520. <P>
  2521. <P>
  2522. <em>for all</em>&lt;identifier&gt;{,&lt;identifier&gt;}*
  2523. <em>such that</em> &lt;condition&gt; <em>let</em> &lt;let statement&gt;
  2524. <P>
  2525. <P>
  2526. <P>
  2527. &lt;identifier&gt; may be any valid REDUCE identifier, &lt;let statement&gt;
  2528. can be an operator, a product or power, or a group or block statement.
  2529. &lt;condition&gt; must be a logical or comparison operator returning true or
  2530. false.
  2531. <P>
  2532. <P>
  2533. <P> <H3>
  2534. examples: </H3>
  2535. <p><pre><tt>
  2536. for all x let f(x) = sin(x**2);
  2537. Declare F operator ? (Y or N)
  2538. y
  2539. f(a);
  2540. 2
  2541. SIN(A )
  2542. operator pos;
  2543. for all x such that x&gt;=0 let pos(x) = sqrt(x + 1);
  2544. pos(5);
  2545. SQRT(6)
  2546. pos(-5);
  2547. POS(-5)
  2548. clear pos;
  2549. pos(5);
  2550. Declare POS operator ? (Y or N)
  2551. for all a such that numberp a let x**a = 1;
  2552. x**4;
  2553. 1
  2554. clear x**a;
  2555. *** X**A not found
  2556. for all a clear x**a;
  2557. x**4;
  2558. 1
  2559. for all a such that numberp a clear x**a;
  2560. x**4;
  2561. 4
  2562. X
  2563. </tt></pre><p>Substitution rules defined by <em>for all</em> or <em>for
  2564. all</em>...<em>such that</em> commands that involve products or powers are
  2565. cleared by reproducing the command, with exactly the same variable names
  2566. used, up to but not including the equal sign, with
  2567. <a href=r38_0150.html#r38_0189>clear</a>
  2568. replacing <em>let</em>, as shown in the last example. Other substitutions
  2569. involving variables or operator names can be cleared with just the name,
  2570. like any other variable.
  2571. <P>
  2572. <P>
  2573. The
  2574. <a href=r38_0200.html#r38_0205>match</a> command can also be used in product and
  2575. power substitutions.
  2576. The syntax of its use and clearing is exactly like <em>let</em>. A <em>match
  2577. </em>
  2578. substitution only replaces the term if it is exactly like the pattern, for
  2579. example <em>match x**5 = 1</em> replaces only terms of <em>x**5</em> and not
  2580. terms of higher powers.
  2581. <P>
  2582. <P>
  2583. It is easier to declare your potential operator before defining the
  2584. <em>for all</em> rule, since the system will ask you to declare it an
  2585. operator anyway. Names of declared arrays or matrices or scalar
  2586. variables are invalid as operator names, to avoid ambiguity. Either
  2587. <em>for all</em>...<em>let</em> statements or procedures are often used to defin
  2588. e
  2589. operators. One difference is that procedures implement ``call by value&quot;
  2590. meaning that assignments involving their formal parameters do not change
  2591. the calling variables that replace them. If you use assignment statements
  2592. on the formal parameters in a <em>for all</em>...<em>let</em> statement, the
  2593. effects are seen in the calling variables. Be careful not to redefine a
  2594. system operator unless you mean it: the statement <em>for all x let
  2595. sin(x)=0;</em> has exactly that effect, and the usual definition for sin(x) has
  2596. been lost for the remainder of the REDUCE session. <P>
  2597. <P>
  2598. <P>
  2599. <P>
  2600. <a name=r38_0196>
  2601. <title>INFIX</title></a>
  2602. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2603. E"></p>
  2604. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2605. <b>INFIX</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>declaration</b><P>
  2606. <P>
  2607. <P>
  2608. <P>
  2609. <em>infix</em>declares identifiers to be infix operators.
  2610. <P> <H3>
  2611. syntax: </H3>
  2612. <P>
  2613. <P>
  2614. <em>infix</em>&lt;identifier&gt;{,&lt;identifier&gt;}*
  2615. <P>
  2616. <P>
  2617. <P>
  2618. &lt;identifier&gt; can be any valid REDUCE identifier, which has not already
  2619. been declared an operator, array or matrix, and is not reserved by the
  2620. system.
  2621. <P>
  2622. <P>
  2623. <P> <H3>
  2624. examples: </H3>
  2625. <p><pre><tt>
  2626. infix aa;
  2627. for all x,y let aa(x,y) = cos(x)*cos(y) - sin(x)*sin(y);
  2628. x aa y;
  2629. COS(X)*COS(Y) - SIN(X)*SIN(Y)
  2630. pi/3 aa pi/2;
  2631. SQRT(3)
  2632. - -------
  2633. 2
  2634. aa(pi,pi);
  2635. 1
  2636. </tt></pre><p>A
  2637. <a href=r38_0150.html#r38_0199>let</a> statement must be used to attach function
  2638. ality to
  2639. the operator. Note that the operator is defined in prefix form in
  2640. the <em>let</em> statement.
  2641. After its definition, the operator may be used in either prefix or infix
  2642. mode. The above operator aa finds the cosine of the sum
  2643. of two angles by the formula
  2644. <P>
  2645. <P>
  2646. cos(x+y) = cos(x)*cos(y) - sin(x)*sin(y).
  2647. <P>
  2648. <P>
  2649. Precedence may be attached to infix operators with the
  2650. <a href=r38_0200.html#r38_0213>precedence</a> declaration.
  2651. <P>
  2652. <P>
  2653. User-defined infix operators may be used in prefix form. If they are used
  2654. in infix form, a space must be left on each side of the operator to avoid
  2655. ambiguity. Infix operators are always binary.
  2656. <P>
  2657. <P>
  2658. <P>
  2659. <a name=r38_0197>
  2660. <title>INTEGER</title></a>
  2661. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2662. E"></p>
  2663. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2664. <b>INTEGER</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>declaration</b><P>
  2665. <P>
  2666. The <em>integer</em> declaration must be made immediately after a
  2667. <a href=r38_0001.html#r38_0040>begin</a> (or other variable declaration such as
  2668. <a href=r38_0200.html#r38_0216>real</a>
  2669. and
  2670. <a href=r38_0200.html#r38_0218>scalar</a>) and declares local integer variables.
  2671. They are
  2672. initialized to 0.
  2673. <P> <H3>
  2674. syntax: </H3>
  2675. <P>
  2676. <P>
  2677. <em>integer</em>&lt;identifier&gt;{,&lt;identifier&gt;}*
  2678. <P>
  2679. <P>
  2680. <P>
  2681. &lt;identifier&gt; may be any valid REDUCE identifier, except
  2682. <em>t</em> or <em>nil</em>.
  2683. <P>
  2684. <P>
  2685. Integer variables remain local, and do not share values with variables of
  2686. the same name outside the
  2687. <a href=r38_0001.html#r38_0040>begin</a>...<em>end</em> block. When the
  2688. block is finished, the variables are removed. You may use the words
  2689. <a href=r38_0200.html#r38_0216>real</a> or
  2690. <a href=r38_0200.html#r38_0218>scalar</a> in the place of <em>integer</em>.
  2691. <em>integer</em> does not indicate typechecking by the
  2692. current REDUCE; it is only for your own information. Declaration
  2693. statements must immediately follow the <em>begin</em>, without a semicolon
  2694. between <em>begin</em> and the first variable declaration.
  2695. <P>
  2696. <P>
  2697. Any variables used inside <em>begin</em>...<em>end</em> blocks that were not
  2698. declared <em>scalar</em>, <em>real</em> or <em>integer</em> are global, and any
  2699. change made to them inside the block affects their global value. Any
  2700. <a href=r38_0150.html#r38_0188>array</a> or
  2701. <a href=r38_0300.html#r38_0345>matrix</a> declared inside a block is always glob
  2702. al.
  2703. <P>
  2704. <P>
  2705. <P>
  2706. <a name=r38_0198>
  2707. <title>KORDER</title></a>
  2708. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2709. E"></p>
  2710. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2711. <b>KORDER</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>declaration</b><P>
  2712. <P>
  2713. <P>
  2714. <P>
  2715. The <em>korder</em> declaration changes the internal canonical ordering of
  2716. kernels.
  2717. <P> <H3>
  2718. syntax: </H3>
  2719. <P>
  2720. <P>
  2721. <em>korder</em>&lt;kernel&gt;{<em>,</em>&lt;kernel&gt;}*
  2722. <P>
  2723. <P>
  2724. <P>
  2725. &lt;kernel&gt; must be a REDUCE
  2726. <a href=r38_0001.html#r38_0002>kernel</a> or a
  2727. <a href=r38_0050.html#r38_0053>list</a> of
  2728. <em>kernel</em>s.
  2729. <P>
  2730. <P>
  2731. The declaration <em>korder</em> changes the internal ordering, but not the print
  2732. ordering, so the effects cannot be seen on output. However, in some
  2733. calculations, the order of the variables can have significant effects on the
  2734. time and space demands of a calculation. If you are doing a demanding
  2735. calculation with several kernels, you can experiment with changing the
  2736. canonical ordering to improve behavior.
  2737. <P>
  2738. <P>
  2739. The first kernel in the argument list is given the highest priority, the
  2740. second gets the next highest, and so on. Kernels not named in a
  2741. <em>korder</em> ordering otherwise. A new <em>korder</em> declaration replaces
  2742. the previous one. To return to canonical ordering, use the command
  2743. <em>korder nil</em>.
  2744. <P>
  2745. <P>
  2746. To change the print ordering, use the declaration
  2747. <a href=r38_0200.html#r38_0212>order</a>.
  2748. <P>
  2749. <P>
  2750. <P>
  2751. <a name=r38_0199>
  2752. <title>LET</title></a>
  2753. <p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
  2754. E"></p>
  2755. <b><a href=r38_idx.html>INDEX</a></b><p><p>
  2756. <b>LET</b> _ _ _ _ _ _ _ _ _ _ _ _ <b>command</b><P>
  2757. <P>
  2758. <P>
  2759. <P>
  2760. The <em>let</em> command defines general or specific substitution rules.
  2761. <P> <H3>
  2762. syntax: </H3>
  2763. <P>
  2764. <P>
  2765. <em>let</em>&lt;identifier&gt; <em>=</em> &lt;expression&gt;{,&lt;identifier&gt;
  2766. <em>=</em> &lt;expression&gt;}*
  2767. <P>
  2768. <P>
  2769. <P>
  2770. &lt;identifier&gt; can be any valid REDUCE identifier except an array, and in
  2771. some cases can be an expression; &lt;expression&gt; can be any valid REDUCE
  2772. expression.
  2773. <P>
  2774. <P>
  2775. <P> <H3>
  2776. examples: </H3>
  2777. <p><pre><tt>
  2778. let a = sin(x);
  2779. b := a;
  2780. B := SIN X;
  2781. let c = a;
  2782. exp(a);
  2783. SIN(X)
  2784. E
  2785. a := x**2;
  2786. 2
  2787. A := X
  2788. exp(a);
  2789. 2
  2790. X
  2791. E
  2792. exp(b);
  2793. SIN(X)
  2794. E
  2795. exp(c);
  2796. 2
  2797. X
  2798. E
  2799. let m + n = p;
  2800. (m + n)**5;
  2801. 5
  2802. P
  2803. operator h;
  2804. let h(u,v) = u - v;
  2805. h(u,v);
  2806. U - V
  2807. h(x,y);
  2808. H(X,Y)
  2809. array q(10);
  2810. let q(1) = 15;
  2811. ***** Substitution for 0 not allowed
  2812. </tt></pre><p>The <em>let</em> command is also used to activate a <em>rule sets
  2813. </em>.
  2814. <P> <H3>
  2815. syntax: </H3>
  2816. <P>
  2817. <P>
  2818. <em>let</em>&lt;list&gt;{,&lt;list&gt;}+
  2819. <P>
  2820. <P>
  2821. <P>
  2822. &lt;list&gt; can be an explicit
  2823. <a href=r38_0050.html#r38_0060>rule</a> <em>list</em>, or evaluate
  2824. to a rule list.
  2825. <P>
  2826. <P>
  2827. <P> <H3>
  2828. examples: </H3>
  2829. <p><pre><tt>
  2830. trig1 := {cos(~x)*cos(~y) =&gt; (cos(x+y)+cos(x-y))/2,
  2831. cos(~x)*sin(~y) =&gt; (sin(x+y)-sin(x-y))/2,
  2832. sin(~x)*sin(~y) =&gt; (cos(x-y)-cos(x+y))/2,
  2833. cos(~x)^2 =&gt; (1+cos(2*x))/2,
  2834. sin(~x)^2 =&gt; (1-cos(2*x))/2}$
  2835. let trig1;
  2836. cos(a)*cos(b);
  2837. COS(A - B) + COS(A + B)
  2838. ------------------------
  2839. 2
  2840. </tt></pre><p>A <em>let</em> command returns no value, though the substitution r
  2841. ule is
  2842. entered. Assignment rules made by
  2843. <a href=r38_0050.html#r38_0065>assign</a> and <em>let</em>
  2844. rules are at the
  2845. same level, and cancel each other. There is a difference in their
  2846. operation, however, as shown in the first example: a <em>let</em> assignment
  2847. tracks the changes in what it is assigned to, while a <em>:=</em> assignment
  2848. is fixed at the value it originally had.
  2849. <P>
  2850. <P>
  2851. The use of expressions as left-hand sides of <em>let</em> statements is a
  2852. little complicated. The rules of operation are:
  2853. <P>
  2854. <P>
  2855. _ _ _ (i)
  2856. Expressions of the form A*B = C do not change A, B or C, but set A*B to C.
  2857. <P>
  2858. <P>
  2859. _ _ _ (ii)
  2860. Expressions of the form A+B = C substitute C - B for A, but do not change
  2861. B or C.
  2862. <P>
  2863. <P>
  2864. _ _ _ (iii)
  2865. Expressions of the form A-B = C substitute B + C for A, but do not change
  2866. B or C.
  2867. <P>
  2868. <P>
  2869. _ _ _ (iv)
  2870. Expressions of the form A/B = C substitute B*C for A, but do not change B or
  2871. C.
  2872. <P>
  2873. <P>
  2874. _ _ _ (v)
  2875. Expressions of the form A**N = C substitute C for A**N in every expression of
  2876. a power of A to N or greater. An asymptotic command such as A**N = 0 sets
  2877. all terms involving A to powers greater than or equal to N to 0. Finite
  2878. fields may be generated by requiring modular arithmetic (the
  2879. <a href=r38_0300.html#r38_0305>modular</a>
  2880. switch) and defining the primitive polynomial via a <em>let</em> statement.
  2881. <P>
  2882. <P>
  2883. <P>
  2884. <em>let</em>substitutions involving expressions are cleared by using
  2885. the
  2886. <a href=r38_0150.html#r38_0189>clear</a> command with exactly the same expressio
  2887. n.
  2888. <P>
  2889. <P>
  2890. Note when a simple <em>let</em> statement is used to assign functionality to an
  2891. operator, it is valid only for the exact identifiers used. For the use of the
  2892. <em>let</em> command to attach more general functionality to an operator,
  2893. see
  2894. <a href=r38_0150.html#r38_0195>forall</a>.
  2895. <P>
  2896. <P>
  2897. Arrays as a whole cannot be arguments to <em>let</em> statements, but
  2898. matrices as a whole can be legal arguments, provided both arguments are
  2899. matrices. However, it is important to note that the two matrices are then
  2900. linked. Any change to an element of one matrix changes the corresponding
  2901. value in the other. Unless you want this behavior, you should not use
  2902. <em>let</em> for matrices. The assignment operator
  2903. <a href=r38_0050.html#r38_0065>assign</a> can be used
  2904. for non-tracking assignments, avoiding the side effects. Matrices are
  2905. redimensioned as needed in <em>let</em> statements.
  2906. <P>
  2907. <P>
  2908. When array or matrix elements are used as the left-hand side of <em>let</em>
  2909. statements, the contents of that element is used as the argument. When the
  2910. contents is a number or some other expression that is not a valid left-hand
  2911. side for <em>let</em>, you get an error message. If the contents is an
  2912. identifier or simple expression, the <em>let</em> rule is globally attached
  2913. to that identifier, and is in effect not only inside the array or matrix,
  2914. but everywhere. Because of such unwanted side effects, you should not
  2915. use <em>let</em> with array or matrix elements. The assignment operator
  2916. <em>:=</em> can be used to put values into array or matrix elements without
  2917. the side effects.
  2918. <P>
  2919. <P>
  2920. Local variables declared inside <em>begin</em>...<em>end</em> blocks cannot
  2921. be used as the left-hand side of <em>let</em> statements. However,
  2922. <a href=r38_0001.html#r38_0040>begin</a>...<em>end</em> blocks themselves can be
  2923. used as the
  2924. right-hand side of <em>let</em> statements. The construction:
  2925. <P> <H3>
  2926. syntax: </H3>
  2927. <P>
  2928. <P>
  2929. <em>for all</em>&lt;vars&gt;
  2930. <em>let</em>&lt;operator&gt;(&lt;vars&gt;)<em>=</em>&lt;block&gt;
  2931. <P>
  2932. <P>
  2933. <P>
  2934. is an alternative to the
  2935. <P> <H3>
  2936. syntax: </H3>
  2937. <P>
  2938. <P>
  2939. <em>procedure</em>&lt;name&gt;(&lt;vars&gt;)<em>;</em>&lt;block&gt;
  2940. <P>
  2941. <P>
  2942. <P>
  2943. construction. One important difference between the two constructions is that
  2944. the &lt;vars&gt; as formal parameters to a procedure have their global values
  2945. protected against change by the procedure, while the &lt;vars&gt; of a
  2946. <em>let</em> statement are changed globally by its actions.
  2947. <P>
  2948. <P>
  2949. Be careful in using a construction such as <em>let x = x + 1</em> except inside
  2950. a controlled loop statement. The process of resubstitution continues until
  2951. a stack overflow message is given.
  2952. <P>
  2953. <P>
  2954. The <em>let</em> statement may be used to make global changes to variables from
  2955. inside procedures. If <em>x</em> is a formal parameter to a procedure, the
  2956. command <em>let x = </em>... makes the change to the calling variable.
  2957. For example, if a procedure was defined by
  2958. <p><pre><tt>
  2959. procedure f(x,y);
  2960. let x = 15;
  2961. </tt></pre><p><P>
  2962. <P>
  2963. and the procedure was called as
  2964. <p><pre><tt>
  2965. f(a,b);
  2966. </tt></pre><p><P>
  2967. <P>
  2968. <em>a</em>would have its value changed to 15. Be careful when using <em>let</em>
  2969. statements inside procedures to avoid unwanted side effects.
  2970. <P>
  2971. <P>
  2972. It is also important to be careful when replacing <em>let</em> statements with
  2973. other <em>let</em> statements. The overlapping of these substitutions can be
  2974. unpredictable. Ordinarily the latest-entered rule is the first to be applied.
  2975. Sometimes the previous rule is superseded completely; other times it stays
  2976. around as a special case. The order of entering a set of related <em>let</em>
  2977. expressions is very important to their eventual behavior. The best
  2978. approach is to assume that the rules will be applied in an arbitrary order.
  2979. <P>
  2980. <P>
  2981. <P>