reduce.doc 256 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972
  1. R E D U C E
  2. U S E R ' S M A N U A L
  3. Version 3.0
  4. Edited by
  5. Anthony C. Hearn
  6. The Rand Corporation
  7. Santa Monica, CA 90406
  8. April 1983
  9. Rand Publication CP78(4/83)
  10. ABSTRACT
  11. This document provides the user with a description of the algebraic
  12. programming system REDUCE. The capabilities of this system include:
  13. 1) expansion and ordering of polynomials and rational functions,
  14. 2) substitutions and pattern matching in a wide variety of forms,
  15. 3) automatic and user controlled simplification of expressions,
  16. 4) calculations with symbolic matrices,
  17. 5) arbitrary precision integer and real arithmetic,
  18. 6) facilities for defining new functions and extending program syntax,
  19. 7) analytic differentiation and integration,
  20. 8) factorization of polynomials,
  21. 9) Dirac matrix calculations of interest to high energy physicists.
  22. ACKNOWLEDGMENT
  23. The production of this version of the manual has been the result of the
  24. contributions of a large number of individuals who have taken the time and
  25. effort to suggest improvements to previous versions, and to draft new
  26. sections. Particular thanks are due to Gerry Rayna, who provided a draft
  27. rewrite of most of the first half of the manual. Other people who have
  28. made significant contributions have included John Fitch, Martin Griss, Don
  29. Morrison, Arthur Norman and Larry Seward.
  30. Copyright (c) 1983 The Rand Corporation
  31. TABLE OF CONTENTS
  32. 1. AN INTRODUCTION TO REDUCE. . . . . . . . . . . . . . . . . . . . .1-1
  33. 2. STRUCTURE OF PROGRAMS. . . . . . . . . . . . . . . . . . . . . . .2-1
  34. 2.1 The REDUCE Standard Character Set . . . . . . . . . . . .2-1
  35. 2.2 Numbers . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  36. 2.3 Identifiers . . . . . . . . . . . . . . . . . . . . . . .2-2
  37. 2.3.1 Restrictions. . . . . . . . . . . . . . . . . . . . . .2-2
  38. 2.4 Variables . . . . . . . . . . . . . . . . . . . . . . . .2-3
  39. 2.4.1 Reserved Variables. . . . . . . . . . . . . . . . . . .2-3
  40. 2.5 Strings . . . . . . . . . . . . . . . . . . . . . . . . .2-4
  41. 2.6 Comments. . . . . . . . . . . . . . . . . . . . . . . . .2-4
  42. 2.7 Operators . . . . . . . . . . . . . . . . . . . . . . . .2-4
  43. 2.7.1 Built-in Infix Operators. . . . . . . . . . . . . . . .2-6
  44. 3. EXPRESSIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . .3-1
  45. 3.1 Scalar Expressions. . . . . . . . . . . . . . . . . . . .3-1
  46. 3.2 Integer Expressions . . . . . . . . . . . . . . . . . . .3-2
  47. 3.3 Boolean Expressions . . . . . . . . . . . . . . . . . . .3-2
  48. 3.4 Proper Statements as Expressions. . . . . . . . . . . . .3-3
  49. 4. STATEMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-1
  50. 4.1 Assignment Statements . . . . . . . . . . . . . . . . . .4-1
  51. 4.2 Group statements. . . . . . . . . . . . . . . . . . . . .4-2
  52. 4.3 Conditional Statements. . . . . . . . . . . . . . . . . .4-2
  53. 4.4 FOR Statements. . . . . . . . . . . . . . . . . . . . . .4-3
  54. 4.5 WHILE ... DO. . . . . . . . . . . . . . . . . . . . . . .4-4
  55. 4.6 REPEAT ... UNTIL. . . . . . . . . . . . . . . . . . . . .4-5
  56. 4.7 Compound Statements . . . . . . . . . . . . . . . . . . .4-6
  57. 4.7.1 Compound Statements with GO TO. . . . . . . . . . . . .4-7
  58. 4.7.2 Labels and GO TO Statements . . . . . . . . . . . . . .4-8
  59. 4.7.3 RETURN Statements . . . . . . . . . . . . . . . . . . .4-8
  60. 5. COMMANDS AND DECLARATIONS. . . . . . . . . . . . . . . . . . . . .5-1
  61. 5.1 Array Declarations. . . . . . . . . . . . . . . . . . . .5-1
  62. 5.2 Mode Handling Declarations. . . . . . . . . . . . . . . .5-2
  63. 5.3 END . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
  64. 5.4 BYE . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
  65. 5.5 QUIT. . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
  66. 5.6 SHOWTIME. . . . . . . . . . . . . . . . . . . . . . . . .5-3
  67. 5.7 DEFINE. . . . . . . . . . . . . . . . . . . . . . . . . .5-3
  68. 6. BUILT-IN PREFIX OPERATORS. . . . . . . . . . . . . . . . . . . . .6-1
  69. 6.1 Numerical Functions . . . . . . . . . . . . . . . . . . .6-1
  70. 6.2 Mathematical Functions. . . . . . . . . . . . . . . . . .6-1
  71. 6.3 DF. . . . . . . . . . . . . . . . . . . . . . . . . . . .6-2
  72. 6.3.1 Adding Differentiation Rules. . . . . . . . . . . . . .6-3
  73. 6.4 INT . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3
  74. 6.4.1 Options . . . . . . . . . . . . . . . . . . . . . . . .6-4
  75. 6.4.2 Advanced Use. . . . . . . . . . . . . . . . . . . . . .6-4
  76. 6.4.3 References. . . . . . . . . . . . . . . . . . . . . . .6-5
  77. 6.5 SOLVE . . . . . . . . . . . . . . . . . . . . . . . . . .6-5
  78. 6.5.1 Options . . . . . . . . . . . . . . . . . . . . . . . .6-5
  79. 6.6 SUB . . . . . . . . . . . . . . . . . . . . . . . . . . .6-7
  80. 6.7 Declaring new Prefix Operators. . . . . . . . . . . . . .6-7
  81. ii
  82. 6.7.1 Declaring new Infix Operators . . . . . . . . . . . . .6-7
  83. 6.8 Linear Operators. . . . . . . . . . . . . . . . . . . . .6-8
  84. 6.9 Non-Commuting Operators . . . . . . . . . . . . . . . . .6-9
  85. 6.10 Creating and Removing Variable Dependency. . . . . . . 6-10
  86. 7. DISPLAY AND STRUCTURING OF EXPRESSIONS . . . . . . . . . . . . . .7-1
  87. 7.1 Kernels . . . . . . . . . . . . . . . . . . . . . . . . .7-1
  88. 7.2 The Expression Workspace. . . . . . . . . . . . . . . . .7-2
  89. 7.3 Output of Expressions . . . . . . . . . . . . . . . . . .7-3
  90. 7.3.1 LINELENGTH. . . . . . . . . . . . . . . . . . . . . . .7-3
  91. 7.3.2 Output Declarations . . . . . . . . . . . . . . . . . .7-3
  92. 7.3.2.1 ORDER . . . . . . . . . . . . . . . . . . . . . . . .7-4
  93. 7.3.2.2 FACTOR. . . . . . . . . . . . . . . . . . . . . . . .7-4
  94. 7.3.3 Output Control Switches . . . . . . . . . . . . . . . .7-4
  95. 7.3.3.1 ALLFAC. . . . . . . . . . . . . . . . . . . . . . . .7-5
  96. 7.3.3.2 DIV . . . . . . . . . . . . . . . . . . . . . . . . .7-5
  97. 7.3.3.3 LIST. . . . . . . . . . . . . . . . . . . . . . . . .7-5
  98. 7.3.3.4 RAT . . . . . . . . . . . . . . . . . . . . . . . . .7-6
  99. 7.3.4 WRITE Command . . . . . . . . . . . . . . . . . . . . .7-6
  100. 7.3.5 Suppression of Zeros. . . . . . . . . . . . . . . . . .7-8
  101. 7.3.6 FORTRAN Style Output of Expressions . . . . . . . . . .7-8
  102. 7.3.6.1 FORTRAN Output Options. . . . . . . . . . . . . . . 7-10
  103. 7.3.7 Saving Expressions for Later Use as Input . . . . . . 7-10
  104. 7.3.8 Displaying Expression Structure . . . . . . . . . . . 7-11
  105. 7.4 Changing the Internal Order of Variables. . . . . . . . 7-12
  106. 7.5 Obtaining Parts of Algebraic Expressions. . . . . . . . 7-12
  107. 7.5.1 COEFF . . . . . . . . . . . . . . . . . . . . . . . . 7-12
  108. 7.5.2 PART. . . . . . . . . . . . . . . . . . . . . . . . . 7-13
  109. 7.5.3 Changing Parts of Expressions . . . . . . . . . . . . 7-14
  110. 8. POLYNOMIAL AND RATIONAL FUNCTION OPERATIONS. . . . . . . . . . . .8-1
  111. 8.1 Controlling the Expansion of Expressions. . . . . . . . .8-1
  112. 8.2 Factorization of Polynomials. . . . . . . . . . . . . . .8-2
  113. 8.3 Cancellation of Common Factors. . . . . . . . . . . . . .8-4
  114. 8.3.1 Determining the GCD of two polynomials. . . . . . . . .8-4
  115. 8.4 Working with Least Common Multiples . . . . . . . . . . .8-5
  116. 8.5 Controlling Use of Common Denominators. . . . . . . . . .8-5
  117. 8.6 REMAINDER . . . . . . . . . . . . . . . . . . . . . . . .8-5
  118. 8.7 RESULTANT . . . . . . . . . . . . . . . . . . . . . . . .8-6
  119. 8.8 Obtaining Parts of Polynomials and Rational Functions . .8-6
  120. 8.8.1 DEG . . . . . . . . . . . . . . . . . . . . . . . . . .8-6
  121. 8.8.2 DEN . . . . . . . . . . . . . . . . . . . . . . . . . .8-6
  122. 8.8.3 LCOF. . . . . . . . . . . . . . . . . . . . . . . . . .8-7
  123. 8.8.4 LTERM . . . . . . . . . . . . . . . . . . . . . . . . .8-7
  124. 8.8.5 MAINVAR . . . . . . . . . . . . . . . . . . . . . . . .8-7
  125. 8.8.6 NUM . . . . . . . . . . . . . . . . . . . . . . . . . .8-8
  126. 8.8.7 REDUCT. . . . . . . . . . . . . . . . . . . . . . . . .8-8
  127. 8.9 Polynomial Coefficient Arithmetic . . . . . . . . . . . .8-8
  128. 8.9.1 Rational Coefficients in Polynomials. . . . . . . . . .8-8
  129. 8.9.2 Real coefficients in Polynomials. . . . . . . . . . . .8-9
  130. 8.9.3 Arbitrary Precision Real Coefficients . . . . . . . . .8-9
  131. 8.9.4 Modular Number Coefficients in Polynomials. . . . . . .8-9
  132. iii
  133. 9. SUBSTITUTION COMMANDS. . . . . . . . . . . . . . . . . . . . . . .9-1
  134. 9.1 Simple LET Rules. . . . . . . . . . . . . . . . . . . . .9-1
  135. 9.2 FOR ALL ... LET . . . . . . . . . . . . . . . . . . . . .9-2
  136. 9.3 FOR ALL ... SUCH THAT ... LET . . . . . . . . . . . . . .9-3
  137. 9.4 Removing Assignments and Substitution Rules . . . . . . .9-3
  138. 9.5 Overlapping LET Rules . . . . . . . . . . . . . . . . . .9-4
  139. 9.5.1 Substitutions for General Expressions . . . . . . . . .9-4
  140. 9.6 Asymptotic Commands . . . . . . . . . . . . . . . . . . .9-6
  141. 10. FILE HANDLING COMMANDS. . . . . . . . . . . . . . . . . . . . . 10-1
  142. 10.1 IN . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
  143. 10.2 OUT. . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
  144. 10.3 SHUT . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
  145. 11. COMMANDS FOR INTERACTIVE USE OF REDUCE. . . . . . . . . . . . . 11-1
  146. 11.1 Referencing Previous Results . . . . . . . . . . . . . 11-1
  147. 11.2 Interactive Editing. . . . . . . . . . . . . . . . . . 11-1
  148. 11.3 Interactive File Control . . . . . . . . . . . . . . . 11-2
  149. 12. MATRIX CALCULATIONS . . . . . . . . . . . . . . . . . . . . . . 12-1
  150. 12.1 MAT. . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
  151. 12.2 Matrix Variables . . . . . . . . . . . . . . . . . . . 12-1
  152. 12.3 Matrix Expressions . . . . . . . . . . . . . . . . . . 12-2
  153. 12.4 Operators With Matrix Arguments. . . . . . . . . . . . 12-2
  154. 12.4.1 DET. . . . . . . . . . . . . . . . . . . . . . . . . 12-2
  155. 12.4.2 TP . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
  156. 12.4.3 TRACE. . . . . . . . . . . . . . . . . . . . . . . . 12-3
  157. 12.5 Matrix Assignments . . . . . . . . . . . . . . . . . . 12-3
  158. 12.6 Evaluating Matrix Elements . . . . . . . . . . . . . . 12-3
  159. 13. PROCEDURES. . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
  160. 13.1 Procedure Heading. . . . . . . . . . . . . . . . . . . 13-1
  161. 13.2 The Procedure Body . . . . . . . . . . . . . . . . . . 13-2
  162. 13.3 Using LET Inside Procedures. . . . . . . . . . . . . . 13-4
  163. 13.4 Let Rules as Procedures. . . . . . . . . . . . . . . . 13-4
  164. 14. SYMBOLIC MODE . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
  165. 14.1 Symbolic Infix Operators . . . . . . . . . . . . . . . 14-2
  166. 14.2 Symbolic Expressions . . . . . . . . . . . . . . . . . 14-2
  167. 14.3 Quoted Expressions . . . . . . . . . . . . . . . . . . 14-2
  168. 14.4 LAMBDA Expressions . . . . . . . . . . . . . . . . . . 14-3
  169. 14.5 Symbolic Assignment Statements . . . . . . . . . . . . 14-3
  170. 14.6 FOR EACH Statement . . . . . . . . . . . . . . . . . . 14-3
  171. 14.7 Symbolic Procedures. . . . . . . . . . . . . . . . . . 14-4
  172. 14.8 Obtaining the Standard LISP Equivalent of REDUCE Input 14-4
  173. 14.9 Communicating with Algebraic Mode. . . . . . . . . . . 14-5
  174. 14.9.1 Passing Algebraic Mode Values to Symbolic Mode. . . 14-5
  175. 14.9.2 Passing Symbolic Mode Values back to Algebraic Mode. 14-7
  176. 14.9.3 Complete Example . . . . . . . . . . . . . . . . . . 14-8
  177. 14.9.4 Defining Procedures which Communicate between Modes. 14-9
  178. 14.10 References: . . . . . . . . . . . . . . . . . . . . . 14-9
  179. iv
  180. 15. CALCULATIONS IN HIGH ENERGY PHYSICS . . . . . . . . . . . . . . 15-1
  181. 15.1 Notation . . . . . . . . . . . . . . . . . . . . . . . 15-1
  182. 15.2 Operators used in High Energy Physics Calculations . . 15-1
  183. 15.2.1 . (DOT). . . . . . . . . . . . . . . . . . . . . . . 15-1
  184. 15.2.2 G. . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
  185. 15.2.3 EPS. . . . . . . . . . . . . . . . . . . . . . . . . 15-2
  186. 15.3 Vector variables . . . . . . . . . . . . . . . . . . . 15-3
  187. 15.4 Additional Expression Types. . . . . . . . . . . . . . 15-3
  188. 15.4.1 Vector Expressions . . . . . . . . . . . . . . . . . 15-3
  189. 15.4.2 Dirac Expressions. . . . . . . . . . . . . . . . . . 15-4
  190. 15.5 Trace Calculations . . . . . . . . . . . . . . . . . . 15-4
  191. 15.6 Mass Declarations. . . . . . . . . . . . . . . . . . . 15-4
  192. 15.7 Example. . . . . . . . . . . . . . . . . . . . . . . . 15-5
  193. 15.8 Extensions to More than Four Dimensions. . . . . . . . 15-6
  194. 16. REDUCE AND RLISP UTILITIES. . . . . . . . . . . . . . . . . . . 16-1
  195. 16.1 The Standard LISP Compiler . . . . . . . . . . . . . . 16-1
  196. 16.2 Fast Loading Code Generation Program . . . . . . . . . 16-1
  197. 16.3 The Standard LISP Cross-Reference Program. . . . . . . 16-2
  198. 16.3.1 Restrictions:. . . . . . . . . . . . . . . . . . . . 16-3
  199. 16.3.2 Usage: . . . . . . . . . . . . . . . . . . . . . . . 16-3
  200. 16.3.3 Options: . . . . . . . . . . . . . . . . . . . . . . 16-3
  201. 16.4 Prettyprinting Reduce Expressions. . . . . . . . . . . 16-4
  202. 16.5 Prettyprinting Standard LISP S-expressions . . . . . . 16-4
  203. A. RESERVED IDENTIFIERS . . . . . . . . . . . . . . . . . . . . . . .A-1
  204. B. OPERATORS NORMALLY AVAILABLE IN REDUCE . . . . . . . . . . . . . .B-1
  205. C. COMMANDS AND DECLARATIONS. . . . . . . . . . . . . . . . . . . . .C-1
  206. D. MODE SWITCHES IN REDUCE. . . . . . . . . . . . . . . . . . . . . .D-1
  207. E. DIAGNOSTIC AND ERROR MESSAGES IN REDUCE. . . . . . . . . . . . . .E-1
  208. F. VARIABLES IN REDUCE. . . . . . . . . . . . . . . . . . . . . . . .F-1
  209. G. KEYWORD INDEX. . . . . . . . . . . . . . . . . . . . . . . . . . .G-1
  210. 1-1
  211. 1. AN INTRODUCTION TO REDUCE __ ____________ __ ______
  212. REDUCE is a system for carrying out algebraic operations accurately, no
  213. matter how complicated the expressions become. It can manipulate
  214. polynomials in a variety of forms, both expanding and factoring them, and
  215. extracting various parts of them as required. REDUCE can also do
  216. differentiation and integration, but we shall only show trivial examples of
  217. this in this introduction. Other topics which are not considered include
  218. the use of arrays, the definition of procedures and operators, the specific
  219. routines for high energy physics calculations, the use of files to
  220. eliminate repetitious typing and for saving results, and the editing of the
  221. input text.
  222. Also not considered in any detail in this introduction are the many options
  223. that are available for varying computational procedures, output forms,
  224. number systems used, and so on.
  225. REDUCE is designed to be an interactive system, so that the user can input
  226. an algebraic expression and see its value before moving on to the next
  227. calculation. Not all computer systems support interactive use, of course.
  228. However, REDUCE can also be used in batch mode by inputting a sequence of
  229. calculations and getting results without any possibility of interaction
  230. during the calculations.
  231. In this introduction, we shall limit ourselves to the interactive use of
  232. REDUCE, since this illustrates most completely the capabilities of the
  233. system. When REDUCE is called, it begins by printing a banner message
  234. like:
  235. REDUCE 3.0, 15-Apr-83 ...
  236. where the version number (3.0) and the system release date will change from
  237. time to time. It then prompts the user for input by:
  238. 1:
  239. The user can now type a valid REDUCE statement, terminated by a semicolon
  240. to indicate the end of the expression, for example:
  241. (x+y+z)**2;
  242. This expression would normally be followed by another character (a Return
  243. on an Ascii keyboard) to "wake up" the system, which would then input the
  244. expression, evaluate it, and return the result. in a form like:
  245. 2 2 2
  246. X + 2*X*Y + 2*X*Z + Y + 2*Y*Z + Z
  247. Let us review this simple example to learn a little more about the way
  248. that REDUCE works. First, we note that REDUCE deals with variables, and
  249. constants like other computer languages, but that in evaluating the
  250. former, a variable can stand for itself. Expression evaluation normally
  251. 1-2
  252. follows the rules of high school algebra, so the only surprise in the
  253. above might be that the expression was expanded. The normal mode of REDUCE
  254. does in fact expand all expressions where possible, collecting like terms
  255. and ordering the variables in a specific manner. However, the expansion
  256. option, ordering of variables, the format of output and so on is under the
  257. control of the user, and various declarations are available to control
  258. these.
  259. Another characteristic of the above example is the use of lower case on
  260. input and upper case on output. In fact, input may be in either mode, but
  261. lower case is converted to upper case by the system.
  262. Finally, the numerical prompt can be used to reference the result in a
  263. later computation.
  264. As a further illustration of the system characteristics, the user should
  265. try:
  266. for i:= 1:50 product i;
  267. The result in this case is the number
  268. 30414093201713378043612608166064768844377641568960512000000000000
  269. Since we want exact results in algebraic calculations, it is essential that
  270. integer arithmetic be performed to arbitrary precision, as in the above
  271. example. Furthermore, the FOR statement in the above is illustrative of a
  272. whole range of combining forms which REDUCE supports for the convenience of
  273. the user.
  274. Among the many options in REDUCE is the use of other number systems, such
  275. as multiple precision floating point with any specified number of digits --
  276. of use if roundoff in, say, the 100th digit is all that can be tolerated.
  277. In many cases, it is necessary to use the results of one calculation in
  278. succeeding calculations. One way to do this is via an assignment for a
  279. variable, such as
  280. u := (x+y+z)**2;
  281. If we now use u in later calculations, the value of the right hand side of
  282. the above will be used.
  283. The results of a given calculation are in fact saved in the variable WS
  284. (for workspace), so this can be used in the next calculation for further
  285. processing.
  286. For example, the expression
  287. df(ws,x);
  288. following the previous evaluation will calculate the derivative of
  289. (x+y+z)**2 with respect to x.
  290. 1-3
  291. Alternatively,
  292. int(ws,y);
  293. would calculate the integral of the same expression with respect to y.
  294. One nice feature of REDUCE is its handling of symbolic matrices. For
  295. example,
  296. matrix m(2,2);
  297. declares m to be a two by two matrix, and
  298. m := mat((a,b),(c,d));
  299. gives it specific element values. Expressions which include m and make
  300. algebraic sense may now be evaluated, such as 1/m to give the inverse, 2*m
  301. - u*m**2 to give us another matrix and det(m) to give us the determinant
  302. of m.
  303. REDUCE also has a wide range of substitution capabilities. The system
  304. knows about elementary functions, but does not automatically invoke many
  305. of their well-known properties. For example, products of trigonometrical
  306. functions are not converted automatically into multiple angle expressions,
  307. but if the user wants this, he can say:
  308. for all x,y let cos(x)*cos(y) = (cos(x+y)+cos(x-y))/2,
  309. cos(x)*sin(y) = (sin(x+y)-sin(x-y))/2,
  310. sin(x)*sin(y) = (cos(x-y)-cos(x+y))/2;
  311. An expression such as sin(a+b)*cos(a-b) would now convert into the
  312. equivalent expression
  313. (SIN(2*A) + SIN(2*B))/2.
  314. Another very commonly used capability of the system, and an illustration
  315. of one of the many output modes of Reduce, is the ability to output
  316. results in a Fortran compatible form. Such results can then be used later
  317. in a Fortran-based numerical calculation. This is particularly useful as a
  318. way of generating algebraic formulas to be used as the basis of extensive
  319. numerical calculations.
  320. For example, the statements
  321. on fort;
  322. df(log(x)*(sin(x)+cos(x))/sqrt(x),x,2);
  323. will result in the output
  324. ANS=(-4.*LOG(X)*COS(X)*X**2-4.*LOG(X)*COS(X)*X+3.*LOG(X)*
  325. . COS(X)-4.*LOG(X)*SIN(X)*X**2+4.*LOG(X)*SIN(X)*X+3.*LOG(X)
  326. . *SIN(X)+8.*COS(X)*X-8.*COS(X)-8.*SIN(X)*X-8.*SIN(X))/(4.*
  327. . SQRT(X)*X**2)
  328. 1-4
  329. These algebraic manipulations illustrate the algebraic mode of REDUCE.
  330. REDUCE is based on Standard LISP. A symbolic mode is also available for
  331. executing LISP statements. These statements follow the syntax of LISP,
  332. e.g.
  333. symbolic car '(a);
  334. Communication between the two modes is possible.
  335. With this simple introduction, the user is now in a position to study the
  336. material in the full REDUCE manual in order to learn just how extensive the
  337. range of facilities really is. If further tutorial material is considered
  338. necessary, the seven REDUCE Interactive Lessons by David R. Stoutemyer are
  339. recommended. These are normally available online at most installations.
  340. 2-1
  341. 2. STRUCTURE OF PROGRAMS _________ __ ________
  342. A REDUCE program consists of a set of functional commands which are
  343. evaluated sequentially by the computer. These commands are built up from
  344. declarations, statements and expressions. Such entities are composed of
  345. sequences of numbers, variables, operators, strings, reserved words and
  346. delimiters (such as commas and parentheses), which in turn are sequences of
  347. basic characters.
  348. 2.1 The REDUCE Standard Character Set ___ ______ ________ _________ ___
  349. The basic characters which are used to build up REDUCE symbols are the
  350. following:
  351. i) The 26 upper case letters A through Z
  352. ii) The 10 decimal digits 0 through 9
  353. iii) The special characters ! " $ % ' ( ) * + , - . / : ; < > =
  354. Programs composed from this standard set of characters will run in any
  355. available REDUCE system. Most implementations permit lower case on input.
  356. With the exception of strings and characters preceded by an exclamation
  357. mark (qv), such lower case characters will be converted internally into
  358. upper case. If you do not wish this conversion to occur, the command OFF
  359. RAISE; achieves this. However, now case IS distinguished internally, so
  360. that df for example is not the same as DF (the derivative operator).
  361. Several implementations also allow some special characters to represent
  362. operators in the system. The operating instructions for the particular
  363. implementation should be consulted on these points. For generality, we
  364. shall limit ourselves to the standard character set in this exposition.
  365. 2.2 Numbers _______
  366. There are several different types of numbers available in REDUCE. Integers
  367. consist of a signed or unsigned sequence of decimal digits written without
  368. a decimal point.
  369. e.g. -2, 5396, +32
  370. In principle, there is no practical limit on the number of digits
  371. permitted as arbitrary precision arithmetic is used in most
  372. implementations. (You should however check the specific instructions for
  373. your particular system implementation to make sure that this is true.) For
  374. example, if you ask for the value of 2**2000 (2 to the 2000th power) you
  375. get it displayed as a number of 603 decimal digits, taking up nine lines
  376. of output on an interactive display.
  377. Numbers that aren't integers are usually represented as the quotient of
  378. two integers, in lowest terms: that is, as rational numbers.
  379. In most versions of REDUCE it is also possible (but not always desirable!)
  380. 2-2
  381. to ask REDUCE to work with floating point approximations to numbers,
  382. either single precision or -- in some versions -- multiple precision with
  383. any specified number of digits. Such numbers are called REAL. They can be
  384. input in two ways:
  385. i) as a signed or unsigned sequence of decimal digits with an embedded
  386. or trailing decimal point. Up to 8 such digits are allowed in most
  387. implementations, although this can vary. Again, you should check the
  388. specific instructions for a given implementation for the maximum size
  389. permitted.
  390. ii) as in i) followed by a decimal exponent which is written as the
  391. letter E followed by a signed or unsigned integer.
  392. e.g. 32. +32.0 0.32E2 and 320.E-1 are all representations of 32.
  393. CAUTION: The unsigned part of any number may NOT begin with a decimal
  394. point, as this causes confusion with the CONS (.) operator in symbolic
  395. mode (qv),
  396. i.e. NOT ALLOWED: .5 -.23 +.12; use: 0.5 -0.23 +0.12 instead.
  397. 2.3 Identifiers ___________
  398. Identifiers in REDUCE consist of one or more alphanumeric characters (i.e.
  399. upper case alphabetic letters or decimal digits) the first of which must
  400. be alphabetic. The maximum number of characters allowed is implementation
  401. dependent, although twenty-four is permitted in most implementations:
  402. e.g. A AZ P1 Q23P AVERYLONGVARIABLE
  403. Special characters, such as -, *, and blank, may be used in identifiers
  404. too, even as the first character, but each must be preceded by an
  405. exclamation mark in input:
  406. e.g. LIGHT!-YEARS D!*!*N GOOD! MORNING
  407. !$SIGN !5GOLDRINGS
  408. CAUTION: Many system identifiers have such special characters in their
  409. names (especially * and =). If the user accidentally picks the name of one
  410. of them for his own purposes it may have catastrophic consequences for his
  411. REDUCE run.
  412. Identifiers are used as variables, labels and to name arrays, operators
  413. and procedures.
  414. 2.3.1 Restrictions ____________
  415. The reserved words listed in another section may not be used as
  416. identifiers. No spaces may appear within an identifier, and an identifier
  417. may not extend over a line of text. (Hyphenation of an identifier, by using
  418. 2-3
  419. a reserved character as a hyphen before an end-of-line character is
  420. possible in some versions of REDUCE).
  421. 2.4 Variables _________
  422. Every variable is named by an identifier, and is given a specific type.
  423. The type is of no concern to the ordinary user. Most variables are allowed
  424. to have the default type, called SCALAR. These can receive, as values, the
  425. representation of any ordinary algebraic expression. In the absence of
  426. such a value, they stand for themselves.
  427. 2.4.1 Reserved Variables ________ _________
  428. Several variables in REDUCE have particular properties which should not be
  429. changed by the user. These variables are as follows:
  430. E Intended to represent the base of the natural
  431. logarithms. LOG(E), if it occurs in an expression,
  432. is automatically replaced by 1. In the ON NUMVAL
  433. mode (qv), E is replaced by the value of E to the
  434. current degree of floating point precision.
  435. I Intended to represent the square root of -1. I**2
  436. is replaced by -1, and appropriately for higher
  437. powers of I. (This applies only to the symbol I
  438. used on the top level, not as a formal parameter
  439. in a procedure, a local variable, nor in the
  440. context FOR I:= ... .)
  441. NIL In REDUCE (algebraic mode only) taken as a synonym
  442. for zero. Therefore NIL can not be used as a
  443. variable.
  444. PI Intended to represent the circular constant. In the
  445. ON NUMVAL mode, it is replaced by the value of PI
  446. to the current degree of floating point precision.
  447. T Can not be used as a formal parameter or local
  448. variable in procedures, since conflict arises with
  449. the symbolic mode meaning of T as "true".
  450. Use of these reserved variables inappropriately will lead to an error.
  451. Certain words are reserved in REDUCE. They may only be used in the manner
  452. intended. A partial list follows:
  453. ALGEBRAIC EDITDEF HELP MATCH REMFAC SYMMETRIC
  454. ANTISYMMETRIC EMB IF MATRIX REPEAT TR
  455. ARRAY END IN MSHELL RETRY TRST
  456. BEGIN EXEC INDEX NODEPEND RETURN UP
  457. CLEAR EXPR INFIX OFF RLISP VARNAME
  458. 2-4
  459. CMD FACTOR INPUT ON SAVEAS VECTOR
  460. CONT FEXPR INTEGER OPERATOR SCALAR WEIGHT
  461. CORE FLAGOP KORDER ORDER SHARE WHILE
  462. CREATE FLOAD LAMBDA OUT SHOWTIME WRITE
  463. DCL FOR LET PAUSE SHUT WS
  464. DEFINE FORALL LINEAR PRECEDENCE SLISP WTLEVEL
  465. DEPEND FOREACH LISP PROCEDURE SMACRO
  466. DOWN FSLOUT MACRO QUIT STRUCTR
  467. EDIT GO MASS REAL SYMBOLIC
  468. This is, of course, an impossibly long list to keep in mind. The reader
  469. may want to make himself a copy of it, deleting the names he doesn't think
  470. he is likely to use by mistake.
  471. 2.5 Strings _______
  472. Strings are used only in WRITE statements (qv). A string consists of any
  473. number of characters enclosed in double quotes.
  474. e.g. "A STRING".
  475. Lower case characters within a string are not converted to upper case.
  476. The string "" represents the empty string. It is not possible to include a
  477. double quote itself in a string.
  478. 2.6 Comments ________
  479. Text can be included in program listings for the convenience of human
  480. readers, in such a way that REDUCE pays no attention to it. There are two
  481. ways to do this:
  482. 1) Everything from the word COMMENT to the next statement terminator (qv)
  483. is ignored. Such comments can be placed anywhere a blank could properly
  484. appear. (Note that END and >> are NOT treated as COMMENT delimiters!)
  485. 2) Everything from the symbol % to the end of the line on which it appears
  486. is ignored. Such comments can be placed as the last part of any line.
  487. Statement terminators have no special meaning in such comments. Remember
  488. to put a semicolon before the % if the earlier part of the line is
  489. intended to be so terminated. Remember also to begin EACH line of a
  490. multi-line "%" comment with a % sign.
  491. 2.7 Operators _________
  492. Operators in REDUCE are specified by name and type. There are two types,
  493. infix and prefix. Operators can be purely abstract, just symbols with no
  494. properties; they can have values assigned (using := or simple LET
  495. declarations) for specific arguments; they can have properties declared for
  496. some collection of arguments (using more general LET declarations); or they
  497. 2-5
  498. can be fully defined (usually by a procedure declaration).
  499. Infix operators occur between their arguments.
  500. e.g. A + B - C (spaces optional)
  501. X<Y AND Y>Z (spaces required where shown)
  502. Spaces can be freely inserted between operators and variables or operators
  503. and operators. They are required only where operator names are spelled out
  504. with letters (such as the AND in the example) and must be unambiguously
  505. separated from another such or from a variable (like Y). Wherever one
  506. space can be used, so can any larger number.
  507. Prefix operators occur to the left of their arguments, which are written as
  508. a list enclosed in parentheses and separated by commas, as with normal
  509. mathematical functions.
  510. e.g. COS(U)
  511. DF(X**2,X)
  512. Q(V+W)
  513. Unmatched parentheses, incorrect groupings of infix operators and the like,
  514. naturally lead to syntax errors. The parentheses can be omitted (replaced
  515. by a space following the operator name) if the operator is unary and the
  516. argument is a single symbol or begins with a prefix operator name:
  517. COS Y means COS(Y)
  518. COS (-Y) -- parentheses necessary
  519. LOG COS Y means LOG(COS(Y))
  520. LOG COS (A+B) means LOG(COS(A+B))
  521. but
  522. COS A*B means (COS A)*B
  523. COS -Y is erroneous (treated as a variable
  524. "COS" minus the variable Y)
  525. A unary prefix operator has a precedence higher than any infix operator.
  526. In other words, REDUCE will always interpret COS Y + 3 as (COS Y) + 3
  527. rather than as COS(Y + 3).
  528. Infix operators may also be used in a prefix format on input, e.g.,
  529. +(A,B,C). On output, however, such expressions will always be printed in
  530. infix form (i.e., A + B + C for this example).
  531. A number of prefix operators are built into the system with predefined
  532. properties. Users may also add new operators and define their rules for
  533. simplification. The built in operators are described in another section.
  534. 2-6
  535. 2.7.1 Built-in Infix Operators ________ _____ _________
  536. The following infix operators are built into the system. They are all
  537. defined internally as procedures.
  538. <infix operator>::= :=|OR|AND|NOT|MEMBER|MEMQ|=|NEQ|EQ|>=|
  539. >|<=|<|+|-|*|/|**|.
  540. These operators may be further divided into the following subclasses:
  541. <assignment operator> ::= :=
  542. <logical operator> ::= OR|AND|NOT|MEMBER|MEMQ
  543. <relational operator> ::= =|NEQ|EQ|>=|>|<=|<
  544. <arithmetic operator> ::= +|-|*|/|**
  545. <symbolic operator> ::= .
  546. (MEMBER, MEMQ, and EQ are not used in the algebraic mode of REDUCE. They
  547. are explained in the section on symbolic mode (qv).)
  548. For compatibility with the intermediate language used by REDUCE, each
  549. special character infix operator has an alternative alphanumeric identifier
  550. associated with it. These identifiers may be used interchangeably with the
  551. corresponding special character names on input. This correspondence is as
  552. follows:
  553. := SETQ (the assignment operator)
  554. = EQUAL
  555. >= GEQ
  556. > GREATERP
  557. <= LEQ
  558. < LESSP
  559. + PLUS
  560. - DIFFERENCE (if unary, MINUS)
  561. * TIMES
  562. / QUOTIENT (if unary, RECIP)
  563. ** EXPT (raising to a power)
  564. . CONS
  565. Note: NEQ is used to mean NOT EQUAL. There is no special symbol provided
  566. for it.
  567. The above operators are binary, except NOT which is unary and + and * which
  568. are n-ary (i.e., taking an arbitrary number of arguments). In addition, -
  569. and / may be used in a unary position, e.g., /2 means the same as 1/2. Any
  570. other operator is parsed as a binary operator using a left association
  571. rule. Thus A/B/C is interpreted as (A/B)/C. There are two exceptions to
  572. this rule: := and . are right associative. Example: A:=B:=C is interpreted
  573. as A:=(B:=C).
  574. The operators <, <=, >, >= can only be used for making comparisons between
  575. numbers. No meaning is currently assigned to this kind of comparison
  576. between general expressions.
  577. 2-7
  578. Parentheses may be used to specify the order of combination. If
  579. parentheses are omitted then this order is by the ordering of the
  580. precedence list defined by the right hand side of the BNF definition of
  581. <infix operator> above, from lowest to highest. In other words, := has the
  582. lowest precedence, and . (the dot operator) the highest.
  583. 3-1
  584. 3. EXPRESSIONS ___________
  585. REDUCE expressions may be of several types and consist of syntactically
  586. allowed sequences of numbers, variables, operators, left and right
  587. parentheses and commas. The most common types are as follows:
  588. 3.1 Scalar Expressions ______ ___________
  589. Scalar expressions are composed, using the arithmetic operations + - * /
  590. ** (power) and parentheses, from
  591. numbers,
  592. ordinary ("SCALAR") variables (or identifiers),
  593. array names with appropriate subscripts given,
  594. operator or procedure names with suitable arguments,
  595. statement expressions.
  596. Examples:
  597. X
  598. X**3 - 2*Y/(2*Z**2 - DF(X,Z))
  599. (P**2 + M**2)**(1/2)*LOG (Y/M)
  600. A(5) + B(I,Q)
  601. Statement expressions (qv), usually in parentheses, can also form part of a
  602. scalar expression, as in the example
  603. W + (C:=X+Y) + Z
  604. When the (algebraic) value of an expression is needed, REDUCE determines
  605. it, starting with the (algebraic) values of the parts, roughly as follows:
  606. Variables and operator symbols with an argument list have the algebraic
  607. values they were last assigned, or if never assigned stand for themselves.
  608. Array symbols with appropriate subscripts have the algebraic values they
  609. were last assigned, or, if never assigned, are taken to be 0.
  610. Procedures are evaluated with the values of the given arguments.
  611. In evaluating expressions, the standard rules of algebra are applied.
  612. Unfortunately, this algebraic evaluation of an expression is not as
  613. unambiguous as is numerical evaluation. This process is generally referred
  614. to as 'simplification' in the sense that the evaluation usually but not
  615. always produces a simplified form for the expression.
  616. There are many options available to the user for carrying out such
  617. simplification. If the user doesn't specify any method, the default method
  618. is used. The default evaluation of an expression involves expansion of the
  619. expression and collection of like terms, ordering of the terms, evaluation
  620. of derivatives and other functions and substitution for any expressions
  621. 3-2
  622. which have values assigned or declared (qv assignments and LET statements).
  623. In many cases, this is all that the user needs.
  624. The declarations by which the user can exercise some control over the way
  625. in which the evaluation is performed are explained in another section. For
  626. example, if a real (floating point) number is encountered during
  627. evaluation, the system will normally convert it into a ratio of two
  628. integers, and print a message informing the user of the conversion. If the
  629. user wants to use real arithmetic, he can affect this by the command ON
  630. FLOAT;. Other modes for coefficient arithmetic are described elsewhere.
  631. If an illegal expression occurs during evaluation (such as division by zero)
  632. or functions are called with the wrong number of arguments, an appropriate
  633. error message is generated.
  634. 3.2 Integer Expressions _______ ___________
  635. These are expressions which, because of the values of the constants and
  636. variables in them, evaluate to whole numbers.
  637. Examples:
  638. 2, 37 * 999, (X + 3)**2 - X**2 - 6*X
  639. are obviously integer expressions.
  640. J + K - 2 * J**2
  641. is an integer expression when J and K have values that are integers, or if
  642. not integers are such that "the variables and fractions cancel out", as in
  643. K = 7/3 - J + 2/3 + 2*J**2.
  644. 3.3 Boolean Expressions _______ ___________
  645. A boolean expression returns a truth value. In the algebraic mode of
  646. REDUCE, boolean expressions have the syntactical form:
  647. <expression> <relational operator> <expression>
  648. or
  649. <boolean function> (<arguments>)
  650. or
  651. <boolean expression> <logical operator> <boolean expression>.
  652. In addition to the logical and relational operators defined earlier as
  653. infix operators (qv), the following boolean functions are also defined:
  654. FIXP(U) determines if the expression U is integer or not.
  655. FREEOF(U,V) determines if the expression U does not contain
  656. the kernel (qv) V anywhere in its structure.
  657. NUMBERP(U) determines if U is a number or not.
  658. 3-3
  659. ORDP(U,V) determines if U is ordered ahead of V by
  660. some canonical ordering (based on the
  661. expression structure and an internal ordering
  662. of identifiers).
  663. In the algebraic mode of REDUCE the result, True or False, of such an
  664. expression cannot be assigned to a variable. Boolean expressions can only
  665. appear directly within IF, FOR, WHILE, and UNTIL statements, as described
  666. in other sections.
  667. Examples:
  668. J<1
  669. X>0 OR X=-2
  670. NUMBERP X
  671. NUMBERP X AND X NEQ 0
  672. When two or more boolean expressions are combined with AND, they are
  673. evaluated one by one until a False expression is found. The rest are not
  674. evaluated. Thus
  675. NUMBERP X AND NUMBERP Y AND X>Y
  676. does not attempt to make the X>Y comparison unless X and Y are both
  677. verified to be numbers.
  678. Similarly, evaluation of a string of boolean expressions connected by OR
  679. stops as soon as a True expression is found.
  680. If an algebraic (non-boolean) expression is used in place where a boolean
  681. expression is expected, then True is assumed (i.e., no error occurs) as in
  682. IF (X := A+B) THEN Y := C+D.
  683. 3.4 Proper Statements as Expressions ______ __________ __ ___________
  684. Several kinds of proper statements (qv) deliver an algebraic or numeric
  685. result of some kind, which can in turn be used as an expression or part of
  686. an expression. For example, the assignment statement (placed in
  687. parentheses) itself has a value, namely the value assigned: so
  688. 2 * (X:=A+B)
  689. is equal to 2*(A+B), as well as having the "side-effect" of assigning the
  690. value A+B to X. In context,
  691. Y := 2 * (X:=A+B);
  692. sets X to A+B and Y to 2*(A+B).
  693. The sections on the various proper statement types indicate which can be
  694. used usefully as expressions as well.
  695. 4-1
  696. 4. STATEMENTS __________
  697. A statement is any allowed combination of reserved words and expressions,
  698. and has the syntax
  699. <statement> ::= <expression>|<proper statement>
  700. A REDUCE program consists of a series of commands (qv), which are statements
  701. each followed by a terminator:
  702. <terminator> ::= ;|$
  703. The division of the program into lines is arbitrary. Several statements
  704. can be on one line, or one statement can be freely broken into several
  705. lines. If the program is run interactively, statements ending with ; or $
  706. are not processed until an end-of-line character is hit. This character
  707. can vary from system to system, but is normally the RETURN key on an Ascii
  708. terminal. Specific systems can also use additional keys as statement
  709. terminators. For example, on the DECSystem 20, the ESCAPE key can be used.
  710. This also terminates the line. Thus ESCAPE in this case is equivalent to
  711. typing $ and hitting return: in fact in many contexts a dollar sign is
  712. printed automatically when ESCAPE is hit.
  713. If the statement is a proper statement, the appropriate action takes place.
  714. Depending on the nature of the proper statement some appropriate result or
  715. response may or may not print out, and the response may or may not depend
  716. on the terminator used.
  717. If the statement is an expression, it is evaluated. If the terminator was
  718. a semicolon, the result is automatically printed. Because it is not
  719. usually possible to know in advance how large an expression will be, no
  720. explicit format statements are offered to the user. However, a variety of
  721. output declarations are available so that the output can be produced in a
  722. variety of forms. These output declarations are explained elsewhere.
  723. If the statement is an expression and the terminator is a dollar sign or
  724. an ESCAPE keystroke, the result of the evaluation is not automatically
  725. printed out. The following sub-sections describe some proper statements
  726. types in REDUCE.
  727. 4.1 Assignment Statements __________ __________
  728. These statements have the syntax
  729. <assignment statement> ::= <expression> := <expression>
  730. The <expression> on the left side is normally the name of a variable, an
  731. operator symbol with its list of arguments filled in, or an array name with
  732. the proper number of integer subscript values within the array bounds.
  733. (More general assignments such as A+B := C are in fact also allowed. The
  734. 4-2
  735. effect of these is explained in the section "Substitutions for General
  736. Expressions".)
  737. e.g. A1 := B+C
  738. H(L,M) := X-2*Y (where H is an operator)
  739. K(3,5) := X-2*Y (where K is a 2-dim. array)
  740. An assignment statement causes the expression on the right side to be
  741. evaluated, and the resulting value is assigned to the variable or array
  742. position or operator "position" indicated on the left.
  743. If a semicolon is used as terminator when an assignment is issued as a
  744. command (i.e. not as a part of a group statement or procedure or other
  745. similar construct), the left-hand side symbol of the assignment statement
  746. is printed out, followed by a ":=" , followed by the value of the
  747. expression on the right.
  748. It is also possible to write a multiple assignment statement:
  749. <expression> := <expression> := ... := <expression> := <expression>
  750. In this form, each <expression> is set to the value of the rightmost
  751. <expression>.
  752. 4.2 Group statements _____ __________
  753. The group statement is a construct used where REDUCE expects a single
  754. statement, but a series of actions needs to be performed. It is formed by
  755. enclosing one or more statements (of any kind) between the symbols << and
  756. >>, separated by semicolons or dollar signs -- it doesn't matter which.
  757. The statements are executed one after another.
  758. Examples will be given in the sections on IF and other types of statements
  759. in which the << ... >> construct is useful.
  760. If the last statement in the enclosed group has a value, then that is also
  761. the value of the group statement. Care must be taken not to have a
  762. semicolon or dollar sign after the last grouped statement, if the value of
  763. the group is relevant: such an extra terminator causes the group to have
  764. the value NIL or zero.
  765. 4.3 Conditional Statements ___________ __________
  766. The conditional statement has the following syntax:
  767. <conditional statement> ::= IF <boolean expression> THEN <statement>
  768. ELSE <statement>
  769. The boolean expression is evaluated. If the result is True, the first
  770. <statement> is executed. If it is False, the second is. In either case the
  771. statement after the entire conditional statement is executed next.
  772. 4-3
  773. Examples:
  774. IF X=5 THEN A:=B+C ELSE D:=E+F
  775. IF X=5 AND NUMBERP Y
  776. THEN <<FF:=Q1; A:=B+C>>
  777. ELSE <<FF:=Q2; D:=E+F>>
  778. Note the use of the group statement.
  779. If it is the value of the conditional statement which is of primary
  780. interest, it is often called a conditional expression instead. Its value
  781. is the value of whichever statement was executed. (If the executed
  782. statement has no value, the conditional expression has no value or the
  783. value 0, depending on how it is used.)
  784. Examples:
  785. A:=IF X<5 THEN 123 ELSE 456;
  786. B:=U + V**(IF NUMBERP Z THEN 10*Z ELSE 1) + W;
  787. If the value is of no concern, the ELSE clause may be omitted if no action
  788. is required in the "False" case.
  789. IF X=5 THEN A:=B+C;
  790. Note: If by mistake a scalar or numeric expression is used in place of the
  791. boolean expression in forming a conditional -- for example, a variable is
  792. written there -- the True alternative is always followed.
  793. 4.4 FOR Statements ___ __________
  794. The FOR statement is used to define a variety of program loops. Its
  795. general syntax is as follows:
  796. FOR <variable> := <number> STEP <number> UNTIL <number>
  797. (DO <statement>
  798. (SUM <algebraic expression>
  799. (PRODUCT <algebraic expression>
  800. If expressions that do not evaluate to numbers are used in the designated
  801. places, an error will result.
  802. The DO version of the FOR statement is like the FOR statement of ALGOL and
  803. the DO statement of FORTRAN. The <statement> is executed repeatedly with
  804. the <variable> running through the prescribed range of values. If the
  805. limit is less than the starting value (in the case of negative steps:
  806. greater), the <statement> is not executed at all.
  807. Example:
  808. 4-4
  809. FOR I := 5 STEP 1 UNTIL 10 DO
  810. <<A(I):=I**2; B(I):=I**3>>
  811. If A, B have been declared to be arrays, this stores 5**2 through 10**2 in
  812. A(5) through A(10), and at the same time stores the cubes in the B array.
  813. As a convenience, the common construction
  814. STEP 1 UNTIL
  815. may be abbreviated to a colon. Thus we could write, instead of the above,
  816. FOR I := 5:10 DO <<A(I):=I**2; B(I):=I**3>>
  817. The FOR ... DO statement is not intended to be used as an expression. If
  818. it is, its value is 0.
  819. The SUM and PRODUCT versions respectively form the sum and product of the
  820. specified algebraic expression over the defined range. They are intended
  821. to be used as expressions, and return the value of the computed sum or
  822. product.
  823. Examples:
  824. C := FOR J:=1 STEP 2 UNTIL 9 SUM J**2;
  825. D := FOR K:=0 STEP 1 UNTIL 4 PRODUCT (X+K);
  826. This sets C to the sum of the squares of 1,3,5,7,9; and D is set to the
  827. expression
  828. X * (X+1) * (X+2) * (X+3) * (X+4).
  829. The control variable used in the FOR statement is actually a new variable,
  830. not related to the variable of the same name outside the FOR statement. In
  831. other words, executing a statement FOR I:= ... doesn't change the value
  832. (if any) the user may have given I, or the system's assumption that I**2 =
  833. -1.
  834. 4.5 WHILE ... DO _____ ___ __
  835. The FOR ... DO feature allows easy coding of a repeated operation in which
  836. the number of repetitions is known in advance. If the criterion for
  837. repetition is more complicated, WHILE ... DO can often be used. Its syntax
  838. is:
  839. WHILE <boolean expression> DO <statement>
  840. For the meaning of boolean expression, see the appropriate section.
  841. The WHILE ... DO controls the single statement following DO. If several
  842. statements are to be repeated, as is almost always the case, they must be
  843. 4-5
  844. grouped using the << ... >> as in the example below.
  845. The WHILE condition is tested each time BEFORE the action following the DO
  846. is attempted. If the condition is false to begin with, the action is not
  847. performed at all. Make sure that what is to be tested has an appropriate
  848. value initially.
  849. Example:
  850. Suppose we want to add up a series of terms, generated one by one, until
  851. we reach a term which is less than 1/1000 in value. For our simple
  852. example, let us suppose the first term equals 1 and each term is gotten
  853. from the one before by taking one third of it and adding one third its
  854. square. We would write:
  855. EX:=0; TERM:=1;
  856. WHILE NUM(TERM - 1/1000) >= 0 DO
  857. <<EX := EX+TERM; TERM:=(TERM + TERM**2)/3>>;
  858. EX;
  859. As long as TERM is greater than or equal ( >= ) to 1/1000 it will be added
  860. to EX and the next TERM calculated. As soon as TERM becomes less than
  861. 1/1000 the WHILE test fails and the TERM will not be added.
  862. 4.6 REPEAT ... UNTIL ______ ___ _____
  863. REPEAT ... UNTIL is very similar in purpose to WHILE ... DO. Its syntax
  864. is:
  865. REPEAT <statement> UNTIL <boolean expression>
  866. (PASCAL users note: Only a single statement -- usually a group statement
  867. -- is allowed between the REPEAT and the UNTIL.)
  868. There are two essential differences:
  869. 1) The test is performed after the controlled statement (or group of
  870. statements) is executed, so the controlled statement is always executed at
  871. least once.
  872. 2) The test is a test for when to stop rather than when to continue, so its
  873. "polarity" is the opposite of that in WHILE ... DO.
  874. Example:
  875. We rewrite the example from the WHILE ... DO section:
  876. EX:=0; TERM:=1;
  877. REPEAT <<EX := EX+TERM; TERM:=(TERM + TERM**2)/3>>
  878. UNTIL NUM(TERM - 1/1000) < 0;
  879. EX;
  880. 4-6
  881. The answer here will not be exactly the same as before, because the first
  882. term which is less than 1/1000 WILL be added to EX this time.
  883. 4.7 Compound Statements ________ __________
  884. Often the desired process can best (or only) be described as a series of
  885. steps to be carried out one after the other. In many cases, this can be
  886. achieved by use of the group statement (qv). However, each step often
  887. provides some intermediate result, until at the end we have the final
  888. result wanted. Alternatively, iterations on the steps are needed that are
  889. not possible with constructs such as WHILE or REPEAT statements (qv). In
  890. such cases the steps of the process must be enclosed between the words
  891. BEGIN and END forming what is technically called a block or compound
  892. statement. Such a compound statement can in fact be used wherever a group
  893. statement appears. The converse is not true: BEGIN ... END can be used in
  894. ways that << ... >> can not.
  895. If intermediate results must be formed, local variables must be provided in
  896. which to store them. "Local" means that their values are deleted as soon as
  897. the block's operations are complete, and there is no conflict with
  898. variables outside the block that happen to have the same name. Local
  899. variables are created by a SCALAR declaration immediately after the BEGIN:
  900. SCALAR A,B,C,Z;
  901. If more convenient, several SCALAR declarations can be given one after
  902. another:
  903. SCALAR A,B,C;
  904. SCALAR Z;
  905. In place of SCALAR one can also use the declarations INTEGER or REAL. In
  906. the present version of REDUCE variables declared INTEGER are expected to
  907. have only integer values, and are initialized to 0. REAL variables on the
  908. other hand are currently treated as SCALAR.
  909. CAUTION: INTEGER, REAL and SCALAR declarations can only be given
  910. immediately after a BEGIN. An error will result if they are used after
  911. other statements in a block (including ARRAY and OPERATOR declarations,
  912. which are global in scope), or outside the top-most block (e.g., at the
  913. top level). All variables declared SCALAR are automatically initialized to
  914. zero in algebraic mode (NIL in symbolic mode).
  915. Any symbols not declared as local variables in a block are global, in the
  916. sense that they refer to the variables of the same name outside the block.
  917. In particular, if they are not so declared at a higher level (e.g., in
  918. another block or as parameters in a procedure (qv)), their values can be
  919. permanently changed.
  920. Following the SCALAR declaration(s), if any, write the statements to be
  921. executed, one after the other, separated by delimiters (e.g., ; or $) (it
  922. 4-7
  923. doesn't matter which).
  924. The last statement in the body, just before END, need not have a terminator
  925. (since the BEGIN ... END are in a sense brackets confining the block
  926. statements). The last statement must also be the command RETURN followed by
  927. the variable or expression whose value is to be the value returned by the
  928. procedure. If the RETURN is omitted (or nothing is written after the word
  929. RETURN) the value returned by the procedure will be zero (or NIL in
  930. symbolic mode).
  931. Remember to put a terminator after the END.
  932. Example:
  933. Given a previously assigned integer value for N, the following block will
  934. compute the Legendre polynomial of degree N in the variable X:
  935. BEGIN SCALAR SEED,DERIV,TOP,FACT;
  936. SEED:=1/(Y**2 - 2*X*Y +1)**(1/2);
  937. DERIV:=DF(SEED,Y,N);
  938. TOP:=SUB(Y=0,DERIV);
  939. FACT:=FOR I:=1:N PRODUCT I;
  940. RETURN TOP/FACT
  941. END;
  942. 4.7.1 Compound Statements with GO TO ________ __________ ____ __ __
  943. It is possible to have more complicated structures inside the BEGIN ...
  944. END brackets than indicated in the previous example. That the individual
  945. lines of the program need not be assignment statements, but could be
  946. almost any other kind of statement or command, needs no explanation. For
  947. example, conditional statements, and WHILE and REPEAT constructions, have
  948. an obvious role in defining more intricate blocks.
  949. If these structured constructs don't suffice, it is possible to use labels
  950. and GO TOs within a compound statement, and also to use RETURN in places
  951. within the block other than just before the END. The following subsections
  952. discuss these matters in detail. For many readers the following example,
  953. presenting one possible definition of a process to calculate the factorial
  954. of N for preassigned N (there are far simpler ones!) will suffice:
  955. Example:
  956. BEGIN SCALAR M;
  957. M:=1;
  958. L: IF N=0 THEN RETURN M;
  959. M:=M*N;
  960. N:=N-1;
  961. GO TO L
  962. END;
  963. 4-8
  964. 4.7.2 Labels and GO TO Statements ______ ___ __ __ __________
  965. Within a BEGIN ... END compound statement it is possible to label
  966. statements, and transfer to them out of sequence using GO TO statements.
  967. Only statements on the top level inside compound statements can be
  968. labeled, not ones inside subsidiary constructions like << ... >>, IF ...
  969. THEN ..., WHILE ... DO ... , etc.
  970. Labels and GO TO statements have the syntax:
  971. <go to statement> ::= GO TO <label> | GOTO <label> <label> ::=
  972. <identifier> <labeled statement> ::= <label>:<statement>
  973. While GO TO is an unconditional transfer, it is frequently used in
  974. conditional statements such as
  975. IF X>5 THEN GO TO ABCD;
  976. giving the effect of a conditional transfer.
  977. 4.7.3 RETURN Statements ______ __________
  978. The value corresponding to a BEGIN ... END compound statement, such as a
  979. procedure body, is normally 0 (NIL in symbolic mode). By executing a
  980. RETURN statement in the compound statement a different value can be
  981. returned. After a RETURN statement is executed no further statements
  982. within the compound statement are.
  983. Examples:
  984. RETURN X+Y;
  985. RETURN M;
  986. RETURN;
  987. Note that parentheses are not required around the X+Y, although they are
  988. permitted. The last example is equivalent to RETURN 0; .
  989. Since RETURN actually moves up only one block level, in a sense the casual
  990. user is not expected to understand, we tabulate some cautions concerning
  991. its use.
  992. RETURN can be used on the top level inside the compound statement, i.e. as
  993. one of the statements bracketed together by the BEGIN ... END.
  994. RETURN can be used within a top level << ... >> construction within the
  995. compound statement.
  996. RETURN can be used within an IF ... THEN ... ELSE ... on the top level
  997. within the compound statement.
  998. If RETURN is used in a FOR, WHILE, or REPEAT statement within the compound
  999. 4-9
  1000. statement, presumably to force early termination in some circumstance, the
  1001. RETURN only exits from the FOR, WHILE, or REPEAT, not from the compound
  1002. statement (and procedure).
  1003. Example:
  1004. Suppose that as a step within a process you want to search a 100-place
  1005. array A(0) through A(99), and if X is found in some A(I) you want to set Y
  1006. to B(I), B being a similar array. Write
  1007. Y := FOR I:=0:99 DO IF A(I)=X THEN RETURN B(I);
  1008. If X is found, Y will be set to B(I). If not found, the Y will be set to 0
  1009. (the normal "value" of a FOR ... DO).
  1010. If instead of setting Y to B(I) we want the result to be the B(I) (or zero
  1011. if not found), we could use
  1012. RETURN FOR I:=0:99 DO IF A(I)=X THEN RETURN B(I);
  1013. Note the two RETURNs!
  1014. 5-1
  1015. 5. COMMANDS AND DECLARATIONS ________ ___ ____________
  1016. A command is an order to the system to do something. Some commands cause
  1017. visible results (such as calling for input or output); others, usually
  1018. called declarations, set options, define properties of variables, or define
  1019. procedures. Commands are formally defined as a statement followed by a
  1020. terminator
  1021. <command> ::= <statement> <terminator>
  1022. <terminator> ::= ;|$
  1023. Some REDUCE commands and declarations are described in the following
  1024. sub-sections.
  1025. 5.1 Array Declarations _____ ____________
  1026. Array declarations in REDUCE are similar to FORTRAN dimension statements.
  1027. e.g. ARRAY A(10),B(2,3,4);
  1028. Array indices each range from 0 to the value declared. An element of an
  1029. array is referred to in standard FORTRAN notation,
  1030. e.g. A(2)
  1031. We can also use an expression for defining an array bound, provided the
  1032. value of the expression is a positive integer. For example, if X has the
  1033. value 10 and Y the value 7 then
  1034. ARRAY C(5*X+Y) is the same as ARRAY C(57).
  1035. If an array is referenced by an index outside its range, an error occurs.
  1036. If the array is to be one-dimensional, and the bound a number or a
  1037. variable (not a more general expression) the parentheses may be omitted:
  1038. ARRAY A 10, C 57;
  1039. All array elements are initialized to 0 at declaration time. In other words,
  1040. an array element cannot stand for itself. If this is required, then an
  1041. operator (qv) should be used instead.
  1042. Array declarations can appear anywhere in a program. Once a symbol is
  1043. declared to name an array, it can not also be used to name an operator or
  1044. a procedure. It can however be re-declared to be an array, and its size
  1045. may be changed at that time. An array name can also continue to be used as
  1046. an ordinary variable.
  1047. 5-2
  1048. 5.2 Mode Handling Declarations ____ ________ ____________
  1049. Two declarations are offered to the user for controlling various system
  1050. options. Each option is represented by a so-called "switch" being ON or
  1051. OFF. The declarations ON and OFF take a list of switch names as argument
  1052. and turn them on and off respectively.
  1053. e.g. ON TIME;
  1054. causes the system to print a message after each command giving the elapsed
  1055. cpu time since the last command, or since TIME was last turned off, or the
  1056. session began. Another useful switch with interactive use is DEMO, which
  1057. causes the system to pause after each command in a file until a Return is
  1058. typed on the terminal. This enables a user to set up a demonstration file
  1059. and step through it command by command.
  1060. As with most declarations, arguments to ON and OFF may be strung together
  1061. separated by commas. For example,
  1062. OFF TIME,DEMO;
  1063. will turn off both the time messages and the demonstration switch.
  1064. We note here that while most ON and OFF commands are obeyed almost
  1065. instantaneously, some trigger time-consuming actions such as reading in
  1066. necessary modules from secondary storage.
  1067. Caution: No error message is generated if the name of a switch is
  1068. mistyped. If mistyped, the intended option change simply doesn't take
  1069. place.
  1070. 5.3 END ___
  1071. The identifier END has three separate uses.
  1072. 1) Its use in a BEGIN ... END bracket has been discussed in connection
  1073. with compound statements (qv).
  1074. 2) Files to be read using IN should end with an extra END; command. The
  1075. reason for this is explained in the section on the IN command (qv). This
  1076. use of END does not allow an immediately preceding END (such as the END of
  1077. a procedure definition), so we advise using ;END; there.
  1078. 3) A command END; entered at the top level transfers control to the
  1079. Standard LISP system which is the host of the REDUCE system. All files
  1080. opened by IN or OUT statements are closed in the process. END; does not
  1081. stop REDUCE. Those familiar with LISP can experiment with typing
  1082. identifiers and (<function name><argument list>) lists to see the value
  1083. returned by LISP. (No terminators, other than RETURN, should be used.) The
  1084. data structures created during the REDUCE run are accessible.
  1085. 5-3
  1086. You remain in this LISP mode until you make a LISP error, or explicitly
  1087. re-enter REDUCE by saying (BEGIN) at the LISP top level. Any error
  1088. automatically returns you to REDUCE (always the algebraic mode, even if
  1089. you were in symbolic mode before the END;). If you are in LISP mode by
  1090. mistake -- which is usually the case, the result of typing more ENDs than
  1091. BEGINs -- type some identifier you haven't used, perhaps BYE, and hit
  1092. RETURN. If you prefer, type (BEGIN) in parentheses as shown and hit
  1093. RETURN.
  1094. 5.4 BYE ___
  1095. The command BYE; stops the execution of REDUCE and returns you to the
  1096. computer system monitor program. Where the implementation permits it, your
  1097. REDUCE session is destroyed. If you wish to return later to that session,
  1098. use QUIT; instead.
  1099. 5.5 QUIT ____
  1100. The command QUIT; stops the execution of REDUCE and returns you to the
  1101. computer system monitor program. Where the implementation permits it, your
  1102. REDUCE session is retained so that you can use it again later. If you do
  1103. not wish to reenter the REDUCE session, use BYE; instead.
  1104. 5.6 SHOWTIME ________
  1105. SHOWTIME; prints the elapsed time since the last call of this command or,
  1106. on its first call, since the current REDUCE session began. The time is
  1107. normally given in milliseconds and gives the time as measured by a system
  1108. clock. The operations covered by this measure are system dependent.
  1109. 5.7 DEFINE ______
  1110. The command DEFINE allows a user to supply a new name for any identifier
  1111. or replace it by any well-formed expression. Its argument is a list of
  1112. expressions of the form
  1113. <identifier> = <number>|<identifier>|<operator>|
  1114. <reserved word>|<expression>
  1115. Example:
  1116. DEFINE BE==,X=Y+Z;
  1117. means that 'BE' will be interpreted as an equal sign, and 'X' as the
  1118. expression Y+Z from then on. This renaming is done at the input level and
  1119. therefore takes precedence over any other replacement declared for the
  1120. same identifier. It stays in effect until the end of the REDUCE run.
  1121. The identifiers ALGEBRAIC and SYMBOLIC have properties which prevent
  1122. 5-4
  1123. DEFINE from being used on them. To define ALG to be a synonym for
  1124. ALGEBRAIC, the more complicated construction
  1125. PUT('ALG,'NEWNAM,'ALGEBRAIC);
  1126. must be used.
  1127. 6-1
  1128. 6. BUILT-IN PREFIX OPERATORS ________ ______ _________
  1129. In the following subsections are descriptions of the most useful prefix
  1130. operators built into REDUCE. Some are fully defined internally as
  1131. procedures; others are more nearly abstract operators, with only some of
  1132. their properties known to the system.
  1133. In many cases, an operator is described by a prototypical header line as
  1134. follows. Each formal parameter is given a name and followed by its allowed
  1135. type. The names of classes referred to in the definition are printed in
  1136. lower case, and parameter names in upper case. If a parameter type is not
  1137. commonly used, it may be a specific set enclosed in brackets {...}.
  1138. Operators which accept formal parameter lists of arbitrary length have the
  1139. parameter and type class enclosed in square brackets indicating that zero
  1140. or more occurrences of that argument are permitted. Optional parameters
  1141. and their type classes are enclosed in angle brackets.
  1142. 6.1 Numerical Functions _________ _________
  1143. REDUCE knows that the following represent functions that can take an
  1144. arbitrary number of numerical expressions as their arguments:
  1145. MAX MIN.
  1146. For example,
  1147. MAX(2,-3,4,5) ==> 5
  1148. MIN(2,-2) ==> 2.
  1149. In addition, the function ABS will return the absolute value of its single
  1150. numerical argument.
  1151. An error occurs if a non-numeric argument is supplied to any of these
  1152. functions.
  1153. 6.2 Mathematical Functions ____________ _________
  1154. REDUCE knows that the following represent mathematical functions that can
  1155. take arbitrary scalar expressions as their single argument:
  1156. SIN COS TAN COT ASIN ACOS ATAN SQRT EXP LOG SINH COSH TANH
  1157. ASINH ACOSH ATANH ERF DILOG EXPINT.
  1158. It only knows the most elementary identities and properties of these
  1159. functions, however (except in ON NUMVAL mode (qv)). For example:
  1160. COS (-X) = COS (X) SIN (-X) = - SIN (X)
  1161. COS (n*PI) = (-1)**n SIN (n*PI) = 0
  1162. LOG (E) = 1 E**(I*PI/2) = I
  1163. 6-2
  1164. LOG (1) = 0 E**(I*PI) = -1
  1165. LOG (E**X) = X E**(3*I*PI/2) = -I
  1166. SQRT (-X) = I * SQRT(X) SQRT (A**2) = A
  1167. SQRT (A*B) = SQRT(A) * SQRT(B) SQRT (100) = 10
  1168. SQRT (200) = 10 * SQRT(2), etc.
  1169. REDUCE replaces SQRT(A**2) by A, which is usually reasonable but can cause
  1170. trouble if A eventually is given a value which is a negative number.
  1171. The square root function can be input using the name SQRT, or the power
  1172. operation **(1/2). On output, unsimplified square roots are represented by
  1173. the operator SQRT rather than a fractional power.
  1174. The derivatives of these functions are also known to the system.
  1175. The user can add further rules for the reduction of expressions involving
  1176. these operators by using the LET command (qv).
  1177. The statement that REDUCE knows very little about these functions applies
  1178. only in the mathematically exact OFF NUMVAL mode. If the mode ON NUMVAL is
  1179. set, any of the functions
  1180. SIN COS TAN ASIN ACOS ATAN SQRT EXP LOG
  1181. which is given a numeric argument has its value calculated to the current
  1182. degree of floating point precision.
  1183. 6.3 DF __
  1184. The operator DF is used to represent partial differentiation with respect
  1185. to one or more variables. It is used with the syntax:
  1186. DF(EXPRN:algebraic,[VAR:kernel<,NUM:integer>]):algebraic.
  1187. The first argument is the expression to be differentiated. The remaining
  1188. arguments specify the differentiation variables and the number of times
  1189. they are applied.
  1190. The number NUM may be omitted if it is 1.
  1191. e.g. DF(Y,X) = dY/dX
  1192. 2 2
  1193. DF(Y,X,2) = d Y/dX
  1194. 5 2 2
  1195. DF(Y,X1,2,X2,X3,2)= d Y/dX1 dX2 dX3
  1196. The evaluation of DF(Y,X) proceeds as follows: first, the values of Y and
  1197. X are found. Let us assume that X has no assigned value, so its value is
  1198. X. Each term or other part of the value of Y which contains the variable X
  1199. is differentiated by the standard rules. If Z is another variable, not X
  1200. itself, then its derivative with respect to X is taken to be 0, unless Z
  1201. has previously been declared to DEPEND (qv) on X, in which case the
  1202. 6-3
  1203. derivative is reported as the symbol DF(Z,X).
  1204. 6.3.1 Adding Differentiation Rules ______ _______________ _____
  1205. The LET statement (qv) can be used for the introduction of rules for
  1206. differentiation of user-defined operators. Its general form is
  1207. FOR ALL <var1>,...,<varn>
  1208. LET DF(<operator><varlist>,<vari>)=<expression>
  1209. where <varlist> ::= (<var1>,...,<varn>), and <var1>,...,<varn> are the
  1210. dummy variable arguments of <operator>.
  1211. An analogous form applies to infix operators.
  1212. Examples:
  1213. FOR ALL X LET DF(TAN X,X)= SEC(X)**2;
  1214. (This is how the Tan differentiation rule appears in the
  1215. REDUCE source.)
  1216. FOR ALL X,Y LET DF(F(X,Y),X)=2*F(X,Y), DF(F(X,Y),Y)=X*F(X,Y);
  1217. Notice that all dummy arguments of the relevant operator must be declared
  1218. arbitrary by the FOR ALL command, and that rules may be supplied for
  1219. operators with any number of arguments. If no differentiation rule appears
  1220. for any argument in an operator, the differentiation routines will return
  1221. as result an expression in terms of DF. For example, if the rule for the
  1222. differentiation with respect to the second argument of F is not supplied,
  1223. the evaluation of DF(F(X,Z),Z) would leave this expression unchanged. (No
  1224. DEPEND declaration (qv) is needed here, since F(X,Z) obviously "depends
  1225. on" Z.
  1226. 6.4 INT ___
  1227. INT is an operator in REDUCE for analytic integration using a combination
  1228. of the Risch-Norman algorithm and pattern matching. It is used with the
  1229. syntax:
  1230. INT(EXPRN1:algebraic,VAR:kernel):algebraic.
  1231. It will return correctly the indefinite integral for expressions
  1232. comprising polynomials, log functions, exponential functions and tan and
  1233. atan. The arbitrary constant is not represented. If the integral cannot be
  1234. done in closed terms, it returns a formal integral for the answer in one
  1235. of two ways:
  1236. 1) It returns the input, INT( ... , ... ) unchanged.
  1237. 2) It returns an expression involving INT's of some
  1238. other functions (sometimes more complicated than
  1239. the original one, unfortunately).
  1240. 6-4
  1241. Rational functions can be integrated when the denominator is factorizable
  1242. by the program.
  1243. In addition it will attempt to integrate expressions involving error
  1244. functions, dilogarithms and other trigonometric expressions. In these
  1245. cases it might not always succeed in finding the solution, even if one
  1246. exists.
  1247. Examples:
  1248. INT(LOG(X),X) ==> X*(LOG(X) - 1),
  1249. INT(E**X,X) ==> E**X.
  1250. The program checks that the variable supplied is a variable and gives an
  1251. error if it is not.
  1252. 6.4.1 Options _______
  1253. The switch TRINT when on will trace the operation of the algorithm. It
  1254. produces a great deal of output in a somewhat illegible form, and is not
  1255. of much interest to the general user.
  1256. If the switch FAILHARD is on the algorithm will terminate with an error if
  1257. the integral cannot be done in closed terms, rather than return a formal
  1258. integration form.
  1259. The switch NOLNR suppresses the use of the linear properties of
  1260. integration in cases when then integral cannot be found in closed terms.
  1261. 6.4.2 Advanced Use ________ ___
  1262. If a function appears in the integrand which is not one of the functions
  1263. EXP, ERF, TAN, ATAN, LOG, DILOG then the algorithm will make an attempt to
  1264. integrate the argument if it can, differentiate it and reach a known
  1265. function. However the answer cannot be guaranteed in this case. If a
  1266. function is known to be algebraically independent of this set it can be
  1267. flagged transcendental by
  1268. FLAG('TRILOG,'TRANSCENDENTAL);
  1269. in which case this function will be added to the permitted field
  1270. descriptors for an genuine decision procedure. If this is done the user is
  1271. responsible for the mathematical correctness of his actions.
  1272. The current version does not deal with algebraic extensions. Thus
  1273. integration of expressions involving square roots and other like things
  1274. will lead to trouble. If however the answer is known to involve certain
  1275. logarithms they can be added as a 'hint' by providing a third argument
  1276. which is a list of the hints. This must only be done if the hints are the
  1277. correct ones, and strange results will occur if they are not.
  1278. 6-5
  1279. 6.4.3 References __________
  1280. A. C. Norman & P. M. A. Moore, "Implementing the New Risch
  1281. Algorithm", Proc. 4th International Symposium on Advanced
  1282. Comp. Methods in Theor. Phys., CNRS, Marseilles, 1977.
  1283. S. J. Harrington, "A New Symbolic Integration System in Reduce",
  1284. Comp. Journ. 22 (1979) 2.
  1285. A. C. Norman & J. H. Davenport, "Symbolic Integration - The Dust
  1286. Settles?", Proc. EUROSAM 79, Lecture Notes in Computer
  1287. Science 72, Springer-Verlag, Berlin Heidelberg New York
  1288. (1979) 398-407.
  1289. Comments and complaints should be sent to;
  1290. Professor John P. Fitch, or Dr. Arthur C. Norman
  1291. Dept of Computing Studies, Computer Laboratory,
  1292. Bath University, University of Cambridge
  1293. Bath, Somerset Cambridge, CB2 3QG,
  1294. England England.
  1295. 6.5 SOLVE _____
  1296. SOLVE is an EXPERIMENTAL operator for solving one or more simultaneous
  1297. algebraic equations. It is used with the syntax:
  1298. SOLVE(EXPRN:algebraic[,VAR:kernel]):integer.
  1299. EXPRN is of the form <expression> or LST(<expression1>, <expression2>,
  1300. ...). Each expression is the difference in the two sides of an algebraic
  1301. equation. The second argument may be omitted if the number of distinct
  1302. top-level kernels equals the number of unknowns, in which case these
  1303. kernels are presumed to be the unknowns. Simultaneous equations must
  1304. currently be linear in the kernels in terms of which the solutions are
  1305. sought.
  1306. 6.5.1 Options _______
  1307. If SOLVESINGULAR is on, degenerate systems such as x+y=0,2x+2y=0 will be
  1308. solved by introducing appropriate arbitrary constants.
  1309. For example:
  1310. SOLVE(LOG(SIN(X+3))**5 - 8);
  1311. or
  1312. SOLVE(A*LOG(SIN(X+3))**5 - B, SIN(X+3));
  1313. or
  1314. SOLVE(LST(A*X+Y-3, Y+2), X, Y);
  1315. If SOLVEINTERVAL is on, real roots which cannot be determined exactly, are
  1316. isolated using Vincent's method, if possible. (CAUTION: This loses if the
  1317. roots are very large.) SOLVEINTERVAL is initially off. At most 10 real
  1318. 6-6
  1319. roots are isolated. If more are needed, define an N by 2 array, where N is
  1320. greater than or equal to the number of roots to be isolated, and put its
  1321. name in the (symbolic) global variable !!INTERVALARRAY. Isolated solutions
  1322. are returned in the form: INTERVL(lowlim, highlim), where lowlim and
  1323. highlim are rational numbers.
  1324. SOLVE returns the number of rows in the global matrix SOLN, after storing
  1325. one solution per row with the components in the order of the kernels in the
  1326. second argument of SOLVE. When there is only one equation, the
  1327. corresponding multiplicities are stored in the global one-column matrix
  1328. MULTIPLICITY. A negative multiplicity indicates that the corresponding row
  1329. of SOLN is an unsolved factor with the absolute value of that multiplicity.
  1330. This situation is also revealed by the appearance of the unknown in that
  1331. row of SOLN.
  1332. SOLN is automatically printed if SOLVEWRITE is ON, which is the default.
  1333. For one equation, SOLVE recursively uses square-free factorization together
  1334. with the known inverses of LOG, SIN, COS, **, ACOS, ASIN, and linear,
  1335. quadratic, cubic, quartic, or binomial factors. For simultaneous linear
  1336. equations, the built-in Bareiss matrix equation solver is used, SOLVE
  1337. merely providing a convenient form of input for small or sparse systems.
  1338. The consistent singular equation 0=0 or equations involving functions with
  1339. multiple inverses may introduce unique new indeterminant kernels
  1340. ARBCOMPLEX(j), ARBREAL(j), or ARBINT(j), (j=1,2,...), representing
  1341. arbitrary complex, real or integer numbers respectively. To automatically
  1342. select the principal branches, do OFF ALLBRANCH. To suppress solutions of
  1343. consistent singular equations do OFF SOLVESINGULAR.
  1344. To incorporate additional inverse functions do, for example:
  1345. PUT('SINH,'INVERSE,'ASINH);
  1346. PUT('ASINH,'INVERSE,'SINH);
  1347. together with any desired simplification rules such as
  1348. FOR ALL X LET SINH(ASINH(X))=X, ASINH(SINH(X))=X;
  1349. For completeness, functions with non-unique inverses should be treated as
  1350. **, SIN, and COS are in the SOLVE module source.
  1351. Arguments of ASIN and ACOS are not checked to insure that the absolute
  1352. value of the real part does not exceed 1; and arguments of LOG are not
  1353. checked to insure that the absolute value of the imaginary part does not
  1354. exceed PI; but checks (perhaps involving user response for non-numerical
  1355. arguments) could be introduced using LET statements for these operators.
  1356. 6-7
  1357. 6.6 SUB ___
  1358. Syntax: SUB([VAR:kernel = EXPRN:algebraic,]EXPRN1:algebraic):algebraic.
  1359. The SUB operator gives the algebraic result of replacing every occurrence
  1360. of the variable VAR in the expression EXPRN1 by the expression EXPRN.
  1361. Specifically, EXPRN1 is first evaluated using all available rules. Next
  1362. the substitutions are made, and finally the substituted expression is
  1363. reevaluated. When more than one variable occurs in the substitution list,
  1364. the substitution is performed by recursively walking down the tree
  1365. representing EXPRN1, and replacing every VAR found by the appropriate
  1366. EXPRN. The EXPRN are not themselves searched for any occurrences of the
  1367. various VARs. The trivial case SUB(EXPRN1) returns the algebraic value of
  1368. EXPRN1.
  1369. Example:
  1370. SUB(X=A+Y,Y=Y+1,X**2+Y**2) ==>
  1371. (A+Y)**2+(Y+1)**2 (normally multiplied out).
  1372. Note that the assignments X:=A+Y, etc, do not take place.
  1373. 6.7 Declaring new Prefix Operators _________ ___ ______ _________
  1374. The user may add new prefix operators to the system by the using the
  1375. declaration OPERATOR.
  1376. e.g. OPERATOR H,G1,ARCTAN;
  1377. adds the prefix operators H, G1 and ARCTAN to the system.
  1378. This allows symbols like H(W), H(X,Y,Z), G1(P+Q), ARCTAN(U/V) to be used
  1379. in expressions, but no meaning or properties of the operator are implied.
  1380. The same operator symbol can be used equally well as a 1-, 2-, 3-, etc.-
  1381. place operator.
  1382. To give a meaning to an operator symbol, or express some of its
  1383. properties, LET statements can be used, or the operator can be given a
  1384. definition as a procedure (qv).
  1385. If the user forgets to declare an identifier as an operator, the system
  1386. will prompt the user to do so in interactive mode, or do it automatically
  1387. in non-interactive mode. A diagnostic message will also be printed if an
  1388. identifier is declared operator more than once.
  1389. 6.7.1 Declaring new Infix Operators _________ ___ _____ _________
  1390. The advanced user can add new infix operators by using the declarations
  1391. INFIX and PRECEDENCE.
  1392. 6-8
  1393. e.g. INFIX MM;
  1394. PRECEDENCE MM,-;
  1395. The declaration INFIX MM would allow one to use the symbol MM as an infix
  1396. operator:
  1397. A MM B instead of MM(A,B).
  1398. The declaration PRECEDENCE MM,- says that MM should be inserted into the
  1399. infix operator precedence list (qv) just AFTER the - operator. This gives
  1400. it higher precedence than - and lower precedence than * . Thus
  1401. A - B MM C - D means A - (B MM C) - D,
  1402. while A * B MM C * D means (A * B) MM (C * D).
  1403. Both infix and prefix operators have no transformation properties unless
  1404. LET statements or procedure declarations are used to assign a meaning.
  1405. We should note here that infix operators so defined are always binary:
  1406. A MM B MM C means (A MM B) MM C.
  1407. 6.8 Linear Operators ______ _________
  1408. An operator can be declared to be linear in its first argument over powers
  1409. of its second argument. If an operator F is so declared, F of any sum is
  1410. broken up into sums of F's, and any factors which are not powers of the
  1411. variable are taken outside. This means that F must have (at least) two
  1412. arguments. In addition, the second argument must be an identifier (or more
  1413. generally a kernel), not an expression.
  1414. Example:
  1415. If F were declared linear, then
  1416. F(A*X**5 + B*X + C,X) ==> A*F(X**5,X) + B*F(X,X) + C*F(1,X).
  1417. More precisely, not only will the variable and its powers remain within the
  1418. scope of the F operator, but so will any variable and its powers which had
  1419. been declared to DEPEND (qv) on the prescribed variable; and so would any
  1420. expression which contains that variable or a dependent variable on any
  1421. level : e.g. COS(SIN(X)).
  1422. To declare F and G to be linear operators, use:
  1423. LINEAR F,G;
  1424. (If F or G were previously declared OPERATOR, there is a warning message,
  1425. but the LINEAR declaration is accepted.)
  1426. The analysis is done of the first argument with respect to the second; any
  1427. other arguments are ignored. It uses the following rules of evaluation:
  1428. 6-9
  1429. F(0) => 0
  1430. F(-Y,X) => -F(Y,X)
  1431. F(Y+Z,X) => F(Y,X)+F(Z,X)
  1432. F(Y*Z,X) => Z*F(Y,X) if Z does not depend on X.
  1433. F(Y/Z,X) => F(Y,X)/Z if Z does not depend on X.
  1434. To summarize, Y "depends" on the indeterminate X in the above if either of
  1435. the following hold:
  1436. 1) Y is an expression which contains X at any level as a variable,
  1437. e.g.: COS(SIN(X))
  1438. 2) Any variable in the expression Y has been declared dependent on
  1439. X by use of the declaration DEPEND (qv).
  1440. The use of such linear operators can be seen in the paper Fox, J.A. and A.
  1441. C. Hearn, "Analytic Computation of Some Integrals in Fourth Order Quantum
  1442. Electrodynamics" Journ. Comp. Phys. 14 (1974) 301-317, which contains a
  1443. complete listing of a program for definite integration of some expressions
  1444. which arise in fourth order quantum electrodynamics.
  1445. 6.9 Non-Commuting Operators _____________ _________
  1446. An operator can be declared to be non-commutative under multiplication by
  1447. the declaration NONCOM.
  1448. Example: If the declaration NONCOM U,V; is given, then the expressions
  1449. U(X)*U(Y)-U(Y)*U(X) and U(X)*V(Y)-V(Y)*U(X) will remain unchanged on
  1450. simplification, and in particular will not simplify to zero.
  1451. Note that it is the operator (U and V in the above example) and not the
  1452. variable that has the non-commutative property.
  1453. The LET statement may be used to introduce rules of evaluation for such
  1454. operators. In particular, the boolean operator ORDP is useful for
  1455. introducing an ordering on such expressions.
  1456. Example: The rule
  1457. FOR ALL X,Y SUCH THAT X NEQ Y AND ORDP(X,Y)
  1458. LET U(X)*U(Y)= U(Y)*U(X)+COMM(X,Y);
  1459. would introduce the commutator of U(X) and U(Y) for all X and Y. Note that
  1460. since ORDP(X,X) is True, the equality check is necessary in the degenerate
  1461. case to avoid a circular loop in the rule.
  1462. 6-10
  1463. 6.10 Creating and Removing Variable Dependency ________ ___ ________ ________ __________
  1464. There are several facilities in REDUCE, such as the differentiation
  1465. operator and the linear operator facility, which can utilize knowledge of
  1466. the dependency between various variables, or kernels (qv). Such dependency
  1467. may be expressed by the command DEPEND. DEPEND takes an arbitrary number
  1468. of arguments and sets up a dependency of the first argument on the
  1469. remaining arguments.
  1470. e.g.: DEPEND X, Y, Z;
  1471. says that X is dependent on both Y and Z.
  1472. DEPEND Z,COS(X),Y;
  1473. says that Z is dependent on COS(X) and Y.
  1474. Dependencies introduced by DEPEND can be removed by the command NODEPEND.
  1475. The arguments of this are the same as for DEPEND.
  1476. e.g., given the above dependencies,
  1477. NODEPEND Z,COS(X);
  1478. says that Z is no longer dependent on COS(X), although it remains
  1479. dependent on Y.
  1480. 7-1
  1481. 7. DISPLAY AND STRUCTURING OF EXPRESSIONS _______ ___ ___________ __ ___________
  1482. In this section, we consider a variety of commands and operators which
  1483. permit the user to obtain various parts of algebraic expressions and also
  1484. display their structure in a variety of forms. Also presented are some
  1485. additional concepts in the REDUCE design that help the user gain a better
  1486. understanding of the structure of the system.
  1487. 7.1 Kernels _______
  1488. REDUCE is designed so that each operator in the system has an evaluation
  1489. (or simplification) function associated with it which transforms the
  1490. expression into an internal canonical form. This form, which bears little
  1491. resemblance to the original expression, is described in detail in Hearn, A.
  1492. C., "REDUCE 2, A System and Language for Algebraic Manipulation," Proc. of
  1493. Second Symposium on Symbolic and Algebraic Manipulation, ACM, New York
  1494. (1971) 128-133.
  1495. The evaluation function may transform its arguments in one of two
  1496. alternative ways. First, it may convert the expression into other
  1497. operators in the system, leaving no functions of the original operator for
  1498. further manipulation. This is in a sense true of the evaluation functions
  1499. associated with the operators +, * and / , for example, because the
  1500. canonical form does not include these operators explicitly. It is also
  1501. true of an operator such as the determinant operator DET (qv) because the
  1502. relevant evaluation function calculates the appropriate determinant, and
  1503. the operator DET no longer appears. On the other hand, the evaluation
  1504. process may leave some residual functions of the relevant operator. For
  1505. example, with the operator COS, a residual expression like COS(X) may
  1506. remain after evaluation unless a rule for the reduction of cosines into
  1507. exponentials, for example, were introduced. These residual functions of an
  1508. operator are termed kernels and are stored uniquely like variables.
  1509. Subsequently, the kernel is carried through the calculation as a variable
  1510. unless transformations are introduced for the operator at a later stage.
  1511. In cases where the arguments of the kernel operators may be reordered, the
  1512. system puts them in a canonical order, based on an internal intrinsic
  1513. ordering of the variables. However, some commands allow arguments in the
  1514. form of kernels, and the user has no way of telling what internal order the
  1515. system will assign to these arguments. To resolve this difficulty, we
  1516. introduce the notion of a kernel form as an expression which transforms to
  1517. a kernel on evaluation.
  1518. Examples of kernel forms are:
  1519. A
  1520. COS (X*Y)
  1521. LOG (SIN (X))
  1522. whereas
  1523. 7-2
  1524. A*B
  1525. (A+B)**4
  1526. are not.
  1527. We see that kernel forms can usually be used as generalized variables, and
  1528. most algebraic properties associated with variables may also be associated
  1529. with kernels.
  1530. 7.2 The Expression Workspace ___ __________ _________
  1531. Several mechanisms are available for saving and retrieving previously
  1532. evaluated expressions. The simplest of these refers to the last algebraic
  1533. expression simplified. When an assignment of an algebraic expression is
  1534. made, or an expression is evaluated at the top level, (i.e., not inside a
  1535. compound statement or procedure) the results of the evaluation are
  1536. automatically saved in a variable WS which we shall refer to as the
  1537. workspace. (More precisely, the expression is assigned to the variable WS
  1538. which is then available for further manipulation.)
  1539. Example:
  1540. If we evaluate the expression (X+Y)**2 at the top level and next wish to
  1541. differentiate it with respect to Y, we can simply say
  1542. DF(WS,Y);
  1543. to get the desired answer.
  1544. If the user wishes to assign the workspace to a variable or expression for
  1545. later use, the SAVEAS statement can be used. It has the syntax
  1546. SAVEAS <expression>
  1547. e.g. after the differentiation in the last example, the workspace holds
  1548. the expression 2*X+2*Y. If we wish to assign this to the variable Z we can
  1549. now say
  1550. SAVEAS Z;
  1551. If the user wishes to save the expression in a form that allows him to use
  1552. some of its variables as arbitrary parameters, the FOR ALL (qv) command
  1553. can be used.
  1554. Example:
  1555. FOR ALL X SAVEAS H(X);
  1556. with the above expression would mean that H(Z) evaluates to 2*Y+2*Z.
  1557. A further method for referencing more than the last expression is described
  1558. in the section on interactive use of REDUCE.
  1559. 7-3
  1560. 7.3 Output of Expressions ______ __ ___________
  1561. A considerable degree of flexibility is available in REDUCE in the printing
  1562. of expressions generated during calculations. No explicit format
  1563. statements are supplied, as these prove to be of little use in algebraic
  1564. calculations, where the size of output or its composition is not generally
  1565. known in advance. Instead, REDUCE provides a series of mode options to the
  1566. user which should enable him to produce his output in a comprehensible and
  1567. possibly pleasing form.
  1568. The most extreme option offered is to suppress the output entirely from
  1569. any top level evaluation. This is accomplished by turning off the switch
  1570. OUTPUT which is normally on. It is useful for limiting output when loading
  1571. large files or producing "clean" output from the prettyprint programs (qv).
  1572. In most circumstances, however, we wish to view the output, so we need to
  1573. know how to format it appropriately. As we mentioned earlier, an algebraic
  1574. expression is normally printed in an expanded form, filling the whole
  1575. output line with terms. Certain output declarations, however, can be used
  1576. to affect this format. To begin with, we look at an operator for changing
  1577. the length of the output line.
  1578. 7.3.1 LINELENGTH __________
  1579. This operator is used with the syntax
  1580. LINELENGTH(NUM:integer):integer,
  1581. and sets the output line length to the integer NUM. It returns the
  1582. previous output line length (so that it can be stored for later resetting
  1583. of the output line if needed).
  1584. 7.3.2 Output Declarations ______ ____________
  1585. We now describe a number of switches and declarations which are available
  1586. for controlling output formats. It should be noted, however, that the
  1587. transformation of large expressions to produce these varied output formats
  1588. can take a lot of computing time and space. If a user wishes to speed up
  1589. the printing of his output in such cases, he can turn off the switch PRI.
  1590. If this is done, then output is produced in one fixed format, which
  1591. basically reflects the internal form of the expression, and none of the
  1592. options below apply. PRI is normally on.
  1593. With PRI on, the output declarations and switches available are as
  1594. follows:
  1595. 7-4
  1596. 7.3.2.1 ORDER _____
  1597. The declaration ORDER may be used to order variables on output. The syntax
  1598. is:
  1599. ORDER V1,...VN;
  1600. where the Vi are kernels (qv). Thus,
  1601. ORDER X,Y,Z;
  1602. orders X ahead of Y, Y ahead of Z and all three ahead of other variables
  1603. not given an order. ORDER NIL; resets the output order to the system
  1604. default. The order of variables may be changed by further calls of ORDER,
  1605. but then the reordered variables would have an order lower than those in
  1606. earlier ORDER calls. Thus,
  1607. ORDER X,Y,Z;
  1608. ORDER Y,X;
  1609. would order Z ahead of Y and X. The default ordering is implementation
  1610. dependent, but is usually alphabetic.
  1611. 7.3.2.2 FACTOR ______
  1612. This declaration takes a list of identifiers or kernels (qv) as argument.
  1613. FACTOR is not a factoring command (use FACTORIZE or the FACTOR switch (qv)
  1614. for this purpose); rather it is a separation command. All terms involving
  1615. fixed powers of the declared expressions are printed as a product of the
  1616. fixed powers and a sum of the rest of the terms.
  1617. All expressions involving a given prefix operator may also be factored by
  1618. putting the operator name in the list of factored identifiers.
  1619. e.g. FACTOR X,COS,SIN(X);
  1620. causes all powers of X and SIN(X) and all functions of COS to be factored.
  1621. The declaration REMFAC V1,...,Vn; removes the factoring flag from the
  1622. expressions V1 through Vn.
  1623. 7.3.3 Output Control Switches ______ _______ ________
  1624. In addition to these declarations, the form of the output can be modified
  1625. by switching various output control switches using the declarations ON and
  1626. OFF. We shall illustrate the use of these switches by an example, namely
  1627. the printing of the expression
  1628. X**2*(Y**2+2*Y)+X*(Y**2+Z)/(2*A).
  1629. 7-5
  1630. The relevant switches are as follows:
  1631. 7.3.3.1 ALLFAC ______
  1632. This switch will cause the system to search the whole expression, or any
  1633. sub-expression enclosed in parentheses, for simple multiplicative factors
  1634. and print them outside the parentheses. Thus our expression with ALLFAC
  1635. off will print as
  1636. 2 2 2 2
  1637. (2*X *Y *A + 4*X *Y*A + X*Y + X*Z)/(2*A)
  1638. and with ALLFAC on as
  1639. 2 2
  1640. X*(2*X*Y *A + 4*X*Y*A + Y + Z)/(2*A)
  1641. ALLFAC is normally on, and is on in the following examples, except where
  1642. otherwise stated.
  1643. 7.3.3.2 DIV ___
  1644. This switch makes the system search the denominator of an expression for
  1645. simple factors which it divides into the numerator, so that rational
  1646. fractions and negative powers appear in the output. With DIV on, our
  1647. expression would print as
  1648. 2 2 (-1) (-1)
  1649. X*(X*Y + 2*X*Y + 1/2*Y *A + 1/2*A *Z)
  1650. DIV is normally off.
  1651. 7.3.3.3 LIST ____
  1652. This switch causes the system to print each term in any sum on a separate
  1653. line. With LIST on, our expression prints as
  1654. 2
  1655. X*(2*X*Y *A
  1656. + 4*X*Y*A
  1657. 2
  1658. + Y
  1659. + Z)/(2*A)
  1660. LIST is normally off.
  1661. 7-6
  1662. 7.3.3.4 RAT ___
  1663. This switch is only useful with expressions in which variables are
  1664. factored with FACTOR. With this mode, the overall denominator of the
  1665. expression is printed with each factored sub-expression. We assume a prior
  1666. declaration FACTOR X; in the following output. We first print the
  1667. expression with RAT off:
  1668. 2 2
  1669. (2*X *Y*A*(Y + 2) + X*(Y + Z))/(2*A)
  1670. With RAT on the output becomes:
  1671. 2 2
  1672. X *Y*(Y + 2) + X*(Y + Z)/(2*A)
  1673. RAT is normally off.
  1674. Next, if we leave X factored, and turn on both DIV and RAT, the result
  1675. becomes
  1676. 2 (-1) 2
  1677. X *Y*(Y + 2) + 1/2*X*A *(Y + Z)
  1678. Finally, with X factored, RAT on and ALLFAC off we retrieve the original
  1679. structure
  1680. 2 2 2
  1681. X *(Y + 2*Y) + X*(Y + Z)/(2*A)
  1682. 7.3.4 WRITE Command _____ _______
  1683. In simple cases no explicit output command is necessary in REDUCE, since
  1684. the value of any expression is automatically printed if a semicolon is
  1685. used as a delimiter. There are, however, several situations in which such
  1686. a command is useful.
  1687. In a FOR, WHILE, or REPEAT statement it may be desired to output something
  1688. each time the statement within the loop construct is repeated.
  1689. It may be desired for a procedure to output intermediate results or other
  1690. information while it is running. It may be desired to have results labeled
  1691. in special ways, especially if the output is directed to a file or device
  1692. other than the terminal.
  1693. The WRITE command consists of the word WRITE followed by one or more items
  1694. separated by commas, and followed by a terminator. There are three kinds
  1695. of items which can be used:
  1696. 1) Expressions (including variables and constants). The expression is
  1697. evaluated, and the result is printed out.
  1698. 7-7
  1699. 2) Assignments. The expression on the right side of the := operator is
  1700. evaluated, and is assigned to the variable on the left; then the symbol on
  1701. the left is printed, followed by a ":=", followed by the value of the
  1702. expression on the right -- almost exactly the way an assignment followed
  1703. by a semicolon prints out normally. (The difference is that if the WRITE
  1704. is in a FOR statement and the left-hand side of the assignment is an array
  1705. position or something similar containing the variable of the FOR
  1706. iteration, then the value of that variable is inserted in the printout.)
  1707. 3) Arbitrary strings of characters, preceded and followed by double-quote
  1708. (") marks.
  1709. The items specified by a single WRITE statement print side by side on one
  1710. line. (The line is broken automatically if it is too long.) Strings print
  1711. exactly as quoted.
  1712. The print line is closed at the end of a WRITE command evaluation.
  1713. Therefore the command WRITE ""; (specifying nothing to be printed except
  1714. the empty string) causes a line to be skipped.
  1715. Examples:
  1716. (1) If A is X+5, B is itself, C is 123, M is an array, and Q=3, then
  1717. WRITE M(Q):=A," ",B/C," THANK YOU"
  1718. will set M(3) to X+5 and prints
  1719. M(Q) := X + 5 B/123 THANK YOU
  1720. The only reason there are blanks between the 5 and B, and the 3 and T, are
  1721. the blanks in the quoted strings.
  1722. (2) To print a table of the squares of the integers from 1 to 20:
  1723. FOR I:=1:20 DO WRITE I," ",I**2;
  1724. (3) To print a table of the squares of the integers from 1 to 20, and at
  1725. the same time store them in positions 1 to 20 of an array A:
  1726. FOR I:=1:20 DO <<A(I):=I**2; WRITE I," ",A(I)>>;
  1727. This will give us two columns of numbers. If we had used
  1728. FOR I:=1:20 DO WRITE I," ",A(I):=I**2;
  1729. we would also get "A(i) := " repeated on each line.
  1730. (4) The following more complete example calculates the famous f and g
  1731. series, first reported in Sconzo, P., LeSchack, A. R., and Tobey, R.,
  1732. "Symbolic Computation of f and g Series by Computer", Astronomical Journal
  1733. 70 (May 1965).
  1734. 7-8
  1735. X1:= -SIG*(MU+2*EPS)$
  1736. X2:= EPS-2*SIG**2$
  1737. X3:= -3*MU*SIG$
  1738. F:= 1$
  1739. G:= 0$
  1740. FOR I:= 1 STEP 1 UNTIL 10 DO BEGIN
  1741. F1:= -MU*G + X1*DF(F,EPS) + X2*DF(F,SIG) + X3*DF(F,MU);
  1742. WRITE "F(",I,") := ",F1;
  1743. G1:= F + X1*DF(G,EPS) + X2*DF(G,SIG) + X3*DF(G,MU);
  1744. WRITE "G(",I,") := ",G1;
  1745. F:=F1$
  1746. G:=G1$
  1747. END;
  1748. A portion of the output, to illustrate the printout from the WRITE
  1749. command, is as follows:
  1750. ... <prior output> ...
  1751. 2
  1752. F(4) := MU*(3*EPS - 15*SIG + MU)
  1753. G(4) := 6*SIG*MU
  1754. 2
  1755. F(5) := 15*SIG*MU*( - 3*EPS + 7*SIG - MU)
  1756. 2
  1757. G(5) := MU*(9*EPS - 45*SIG + MU)
  1758. ... <more output> ...
  1759. 7.3.5 Suppression of Zeros ___________ __ _____
  1760. It is sometimes annoying to have zero assignments (i.e. assignments of the
  1761. form <expression> := 0) printed, especially in printing large arrays with
  1762. many zero elements. The output from such assignments can be suppressed by
  1763. turning on the switch NERO.
  1764. 7.3.6 FORTRAN Style Output of Expressions _______ _____ ______ __ ___________
  1765. It is naturally possible to evaluate expressions numerically in REDUCE by
  1766. giving all variables and sub-expressions numerical values. However, as we
  1767. pointed out elsewhere the user must declare real arithmetical operation by
  1768. turning on the switches FLOAT or BIGFLOAT. However, it should be
  1769. remembered that arithmetic in REDUCE is not particularly fast, since
  1770. results are interpreted rather than evaluated in a compiled form. The user
  1771. with a large amount of numerical computation after all necessary algebraic
  1772. manipulations have been performed is therefore well advised to perform
  1773. these calculations in a FORTRAN or similar system. For this purpose,
  1774. REDUCE offers facilities for users to produce FORTRAN compatible files for
  1775. 7-9
  1776. numerical processing.
  1777. First, when the switch FORT is on, the system will print expressions in a
  1778. FORTRAN notation. Expressions begin in column 7. If an expression extends
  1779. over one line, a continuation mark (.) followed by a blank appears on
  1780. subsequent cards. After a certain number of lines have been produced
  1781. (according to the value of the variable *CARDNO (qv)), a new expression is
  1782. started. If the expression printed arises from an assignment to a
  1783. variable, the variable is printed as the name of the expression. Otherwise
  1784. the expression is given the default name ANS. An error occurs if
  1785. identifiers or numbers are outside the bounds permitted by FORTRAN.
  1786. A second option is to use the WRITE command to produce other programs.
  1787. Example:
  1788. The following REDUCE statements
  1789. ON FORT;
  1790. OUT FORFIL;
  1791. WRITE "C THIS IS A FORTRAN PROGRAM";
  1792. WRITE " 1 FORMAT(E13.5)";
  1793. WRITE " U=1.23";
  1794. WRITE " V=2.17";
  1795. WRITE " W=5.2";
  1796. X:=(U+V+W)**11;
  1797. WRITE "C OF COURSE IT WAS FOOLISH TO EXPAND THIS EXPRESSION";
  1798. WRITE " PRINT 1,X";
  1799. WRITE " END";
  1800. SHUT FORFIL;
  1801. OFF FORT;
  1802. will generate a file FORFIL which contains:
  1803. C THIS IS A FORTRAN PROGRAM
  1804. 1 FORMAT(E13.5)
  1805. U=1.23
  1806. V=2.17
  1807. W=5.2
  1808. ANS1=1320.*U**3*V*W**7+165.*U**3*W**8+55.*U**2*V**9+495.*U
  1809. . **2*V**8*W+1980.*U**2*V**7*W**2+4620.*U**2*V**6*W**3+
  1810. . 6930.*U**2*V**5*W**4+6930.*U**2*V**4*W**5+4620.*U**2*V**3*
  1811. . W**6+1980.*U**2*V**2*W**7+495.*U**2*V*W**8+55.*U**2*W**9+
  1812. . 11.*U*V**10+110.*U*V**9*W+495.*U*V**8*W**2+1320.*U*V**7*W
  1813. . **3+2310.*U*V**6*W**4+2772.*U*V**5*W**5+2310.*U*V**4*W**6
  1814. . +1320.*U*V**3*W**7+495.*U*V**2*W**8+110.*U*V*W**9+11.*U*W
  1815. . **10+V**11+11.*V**10*W+55.*V**9*W**2+165.*V**8*W**3+330.*
  1816. . V**7*W**4+462.*V**6*W**5+462.*V**5*W**6+330.*V**4*W**7+
  1817. . 165.*V**3*W**8+55.*V**2*W**9+11.*V*W**10+W**11
  1818. X=U**11+11.*U**10*V+11.*U**10*W+55.*U**9*V**2+110.*U**9*V*
  1819. . W+55.*U**9*W**2+165.*U**8*V**3+495.*U**8*V**2*W+495.*U**8
  1820. . *V*W**2+165.*U**8*W**3+330.*U**7*V**4+1320.*U**7*V**3*W+
  1821. . 1980.*U**7*V**2*W**2+1320.*U**7*V*W**3+330.*U**7*W**4+462.
  1822. 7-10
  1823. . *U**6*V**5+2310.*U**6*V**4*W+4620.*U**6*V**3*W**2+4620.*U
  1824. . **6*V**2*W**3+2310.*U**6*V*W**4+462.*U**6*W**5+462.*U**5*
  1825. . V**6+2772.*U**5*V**5*W+6930.*U**5*V**4*W**2+9240.*U**5*V
  1826. . **3*W**3+6930.*U**5*V**2*W**4+2772.*U**5*V*W**5+462.*U**5
  1827. . *W**6+330.*U**4*V**7+2310.*U**4*V**6*W+6930.*U**4*V**5*W
  1828. . **2+11550.*U**4*V**4*W**3+11550.*U**4*V**3*W**4+6930.*U**
  1829. . 4*V**2*W**5+2310.*U**4*V*W**6+330.*U**4*W**7+165.*U**3*V
  1830. . **8+1320.*U**3*V**7*W+4620.*U**3*V**6*W**2+9240.*U**3*V**
  1831. . 5*W**3+11550.*U**3*V**4*W**4+9240.*U**3*V**3*W**5+4620.*U
  1832. . **3*V**2*W**6+ANS1
  1833. C OF COURSE IT WAS FOOLISH TO EXPAND THIS EXPRESSION
  1834. PRINT 1,X
  1835. END
  1836. 7.3.6.1 FORTRAN Output Options _______ ______ _______
  1837. There are a number of methods available to change the default format of the
  1838. FORTRAN output.
  1839. The breakup of the expression into subparts is such that the number of
  1840. continuation lines produced is less than a given number. This number can
  1841. be modified by the assignment
  1842. CARDNO!* := <number>;
  1843. where <number> is the TOTAL number of cards allowed in a statement.
  1844. CARDNO!* is initially set to 20.
  1845. The width of the output expression is also adjustable by the assignment
  1846. FORTWIDTH!* := <integer>;
  1847. which sets the total width of a given line to <integer>. The initial
  1848. FORTRAN output width is 70.
  1849. REDUCE automatically inserts a decimal point after each isolated integer
  1850. coefficient in a FORTRAN expression (so that, for example, 4 becomes 4.).
  1851. To prevent this, set the PERIOD mode switch to OFF.
  1852. Finally, the default name ANS assigned to an unnamed expression and its
  1853. subparts can be changed by the operator VARNAME. This takes a single
  1854. identifier as argument, which then replaces ANS as the expression name.
  1855. The value of VARNAME is its argument.
  1856. 7.3.7 Saving Expressions for Later Use as Input ______ ___________ ___ _____ ___ __ _____
  1857. It is often useful to save an expression on an external file for use later
  1858. as input in further calculations. The commands for opening and closing
  1859. output files are explained elsewhere. However, we see in the examples on
  1860. output of expressions that the standard 'natural' method of printing
  1861. expressions in not compatible with the input syntax. So to print the
  1862. 7-11
  1863. expression in an input compatible form we must inhibit this natural style
  1864. by turning off the switch NAT. If this is done, a dollar sign will also be
  1865. printed at the end of the expression.
  1866. Example:
  1867. The following sequence of commands
  1868. OFF NAT; OUT OUT; X := (Y+Z)**2; WRITE "END"; SHUT OUT; ON NAT;
  1869. will generate a file OUT which contains
  1870. X := Y**2 + 2*Y*Z + Z**2$
  1871. END$
  1872. 7.3.8 Displaying Expression Structure __________ __________ _________
  1873. In those cases where the final result has a complicated form, it is often
  1874. convenient to display the skeletal structure of the answer. The operator
  1875. STRUCTR, which takes a single expression as argument, will do this for
  1876. you. Its syntax is:
  1877. STRUCTR(EXPRN:algebraic):EXPRN;
  1878. The answer is printed effectively as a tree, in which the subparts are
  1879. laid out with auxiliary names prefixed by the root ANS. This root may be
  1880. changed by the operator VARNAME (qv).
  1881. Example:
  1882. Let us suppose that the workspace contains ((A+B)**2+C)**3+D. Then the
  1883. input STRUCTR WS; will (with EXP off) result in the output:
  1884. ANS3
  1885. WHERE
  1886. 3
  1887. ANS3 := ANS2 + D
  1888. 2
  1889. ANS2 := ANS1 + C
  1890. ANS1 := A + B
  1891. The workspace remains unchanged after this operation, since the
  1892. expressions are only displayed and not stored in this form. However, the
  1893. PART operator (qv) can be used to retrieve the appropriate parts of the
  1894. expression. For example, to get the term corresponding to ANS2 in the
  1895. above, one could say:
  1896. PART(WS,1,1);
  1897. 7-12
  1898. If FORT is on, then the results are printed in the reverse order; the
  1899. algorithm in fact guaranteeing that no sub-expression will be referenced
  1900. before it is defined.
  1901. 7.4 Changing the Internal Order of Variables ________ ___ ________ _____ __ _________
  1902. In its default state, REDUCE uses a specific order for variables (more
  1903. precisely kernels) in expressions during simplification, However, it is
  1904. possible for the user to change this internal order by means of the
  1905. declaration KORDER. The syntax for this is:
  1906. KORDER V1,...,Vn;
  1907. where the Vi are kernels. With this declaration, the Vi are ordered
  1908. internally ahead of any other kernels in the system. V1 has the highest
  1909. order, V2 the next highest, and so on. A further call of KORDER replaces a
  1910. previous one. KORDER NIL; resets the internal order to that used by the
  1911. system.
  1912. Unlike the ORDER declaration (qv), which has a purely cosmetic effect on
  1913. the way results are printed, the use of KORDER can have potentially
  1914. significant effects on the space and time associated with a calculation.
  1915. In critical cases then, the user can experiment with the ordering of the
  1916. variables used to determine the optimum set for a given problem.
  1917. 7.5 Obtaining Parts of Algebraic Expressions _________ _____ __ _________ ___________
  1918. There are many occasions where it is desirable to obtain a specific part
  1919. of an expression, or even change such a part to another expression. A
  1920. number of operators are available in REDUCE for this purpose, and will be
  1921. described in this section. In addition, operators for obtaining specific
  1922. parts of polynomials and rational functions (such as a denominator) are
  1923. described in another section.
  1924. 7.5.1 COEFF _____
  1925. Syntax: COEFF(EXPRN:polynomial,VAR:kernel,ID:identifier).
  1926. COEFF is an operator which partitions EXPRN into its various coefficients
  1927. with respect to VAR and stores them in ID. If ID has been previously
  1928. declared a single dimensioned array, the size of the array is redefined to
  1929. match the highest power in EXPRN and the ith array element is assigned to
  1930. the coefficient (zero or non zero) of the ith power of VAR in EXPRN, up to
  1931. the highest power. An error results if EXPRN is not a polynomial.
  1932. If ID is not an array name, a variable with name ID<power> is assigned to
  1933. the coefficient of that power. Only NON ZERO powers are set in this
  1934. manner, and a message is printed to inform the user of the variables set.
  1935. Example:
  1936. 7-13
  1937. ARRAY X(2);
  1938. COEFF((Y**2+Z)**3,Y,X);
  1939. will cause X to be redefined as a seven-dimensioned array (i.e., equivalent
  1940. to saying ARRAY X(6)) and then X(6) set to 1, X(5) to 0, X(4) to 3*Z and so
  1941. on until X(0), which would be set to Z**3.
  1942. On the other hand, if we said
  1943. COEFF((Y**2+Z)**3,Y,W);
  1944. we would get a message
  1945. W6 W4 W2 W0 are non zero
  1946. and W6 would be set to 1, W4 to 3*Z and so on.
  1947. It is also possible to place the various coefficients generated by COEFF in
  1948. a particular column of a multi-dimensional array. To do this, ID in the
  1949. above symbols should be replaced by an array expression in which the
  1950. relevant array column is indicated by an asterisk. In this case, the array
  1951. size is not changed so an error occurs if the array is too small to take
  1952. all powers, and elements corresponding to missing powers are set to zero up
  1953. to the maximum size of the array column.
  1954. For example,
  1955. ARRAY XX(7,7,7);
  1956. COEFF((Y**2+Z)**3,Y,XX(5,*,7));
  1957. will cause XX(5,7,7) to be set to 0, XX(5,6,7) to 1, XX(5,5,7) to 0 and so
  1958. on.
  1959. The value of COEFF is the highest non-zero power encountered in the
  1960. expression. Thus in the above examples it would be 6. In addition, the
  1961. variables HIPOW!* and LOWPOW!* are set to the highest and lowest non-zero
  1962. power found in EXPRN during the evaluation. If EXPRN is zero, then HIPOW!*
  1963. and LOWPOW!* are both set to zero.
  1964. 7.5.2 PART ____
  1965. Syntax: PART(EXPRN:algebraic[,INTEXP:integer]).
  1966. This operator works on the form of the expression as printed OR AS IT WOULD
  1967. HAVE BEEN PRINTED AT THAT POINT IN THE CALCULATION bearing in mind all the
  1968. relevant switch settings at that point. The reader therefore needs some
  1969. familiarity with the way that expressions are represented in prefix form in
  1970. REDUCE to use these operators effectively. Furthermore, it is assumed that
  1971. PRI is ON at that point in the calculation. The reason for this is that
  1972. with PRI off, an expression is printed by walking the tree representing the
  1973. expression internally. To save space, it is never actually transformed
  1974. 7-14
  1975. into the equivalent prefix expression as occurs when PRI is on. However,
  1976. the operations on polynomials described elsewhere can be equally well used
  1977. in this case to obtain the relevant parts.
  1978. The evaluation proceeds recursively down the integer expression list. In
  1979. other words,
  1980. PART(<expression>,<integer1>,<integer2>)
  1981. ==> PART(PART(<expression>,<integer1>),<integer2>)
  1982. and so on, and
  1983. PART(<expression>) ==> <expression>.
  1984. INTEXP can be any expression that evaluates to an integer. If the integer
  1985. is positive, then that term of the expression is found. If the integer is
  1986. 0, the operator is returned. Finally, if the integer is negative, the
  1987. counting is from the tail of the expression rather than the head.
  1988. For example, if the expression A+B is printed as A+B (i.e., the ordering of
  1989. the variables is alphabetical), then
  1990. PART(A+B,2) ==> B
  1991. PART(A+B,-1) ==> B
  1992. and
  1993. PART(A+B,0) ==> PLUS.
  1994. An operator ARGLENGTH is available to determine the number of arguments of
  1995. the top level operator in an expression. If the expression does not
  1996. contain a top level operator, then -1 is returned. For example,
  1997. ARGLENGTH(A+B+C) ==> 3
  1998. ARGLENGTH(F()) ==> 0
  1999. ARGLENGTH(A) ==> -1.
  2000. 7.5.3 Changing Parts of Expressions ________ _____ __ ___________
  2001. PART may also be used to change a given part of an expression. In this case,
  2002. the PART construct appears on the left-hand-side of an assignment statement,
  2003. and the expression to replace the given part on the right-hand-side.
  2004. For example, with the normal settings of REDUCE's switches:
  2005. PART(A+B,2) := C; ==> A+C
  2006. PART(A+B,0) := -; ==> A-B.
  2007. 8-1
  2008. 8. POLYNOMIAL AND RATIONAL FUNCTION OPERATIONS __________ ___ ________ ________ __________
  2009. Many operations in computer algebra are concerned with polynomials and
  2010. rational functions. In this section, we review some of the switches and
  2011. operators available for this purpose. These are in addition to those that
  2012. work on general expressions (such as DF and INT) described elsewhere. In
  2013. the case of operators, the arguments are first simplified before the
  2014. operations are applied. In addition, they operate only on arguments of
  2015. prescribed types, and produce a type mismatch error if given arguments which
  2016. cannot be interpreted in the required mode with the current switch settings.
  2017. For example, if an argument is required to be a kernel and A/2 is used (with
  2018. no other rules for A), an error
  2019. A/2 invalid as kernel
  2020. will result.
  2021. With the exception of those that select various parts of a polynomial or
  2022. rational function, these operations have potentially significant effects on
  2023. the space and time associated with a given calculation. The user should
  2024. therefore experiment with their use in a given calculation in order to
  2025. determine the optimum set for a given problem.
  2026. One such operation provided by the system is an operator TERMS that returns
  2027. the number of top level terms in the numerator of its argument. For example,
  2028. TERMS ((A+B+C)**3/(C+D));
  2029. has the value 10. To get the number of terms in the denominator, one would
  2030. first select the denominator by the operator DEN (qv) and then call terms,
  2031. as in
  2032. TERMS DEN ((A+B+C)**3/(C+D));
  2033. Other operations currently supported, the relevant switches and operators,
  2034. and the required argument and value modes of the latter, follow.
  2035. 8.1 Controlling the Expansion of Expressions ___________ ___ _________ __ ___________
  2036. The switch EXP controls the expansion of expressions. If it is off, no
  2037. expansion of powers or products of expressions occurs. Users should note
  2038. however that in this case results come out in a normal but not necessarily
  2039. canonical form. This means that zero expressions simplify to zero, but
  2040. that two equivalent expressions need not necessarily simplify to the same
  2041. form.
  2042. Example:
  2043. With EXP on, the two expressions (A+B)*(A+2*B) and A**2+3*A*B+2*B**2 will
  2044. both simplify to the latter form. With EXP off, they would remain
  2045. unchanged (unless the complete factoring option were in force).
  2046. 8-2
  2047. EXP is normally on.
  2048. Several operators that expect a polynomial as an argument behave
  2049. differently when EXP is off, since there is often only one term at the top
  2050. level. For example, with EXP off
  2051. TERMS ((A+B+C)**3/(C+D));
  2052. returns the value 1.
  2053. 8.2 Factorization of Polynomials _____________ __ ___________
  2054. REDUCE is capable of factorizing univariate and multivariate polynomials
  2055. that have integer coefficients, finding all factors that also have integer
  2056. coefficients. The easiest way to use this facility is to turn on the
  2057. switch FACTOR, which causes all expressions to be output in a factored
  2058. form. For example, with FACTOR on, the expression A**2-B**2 is returned as
  2059. (A+B)*(A-B).
  2060. It is also possible to factorize a given expression explicitly. The
  2061. operator FACTORIZE that invokes this facility generally leaves its results
  2062. in an array, returning an indication of how many factors it found. Thus to
  2063. find and display all factors of the cyclotomic polynomial x**105-1, one
  2064. could write:
  2065. ARRAY W(20); % Place for results to be put;
  2066. N := FACTORIZE(X**105-1,W); % N gets set to number of factors found;
  2067. FOR I:=0:N DO WRITE W(I); % Display results;
  2068. In the above example W(1) through W(N) get set to the proper factors of
  2069. the input polynomial and W(0) receives any purely numeric content. No
  2070. attempt is made by FACTORIZE to split this integer, but it will always be
  2071. normalized to be positive. The order in which the factors are put into the
  2072. result array is system dependent and should not be relied on. Similarly it
  2073. should be noted that any pair of individual factors can be negated without
  2074. altering their product, and that REDUCE may sometimes do that.
  2075. If the name used as a second argument to FACTORIZE has not been declared as
  2076. an array, results are left in variables. A call
  2077. FACTORIZE(X**2-A**2,ZZZ);
  2078. where ZZZ has not been mentioned before will lead to a message of the form
  2079. *** ZZZ0 ZZZ1 ZZZ2 ARE NOW NON-ZERO
  2080. and ZZZ0 will be numeric, with ZZZ0*ZZZ1*ZZZ2 = X**2-A**2. If FACTORIZE is
  2081. called without a second argument it deposits its results in variables called
  2082. FACTOR0, FACTOR1 and so on.
  2083. The factorizer works by first reducing multivariate problems to univariate
  2084. ones and then solving the univariate ones modulo small primes. It normally
  2085. 8-3
  2086. selects both evaluation points and primes using a random number generator
  2087. that should lead to different detailed behavior each time any particular
  2088. problem is tackled. If, for some reason, it is known that a certain
  2089. (probably univariate) factorization can be performed effectively with a
  2090. known prime, P say, this value of P can be handed to FACTORIZE as a third
  2091. argument. It is an error to provide a non-prime to FACTORIZE in this way,
  2092. and it is also an error to specify a prime that divides the discriminant
  2093. of the polynomial to be worked with.
  2094. When factorization of a univariate polynomial is required modulo some
  2095. prime, the form
  2096. N := PFACTORIZE(polynomial,identifier,prime);
  2097. may be used. Its behavior is analogous to FACTORIZE except that it works
  2098. modulo the given odd prime, and none of the arguments are optional.
  2099. Finally, the polynomial must be univariate, otherwise an error occurs. The
  2100. modular factors that are returned are all normalized to be monic.
  2101. The factorization module is provided with a trace facility that may be useful
  2102. as a way of monitoring progress on large problems, and of satisfying
  2103. curiosity about the internal workings of the package. The most simple use
  2104. of this is enabled by issuing the REDUCE command
  2105. ON TRFAC;
  2106. Following this, all calls to the factorizer will generate informative messages
  2107. reporting on such things as the reduction of multivariate to univariate cases,
  2108. the choice of a prime and the reconstruction of full factors from their
  2109. images. Further levels of detail in the trace are intended mainly for
  2110. system tuners and for the investigation of suspected bugs. The switch that
  2111. can be set by "ON TIMINGS;" makes it possible for one who is familiar with
  2112. the algorithms used to determine what part of the factorization code is
  2113. consuming the most resources. "ON OVERVIEW;" modifies the level of detail
  2114. presented in other forms of trace. Other forms of trace output are enabled
  2115. by directives of the form
  2116. SYMBOLIC SET!-TRACE!-FACTOR(number,filename);
  2117. where useful numbers are 1,2,3 and 100,101,... . This facility is intended to
  2118. make it possible to discover in fairly great detail what just some small
  2119. part of the code has been doing - the numbers refer mainly to depths of
  2120. recursion when the factorizer calls itself, and to the split between its
  2121. work forming and factorizing images and reconstructing full factors from
  2122. these. If NIL is used in place of a filename the trace output requested is
  2123. directed to the standard output stream. After use of this trace facility the
  2124. generated trace files should be closed by calling
  2125. SYMBOLIC CLOSE!-TRACE!-FILES();
  2126. CAUTION: The code for performing multivariate factorization is very large,
  2127. and therefore takes considerable time to load. As a result, there is some
  2128. delay when the factorizer is first used while the code is being loaded.
  2129. 8-4
  2130. 8.3 Cancellation of Common Factors ____________ __ ______ _______
  2131. Facilities are available in REDUCE for cancelling common factors in the
  2132. numerators and denominators of expressions, at the option of the user. The
  2133. system will perform this greatest common divisor computation if the switch
  2134. GCD is on.
  2135. A check is automatically made, however, for common variable and numerical
  2136. products in the numerators and denominators of expressions, and the
  2137. appropriate cancellations made.
  2138. When GCD is on, and EXP is off, a check is made for square free factors in
  2139. an expression. This includes separating out and independently checking the
  2140. content of a given polynomial where appropriate. (For an explanation of
  2141. these terms, see Anthony C. Hearn, "Non-Modular Computation of Polynomial
  2142. GCDS Using Trial Division", Proc. EUROSAM 79, published as Lecture Notes
  2143. on Comp. Science, Springer-Verlag, Berlin, No 72 (1979) 227-239.)
  2144. Example:
  2145. With EXP off and GCD on, the polynomial A*C+A*D+B*C+B*D would be returned
  2146. as (A+B)*(C+D).
  2147. Under normal circumstances, gcd's are computed using an algorithm described
  2148. in the above paper. It is also possible in REDUCE to compute gcd's using
  2149. an alternative algorithm, called the ezgcd algorithm, that uses modular
  2150. arithmetic. The switch EZGCD, if on in addition to GCD, makes this happen.
  2151. For a description of the ezgcd algorithm, see J. Moses and D. Y. Y. Yun,
  2152. "The EZ GCD Algorithm", Proc. ACM 1973, ACM, New York (1973) 159-166.
  2153. CAUTION: The code for the ezgcd algorithm is included in the factorization
  2154. module. Consequently, there is usually a delay when it is first used while
  2155. that module is loaded. Note also that a certain amount of trace
  2156. information can be produced using the same switches as are used to control
  2157. the factorizer.
  2158. GCD is normally off.
  2159. 8.3.1 Determining the GCD of two polynomials ___________ ___ ___ __ ___ ___________
  2160. This operator, used with the syntax
  2161. GCD(EXPRN1:polynomial,EXPRN2:polynomial):polynomial,
  2162. returns the greatest common divisor of the two polynomials EXPRN1 and
  2163. EXPRN2.
  2164. Examples:
  2165. GCD(X**2+2*X+1,X**2+3*X+2) ==> X+1
  2166. GCD(2*X**2-2*Y**2,4*X+4*Y) ==> 2*X+2*Y
  2167. 8-5
  2168. GCD(X**2+Y**2,X-Y) ==> 1.
  2169. 8.4 Working with Least Common Multiples _______ ____ _____ ______ _________
  2170. Greatest common divisor calculations can often become expensive if
  2171. extensive work with large rational expressions is required. However, in
  2172. many cases, the only significant cancellations arise from the fact that
  2173. there are often common factors in the various denominators which are
  2174. combined when two rationals are added. Since these denominators tend to be
  2175. smaller and more regular in structure than the numerators, considerable
  2176. savings in both time and space can occur if a full gcd check is made when
  2177. the denominators are combined and only a partial check when numerators are
  2178. constructed. In other words, the true least common multiple of the
  2179. denominators is computed at each step. The switch LCM is available for
  2180. this purpose, and is normally on.
  2181. 8.5 Controlling Use of Common Denominators ___________ ___ __ ______ ____________
  2182. When two rational functions are added, REDUCE normally produces an
  2183. expression over a common denominator. However, if the user does not want
  2184. denominators combined, he can turn off the switch MCD which controls this
  2185. process. The latter switch is particularly useful if no greatest common
  2186. divisor calculations are desired, or excessive differentiation of rational
  2187. functions is required.
  2188. CAUTION: With MCD off, results are not guaranteed to come out in either
  2189. normal or canonical form. In other words, an expression equivalent to zero
  2190. may in fact not be simplified to zero. This option is therefore most
  2191. useful for avoiding expression swell during intermediate parts of a
  2192. calculation.
  2193. MCD is normally on.
  2194. 8.6 REMAINDER _________
  2195. Syntax: REMAINDER(EXPRN1:polynomial,EXPRN2:polynomial):polynomial.
  2196. Returns the remainder when EXPRN1 is divided by EXPRN2. This is the true
  2197. remainder based on the internal ordering of the variables, and not the
  2198. pseudo-remainder.
  2199. Examples:
  2200. REMAINDER((X+Y)*(X+2*Y),X+3*Y) ==> 2*Y**2
  2201. REMAINDER(2*X+Y,2) ==> Y.
  2202. 8-6
  2203. 8.7 RESULTANT _________
  2204. This is used with the syntax
  2205. RESULTANT(EXPRN1:polynomial,EXPRN2:polynomial,VAR:kernel):polynomial.
  2206. It computes the resultant of the two given polynomials with respect to the
  2207. given variable. The result can be identified as the determinant of a
  2208. Sylvester matrix, but can often also be thought of informally as the
  2209. result obtained when the given variable is eliminated between the two input
  2210. polynomials. If the two input polynomials have a non-trivial gcd their
  2211. resultant vanishes.
  2212. CAUTION: Since the code for resultant computations is contained in the
  2213. factorization module, there is usually a delay when it is first used while
  2214. that module is loaded.
  2215. 8.8 Obtaining Parts of Polynomials and Rational Functions _________ _____ __ ___________ ___ ________ _________
  2216. These operators select various parts of a polynomial or rational function
  2217. structure. Except for the cost of rearrangement of the structure, these
  2218. operations take very little time to perform.
  2219. 8.8.1 DEG ___
  2220. This operator is used with the syntax
  2221. DEG(EXPRN:polynomial,VAR:kernel):integer.
  2222. It returns the leading degree of the polynomial EXPRN in the variable VAR.
  2223. If VAR does not occur as a variable in EXPRN, 0 is returned.
  2224. Examples:
  2225. DEG((A+B)*(C+2*D)**2,A) ==> 1
  2226. DEG((A+B)*(C+2*D)**2,D) ==> 2
  2227. DEG((A+B)*(C+2*D)**2,E) ==> 0.
  2228. 8.8.2 DEN ___
  2229. This is used with the syntax:
  2230. DEN(EXPRN:rational):polynomial.
  2231. It returns the denominator of the rational expression EXPRN. If EXPRN is a
  2232. polynomial, 1 is returned.
  2233. Examples:
  2234. 8-7
  2235. DEN(X/Y**2) ==> Y**2
  2236. DEN(100/6) ==> 3
  2237. [since 100/6 is first simplified to 50/3]
  2238. DEN(A/4+B/6) ==> 12
  2239. DEN(A+B) ==> 1
  2240. 8.8.3 LCOF ____
  2241. LCOF is used with the syntax
  2242. LCOF(EXPRN:polynomial,VAR:kernel):polynomial.
  2243. It returns the leading coefficient of the polynomial EXPRN in the variable
  2244. VAR. If VAR does not occur as a variable in EXPRN, 0 is returned.
  2245. Examples:
  2246. LCOF((A+B)*(C+2*D)**2,A) ==> C**2+4*C*D+4*D**2
  2247. LCOF((A+B)*(C+2*D)**2,D) ==> 4*(A+B)
  2248. LCOF((A+B)*(C+2*D)**2,E) ==> 0.
  2249. 8.8.4 LTERM _____
  2250. Syntax: LTERM(EXPRN:polynomial,VAR:kernel):polynomial.
  2251. LTERM is used with the syntax
  2252. LTERM(EXPRN:polynomial,VAR:kernel):polynomial.
  2253. It returns the leading term of EXPRN with respect to VAR. If EXPRN does
  2254. not depend on VAR, 0 is returned.
  2255. Examples:
  2256. LTERM((A+B)*(C+2*D)**2,A) ==> A*(C**2+4*C*D+4*D**2)
  2257. LTERM((A+B)*(C+2*D)**2,D) ==> 4*D**2*(A+B)
  2258. LTERM((A+B)*(C+2*D)**2,E) ==> 0.
  2259. 8.8.5 MAINVAR _______
  2260. Syntax: MAINVAR(EXPRN:polynomial):expression.
  2261. Returns the main variable (based on the internal polynomial representation)
  2262. of EXPRN. If EXPRN is a domain element, 0 is returned.
  2263. Examples:
  2264. MAINVAR((A+B)*(C+2*D)**2) ==> A (normally)
  2265. MAINVAR(2) ==> 0
  2266. 8-8
  2267. 8.8.6 NUM ___
  2268. Syntax: NUM(EXPRN:rational):polynomial.
  2269. Returns the numerator of the rational expression EXPRN. If EXPRN is a
  2270. polynomial, that polynomial is returned.
  2271. Examples:
  2272. NUM(X/Y**2) ==> X
  2273. NUM(100/6) ==> 50
  2274. NUM(A/4+B/6) ==> 2*A+3*B
  2275. NUM(A+B) ==> A+B
  2276. 8.8.7 REDUCT ______
  2277. Syntax: REDUCT(EXPRN:polynomial,VAR:kernel):polynomial.
  2278. Returns the reductum of EXPRN with respect to VAR (i.e., the part of EXPRN
  2279. left after the leading term is removed). If EXPRN does not depend on the
  2280. variable VAR, 0 is returned.
  2281. Examples:
  2282. REDUCT((A+B)*(C+2*D)**2,A) ==> B*(C**2+4*C*D+4*D**2)
  2283. REDUCT((A+B)*(C+2*D)**2,D) ==> C*(A+B)
  2284. REDUCT((A+B)*(C+2*D)**2,E) ==> 0.
  2285. 8.9 Polynomial Coefficient Arithmetic __________ ___________ __________
  2286. REDUCE allows for a variety of numerical modes for the numerical coefficients
  2287. of polynomials used in calculations. The default mode is integer arithmetic,
  2288. although the possibility of using real coefficients has been discussed
  2289. elsewhere. Rational coefficients have also been available by using integer
  2290. coefficients in both the numerator and denominator of an expression, using
  2291. the ON DIV option (qv) to print the coefficients as rationals. However,
  2292. REDUCE includes several other coefficient options in its basic version which
  2293. we shall describe in this section. All such coefficient modes are actually
  2294. supported in a table-driven manner so that it is straightforward to extend
  2295. the range of possibilities. A description of how to do this is given in
  2296. another publication.
  2297. 8.9.1 Rational Coefficients in Polynomials ________ ____________ __ ___________
  2298. Instead of treating rational numbers as the numerator and denominator of a
  2299. rational expression, it is also possible to use them as polynomial
  2300. coefficients directly. This is accomplished by turning on the switch RATIONAL.
  2301. Example: With RATIONAL off, the input expression A/2 would be converted into
  2302. 8-9
  2303. a rational expression, whose numerator was A and denominator 2. With RATIONAL
  2304. on, the same input would become a rational expression with numerator 1/2*A
  2305. and denominator 1. Thus the latter can be used in operations that require
  2306. polynomial input whereas the former could not.
  2307. 8.9.2 Real coefficients in Polynomials ____ ____________ __ ___________
  2308. The switch FLOAT permits the use of fixed-sized real coefficients in polynomial
  2309. expressions. The actual precision of these coefficients is system dependent.
  2310. In this mode, denominators are automatically made monic, and an appropriate
  2311. adjustment made to the numerator.
  2312. Example: With FLOAT on, the input expression A/2 would be converted into a
  2313. rational expression whose numerator is 0.5*A and denominator 1.
  2314. 8.9.3 Arbitrary Precision Real Coefficients _________ _________ ____ ____________
  2315. REDUCE includes a module for those calculations that require greater real
  2316. number precision than the FLOAT mode supports. To use this mode, the command
  2317. ON BIGFLOAT; is used. The default precision in this case is ten decimal
  2318. digits. This precision can however be changed by the command PRECISION. For
  2319. example, PRECISION 50; sets the precision to fifty decimal digits.
  2320. Further information on this module may be found in T. Sasaki, "Manual for
  2321. Arbitrary Precision Real Arithmetic System in REDUCE", Department of Computer
  2322. Science, University of Utah, Technical Note No. TR-8 (1979).
  2323. 8.9.4 Modular Number Coefficients in Polynomials _______ ______ ____________ __ ___________
  2324. REDUCE includes facilities for manipulating polynomials whose coefficients
  2325. are computed modulo a given base. To use this option, two commands must be
  2326. used; SETMOD <integer>, to set the prime modulus, and ON MODULAR to cause the
  2327. actual modular calculations to occur.
  2328. For example, with SETMOD 3; and ON MODULAR, the polynomial (A+2*B)**3 would
  2329. become A**3 + B**3. Note that the modular calculations are on the
  2330. polynomial coefficients only. It is not currently possible to reduce the
  2331. exponents since no check for a prime modulus is made (which would allow
  2332. x**(p-1) to be reduced to 1 mod p).
  2333. Users should also note that since the argument of SETMOD is evaluated by
  2334. the algebraic processor in algebraic mode, it is usually necessary to
  2335. change it with the modular switch off. In addition, any division by a
  2336. number not co-prime with the modulus will result in the error "Invalid
  2337. modular division".
  2338. 9-1
  2339. 9. SUBSTITUTION COMMANDS ____________ ________
  2340. An important class of commands in REDUCE is that which defines
  2341. substitutions for variables and expressions to be made during the
  2342. evaluation of expressions. Such substitutions use forms of the command
  2343. LET.
  2344. LET rules stay in effect until replaced or CLEARed. Temporary substitution
  2345. rules, for the evaluation of a single statement, are created using the SUB
  2346. operator (qv).
  2347. 9.1 Simple LET Rules ______ ___ _____
  2348. The simplest use of the LET statement is in the form
  2349. LET <substitution list>
  2350. where <substitution list> is a list of rules, each of the form:
  2351. <variable> = <expression>
  2352. or <prefix operator> (<argument>,...,<argument>) = <expression>
  2353. or <argument> <infix operator>,..., <argument> = <expression>
  2354. e.g. LET X = Y**2,
  2355. H(U,V) = U - V,
  2356. COS(PI/3) = 1/2,
  2357. A*B = C,
  2358. L+M = N,
  2359. W**3 = 2*Z - 3,
  2360. Z**10 = 0
  2361. (These could have been entered as seven separate LET statements.)
  2362. After such LET rules have been input, X will always be evaluated as the
  2363. square of Y, and so on. This is so even if at the time the LET rule was
  2364. input, the variable Y had a value other than Y. (In contrast, the
  2365. assignment X:=Y**2 will set X equal to the square of the current value of
  2366. Y, which could be quite different.)
  2367. The rule LET A*B=C means that whenever A and B are both factors in an
  2368. expression their product will be replaced by C. For example, A**5 * B**7 *
  2369. W would be replaced by C**5 * B**2 * W.
  2370. The rule pertaining to W**3 will apply to any power of W greater than or
  2371. equal to the third.
  2372. Note especially the last example, LET Z**10=0. This declaration means, in
  2373. effect: ignore the tenth or any higher power of Z. Such declarations, when
  2374. appropriate, often speed up a computation to a considerable degree. (qv
  2375. 9-2
  2376. Asymptotic Commands for more details.)
  2377. Any new operators occurring in such LET rules will be automatically
  2378. declared OPERATOR by the system, if the rules are being read from a file.
  2379. If they are being entered interactively, the system will ask DECLARE ...
  2380. OPERATOR? . Answer Y or N and hit RETURN.
  2381. In each of these examples, substitutions are only made for the explicit
  2382. expressions given; i.e., none of the variables may be considered arbitrary
  2383. in any sense. For example, the command
  2384. LET H(U,V) = U - V;
  2385. will cause H(U,V) to evaluate to U - V, but will not affect H(U,Z) or H
  2386. with any arguments other than precisely the symbols U,V.
  2387. These simple LET rules are on the same logical level as assignments made
  2388. with the := operator. An assignment X := P+Q cancels a rule LET X = Y**2
  2389. made earlier, and vice versa.
  2390. CAUTION: A rule such as
  2391. LET X = X + 1;
  2392. is erroneous, since any subsequent evaluation of X will lead to a
  2393. non-terminating chain of substitutions (and finally a stack overflow
  2394. error):
  2395. X ==> X + 1 ==> (X + 1) + 1 ==> ((X + 1) + 1) + 1 ==> ...
  2396. Similarly, coupled substitutions such as
  2397. LET L = M + N, N = L + R;
  2398. will lead to the same error.
  2399. 9.2 FOR ALL ... LET ___ ___ ___ ___
  2400. If a substitution for all possible values of a given argument of an
  2401. operator is required, the declaration FOR ALL (or FORALL) may be used. The
  2402. syntax of such a command is
  2403. FOR ALL <variable>,...,<variable> <LET statement> <terminator>
  2404. e.g. FOR ALL X,Y LET H(X,Y) = X-Y;
  2405. FOR ALL X LET K(X,Y) = X**Y;
  2406. The first of these declarations would cause H(A,B) to be evaluated as A-B,
  2407. H(U+V,U+W) to be V-W, etc. If the operator symbol H is used with more or
  2408. fewer argument places, not two, the LET would have no effect, and no error
  2409. would result.
  2410. 9-3
  2411. The second declaration would cause K(A,Y) to be evaluated as A**Y, but
  2412. would have no effect on K(A,Z) since the rule didn't say FOR ALL Y ... .
  2413. Where we used X and Y in the examples, any variables could have been used.
  2414. This use of a variable doesn't affect the value it may have outside the
  2415. LET statement. However, you should remember what variables you actually
  2416. used. If you want to delete the rule subsequently, you must use the same
  2417. variables in the CLEAR command (qv).
  2418. It is possible to use more complicated expressions as a template for a LET
  2419. statement, as explained in the section on substitutions for general
  2420. expressions. However, there is a limit to the complexity of the expression
  2421. which can appear after the LET. This limit will change with successive
  2422. versions of REDUCE. If the expression is too complicated, the error
  2423. message
  2424. SUBSTITUTION FOR ... NOT ALLOWED
  2425. will be issued, with the ... a copy of the left-hand side of the equal
  2426. sign, possibly slightly rearranged. Any variable listed in the FOR ALL
  2427. part will have its symbol preceded by an equal sign: X, for example will
  2428. appear as =X . An error will also occur if a variable in the FOR ALL part
  2429. is not properly matched on both sides of the LET equation.
  2430. 9.3 FOR ALL ... SUCH THAT ... LET ___ ___ ___ ____ ____ ___ ___
  2431. If a substitution is desired for more than a single value of a variable in
  2432. an operator or other expression, but not all values, a conditional form of
  2433. the FOR ALL ... LET declaration can be used.
  2434. Example:
  2435. FOR ALL X SUCH THAT NUMBERP X AND X<0 LET H(X)=0;
  2436. will cause H(-5) to be evaluated as 0, but H of a positive integer, or of
  2437. an argument which is not an integer at all, would not be affected. Any
  2438. boolean expression can follow the SUCH THAT keywords.
  2439. 9.4 Removing Assignments and Substitution Rules ________ ___________ ___ ____________ _____
  2440. The user may remove all assignments and substitution rules from any
  2441. expression by the command CLEAR, in the form
  2442. CLEAR <expression>,...,<expression><terminator>
  2443. e.g. CLEAR X, H(X,Y);
  2444. An individual element of an array A can be reset to 0 by a command such as
  2445. CLEAR A(3);.
  2446. A whole array A can be cleared by the command CLEAR A; . This means much
  2447. 9-4
  2448. more than resetting to 0 all the elements of A. The fact that A is an
  2449. array, and what its dimensions are, are forgotten, so A can be redefined
  2450. as another type of object -- say, operator.
  2451. The more general types of LET declarations can also be deleted by using
  2452. CLEAR. Simply repeat the LET rule to be deleted, using CLEAR in place of
  2453. LET, and omitting the equal sign and right-hand part. The same dummy
  2454. variables must be used in the FOR ALL part, and the boolean expression in
  2455. the SUCH THAT part must be written the same way. (The placing of blanks
  2456. doesn't have to be identical.)
  2457. Example:
  2458. The LET rule
  2459. FOR ALL X SUCH THAT NUMBERP X AND X<0 LET H(X)=0;
  2460. can be erased by the command
  2461. FOR ALL X SUCH THAT NUMBERP X AND X<0 CLEAR H(X);
  2462. 9.5 Overlapping LET Rules ___________ ___ _____
  2463. CLEAR is not the only way to delete a LET rule. A new LET rule identical
  2464. to the first, but with a different expression after the equal sign,
  2465. replaces the first. The user should however be cautioned against having
  2466. several LET rules in effect which relate to the same expression. No
  2467. guarantee can be given as to which rules will be applied by REDUCE or in
  2468. what order. It is best to CLEAR an old rule before entering a new related
  2469. LET rule.
  2470. 9.5.1 Substitutions for General Expressions _____________ ___ _______ ___________
  2471. All substitutions discussed so far have been very limited in scope, because
  2472. they involve only replacements for variables and kernels. These
  2473. substitutions are very efficient to implement because variables and kernels
  2474. are stored uniquely in the system. However, there are many situations
  2475. where more general substitutions are required, most of which require
  2476. extensive pattern matching within the expression being evaluated.
  2477. Consequently, such substitutions cannot be as efficiently implemented as
  2478. those discussed so far.
  2479. The general substitution mechanism used in REDUCE is discussed in Hearn, A.
  2480. C., "REDUCE, A User-Oriented Interactive System for Algebraic
  2481. Simplification," Interactive Systems for Experimental Applied Mathematics,
  2482. (edited by M. Klerer and J. Reinfelds), Academic Press, New York (1968),
  2483. 79-90, and Hearn. A. C., "The Problem of Substitution," Proc. 1968 Summer
  2484. Institute on Symbolic Mathematical Computation, IBM Programming Laboratory
  2485. Report FSC 69-0312 (1969).
  2486. For the reasons given in these references, REDUCE does not attempt to
  2487. 9-5
  2488. implement a general pattern matching algorithm. However, the present
  2489. system uses more sophisticated techniques than those discussed in the above
  2490. papers. It is now possible for the equations appearing in arguments of LET
  2491. to have the form
  2492. <substitution expression> = <expression>
  2493. where <substitution expression> is ANY expression, subject to the
  2494. following restrictions:
  2495. (i) The operators - and / cannot appear at the top level in a
  2496. substitution expression.
  2497. e.g. LET A - B = 1; is NOT allowed.
  2498. (ii) The operators + and * can only be used in binary form within
  2499. substitution expressions.
  2500. e.g. LET SIN (X + Y) = SIN(X)*COS(Y) + COS(X)*SIN(Y);
  2501. is allowed but a substitution for FN(X+Y+Z) would not be. The
  2502. system will of course substitute for any expression containing +
  2503. or * as an n-ary operator by making the appropriate expansion of
  2504. the binary rule.
  2505. (iii) The operator - can only be specified as a unary operator within
  2506. substitution expressions.
  2507. e.g. LET COS(-X) = COS(X) is allowed
  2508. but LET COS(X-Y) = <expression> is not.
  2509. It should be noted, however, that a rule for COS(X+Y) and one
  2510. for COS(-X) is sufficient to specify the expansion of COS(X-Y).
  2511. After a substitution has been made, the expression being evaluated is
  2512. reexamined in case a new allowed substitution has been generated. This
  2513. process is continued until no more substitutions can be made. However,
  2514. this is sometimes undesirable. For example, if one wishes to integrate a
  2515. polynomial with respect to X by a rule of the form
  2516. FOR ALL N LET X**N = X**(N+1)/(N+1);
  2517. one only wants the substitution to be made once. (Otherwise X**2 would
  2518. become X**3/3 which would then become X**4/12 and so on). This
  2519. resubstitution can be inhibited by turning off the switch RESUBS (which is
  2520. normally on).
  2521. When a substitution expression appears in a product, the substitution is
  2522. made if that expression divides the product. For example, the rule
  2523. LET A**2*C = 3*Z;
  2524. would cause A**2*C*X to be replaced by 3*Z*X and A**2*C**2 by 3*Z*C. If
  2525. 9-6
  2526. the substitution is desired only when the substitution expression appears
  2527. in a product with the explicit powers supplied in the rule, the command
  2528. MATCH should be used instead.
  2529. For example,
  2530. MATCH A**2*C = 3*Z;
  2531. would cause A**2*C*X to be replaced by 3*Z*X, but A**2*C**2 would not be
  2532. replaced. MATCH can also be used with the FOR ALL constructions described
  2533. above.
  2534. To remove substitution rules of the type discussed in this section, the
  2535. CLEAR command can be used, combined, if necessary, with a FOR ALL clause.
  2536. e.g. FOR ALL X CLEAR LOG(E**X),E**LOG(X),COS(W*T+THETA(X));
  2537. Note, however, that the arbitrary variable names in this case MUST be the
  2538. same as those used in defining the substitution.
  2539. 9.6 Asymptotic Commands __________ ________
  2540. In expansions of polynomials involving variables which are known to be
  2541. small, it is often desirable to throw away all powers of these variables
  2542. beyond a certain point to avoid unnecessary computation. The command LET
  2543. may be used to do this. For example, if only powers of X up to X**7 are
  2544. needed, the command
  2545. LET X**8 = 0;
  2546. will cause the system to delete all powers of X higher than 7.
  2547. CAUTION: This particular simplification works differently from most
  2548. substitution mechanisms in REDUCE in that it is applied during polynomial
  2549. manipulation rather than to the whole evaluated expression. Thus, with the
  2550. above rule in effect, x**10/x**5 would give the result zero, since the
  2551. numerator would simplify to zero. Similarly x**20/x**10 would give a ZERO
  2552. DENOMINATOR error message, since both numerator and denominator would
  2553. first simplify to zero.
  2554. The method just described is not adequate when expressions involve several
  2555. variables having different degrees of smallness. In this case, it is
  2556. necessary to supply an asymptotic weight to each variable and count up the
  2557. total weight of each product in an expanded expression before deciding
  2558. whether to keep the term or not. There are two associated commands in the
  2559. system to permit this type of asymptotic constraint. The command WEIGHT
  2560. takes a list of equations of the form
  2561. <kernel form> = <number>,
  2562. where <number> must be a positive integer (not just evaluate to a positive
  2563. integer). This command assigns the weight <number> to the relevant kernel
  2564. 9-7
  2565. form. A check is then made in all algebraic evaluations to see if the
  2566. total weight of the term is greater than the weight level assigned to the
  2567. calculation. If it is, the term is deleted. To compute the total weight of
  2568. a product, the individual weights of each kernel form are multiplied by
  2569. their corresponding powers and then added.
  2570. The weight level of the system is initially set to 2. The user may change
  2571. this setting by the command
  2572. WTLEVEL <number>;
  2573. which sets <number> as the new weight level of the system. Again, <number>
  2574. must be a positive integer.
  2575. 10-1
  2576. 10. FILE HANDLING COMMANDS ____ ________ ________
  2577. In many applications, it is desirable to load previously prepared REDUCE
  2578. files into the system, or to write output on other files. REDUCE offers
  2579. four commands for this purpose, namely, IN, OUT, SHUT and LOAD. The first
  2580. three operators are described here; LOAD is discussed in another section.
  2581. 10.1 IN __
  2582. This command takes a list of file names as argument and directs the system
  2583. to input each file (which should contain REDUCE statements and commands)
  2584. into the system. File names can either be an identifier or a string. The
  2585. explicit format of these will be system dependent and, in many cases, site
  2586. dependent. The explicit instructions for the implementation being used
  2587. should therefore be consulted for further details.
  2588. e.g. IN F1,"GGG.RR.S"; will first load file F1, then GGG.RR.S.
  2589. When a semicolon is used as the terminator of the IN statement, the
  2590. statements in the file are echoed on the terminal or written on the
  2591. current output file. If $ or ESCAPE is used as the terminator, the input
  2592. is not shown. Echoing of all or part of the input file can be prevented,
  2593. even if a semicolon was used, by placing an OFF ECHO; command in the input
  2594. file.
  2595. Files to be read using IN should end with ;END; . (Note the two
  2596. semicolons!) First of all, this is protection against obscure difficulties
  2597. the user will have if there are, by mistake, more BEGINs than ENDs on the
  2598. file. Secondly, it triggers some file control book-keeping which may
  2599. improve system efficiency. If END is omitted, an error message "EOF read"
  2600. will occur.
  2601. 10.2 OUT ___
  2602. This command takes a single file name as argument, and directs output to
  2603. that file from then on, until another OUT changes the output file, or SHUT
  2604. closes it. Output can go to only one file at a time, although many can be
  2605. open. If the file has previously been used for output during the current
  2606. job, and not SHUT, the new output is appended to the end of the file. Any
  2607. existing file is erased before its first use for output in a job, or if
  2608. had been SHUT before the new OUT.
  2609. To output on the terminal without closing the output file, the reserved
  2610. file name T (for terminal) may be used.
  2611. e.g. OUT OFILE; will direct output to the file OFILE and
  2612. OUT T; will direct output to the user's terminal.
  2613. The output sent to the file will be in the same form that it would have on
  2614. the terminal. In particular X**2 would appear on two lines, an X on the
  2615. 10-2
  2616. lower line and a 2 on the line above. If the purpose of the output file is
  2617. to save results to be read in later, this is not an appropriate form. We
  2618. first must turn off the NAT switch which specifies that output should be
  2619. in standard mathematical notation.
  2620. Example: To create a file ABCD from which it will be possible to read --
  2621. using IN -- the value of the expression XYZ:
  2622. OFF NAT$ % output in IN-readable form. Each expression
  2623. % printed will end with a $ .
  2624. OUT ABCD$ % output to new file
  2625. XYZ:=XYZ; % will output "XYZ := " followed by the value
  2626. % of XYZ
  2627. WRITE ";END;"$ % standard for ending files for IN
  2628. SHUT ABCD$ % save ABCD, return to terminal output
  2629. ON NAT$ % restore usual output form
  2630. 10.3 SHUT ____
  2631. This command takes a list of names of files which have been previously
  2632. opened via an "OUT" statement and closes them. Most systems require this
  2633. action by the user before he ends the REDUCE job (if not sooner),
  2634. otherwise the output may be lost. If a file is shut and a further OUT
  2635. command issued for the same file, the file is erased before the new output
  2636. is written.
  2637. If it is the current output file which is shut, output will switch to the
  2638. terminal. Attempts to shut files that have not been opened by "OUT", or an
  2639. input file will lead to errors.
  2640. 11-1
  2641. 11. COMMANDS FOR INTERACTIVE USE OF REDUCE ________ ___ ___________ ___ __ ______
  2642. REDUCE is designed as an interactive system, but naturally it can also
  2643. operate in a batch processing or background mode by taking its input
  2644. command by command from the relevant input stream. There is a basic
  2645. difference, however, between interactive and batch use of the system. In
  2646. the former case, whenever the system discovers an ambiguity at some point
  2647. in a calculation, such as a forgotten type assignment for instance, it asks
  2648. the user for the correct interpretation. In batch operation, it is not
  2649. practical to terminate the calculation at such points and require
  2650. resubmission of the job, so the system makes the most obvious guess of the
  2651. user's intentions and continues the calculation.
  2652. There is also a difference in the handling of errors. In the former case,
  2653. the computation can continue since the user has the opportunity to correct
  2654. the mistake. In batch mode, the error may lead to consequent erroneous (and
  2655. possibly time consuming) computations. So no further evaluation occurs,
  2656. although the remainder of the input is checked for syntax errors. A message
  2657. "Continuing with parsing only" informs the user that this is happening.
  2658. 11.1 Referencing Previous Results ___________ ________ _______
  2659. It is often useful to be able to reference results of previous computations
  2660. during a REDUCE session. For this purpose, REDUCE maintains a history of
  2661. all interactive inputs and the results of all interactive computations during
  2662. a given session. These results are referenced by the command number that
  2663. REDUCE prints automatically in interactive mode. To use an input expression
  2664. in a new computation, one writes INPUT(n), where n is the command number.
  2665. To use an output expression, one writes WS(n). WS references the previous
  2666. command. E.g., if command number 1 was int(x-1,x); and the result of
  2667. command number 7 was X-1, then
  2668. 2*input(1)-ws(7)**2;
  2669. would give the result -1, whereas
  2670. 2*ws(1)-ws(7)**2;
  2671. would yield the same result, but WITHOUT a recomputation of the integral.
  2672. The operator DISPLAY is available to display previous inputs. If its
  2673. argument is a positive integer, n say, then the previous n inputs are
  2674. displayed. If its argument is ALL (or in fact any non-numerical expression),
  2675. then all previous inputs are displayed.
  2676. 11.2 Interactive Editing ___________ _______
  2677. It is possible when working interactively to edit any REDUCE input that
  2678. comes from the user's terminal, and also some user-defined procedure
  2679. definitions. At the top level, one can access any previous command string
  2680. 11-2
  2681. by the command ED(n), where n is the desired command number as prompted by
  2682. the system in interactive mode. ED; (i.e. no argument) accesses the
  2683. previous command.
  2684. After ED has been called, you can now edit the displayed string using a
  2685. string editor with the following commands:
  2686. B move pointer to beginning
  2687. C<character> replace next character by <character>
  2688. D delete next character
  2689. E end editing and reread text
  2690. F<character> move pointer to next occurrence of <character>
  2691. I<string><escape> insert <string> in front of pointer
  2692. K<character> delete all chars until <character>
  2693. P print string from current pointer
  2694. Q give up with error exit
  2695. S<string><escape> search for first occurrence of <string>
  2696. positioning pointer just before it
  2697. <space> or X move pointer right one char.
  2698. The above table can be displayed online by typing a question mark followed
  2699. by a carriage return to the editor. The editor prompts with an angle
  2700. bracket. Commands can be combined on a single line, and all command
  2701. sequences must be followed by a carriage return to become effective.
  2702. Thus, to change the command X := A+1; to X := A+2;, and cause it to be
  2703. executed, the following edit command sequence could be used:
  2704. F1C2E<return>.
  2705. The interactive editor may also be used to edit a user-defined procedure that
  2706. has not been compiled (qv). To do this, one says:
  2707. EDITDEF <id>;
  2708. where <id> is the name of the procedure. The procedure definition will then
  2709. be displayed in editing mode, and may then be edited and redefined on exiting
  2710. from the editor.
  2711. 11.3 Interactive File Control ___________ ____ _______
  2712. If input is coming from an external file, the system treats it as a batch
  2713. processed calculation. If the user desires interactive response in this
  2714. case, he can include the command ON INT; in the file. Likewise, he can
  2715. issue the command OFF INT; in the main program if he does not desire
  2716. continual questioning from the system. Regardless of the setting of INT,
  2717. input commands from a file are not kept in the system, and so can not be
  2718. edited using ED. However, many implementations of REDUCE provide a link to
  2719. an external system editor that can be used for such editing. The specific
  2720. instructions for the particular implementation should be consulted for
  2721. information on this.
  2722. 11-3
  2723. Two commands are available in REDUCE for interactive use of files. PAUSE;
  2724. may be inserted at any point in an input file. When this command is
  2725. encountered on input, the system prints the message CONT? on the user's
  2726. terminal and halts. If the user responds Y (for yes), the calculation
  2727. continues from that point in the file. If the user responds N (for no),
  2728. control is returned to the terminal, and the user can input further
  2729. statements and commands. Later on he can use the command CONT; to transfer
  2730. control back to the point in the file following the last PAUSE encountered.
  2731. A top-level PAUSE; from the user's terminal has no effect.
  2732. 12-1
  2733. 12. MATRIX CALCULATIONS ______ ____________
  2734. A very powerful feature of the REDUCE system is the ease with which matrix
  2735. calculations can be performed. To extend our syntax to this class of
  2736. calculations we need to add another prefix operator, MAT, and a further
  2737. variable and expression type as follows:
  2738. 12.1 MAT ___
  2739. This prefix operator is used to represent n x m matrices. MAT has n
  2740. arguments interpreted as rows of the matrix, each of which is a list of m
  2741. expressions representing elements in that row. For example, the matrix
  2742. (A B C)
  2743. ( )
  2744. (D E F)
  2745. would be written as MAT ((A,B,C),(D,E,F)).
  2746. Note that the single column matrix
  2747. (X)
  2748. (Y)
  2749. becomes MAT((X),(Y)). The inside parentheses are required to distinguish
  2750. it from the single row matrix
  2751. (X Y)
  2752. which would be written as MAT((X,Y)).
  2753. 12.2 Matrix Variables ______ _________
  2754. An identifier may be declared a matrix variable by the declaration MATRIX.
  2755. The size of the matrix may be declared explicitly in the matrix
  2756. declaration, or by default in assigning such a variable to a matrix
  2757. expression.
  2758. e.g. MATRIX X(2,1),Y(3,4),Z;
  2759. declares X to be a 2 x 1 (column) matrix, Y to be a 3 x 4 matrix and Z a
  2760. matrix whose size is declared later by default.
  2761. An element of a matrix is referred to in the expected manner; thus X(1,1)
  2762. gives the first element of the matrix X defined above. References to elements
  2763. of a matrix whose size has not yet been declared leads to an error. All
  2764. elements of a matrix whose size is declared are initialized to 0. As a
  2765. result, a matrix element cannot stand for itself. If this is required,
  2766. then an operator (qv) should be used to name the matrix elements.
  2767. 12-2
  2768. 12.3 Matrix Expressions ______ ___________
  2769. These follow the normal rules of matrix algebra as defined by the
  2770. following syntax:
  2771. <matrix expression> ::= MAT<matrix description>|<matrix variable>|
  2772. <scalar expression>*<matrix expression>|
  2773. <matrix expression>*<matrix expression>
  2774. <matrix expression>+<matrix expression>|
  2775. <matrix expression>**<integer>|
  2776. <matrix expression>/<matrix expression>
  2777. Sums and products of matrix expressions must be of compatible size
  2778. otherwise an error will result during their evaluation. Similarly, only
  2779. square matrices may be raised to a power. A negative power is computed as
  2780. the inverse of the matrix raised to the corresponding positive power. A/B
  2781. is interpreted as A*B**(-1).
  2782. Examples:
  2783. Assuming X and Y have been declared as matrices, the following are matrix
  2784. expressions
  2785. Y
  2786. Y**2*X-3*Y**(-2)*X
  2787. Y+ MAT((1,A),(B,C))/2
  2788. 12.4 Operators With Matrix Arguments _________ ____ ______ _________
  2789. Three additional operators are useful in matrix calculations, namely DET,
  2790. TP and TRACE defined as follows
  2791. 12.4.1 DET ___
  2792. Syntax: DET(EXPRN:matrix_expression):algebraic.
  2793. The operator DET is used to represent the determinant of a square matrix
  2794. expression.
  2795. e.g. DET(Y**2)
  2796. is a scalar expression whose value is the determinant of the square of the
  2797. matrix Y, and
  2798. DET MAT((A,B,C),(D,E,F),(G,H,J));
  2799. is a scalar expression whose value is the determinant of the matrix
  2800. ( A B C )
  2801. ( )
  2802. 12-3
  2803. ( D E F )
  2804. ( )
  2805. ( G H J ).
  2806. 12.4.2 TP __
  2807. Syntax: TP(EXPRN:matrix_expression):matrix.
  2808. This operator takes a single matrix argument and returns its transpose.
  2809. 12.4.3 TRACE _____
  2810. Syntax: TRACE(EXPRN:matrix_expression):algebraic. The operator TRACE is
  2811. used to represent the trace of a square matrix.
  2812. 12.5 Matrix Assignments ______ ___________
  2813. Matrix expressions may appear in the right hand side of assignment
  2814. statements. If the left hand side of the assignment, which must be a
  2815. variable, has not already been declared a matrix, it is declared by default
  2816. to the size of the right hand side. The variable is then set to the value
  2817. of the right hand side.
  2818. Such an assignment may be used very conveniently to find the solution of a
  2819. set of linear equations. For example, to find the solution of the
  2820. following set of equations
  2821. A11*X(1) + A12*X(2) = Y1
  2822. A21*X(1) + A22*X(2) = Y2
  2823. we simply write
  2824. X := 1/MAT((A11,A12),(A21,A22))*MAT((Y1),(Y2));
  2825. 12.6 Evaluating Matrix Elements __________ ______ ________
  2826. Once an element of a matrix has been assigned, it may be referred to in
  2827. standard array element notation. Thus Y(2,1) refers to the element in the
  2828. second row and first column of the matrix Y.
  2829. 13-1
  2830. 13. PROCEDURES __________
  2831. It is often useful to name a statement for repeated use in calculations
  2832. with varying parameters, or to define a complete evaluation procedure for
  2833. an operator. REDUCE offers a procedural declaration for this purpose. Its
  2834. general syntax is:
  2835. <procedural type> PROCEDURE <name><varlist>;<statement>;
  2836. and
  2837. <varlist> ::= (<variable>,...,<variable>)
  2838. This will be explained more fully in the following sections.
  2839. In the algebraic mode of REDUCE the <procedure type> can be omitted, since
  2840. the default is ALGEBRAIC. Procedures of type INTEGER or REAL may also be
  2841. used. In the former case, the system checks to ensure that the input
  2842. parameters and value of the procedure are integers. At present, such
  2843. checking is not done for a real procedure, although this will change in the
  2844. future when a more complete type checking mechanism is installed. Users
  2845. should therefore only use these types when appropriate.
  2846. All procedures are automatically declared to be operators on definition.
  2847. In order to allow users relatively easy access to the whole REDUCE source
  2848. program, system procedures are not protected against user redefinition. If
  2849. a procedure is redefined, a message
  2850. *** <procedure name> REDEFINED
  2851. is printed. If this occurs, and the user is not redefining his own
  2852. procedure, he is well advised to rename it, and possibly start over
  2853. (because he has ALREADY redefined some internal procedure whose correct
  2854. functioning may be required for his job!)
  2855. All required procedures should be defined at the top level, since they
  2856. have global scope throughout a program. In particular, an attempt to
  2857. define a procedure within a procedure will cause an error to occur.
  2858. 13.1 Procedure Heading _________ _______
  2859. Each procedure has a heading consisting of the word PROCEDURE (optionally
  2860. preceded by the word ALGEBRAIC), followed by the name of the procedure to
  2861. be defined, and followed by its formal parameters -- the symbols which
  2862. will be used in the body of the definition to illustrate what is to be
  2863. done. There are three cases:
  2864. 1) No parameters. Simply follow the procedure name with a terminator
  2865. (semicolon or dollar sign or ESCAPE).
  2866. PROCEDURE ABC;
  2867. 13-2
  2868. When such a procedure is used in an expression or command, ABC(), with
  2869. empty parentheses, must be written.
  2870. 2) One parameter. Enclose it in parentheses OR just leave at least one
  2871. space, then follow with a terminator.
  2872. PROCEDURE ABC(X);
  2873. or PROCEDURE ABC X;
  2874. 3) More than one parameter. Enclose them in parentheses, separated by
  2875. commas, then follow with a terminator.
  2876. PROCEDURE ABC(X,Y,Z);
  2877. Referring to the last example, if later in some expression being evaluated
  2878. the symbols ABC(U,P*Q,123) appear, the operations of the procedure body
  2879. will be carried out as if X had the same value as U does, Y the same value
  2880. as P*Q does, and Z the value 123. The values of X, Y, Z, after the
  2881. procedure body operations are completed are unchanged. So, normally, are
  2882. the values of U, P, Q, and (of course) 123. (This is technically referred
  2883. to as call by value.)
  2884. The reader will have noted the word "normally" a few lines earlier. The
  2885. call by value protections can be bypassed if necessary, as described
  2886. elsewhere.
  2887. 13.2 The Procedure Body ___ _________ ____
  2888. Following the delimiter which ends the procedure heading must be a SINGLE
  2889. statement defining the action to be performed or the value to be
  2890. delivered. A terminator must follow the statement. If it is a semicolon,
  2891. the name of the procedure just defined is printed. It is not printed if
  2892. dollar sign or ESCAPE is used.
  2893. If the result wanted is given by a formula of some kind, the body is just
  2894. that formula, using the variables in the procedure heading.
  2895. Simple Example:
  2896. If F(X) is to mean (X+5)*(X+6)/(X+7), the entire procedure definition
  2897. could read
  2898. PROCEDURE F X; (X+5)*(X+6)/(X+7);
  2899. Then F(10) would evaluate to 240/17, F(A-6) to A*(A-1)/(A+1), and so on.
  2900. More Complicated Example:
  2901. Suppose we need a function P(N,X) which, for any positive integer N, is
  2902. the Legendre polynomial of order N. We can define this operator using the
  2903. textbook formula defining these functions:
  2904. 13-3
  2905. n |
  2906. 1 d 1 |
  2907. p (x) = --- --- ---------------|
  2908. n n! n 2 1/2|
  2909. dy (y -2*x*y+1) | y=0
  2910. Put into words, the Legendre polynomial P(N,X) is the result of
  2911. substituting Y=0 in the Nth partial derivative with respect to Y of a
  2912. certain fraction involving X and Y, then dividing that by N factorial.
  2913. This verbal formula can easily be written in REDUCE:
  2914. PROCEDURE P(N,X);
  2915. SUB(Y=0,DF(1/(Y**2-2*X*Y+1)**(1/2),Y,N))
  2916. /(FOR I:=1:N PRODUCT I);
  2917. Having input this definition, the expression evaluation
  2918. 2*P(2,W);
  2919. would result in the output
  2920. 2
  2921. 3*W - 1
  2922. If the desired process is best described as a series of steps, then a group
  2923. or compound statement can be used.
  2924. Example:
  2925. The above Legendre polynomial example can be rewritten as a series of steps
  2926. instead of a single formula as follows:
  2927. PROCEDURE P(N,X);
  2928. BEGIN SCALAR SEED,DERIV,TOP,FACT;
  2929. SEED:=1/(Y**2 - 2*X*Y +1)**(1/2);
  2930. DERIV:=DF(SEED,Y,N);
  2931. TOP:=SUB(Y=0,DERIV);
  2932. FACT:=FOR I:=1:N PRODUCT I;
  2933. RETURN TOP/FACT
  2934. END;
  2935. Procedures may also be defined recursively. In other words, the procedure
  2936. body can include references to the procedure name itself, or to other
  2937. procedures which themselves reference the given procedure. As an example,
  2938. we can define the Legendre polynomial through its standard recurrence
  2939. relation:
  2940. PROCEDURE P(N,X);
  2941. IF N<0 THEN REDERR "Invalid argument to P(N,X)"
  2942. ELSE IF N=0 THEN 1
  2943. ELSE IF N=1 THEN X
  2944. ELSE ((2*N-1)*X*P(N-1,X)-(N-1)*P(N-2,X))/N;
  2945. 13-4
  2946. The operator REDERR in the above example provides for a simple error exit
  2947. from an algebraic procedure. It takes a string as argument.
  2948. It should be noted however that all the above definitions of P(N,X) are
  2949. quite inefficient if extensive use is to be made of such polynomials, since
  2950. each call effectively recomputes all lower order polynomials. It would be
  2951. better to store these expressions in an array, and then use say the
  2952. recurrence relation to compute only those polynomials that have not already
  2953. been derived. We leave it as an exercise for the reader to write such a
  2954. definition.
  2955. 13.3 Using LET Inside Procedures _____ ___ ______ __________
  2956. By using LET instead of an assignment in the procedure body it is possible
  2957. to bypass the call-by-value protection. If X is a formal parameter or
  2958. local variable of the procedure (i.e. is in the heading or in a SCALAR
  2959. declaration), and LET is used instead of := to make an assignment to X,
  2960. e.g.
  2961. LET X = 123;
  2962. then it is the variable which is the value of X that is changed. (If the
  2963. value of X is not a variable, but say P*Q, it is as if LET P*Q = 123 has
  2964. been executed. With P*Q this is a meaningful LET statement; with more
  2965. complicated expressions it may not be, and an error message will result.)
  2966. 13.4 Let Rules as Procedures ___ _____ __ __________
  2967. The LET statement offers an alternative syntax and semantics for procedure
  2968. definition.
  2969. In place of
  2970. PROCEDURE ABC (X,Y,Z);
  2971. <procedure body>;
  2972. one can write
  2973. FOR ALL X,Y,Z LET ABC(X,Y,Z) = <procedure body>;
  2974. There are several differences to note.
  2975. If the procedure body contains an assignment to one of the formal
  2976. parameters, e.g.
  2977. X:=123;
  2978. in the PROCEDURE case it is a variable holding a copy of the first actual
  2979. argument which is changed. The actual argument is not changed.
  2980. In the LET case, the actual argument is changed. Thus, if ABC is defined
  2981. 13-5
  2982. using LET, and ABC(U,V,W) is evaluated, the value of U changes to 123.
  2983. That is, the LET form of definition allows the user to bypass the
  2984. protections which are enforced by the call by value conventions of
  2985. standard PROCEDURE definitions.
  2986. Example: We take our earlier FACTORIAL procedure and write it as a LET
  2987. statement.
  2988. FOR ALL N LET FACTORIAL N =
  2989. BEGIN SCALAR M,S;
  2990. M:=1; S:=N;
  2991. L1: IF S=0 THEN RETURN M;
  2992. M:=M*S;
  2993. S:=S-1;
  2994. GO TO L1
  2995. END;
  2996. The reader will notice that we introduced a new local variable, S, and set
  2997. it equal to N. The original form of the procedure contained the statement
  2998. N:=N-1;. If the user asked for the value of FACTORIAL (5) then N would
  2999. correspond to -- not just have the value of -- 5, and REDUCE would object
  3000. to trying to execute the statement 5:=5-1.
  3001. If PQR is a procedure with no parameters,
  3002. PROCEDURE PQR;
  3003. <procedure body>;
  3004. it can be written as a LET statement quite simply:
  3005. LET PQR = <procedure body>;
  3006. To call "procedure" PQR if defined in the latter form, the empty
  3007. parentheses would not be used: use PQR not PQR() where a call on the
  3008. procedure is needed.
  3009. The two notations for a procedure with no arguments can be combined. PQR
  3010. can be defined in the standard PROCEDURE form. Then a LET statement
  3011. LET PQR = PQR();
  3012. would allow a user to use PQR instead of PQR() in calling the procedure.
  3013. A feature available with LET-defined procedures and not with procedures
  3014. defined in the standard way is the possibility of defining partial
  3015. functions.
  3016. FOR ALL X SUCH THAT NUMBERP X LET UVW(X) = <procedure body);
  3017. Now UVW of an integer would be calculated as prescribed by the procedure
  3018. body, while UVW of a general argument, such as Z or P+Q (assuming these
  3019. evaluate to themselves) would simply stay UVW(Z) or UVW(P+Q) as the case
  3020. may be.
  3021. 14-1
  3022. 14. SYMBOLIC MODE ________ ____
  3023. At the system level, REDUCE is based on a version of the programming
  3024. language LISP known as Standard LISP which is described in J. Marti,
  3025. Hearn, A. C., Griss, M. L. and Griss, C., "Standard LISP Report" SIGPLAN
  3026. Notices, ACM, New York, 14, No 10 (1979) 48-68. We shall assume in this
  3027. section that the reader is familiar with the material in that paper. This
  3028. also assumes implicitly that the reader has a reasonable knowledge about
  3029. LISP in general, say at the level of the LISP 1.5 Programmer's Manual
  3030. (McCarthy, J., Abrahams, P. W., Edwards, D. J., Hart, T. P. and Levin, M.
  3031. I., "LISP 1.5 Programmer's Manual", M.I.T. Press, 1965) or any of the
  3032. books mentioned at the end of this section. Persons unfamiliar with this
  3033. material will have some difficulty understanding this section.
  3034. Although REDUCE is designed primarily for algebraic calculations, its
  3035. source language is general enough to allow for a full range of LISP-like
  3036. symbolic calculations. To achieve this generality, however, it is
  3037. necessary to provide the user with two modes of evaluation, namely an
  3038. algebraic mode and a symbolic mode. To enter symbolic mode, the user types
  3039. SYMBOLIC; (or LISP;) and to return to algebraic mode he types ALGEBRAIC;.
  3040. Evaluations proceed differently in each mode so the user is advised to
  3041. check what mode he is in if a puzzling error arises. He can find his mode
  3042. by typing
  3043. !*MODE;
  3044. The current mode will then be printed as ALGEBRAIC or SYMBOLIC.
  3045. Expression evaluation may proceed in either mode at any level of a
  3046. calculation, provided the results are passed from mode to mode in a
  3047. compatible manner. One simply prefixes the relevant expression by the
  3048. appropriate mode. If the mode name prefixes an expression at the top
  3049. level, it will then be handled as if the global system mode had been
  3050. changed for the scope of that particular calculation.
  3051. For example, if the current mode is ALGEBRAIC, then the commands
  3052. SYMBOLIC CAR '(A);
  3053. X+Y;
  3054. will cause the first expression to be evaluated and printed in symbolic
  3055. mode and the second in algebraic mode. Only the second evaluation will
  3056. thus affect the expression workspace. On the other hand, the statement
  3057. X + SYMBOLIC CAR '(12);
  3058. will result in the algebraic value X+12.
  3059. For convenience, it is assumed that any operator whose FIRST argument is
  3060. quoted is being evaluated in symbolic mode, regardless of the mode in
  3061. effect at that time. Thus, the first example above could be equally well
  3062. written:
  3063. 14-2
  3064. CAR '(A);
  3065. Except where explicit limitations have been made, most REDUCE algebraic
  3066. constructions carry over into symbolic mode. However, there are some
  3067. differences. First, expression evaluation now becomes LISP evaluation.
  3068. Secondly, assignment statements are handled differently, as we discuss
  3069. shortly. Thirdly, local variables and array elements are initialized to
  3070. NIL rather than 0. (In fact, any variables not explicitly declared INTEGER
  3071. and all array elements are also initialized to NIL in algebraic mode, but
  3072. the algebraic evaluator recognizes NIL as 0.) Fourthly, the delimiters SUM
  3073. and PRODUCT in the FOR statement (qv) are not defined in symbolic mode.
  3074. Finally, function definitions follow the conventions of Standard LISP.
  3075. To begin with, we mention a few extensions to our basic syntax which are
  3076. designed primarily if not exclusively for symbolic mode.
  3077. 14.1 Symbolic Infix Operators ________ _____ _________
  3078. There are four binary infix operators in REDUCE intended for use in
  3079. symbolic mode, namely . (CONS), EQ, MEMBER and MEMQ. The precedence of
  3080. these operators was given in another section.
  3081. 14.2 Symbolic Expressions ________ ___________
  3082. These consist of scalar variables and operators and follow the normal
  3083. rules of the LISP meta language.
  3084. Examples:
  3085. X
  3086. CAR U . REVERSE V
  3087. SIMP (U+V**2)
  3088. 14.3 Quoted Expressions ______ ___________
  3089. Because LISP evaluation requires that each variable or expression has a
  3090. value, it is necessary to add to REDUCE the concept of a quoted expression
  3091. by analogy with the LISP QUOTE function. This is provided by the single
  3092. quote mark '.
  3093. e.g. 'A represents the LISP S-expression (QUOTE A)
  3094. '(A B C) represents the LISP S-expression (QUOTE (A B C))
  3095. Note, however, that strings are constants and therefore evaluate to
  3096. themselves in symbolic mode. Thus, to print the string "A string", one
  3097. would write
  3098. PRIN2 "A string";
  3099. Within a quoted expression, identifier syntax rules are those of REDUCE.
  3100. 14-3
  3101. Thus ( A !. B) is the list consisting of the three elements A, . and B,
  3102. whereas (A . B) is the dotted pair of A and B.
  3103. 14.4 LAMBDA Expressions ______ ___________
  3104. LAMBDA expressions provide the means for constructing LISP LAMBDA
  3105. expressions in symbolic mode. They may not be used in algebraic mode.
  3106. Syntax:
  3107. <LAMBDA expression> ::= LAMBDA <varlist><terminator><statement>
  3108. where <varlist> ::= (<variable>,...,<variable>)
  3109. e.g. LAMBDA (X,Y); CAR X . CDR Y
  3110. is equivalent to the LISP LAMBDA expression
  3111. (LAMBDA (X Y) (CONS (CAR X) (CDR Y)))
  3112. The parentheses may be omitted in specifying the variable list if desired.
  3113. LAMBDA expressions may be used in symbolic mode in place of prefix
  3114. operators, or as an argument of the reserved word FUNCTION.
  3115. 14.5 Symbolic Assignment Statements ________ __________ __________
  3116. In symbolic mode, if the left side of an assignment statement is a
  3117. variable, a SETQ of the right hand side to that variable occurs. If the
  3118. left hand side is an expression, it must be of the form of an array
  3119. element, otherwise an error will result.
  3120. e.g. X:=Y translates into (SETQ X Y)
  3121. whereas
  3122. A(3) := 3
  3123. will be valid if A has been previously declared a single dimensioned array
  3124. of at least four elements.
  3125. 14.6 FOR EACH Statement ___ ____ _________
  3126. The FOR EACH (or FOREACH) statement is designed for iteration down a list
  3127. in symbolic mode. Its syntax is:
  3128. FOR EACH ID:identifier {IN|ON} LST:list {DO|COLLECT|CONC} EXPRN:S-expr
  3129. If the keyword IN is used, iteration is on each element of the list, with
  3130. ON, on the whole list remaining at each point in the iteration. The
  3131. keyword DO means that EXPRN is simply evaluated and no value kept; the
  3132. 14-4
  3133. statement returning NIL in this case. COLLECT means that the results of
  3134. evaluating EXPRN each time are consed together, and CONC means they are
  3135. CONCed together. In other words, we have the following equivalence between
  3136. each form of FOR EACH and the various mapping functions in LISP:
  3137. | DO COLLECT CONC
  3138. ----|--------------------------
  3139. IN | MAPC MAPCAR MAPCAN
  3140. ON | MAP MAPLIST MAPCON
  3141. Example:
  3142. To list each element of the list (A B C):
  3143. FOR EACH X IN '(A B C) COLLECT LIST X;
  3144. 14.7 Symbolic Procedures ________ __________
  3145. All the functions described in the Standard LISP Report are available to
  3146. users in symbolic mode. Additional functions may also be defined as
  3147. symbolic procedures. For example, to define the LISP function ASSOC, the
  3148. following could be used:
  3149. SYMBOLIC PROCEDURE ASSOC(U,V);
  3150. IF NULL V THEN NIL
  3151. ELSE IF U = CAAR V THEN CAR V
  3152. ELSE ASSOC(U, CDR V);
  3153. If the default mode were symbolic, then SYMBOLIC could be omitted in the
  3154. above definition. MACROs and FEXPRs may be defined by prefixing the
  3155. keyword PROCEDURE by the word MACRO or FEXPR. (In fact, ordinary functions
  3156. may be defined with the keyword EXPR prefixing PROCEDURE as was used in
  3157. the Standard LISP Report.)
  3158. e.g. we could define a MACRO CONSCONS by
  3159. SYMBOLIC MACRO PROCEDURE CONSCONS L;
  3160. EXPAND(CDR L, 'CONS);
  3161. 14.8 Obtaining the Standard LISP Equivalent of REDUCE Input _________ ___ ________ ____ __________ __ ______ _____
  3162. A user can obtain the Standard LISP equivalent of his REDUCE input by
  3163. turning on the switch DEFN (for definition). The system then prints the
  3164. LISP translation of his input but does not evaluate it. Normal operation
  3165. is resumed when DEFN is turned off.
  3166. 14-5
  3167. 14.9 Communicating with Algebraic Mode _____________ ____ _________ ____
  3168. One of the principal motivations for a user of the algebraic facilities of
  3169. REDUCE to learn about symbolic mode is that it gives one access to a wider
  3170. range of techniques than is possible in algebraic mode alone. For example,
  3171. if a user wishes to use parts of the system defined in the basic system
  3172. source code, or refine their algebraic code definitions to make them more
  3173. efficient, then it is necessary to understand the source language in
  3174. fairly complete detail. Moreover, it is also necessary to know a little
  3175. more about the way REDUCE operates internally. Basically, REDUCE considers
  3176. expressions in two forms; prefix form, which follow the normal LISP rules
  3177. of function composition, and so called canonical form, which uses a
  3178. different syntax.
  3179. Once these details are understood, the most critical problem faced by a
  3180. user is how to make expressions and procedures communicate between symbolic
  3181. and algebraic mode. The purpose of this section is to teach a user the
  3182. basic principles for this.
  3183. If one wants to evaluate an expression in algebraic mode, and then use
  3184. that expression in symbolic mode calculations, or vice versa, the easiest
  3185. way to do this is to assign a variable to that expression whose value is
  3186. easily obtainable in both modes. To facilitate this, a declaration SHARE
  3187. is available. SHARE takes a list of identifiers as argument, and marks
  3188. these variables as having recognizable values in both modes. The
  3189. declaration may be used in either mode.
  3190. E.g.,
  3191. SHARE X,Y;
  3192. says that X and Y will receive values to be used in both modes.
  3193. 14.9.1 Passing Algebraic Mode Values to Symbolic Mode _______ _________ ____ ______ __ ________ ____
  3194. If one wishes to work with parts of an algebraic mode expression in
  3195. symbolic mode, one simply makes an assignment of a shared variable to the
  3196. relevant expression in algebraic mode. For example, if one wishes to work
  3197. with (A+B)**2, one would say, in algebraic mode:
  3198. X := (A+B)**2;
  3199. assuming that X was declared shared as above. If we now change to symbolic
  3200. mode and say
  3201. X;
  3202. its value will be printed as a prefix form with the syntax:
  3203. (*SQ <standard quotient> T)
  3204. 14-6
  3205. This particular format reflects the fact that the algebraic mode processor
  3206. currently likes to transfer prefix forms from command to command, but
  3207. doesn't like to reconvert standard forms (which represent polynomials) and
  3208. standard quotients back to a true LISP prefix form for the expression
  3209. (which would result in excessive computation). So *SQ is used to tell the
  3210. algebraic processor that it is dealing with a prefix form which is really a
  3211. standard quotient and the second argument (T or NIL) tells it whether it
  3212. needs further processing (essentially, an 'already simplified' flag).
  3213. So to get the true standard quotient form in symbolic mode, one needs CADR
  3214. of the variable. E.g.,
  3215. Z := CADR X;
  3216. would store in Z the standard quotient form for (A+B)**2.
  3217. Once you have this expression, you can now manipulate it as you wish. To
  3218. facilitate this, a standard set of selectors and constructors are available
  3219. for getting at parts of the form. Those presently defined are as follows:
  3220. REDUCE Selectors
  3221. DENR denominator of standard quotient
  3222. LC leading coefficient of polynomial
  3223. LDEG leading degree of polynomial
  3224. LPOW leading power of polynomial
  3225. LT leading term of polynomial
  3226. MVAR main variable of polynomial
  3227. NUMR numerator (of standard quotient)
  3228. PDEG degree of a power
  3229. RED reductum of polynomial
  3230. TC coefficient of a term
  3231. TDEG degree of a term
  3232. TPOW power of a term
  3233. REDUCE Constructors
  3234. .+ add a term to a polynomial
  3235. ./ divide (two polynomials to get quotient)
  3236. 14-7
  3237. .* multiply a power by a coefficient to produce a term
  3238. .** raise a variable to a power
  3239. For example, to find the numerator of the standard quotient above, one
  3240. could say:
  3241. NUMR Z;
  3242. or to find the leading term of the numerator:
  3243. LT NUMR Z;
  3244. Conversion between various data structures is facilitated by the use of a
  3245. set of functions defined for this purpose. Those currently implemented
  3246. include:
  3247. !*A2F convert an algebraic expression to a standard form.
  3248. If result is rational, an error results.
  3249. !*A2K converts an algebraic expression to a kernel. If this
  3250. is not possible, an error results.
  3251. !*F2A converts a standard form to an algebraic expression
  3252. !*F2Q convert a standard form to a standard quotient
  3253. !*K2F convert a kernel to a standard form
  3254. !*K2Q convert a kernel to a standard quotient
  3255. !*P2F convert a standard power to a standard form
  3256. !*P2Q convert a standard power to a standard quotient
  3257. !*Q2F convert a standard quotient to a standard form.
  3258. If the quotient denominator is not 1, an error results
  3259. !*Q2K convert a standard quotient to a kernel. If this
  3260. is not possible, an error results.
  3261. !*T2F convert a standard term to a standard form
  3262. !*T2Q convert a standard term to a standard quotient
  3263. 14.9.2 Passing Symbolic Mode Values back to Algebraic Mode _______ ________ ____ ______ ____ __ _________ ____
  3264. In order to pass the value of a shared variable from symbolic mode to
  3265. algebraic mode, the only thing to do is make sure that the value in
  3266. symbolic mode is a prefix expression. E.g.,
  3267. 14-8
  3268. (EXPT (PLUS A B) 2)
  3269. for (A+B)**2, or in the format (*SQ <standard quotient> T) as described
  3270. above. However, if you have been working with parts of a standard form
  3271. they will probably not be in this form. In that case, you can do the
  3272. following:
  3273. 1) If it is a standard quotient, call PREPSQ on it. This takes a standard
  3274. quotient as argument, and returns a prefix expression. Alternatively, you
  3275. can call MK!*SQ on it, which returns a prefix form like (*SQ <standard
  3276. quotient> T) and avoids translation of the expression into a true prefix
  3277. form.
  3278. 2) If it is a standard form, call PREPF on it. This takes a standard form
  3279. as argument, and returns the equivalent prefix expression. Alternatively,
  3280. you can convert it to a standard quotient and then call MK!*SQ.
  3281. 3) If it is a part of a standard form, you must usually first build up a
  3282. standard form out of it, and then go to step 2. The conversion functions
  3283. described earlier may be used for this purpose. For example,
  3284. a) If Z is an expression which is a term, !*T2F Z is a standard form.
  3285. b) If Z is a standard power, !*P2F Z is a standard form.
  3286. c) If Z is a variable, you can pass it direct to algebraic mode.
  3287. For example, to pass the leading term of (A+B)**2 back to algebraic mode,
  3288. one could say:
  3289. Y:= MK!*SQ !*T2Q LT NUMR Z;
  3290. where Y has been declared shared as above. If you now go back to algebraic
  3291. mode, you can work with Y in the usual way.
  3292. 14.9.3 Complete Example ________ _______
  3293. The following is the complete code for doing the above steps. The end
  3294. result will be that the square of the leading term of (A+B)**2 is
  3295. calculated.
  3296. SHARE X,Y; %declare X and Y as shared variables;
  3297. X := (A+B)**2; %store (A+B)**2 in X;
  3298. SYMBOLIC; %transfer to symbolic mode;
  3299. Z := CADR X; %store true standard quotient in Z;
  3300. LT NUMR Z; %print the leading term of the numerator of Z;
  3301. Y := MK!*SQ !*T2Q NUMR Z;
  3302. %store a valid prefix form of this leading term in Y;
  3303. ALGEBRAIC; %return to algebraic mode;
  3304. Y**2; %evaluate the square of the leading term of (A+B)**2;
  3305. 14-9
  3306. 14.9.4 Defining Procedures which Communicate between Modes ________ __________ _____ ___________ _______ _____
  3307. If one wishes to define a procedure in symbolic mode for use as an
  3308. operator in algebraic mode, it is necessary to declare this fact to the
  3309. system by using the declaration OPERATOR in SYMBOLIC MODE. Thus
  3310. SYMBOLIC OPERATOR LEADTERM;
  3311. would declare the procedure LEADTERM as an algebraic operator. This
  3312. declaration MUST be made in symbolic mode as the effect in algebraic mode
  3313. is different. The value of such a procedure must be a prefix form.
  3314. The algebraic processor will pass arguments to such procedures in prefix
  3315. form. Therefore if you want to work with the arguments as standard
  3316. quotients you must first convert them to that form by using the function
  3317. SIMP!*. This function takes a prefix form as argument and returns the
  3318. evaluated standard quotient.
  3319. For example, if you want to define a procedure LEADTERM which gives the
  3320. leading term of an algebraic expression, one could do this as follows:
  3321. SYMBOLIC OPERATOR LEADTERM; %declare LEADTERM as a symbolic mode
  3322. %procedure to be used in algebraic mode;
  3323. SYMBOLIC PROCEDURE LEADTERM U; %define LEADTERM;
  3324. MK!*SQ !*T2Q LT NUMR SIMP!* U;
  3325. Note that this operator has a different effect than the operator LTERM
  3326. (qv). In the latter case, the calculation is done with respect to the
  3327. second argument of the operator. In the example here, we simply extract
  3328. the leading term with respect to the system's choice of main variable.
  3329. Finally, if you wish to use the algebraic evaluator on an argument in a
  3330. symbolic mode definition, the function REVAL can be used. The one argument
  3331. of REVAL must be the prefix form of an expression. REVAL returns the
  3332. evaluated expression as a true LISP prefix form.
  3333. 14.10 References: ___________
  3334. There are a number of useful books which can give you further information
  3335. about LISP. Here is a selection:
  3336. Allen, J. R., "The Anatomy of LISP", McGraw Hill, New York, 1978.
  3337. McCarthy J., P. W. Abrahams, J. Edwards, T. P. Hart and
  3338. M. I. Levin, "LISP 1.5 Programmer's Manual", M.I.T. Press, 1965.
  3339. Weissman, C., "LISP 1.5 Primer", Dickenson, 1967.
  3340. Winston, P. H. and Horn, B. K. P., "LISP", Addison-Wesley, 1981.
  3341. 15-1
  3342. 15. CALCULATIONS IN HIGH ENERGY PHYSICS ____________ __ ____ ______ _______
  3343. A set of REDUCE commands is provided for users interested in symbolic
  3344. calculations in high energy physics. Several extensions to our basic
  3345. syntax are necessary, however, to allow for the different data structures
  3346. encountered.
  3347. 15.1 Notation ________
  3348. In order to allow for the printing of this text on printers with limited
  3349. character sets, we represent Greek characters in this section by their
  3350. (upper case) English names.
  3351. 15.2 Operators used in High Energy Physics Calculations _________ ____ __ ____ ______ _______ ____________
  3352. We begin by introducing three new operators required in these
  3353. calculations.
  3354. 15.2.1 . (DOT) _ _____
  3355. Syntax: (EXPRN1:vector_expression)
  3356. . (EXPRN2:vector_expression):algebraic.
  3357. The . operator is a binary operator used in algebraic mode to denote the
  3358. scalar product of two Lorentz four-vectors. In the present system, the
  3359. index handling routines all assume that Lorentz four-vectors are used, but
  3360. these routines could be rewritten to handle other cases.
  3361. Components of vectors can be represented by including representations of
  3362. unit vectors in the system. Thus if EO represents the unit vector
  3363. (1,0,0,0), (P.EO) represents the zeroth component of the four-vector P.
  3364. Our metric and notation follows Bjorken and Drell "Relativistic Quantum
  3365. Mechanics" (McGraw-Hill, New York, 1965). Similarly, an arbitrary
  3366. component P may be represented by (P.U). If contraction over components of
  3367. vectors is required, then the declaration INDEX must be used.
  3368. Thus
  3369. INDEX U;
  3370. declares U as an index, and the simplification of
  3371. (P.U) * (Q.U)
  3372. would result in
  3373. (P.Q)
  3374. The metric tensor g(u,v) may be represented by (U.V). If contraction over
  3375. 15-2
  3376. u and v is required, then U and V should be declared as indices.
  3377. The declaration REMIND V1...VN; removes the index flags from the variables
  3378. V1 through Vn. However, these variables remain vectors in the system.
  3379. 15.2.2 G _
  3380. Syntax: G(ID:identifier[,EXPRN:vector_expression])
  3381. :gamma_matrix_expression.
  3382. G is an n-ary operator used to denote a product of gamma matrices
  3383. contracted with Lorentz four-vectors. Gamma matrices are associated with
  3384. fermion lines in a Feynman diagram. If more than one such line occurs,
  3385. then a different set of gamma matrices (operating in independent spin
  3386. spaces) is required to represent each line. To facilitate this, the first
  3387. argument of G is a line identification identifier (not a number) used to
  3388. distinguish different lines.
  3389. Thus
  3390. G(L1,P) * G(L2,Q)
  3391. denotes the product of P associated with a fermion line identified as L1,
  3392. and Q associated with another line identified as L2 and where P and Q are
  3393. Lorentz four-vectors. A product of gamma matrices associated with the same
  3394. line may be written in a contracted form.
  3395. Thus
  3396. G(L1,P1,P2,...,P3) = G(L1,P1)*G(L1,P2)*,...,*G(L1,P3)
  3397. The vector A is reserved in arguments of G to denote the special gamma
  3398. matrix GAMMA5. Thus
  3399. G(L,A) = GAMMA5 associated with line L.
  3400. G(L,P,A) = GAMMA.P*GAMMA5 associated with line L.
  3401. GAMMA (associated with line L) may be written as G(L,U), with U flagged
  3402. U
  3403. as an index if contraction over U is required.
  3404. The notation of Bjorken and Drell is assumed in all operations involving
  3405. gamma matrices.
  3406. 15.2.3 EPS ___
  3407. Syntax: EPS(EXPRN1:vector_expression,...,EXPRN4:vector_exp):vector_exp.
  3408. The operator EPS has four arguments, and is used only to denote the
  3409. completely antisymmetric tensor of order 4 and its contraction with Lorentz
  3410. four-vectors.
  3411. 15-3
  3412. Thus
  3413. EPS = ( +1 if I,J,K,L is an even permutation of 0,1,2,3
  3414. IJKL ( -1 if an odd permutation
  3415. ( 0 otherwise
  3416. A contraction of the form EPS p q may be written as EPS(I,J,P,Q),
  3417. IJuv u v
  3418. with I and J flagged as indices, and so on.
  3419. 15.3 Vector variables ______ _________
  3420. Apart from the line identification identifier in the G operator, all other
  3421. arguments of the operators in this section are vectors. Variables used as
  3422. such must be declared so by the type declaration VECTOR.
  3423. e.g. VECTOR P1,P2;
  3424. declares P1 and P2 to be vectors. Variables declared as indices or given a
  3425. mass (qv) are automatically declared vector by these declarations.
  3426. 15.4 Additional Expression Types __________ __________ _____
  3427. Two additional expression types are necessary for high energy
  3428. calculations, namely
  3429. 15.4.1 Vector Expressions ______ ___________
  3430. These follow the normal rules of vector combination. Thus the product of a
  3431. scalar or numerical expression and a vector expression is a vector, as are
  3432. the sum and difference of vector expressions. If these rules are not
  3433. followed, error messages are printed. Furthermore, if the system finds an
  3434. undeclared variable where it expects a vector variable, it will ask the
  3435. user in interactive mode whether to make that variable a vector or not. In
  3436. batch mode, the declaration will be made automatically and the user
  3437. informed of this by a message.
  3438. Examples:
  3439. Assuming P and Q have been declared vectors, the following are vector
  3440. expressions
  3441. P
  3442. P-2*Q/3
  3443. 2*X*Y*P - P.Q*Q/(3*Q.Q)
  3444. whereas P*Q and P/Q are not.
  3445. 15-4
  3446. 15.4.2 Dirac Expressions _____ ___________
  3447. These denote those expressions which involve gamma matrices. A gamma
  3448. matrix is implicitly a 4 x 4 matrix, and so the product, sum and difference
  3449. of such expressions, or the product of a scalar and Dirac expression is
  3450. again a Dirac expression. There are no Dirac variables in the system, so
  3451. whenever a scalar variable appears in a Dirac expression without an
  3452. associated gamma matrix expression, an implicit unit 4 x 4 matrix is
  3453. assumed.
  3454. e.g. G(L,P) + M denotes G(L,P) + M*<unit 4 x 4 matrix>
  3455. Multiplication of Dirac expressions, as for matrix expressions, is of
  3456. course non-commutative.
  3457. 15.5 Trace Calculations _____ ____________
  3458. When a Dirac expression is evaluated, the system computes one quarter of
  3459. the trace of each gamma matrix product in the expansion of the expression.
  3460. One quarter of each trace is taken in order to avoid confusion between the
  3461. trace of the scalar M, say, and M representing M * <unit 4 x 4 matrix>.
  3462. Contraction over indices occurring in such expressions is also performed.
  3463. If an unmatched index is found in such an expression, an error occurs.
  3464. The algorithms used for trace calculations are the best available at the
  3465. time this system was produced. For example, in addition to the algorithm
  3466. developed by Chisholm for contracting indices in products of traces, REDUCE
  3467. uses the elegant algorithm of Kahane for contracting indices in gamma
  3468. matrix products. These algorithms are described in Chisholm, J. S. R., Il
  3469. Nuovo Cimento X, 30, 426 (1963) and Kahane, J., Journal Math. Phys. 9,
  3470. 1732 (1968).
  3471. It is possible to prevent the trace calculation over any line identifier
  3472. by the declaration NOSPUR.
  3473. E.g. NOSPUR L1,L2;
  3474. will mean that no traces are taken of gamma matrix terms involving the line
  3475. numbers L1 and L2. However, in some calculations involving more than one
  3476. line, a catastrophic error "This NOSPUR option not implemented" can occur
  3477. (for the reason stated!) If you encounter this error, please let us know!
  3478. A trace of a gamma matrix expression involving a line identifier which has
  3479. been declared NOSPUR may be later taken by making the declaration SPUR.
  3480. 15.6 Mass Declarations ____ ____________
  3481. It is often necessary to put a particle 'on the mass shell' in a
  3482. calculation. This can, of course, be accomplished with a LET command such
  3483. as
  3484. 15-5
  3485. LET P.P= M**2;
  3486. but an alternative method is provided by two commands MASS and MSHELL.
  3487. MASS takes a list of equations of the form:
  3488. <vector variable> = <scalar variable>
  3489. e.g. MASS P1=M, Q1=MU;
  3490. The only effect of this command is to associate the relevant scalar
  3491. variable as a mass with the corresponding vector. If we now say
  3492. MSHELL <vector variable>,...,<vector variable>;
  3493. and a mass has been associated with these arguments, a substitution of the
  3494. form
  3495. <vector variable>.<vector variable> = <mass>**2
  3496. is set up. An error results if the variable has no preassigned mass.
  3497. 15.7 Example _______
  3498. We give here as an example of a simple calculation in high energy physics
  3499. the computation of the Compton scattering cross-section as given in
  3500. Bjorken and Drell Eqs. (7.72) through (7.74).
  3501. We wish to compute
  3502. 2 2 PF+m E'EKI EE'KF PI+m KIEE' KFE'E
  3503. ALPHA /2 (k'/k) trace ((----)(----- + ------)(----)(----- + ------)).
  3504. 2m 2k.PI 2k'.PI 2m 2k.PI 2k'.PI
  3505. where ki and kf are the four-momenta of incoming and outgoing photons
  3506. (with polarization vectors e and e' and laboratory energies k and k'
  3507. respectively) and pi,pf are incident and final electron four-momenta.
  3508. Upper case momenta in the above formula are used to indicate contractions
  3509. of the momenta with gamma matrices. For example, PF = GAMMA . pf.
  3510. Omitting the factor ALPHA**2/(2*m**2)*(k'/k)**2 we need to find
  3511. E'EKI EE'KF KIEE' KFE'E
  3512. 1/4 trace ((PF+m)(----- + ------)(PI+m)(----- + ------))
  3513. 2k.pi 2k'.pi 2k.pi 2k'.pi
  3514. A straightforward REDUCE program for this, with appropriate substitutions
  3515. would be:
  3516. ON DIV; COMMENT THIS GIVES US OUTPUT IN SAME FORM AS BJORKEN AND DRELL;
  3517. MASS KI= 0, KF= 0, PI= M, PF= M; VECTOR E;
  3518. COMMENT IF E IS USED AS A VECTOR, IT LOSES ITS SCALAR IDENTITY AS THE
  3519. 15-6
  3520. BASE OF NATURAL LOGARITHMS;
  3521. MSHELL KI,KF,PI,PF;
  3522. LET PI.E= 0, PI.EP= 0, PI.PF= M**2+KI.KF, PI.KI= M*K,PI.KF=
  3523. M*KP, PF.E= -KF.E, PF.EP= KI.EP, PF.KI= M*KP, PF.KF=
  3524. M*K, KI.E= 0, KI.KF= M*(K-KP), KF.EP= 0, E.E= -1, EP.EP=-1;
  3525. FOR ALL P LET GP(P)= G(L,P)+M;
  3526. COMMENT THIS IS JUST TO SAVE US A LOT OF WRITING;
  3527. GP(PF)*(G(L,EP,E,KI)/(2*KI.PI) + G(L,E,EP,KF)/(2*KF.PI))
  3528. * GP(PI)*(G(L,KI,E,EP)/(2*KI.PI) + G(L,KF,EP,E)/(2*KF.PI)) $
  3529. WRITE "THE COMPTON CROSS-SECTION IS ",WS;
  3530. This program will print the following result
  3531. (-1) (-1) 2
  3532. THE COMPTON CXN IS 1/2*K*KP + 1/2*K *KP + 2*E.EP - 1
  3533. 15.8 Extensions to More than Four Dimensions __________ __ ____ ____ ____ __________
  3534. In our discussion so far, we have assumed that we are working in the
  3535. normal four dimensions of QED calculations. However, in most cases, the
  3536. programs will also work in an arbitrary number of dimensions. The command
  3537. VECDIM <expression>;
  3538. sets the appropriate dimension. The dimension can be symbolic as well as
  3539. numeric. Users should note however, that the EPS operator and the gamma 5
  3540. symbol (A) are not properly defined in other than four dimensions and will
  3541. lead to an error if used.
  3542. 16-1
  3543. 16. REDUCE AND RLISP UTILITIES ______ ___ _____ _________
  3544. REDUCE and its associated support language system RLISP include a number
  3545. of utilities which have proved useful for program development over the
  3546. years. The following are supported in most of the implementations of
  3547. REDUCE currently available.
  3548. 16.1 The Standard LISP Compiler ___ ________ ____ ________
  3549. REDUCE includes a Standard LISP compiler that is automatically loaded on
  3550. demand. To make the compiler active, the switch COMP should be turned on.
  3551. Any further definitions input after this will be compiled automatically.
  3552. Furthermore, if the switch PWRDS is on (the default), a statistics message
  3553. of the form
  3554. <function-name> COMPILED, <words> WORDS, <words> LEFT
  3555. is printed. The first number is the number of words of binary program
  3556. space the compiled function took, and the second number the number of words
  3557. left unused in binary program space.
  3558. Other switches of interest which may be used with the compiler are as follows:
  3559. PLAP If ON, causes the printing of the portable macros produced
  3560. by the compiler.
  3561. PGWD If ON, causes the printing of the actual assembly language
  3562. instructions generated from the macros.
  3563. A complete description of the compiler may be found in M. L. Griss and A.
  3564. C. Hearn, "A Portable LISP Compiler", SOFTWARE - Practice and Experience
  3565. 11 (1981) 541-605.
  3566. 16.2 Fast Loading Code Generation Program ____ _______ ____ __________ _______
  3567. It is possible to take any set of LISP, RLISP or REDUCE commands and build
  3568. a fast loading version of them. In RLISP or REDUCE, one does the
  3569. following:
  3570. FASLOUT <filename>;
  3571. <commands or IN statements>
  3572. FASLEND;
  3573. To load such a file, one uses the command LOAD, e.g. LOAD FOO; or LOAD
  3574. FOO,BAH;
  3575. Fast-loading files produced by this process may have an implementation
  3576. dependent extension added by this process. For example, on the DEC-10 an
  3577. extension FAP is added, and on the VAX, b (for binary). Such extensions are
  3578. required by the LOAD program; if they are missing, an error occurs.
  3579. 16-2
  3580. In doing this build, as with the production of a Standard LISP form of
  3581. such statements, it is important to remember that some of the commands
  3582. must be instantiated during the building process. For example, macros must
  3583. be expanded, and some property list operations must happen. To facilitate
  3584. this, the EVAL and IGNORE flags (qv) may be used. Note also that there can
  3585. be no LOAD command within the input statements.
  3586. To avoid excessive printout, input statements should be followed by a $
  3587. instead of the semicolon. With LOAD however, the input doesn't print out
  3588. regardless of which terminator is used with the command.
  3589. If you subsequently change the source files used in producing a fast
  3590. loading file, don't forget to repeat the above process in order to update
  3591. the fast loading file correspondingly. Remember also that the text which
  3592. is read in during the creation of the fast load file, in the compiling
  3593. process described above, is NOT stored in your REDUCE environment, but only
  3594. translated and output. If you want to use the file just created, you must
  3595. then use LOAD to load the output of the fast-loading file generation program.
  3596. 16.3 The Standard LISP Cross-Reference Program ___ ________ ____ _______________ _______
  3597. CREF is a Standard LISP program for processing a set of Standard LISP
  3598. function definitions to produce:
  3599. 1) A "summary" showing:
  3600. i. A list of files processed.
  3601. ii. A list of "entry points" (functions which are not called or
  3602. are only called by themselves).
  3603. iii. A list of undefined functions (functions called but not
  3604. defined in this set of functions).
  3605. iv. A list of variables that were used non-locally but not
  3606. declared GLOBAL or FLUID before their use.
  3607. v. A list of variables that were declared GLOBAL but not used
  3608. as FLUIDs, i.e., bound in a function.
  3609. vi. A list of FLUID variables that were not bound in a function
  3610. so that one might consider declaring them GLOBALs.
  3611. vii. A list of all GLOBAL variables present.
  3612. viii. A list of all FLUID variables present.
  3613. ix. A list of all functions present.
  3614. 2) A "global variable usage" table, showing for each non-local
  3615. variable:
  3616. i. Functions in which it is used as a declared FLUID or GLOBAL.
  3617. ii. Functions in which it is used but not declared.
  3618. iii. Functions in which it is bound.
  3619. iv. Functions in which it is changed by SETQ.
  3620. 3) A "function usage" table showing for each function:
  3621. i. Where it is defined.
  3622. 16-3
  3623. ii. Functions which call this function.
  3624. iii. Functions called by it.
  3625. iv. Non-local variables used.
  3626. The program will also check that functions are called with the correct
  3627. number of arguments, and print a diagnostic message otherwise.
  3628. The output is alphabetized on the first seven characters of each function
  3629. name.
  3630. 16.3.1 Restrictions: _____________
  3631. Algebraic procedures in REDUCE are treated as if they were symbolic, so
  3632. that algebraic constructs will actually appear as calls to symbolic
  3633. functions, such as AEVAL.
  3634. 16.3.2 Usage: ______
  3635. To invoke the cross reference program, the switch CREF is used. ON CREF
  3636. causes the cref program to load and the cross-referencing process to
  3637. begin. After all the required definitions are loaded, OFF CREF will cause
  3638. the cross-reference listing to be produced. For example, if you wish to
  3639. cross-reference all functions in the file TST.RED, and produce the
  3640. cross-reference listing in the file TST.CRF, the following sequence can be
  3641. used:
  3642. OUT TST.CRF;
  3643. ON CREF;
  3644. IN TST.RED$
  3645. OFF CREF;
  3646. END;
  3647. To process more than one file, more IN statements may be added before the
  3648. call of OFF CREF, or the IN statement changed to include a list of files.
  3649. 16.3.3 Options: ________
  3650. Functions with the flag NOLIST will not be examined or output. Initially,
  3651. all Standard LISP functions are so flagged. (In fact, they are kept on a
  3652. list NOLIST!*, so if you wish to see references to ALL functions, then CREF
  3653. should be first loaded with the command LOAD CREF, and this variable then
  3654. set to NIL).
  3655. It should also be remembered that any macros with the property list flag
  3656. EXPAND, or, if the switch FORCE is on, without the property list flag
  3657. NOEXPAND, will be expanded before the definition is seen by the cross-
  3658. reference program, so this flag can also be used to select those macros you
  3659. require expanded and those you do not.
  3660. 16-4
  3661. 16.4 Prettyprinting Reduce Expressions ______________ ______ ___________
  3662. REDUCE includes a module for printing REDUCE syntax in a standard format.
  3663. This module is activated by the switch PRET, which is normally off.
  3664. Since the system converts algebraic input into an equivalent symbolic form,
  3665. the printing program tries to interpret this as an algebraic expression
  3666. before printing it. In most cases, this can be done successfully. However,
  3667. there will be occasional instances where results are printed in symbolic
  3668. mode form that bears little resemblance to the original input, even though
  3669. it is formally equivalent.
  3670. If you want to prettyprint a whole file, say OFF OUTPUT,MSG; and
  3671. (hopefully) only clean output will result. Unlike DEFN (qv), input is also
  3672. evaluated with PRET on.
  3673. 16.5 Prettyprinting Standard LISP S-expressions ______________ ________ ____ _____________
  3674. Standard LISP includes a module for printing S-expressions in a standard
  3675. format. The Standard LISP function for this purpose is PRETTYPRINT which
  3676. takes a LISP expression and prints the formatted equivalent.
  3677. Users can also have their REDUCE input printed in this form by use of the
  3678. switch DEFN. This is in fact a convenient way to convert REDUCE (or RLISP)
  3679. syntax into LISP. OFF MSG; will prevent warning messages from being printed.
  3680. NOTE: When DEFN is on, input is not evaluated.
  3681. A-1
  3682. A. RESERVED IDENTIFIERS ________ ___________
  3683. We list here all identifiers which are normally reserved in REDUCE. We
  3684. include in this list all reserved identifiers described in the text plus
  3685. all command names and operators initially in the system.
  3686. Commands ALGEBRAIC ARRAY CLEAR COMMENT END FACTOR FOR
  3687. FORALL GO GOTO IF IN INTEGER LET LISP MASS
  3688. MATCH MATRIX MSHELL NOSPUR OFF ON OPERATOR
  3689. ORDER OUT PROCEDURE REAL RETURN SAVEAS SCALAR
  3690. SHUT SPUR SYMBOLIC VECTOR WEIGHT WRITE
  3691. WTLEVEL (Page 5-1)
  3692. Infix Operators := = >= > <= < + * / ** . SETQ OR AND NOT MEMBER
  3693. MEMQ EQUAL NEQ EQ GEQ GREATERP LEQ LESSP PLUS
  3694. DIFFERENCE MINUS TIMES QUOTIENT EXPT CONS (Page 2-6)
  3695. Prefix Operators COEFF COS DEN DET DF EPS G LOG MAT INT NUM SIN
  3696. SUB TRACE (Page 6-1)
  3697. Reserved Variables E I NIL PI T (Page 2-3)
  3698. Reserved Words ALGEBRAIC ANTISYMMETRIC ARRAY BEGIN CLEAR CMD CONT
  3699. CORE CREATE DCL DEFINE DEPEND DOWN EDIT EDITDEF
  3700. EMB END EXEC EXPR FACTOR FEXPR FLAGOP FLOAD FOR
  3701. FORALL FOREACH FSLOUT GO HELP IF IN INDEX INFIX
  3702. INPUT INTEGER KORDER LAMBDA LET LINEAR LISP MACRO
  3703. MASS MATCH MATRIX MSHELL NODEPEND OFF ON OPERATOR
  3704. ORDER OUT PAUSE PRECEDENCE PROCEDURE QUIT REAL
  3705. REMFAC REPEAT RETRY RETURN RLISP SAVEAS SCALAR
  3706. SHARE SHOWTIME SHUT SLISP SMACRO STRUCTR SYMBOLIC
  3707. SYMMETRIC TR TRST UP VARNAME VECTOR WEIGHT WHILE
  3708. WRITE WS WTLEVEL (Page 2-4)
  3709. B-1
  3710. B. OPERATORS NORMALLY AVAILABLE IN REDUCE _________ ________ _________ __ ______
  3711. Notation: Each operator is provided with a prototypical header line given
  3712. here. Each formal parameter is given a name and followed by its allowed
  3713. type. The names of classes referred to in the definition are printed in
  3714. lower case, and parameter names in upper case. If a parameter type is not
  3715. commonly used, it may be a specific set enclosed in brackets {...}.
  3716. Operators which accept formal parameter lists of arbitrary length have the
  3717. parameter and type class enclosed in square brackets indicating that zero
  3718. or more occurrences of that argument are permitted. Optional parameters
  3719. and their type classes are enclosed in angle brackets.
  3720. ARGLENGTH(EXPRN:algebraic)
  3721. Returns the number of arguments of the top level
  3722. operator in EXPRN (Page 7-14)
  3723. COEFF(EXPRN:polynomial,VAR:kernel,ID:identifier)
  3724. Partitions polynomial EXPRN into its coefficients
  3725. with respect to VAR and stores them in ID
  3726. (Page 7-12)
  3727. DEG(EXPRN:polynomial,VAR:kernel):integer
  3728. Returns the leading degree of the polynomial EXPRN
  3729. in the variable VAR (Page 8-6)
  3730. DEN(EXPRN:rational):polynomial
  3731. Returns the denominator of the rational expression
  3732. EXPRN (Page 8-6)
  3733. DET(EXPRN:matrix_expression):algebraic
  3734. Returns the determinant of the matrix EXPRN
  3735. (Page 12-2)
  3736. DF(EXPRN:algebraic,[VAR:kernel<,NUM:integer>]):algebraic
  3737. Returns the derivative of EXPRN wrt VAR, repeated
  3738. NUM times (Page 6-2)
  3739. EPS(EXPRN1:vector_expression,...,EXPRN4:vector_exp):vector_exp
  3740. Represents the antisymmetric tensor of order 4 in
  3741. high energy physics calculations (Page 15-2)
  3742. FACTORIZE(EXPRN:polynomial[,ID:identifier[,INTEXP:prime integer]])
  3743. Factorizes polynomial EXPRN, leaving factors in ID,
  3744. and using optional prime INTEXP for internal
  3745. computation (Page 8-2)
  3746. GCD(EXPRN1:polynomial,EXPRN2:polynomial):polynomial
  3747. Returns the greatest common divisor of the two
  3748. polynomials EXPRN1 and EXPRN2 (Page 8-4)
  3749. G(ID:identifier[,EXPRN:vector_expression]):gamma_matrix_expression
  3750. Represents a Dirac gamma matrix expression in high
  3751. B-2
  3752. energy physics calculations (Page 15-2)
  3753. LCOF(EXPRN:polynomial,VAR:kernel):polynomial
  3754. Returns the leading coefficient of the polynomial
  3755. EXPRN in the variable VAR (Page 8-7)
  3756. LINELENGTH(NUM:integer):integer
  3757. Sets the output line length to NUM and returns
  3758. previous line length (Page 7-3)
  3759. LTERM(EXPRN:polynomial,VAR:kernel):polynomial
  3760. Returns the leading term of EXPRN with respect to
  3761. VAR (Page 8-7)
  3762. MAINVAR(EXPRN:polynomial):expression
  3763. Returns the main variable of EXPRN (Page 8-7)
  3764. MAT Used to represent matrices (Page 12-1)
  3765. NUM(EXPRN:rational):polynomial
  3766. Returns the numerator of the rational expression
  3767. EXPRN (Page 8-8)
  3768. PART(EXPRN:algebraic[,INTEXP:integer])
  3769. Returns the appropriate part of EXPRN as defined
  3770. by INTEXP (Page 7-13)
  3771. PFACTORIZE(EXPRN:polynomial,ID:identifier,INTEXP:prime integer)
  3772. Factorizes the univariate polynomial EXPRN modulo
  3773. the prime INTEXP, storing the resultant factors in
  3774. ID (Page 8-3)
  3775. REDUCT(EXPRN:polynomial,VAR:kernel):polynomial
  3776. Returns the reductum of EXPRN with respect to'
  3777. VAR (Page 8-8)
  3778. REMAINDER(EXPRN1:polynomial,EXPRN2:polynomial):polynomial
  3779. Returns the remainder when EXPRN1 is divided by
  3780. EXPRN2 (Page 8-5)
  3781. RESULTANT(EXPRN1:polynomial,EXPRN2:polynomial,VAR:kernel):polynomial
  3782. Returns the resultant of EXPRN1 and EXPRN2 with
  3783. respect to the variable VAR (Page 8-6)
  3784. SOLVE(EXPRN:algebraic[,VAR:kernel]):integer
  3785. Solves a set of linear equations in terms of the
  3786. kernel VAR (Page 6-5)
  3787. STRUCTR(EXPRN:algebraic):EXPRN
  3788. Displays the structure of EXPRN (Page 7-11)
  3789. SUB([VAR1:kernel = EXPRN1:algebraic],EXPRN:algebraic):algebraic
  3790. Replaces every occurrence of VAR1 in EXPRN by
  3791. B-3
  3792. EXPRN1 (Page 6-7)
  3793. TP(EXPRN:matrix_expression):matrix
  3794. Returns the transpose of the matrix EXPRN
  3795. (Page 12-3)
  3796. TRACE(EXPRN:matrix_expression):algebraic
  3797. Returns the trace of the matrix EXPRN (Page 12-3)
  3798. VARNAME(ID:identifier) Sets the expression naming variable to ID
  3799. (Page 7-10)
  3800. C-1
  3801. C. COMMANDS AND DECLARATIONS ________ ___ ____________
  3802. This index summarizes the commands and declarations normally available in
  3803. REDUCE.
  3804. Notation: E, E1,...,En denote expressions
  3805. V, V1,...,Vn denote variables (or more generally kernels)
  3806. ALGEBRAIC E; If E is empty, the system mode is set to algebraic.
  3807. Otherwise, E is evaluated in algebraic mode and the
  3808. system mode is not changed (Page 14-1)
  3809. ARRAY V1<size>,...,Vn<size>
  3810. Declares V1 through Vn as array names. <size>
  3811. describes the maximum size of the array (Page 5-1)
  3812. BYE; Stops the execution of REDUCE and returns you to
  3813. the system monitor. The REDUCE job is destroyed
  3814. (Page 5-3)
  3815. CLEAR E1,...En; Removes any substitutions declared for E1 through
  3816. En from system (Page 9-3)
  3817. COMMENT <any>; Used for including comments in text. <any> is any
  3818. sequence of characters not including a
  3819. terminator (Page 2-4)
  3820. CONT; An interactive command which causes the system to
  3821. continue the calculation from the point in the input
  3822. file where the last PAUSE was encountered (Page 11-2)
  3823. DEFINE E1,...,En; Allows for the replacement of the left-hand-side of
  3824. the equations E1 through En by the corresponding
  3825. right-hand-side (Page 5-3)
  3826. DEPEND V1,...,Vn; Sets up a dependency of variable V1 on kernels V2
  3827. through Vn (Page 6-10)
  3828. DISPLAY E; Causes previous inputs to be displayed. If E is a
  3829. non-negative integer, then that many expressions
  3830. will be displayed (Page 11-1)
  3831. EDITDEF <name> Causes the uncompiled procedure <name> to be
  3832. displayed in interactive editing mode (Page 11-2)
  3833. ED <null or number> Invokes an interactive string editor for previous
  3834. command or command <number> (Page 11-2)
  3835. END; Used to terminate a program block, end a file, or
  3836. transfer control to LISP (Page 5-2)
  3837. C-2
  3838. FACTOR E1,...En; Declares expressions as factors in output (Page 7-4)
  3839. FOR Command used to define a variety of program loops
  3840. (Page 4-3)
  3841. FORALL V1,...,Vn <command>
  3842. Declares variables V1 through Vn as arbitrary in
  3843. the substitution rule given by <command> (Page 9-2)
  3844. FOR EACH Used for defining a variety of iterations on lists
  3845. in symbolic mode (Page 14-3)
  3846. GO (TO) V; Performs an unconditional transfer to label V
  3847. Can only be used in compound statements (Page 4-8)
  3848. IF Used to define conditional statements (Page 4-2)
  3849. INDEX V1,...,Vn; Declares high energy vectors V1 through Vn as
  3850. indices (Page 15-1)
  3851. INFIX ID1,...,IDn; Declares ID1 through IDn to be infix operators
  3852. (Page 6-7)
  3853. INTEGER V1,...,Vn; Declares V1 through Vn as local integer variables in
  3854. a block statement (Page 4-6)
  3855. IN V1,...,Vn; Inputs the external REDUCE files V1 through
  3856. Vn (Page 10-1)
  3857. KORDER V1,...,Vn; Declares an internal ordering for variables V1
  3858. through Vn (Page 7-12)
  3859. LET E1,...,En; Declares substitutions for the left hand sides of
  3860. expressions E1 through En. In addition, LET can be
  3861. used to input differentiation rules (Page 9-1)
  3862. LISP E; A synonym for SYMBOLIC E; (Page 14-1)
  3863. MASS V1=M1,...,VN=MN; Assigns a mass Mi to each vector Vi in high energy
  3864. physics calculations (Page 15-5)
  3865. MATCH E1,..., En; Declares substitutions for the left hand sides
  3866. of E1 through En when matching of explicit
  3867. powers is required (Page 9-6)
  3868. MATRIX E1,...,En; Declares matrix variables to the system. The
  3869. Ei may be matrix variable names, or include
  3870. details of the size of the matrix (Page 12-1)
  3871. MSHELL V1,...,Vn; Puts each Vi "on the mass shell" in high energy
  3872. physics calculations (Page 15-5)
  3873. C-3
  3874. NODEPEND V1,...,Vn; Removes dependency of variable V1 on V2 through
  3875. Vn (Page 6-10)
  3876. NONCOM ID1,...,IDn; Declares operators ID1 through IDn to be non-
  3877. commutative under multiplication (Page 6-9)
  3878. NOSPUR V1,...,Vn; Declares that line identification symbols V1 through
  3879. Vn do not have traces taken over them in high energy
  3880. physics calculations (Page 15-4)
  3881. OFF V1,...,Vn; Turns off the switches V1 through Vn (Page 5-2)
  3882. ON V1,...,Vn; Turns on the switches V1 through Vn (Page 5-2)
  3883. OPERATOR V1,...,Vn; Declares identifiers V1 through Vn as algebraic
  3884. operators (Page 6-7)
  3885. ORDER V1,...,Vn; Declares an ordering for variables V1 through Vn on
  3886. output (Page 7-4)
  3887. OUT V; Declares V as an output file (Page 10-1)
  3888. PAUSE; An interactive command for use in an input file.
  3889. When it is evaluated, control is transferred to
  3890. the user's terminal (Page 11-2)
  3891. PRECEDENCE ID1,ID2; Give infix operator ID1 a precedence higher than
  3892. ID2 (Page 6-7)
  3893. PRECISION E; Sets the real number precision to E decimal digits
  3894. when arbitrary precision real arithmetic (BIGFLOAT)
  3895. is used (Page 8-9)
  3896. PROCEDURE Names a statement for repeated use in calculations.
  3897. Type specification of procedure precedes the
  3898. command name (Page 13-1)
  3899. QUIT; Stops the execution of REDUCE and returns you to
  3900. the system monitor. The REDUCE job is retained
  3901. (Page 5-3)
  3902. REAL V1,...,Vn; Declares V1 through Vn as local real variables in a
  3903. block statement (Page 4-6)
  3904. REMFAC E1,...,En; Removes expressions as factors in output (Page 7-4)
  3905. REMIND V1,...,Vn; Declares that V1 through Vn are no longer high
  3906. energy physics indices (Page 15-2)
  3907. RETURN E; Causes a transfer out of a compound statement
  3908. to the next highest program level. Value of E
  3909. is returned from compound statement. E may be
  3910. empty (Page 4-8)
  3911. C-4
  3912. SAVEAS E; Assigns E to the current expression in the
  3913. workspace (Page 7-2)
  3914. SCALAR V1,...,Vn; Declares V1 through Vn as local scalar variables in
  3915. a block statement (Page 4-6)
  3916. SETMOD E; Sets the modular base to E (used with the switch
  3917. MODULAR) (Page 8-9)
  3918. SHARE V1,...,Vn; Permits variables V1 through Vn to be accessed
  3919. in both symbolic and algebraic modes (Page 14-5)
  3920. SHOWTIME; Prints the elapsed time since the last call of this
  3921. command or the beginning of the session (Page 5-3)
  3922. SHUT V1,...,Vn; Closes the output files V1 through Vn (Page 10-2)
  3923. SPUR V1,...,Vn; Declares that line identification symbols V1 through
  3924. Vn now have traces taken over them in high energy
  3925. physics calculations (Page 15-4)
  3926. SYMBOLIC E; If E is empty, the system evaluation mode is set to
  3927. symbolic. Otherwise, E is evaluated in symbolic mode
  3928. and the system mode not changed (Page 14-1)
  3929. VECDIM E; Sets the dimension of the vector and Dirac matrix
  3930. algebra to the expression E in high energy physics
  3931. calculations (Page 15-6)
  3932. VECTOR V1,...,Vn; Declares V1 through Vn to be high energy physics
  3933. vectors (Page 15-3)
  3934. WEIGHT E1,...En; Assigns an asymptotic weight to the left hand sides
  3935. of E1 through En (Page 9-6)
  3936. WRITE E1,...,En; Causes the values of E1 through En to be written on
  3937. the current output channel (Page 7-6)
  3938. WTLEVEL E; Sets the asymptotic weight level of the system to E
  3939. (Page 9-6)
  3940. D-1
  3941. D. MODE SWITCHES IN REDUCE ____ ________ __ ______
  3942. This section lists the switches that may appear as arguments of ON and OFF.
  3943. The action of the switch when it is ON is described here, unless stated
  3944. otherwise. Unless otherwise indicated the default value of the switch is
  3945. OFF.
  3946. ALLBRANCH Used by the SOLVE module to select all or only
  3947. principal branches of solutions. Default ON
  3948. (Page 6-6)
  3949. ALLFAC Causes the system to factor out common products on
  3950. output of expressions. Default ON (Page 7-5)
  3951. BIGFLOAT Provides for the use of arbitrary precision real
  3952. coefficients in polynomials (Page 8-9)
  3953. COMP If ON, causes succeeding function definitions to be
  3954. compiled (Page 16-1)
  3955. CREF If ON, causes a cross-reference analysis of subse-
  3956. quent inputs to occur. The actual table is printed
  3957. following a later OFF CREF (Page 16-3)
  3958. DEFN Causes the system to output the LISP equivalent of
  3959. REDUCE input without evaluation (Page 14-4)
  3960. DEMO Causes the system to pause after each command in a
  3961. file until a Return is typed on the terminal (Page 5-2)
  3962. DIV Causes the system to divide out simple factors on
  3963. output, so that negative powers or rational fractions
  3964. can be produced (Page 7-5)
  3965. ECHO Causes echoing of input (Page 10-1)
  3966. EXP Causes expressions to be expanded during their
  3967. evaluation. Default ON (Page 8-1)
  3968. FACTOR If on, causes the system to factor expressions into
  3969. factors with integer coefficients (Page 8-2)
  3970. FAILHARD If on, causes integration algorithm to terminate
  3971. with an error if integral not possible in closed
  3972. terms (Page 6-4)
  3973. FLOAT Allows for the use of floating point numbers during
  3974. evaluation (Page 3-2)
  3975. FORT Declares output in a FORTRAN notation (Page 7-9)
  3976. D-2
  3977. GCD Causes the system to cancel greatest common divisors
  3978. in rational expressions (Page 8-4)
  3979. INT Specifies an interactive mode of operation. Default
  3980. is system dependent (Page 11-2)
  3981. LCM When on, uses least common multiple of denominators
  3982. when combining rational expressions (Page 8-5)
  3983. LIST Causes output to be listed one term to each line
  3984. (Page 7-5)
  3985. MCD Causes denominators to be combined when expressions
  3986. are added. Default ON (Page 8-5)
  3987. MODULAR Provides for the use of modular integer coefficients.
  3988. Base used is set by SETMOD (Page 8-9)
  3989. MSG When off, suppresses the printing of warning
  3990. messages. Error messages are still printed.
  3991. Default ON (Page 16-4)
  3992. NAT Specifies 'natural' style of output. Default ON
  3993. (Page 7-11)
  3994. NERO Inhibits printing of zero assignments (Page 7-8)
  3995. NOLNR Suppresses the use of the linear properties in the
  3996. integration algorithm (Page 6-4)
  3997. OUTPUT If OFF, suppresses printing the value of any top
  3998. level expression. Default ON (Page 7-3)
  3999. PERIOD Causes a period to be printed after each integer
  4000. coefficient in FORTRAN output. Default ON
  4001. (Page 7-10)
  4002. PGWD Causes the printing of the assembly language
  4003. instructions generated from the macros (Page 16-1)
  4004. PLAP Causes the printing of the portable macros produced
  4005. by the compiler (Page 16-1)
  4006. PRET Causes input commands to be printed in REDUCE syntax
  4007. in a standard format (Page 16-4)
  4008. PRI Specifies formatted printing for output. Default
  4009. ON (Page 7-3)
  4010. PWRDS Causes a statistics message to be printed after a
  4011. function is compiled. Default ON (Page 16-1)
  4012. D-3
  4013. RAISE Causes input lower case characters to be converted
  4014. into upper case. Characters in strings and those
  4015. preceded by ! are excluded. Default ON (Page 2-1)
  4016. RAT Output switch used in conjunction with FACTOR. Causes
  4017. the overall denominator in an expression to be
  4018. printed with each factored sub-expression (Page 7-6)
  4019. RATIONAL Provides for the use of rational number coefficients
  4020. in polynomials (Page 8-8)
  4021. RESUBS When RESUBS is off, the system does not re-examine
  4022. an expression for further substitutions after one
  4023. has been made. Default ON (Page 9-5)
  4024. SOLVEINTERVAL Used by the SOLVE module to represent inexact roots
  4025. by intervals (Page 6-5)
  4026. SOLVESINGULAR Used by the SOLVE module to solve degenerate systems
  4027. by introducing arbitrary constants. Default ON
  4028. (Page 6-5)
  4029. SOLVEWRITE Used by the SOLVE module to control printing of
  4030. solutions. Default ON (Page 6-6)
  4031. TIME Causes the system to print a message after each
  4032. command giving the elapsed cpu time since the last
  4033. command, or since TIME was last turned OFF or the
  4034. session began (Page 5-2)
  4035. TRFAC Traces the operation of the factorization algorithm
  4036. (Page 8-3)
  4037. TRINT Traces the operation of the integration algorithm
  4038. (Page 6-4)
  4039. E-1
  4040. E. DIAGNOSTIC AND ERROR MESSAGES IN REDUCE __________ ___ _____ ________ __ ______
  4041. Diagnostic messages in the REDUCE system are of two types; error messages
  4042. and warning messages. The former usually cause the termination of the
  4043. current calculation whereas the latter warn the user of an ambiguity
  4044. encountered or some action taken which may indicate an error. If the
  4045. system is in an interactive state, it can ask the user when it encounters
  4046. an ambiguity for the correct interpretation. Otherwise it will make the
  4047. most plausible guess, print a message informing the user of the choice
  4048. made, and continue.
  4049. If an error is found during the parsing of the input, the current phrase
  4050. is reprinted with the place marked where the error was encountered. In
  4051. interactive systems, the expression can then be edited with the command
  4052. ED.
  4053. A list of the current diagnostic messages is given below. Those that
  4054. indicate a warning (as opposed to an error) are so marked.
  4055. Notation: E, E1,...,En denote expressions
  4056. ID, ID1...,IDn denote identifiers
  4057. A represents only gamma5 in vector expressions
  4058. An attempt to use A as other than gamma5 in a high
  4059. energy physics expression has been found (Page 15-2)
  4060. CATASTROPHIC ERROR This error should not occur normally. If it does,
  4061. please send a copy of the relevant input and output
  4062. to the author (Page 3-2)
  4063. Cannot shut current input file ID
  4064. An attempt has been made to shut the current input
  4065. file (Page 10-2)
  4066. Continuing with parsing only
  4067. An error has been found in a session being run in
  4068. batch mode, so no further computation is done
  4069. (Page 11-1)
  4070. Domain mode ID1 changed to ID2
  4071. An automatic change of domain mode has occurred. This
  4072. is usually the result of a user's change in a switch
  4073. value. WARNING (Page 8-8)
  4074. Domain mode error: <reason>
  4075. A check of the tables that control polynomial coeff-
  4076. icient arithmetic has revealed an error. This should
  4077. only occur if a user has introduced a new coefficient
  4078. mode (Page 8-8)
  4079. EOF read [in file ID] There was a missing END in a file, or an end-of-file
  4080. character had been typed on a terminal (Page 10-1)
  4081. E-2
  4082. E invalid [in ID statement]
  4083. The expression E is not permitted at this point in
  4084. the (optionally) named statement (Page 4-1)
  4085. E invalid as ID The expression E has been used in a context where
  4086. ID was required (Page 8-1)
  4087. Gamma5 not allowed unless vecdim is 4
  4088. Gamma5 has been used in a computation involving a
  4089. vector dimension other than 4 (Page 15-6)
  4090. ID invalid outside block
  4091. An INTEGER, REAL or SCALAR declaration has been
  4092. used outside a block. Such declarations should be
  4093. deleted (Page 4-6)
  4094. ID is a reserved identifier
  4095. The reserved variable ID has not been used
  4096. correctly (Page 2-3)
  4097. ID not found ID was expected but could not be found (Page 6-7)
  4098. ID not open An attempt has been made to shut a file that has
  4099. not been opened for output (Page 10-2)
  4100. ID redefined ID has been defined of a particular type more than
  4101. once. WARNING (Page 6-7)
  4102. ID too long for FORTRAN An identifier exceeds the size allowed for FORTRAN
  4103. identifiers (Page 7-9)
  4104. ID1 ID2 not set An object of type ID1 and name ID2 whose size is not
  4105. yet known has been referenced (Page 12-1)
  4106. ID1 declared ID2 ID1 has been declared of type ID2. Posed as a
  4107. question in interactive mode. WARNING (Page 6-7)
  4108. Improper delimiter An unexpected delimiter has been found at or near
  4109. the marked position (Page 2-5)
  4110. Index out of range A reference has been made to an array element or
  4111. other structure outside the defined index range
  4112. (Page 5-1)
  4113. Invalid S-expression An ill-formed S-expression has been found on input
  4114. at or near the marked point (Page 14-3)
  4115. Invalid modular division
  4116. A modular division in which the argument is not
  4117. co-prime with the modulus has occurred (Page 8-9)
  4118. MACRO ID used as function
  4119. A MACRO has been used as a functional argument
  4120. E-3
  4121. (Page 14-4)
  4122. Matrix mismatch Two matrix expressions are not correctly matched for
  4123. addition or multiplication (Page 12-2)
  4124. Missing ID A symbol of type ID (e.g., matrix or vector) was
  4125. expected and not found (Page 15-3)
  4126. Missing arguments for G operator
  4127. A line symbol is missing in a gamma matrix
  4128. expression (Page 15-2)
  4129. Missing operator An operator was expected at or near the marked
  4130. position (Page 2-5)
  4131. Non square matrix An invalid operation on a non square matrix has been
  4132. requested (e.g., a trace) (Page 12-2)
  4133. No file open CONT has been improperly called with no files open
  4134. (Page 11-3)
  4135. Redundant operator An unexpected operator was found at or near the
  4136. marked position (Page 2-5)
  4137. Redundant vector A redundant vector has been found in a vector
  4138. expression (Page 15-3)
  4139. Singular matrix A request has been made to invert a singular
  4140. matrix (Page 12-2)
  4141. Substitution for <expression> not allowed
  4142. Indicates that <expression> is an invalid form in a
  4143. LET or CLEAR statement (Page 9-3)
  4144. Syntax error: <reason> A syntax error has been encountered in the input
  4145. for the reason given (Page 2-5)
  4146. Too few right parentheses
  4147. Input syntax error (Page 2-5)
  4148. Too many right parentheses
  4149. Input syntax error (Page 2-5)
  4150. Unmatched free variables <list>
  4151. The variables in <list> have not been properly
  4152. matched in a LET statement (Page 9-3)
  4153. Unmatched index <list> Unmatched indices have been encountered during the
  4154. evaluation of a gamma matrix expression (Page 15-4)
  4155. V has no mass A variable encountered in an MSHELL declaration has
  4156. no mass assigned to it (Page 15-5)
  4157. E-4
  4158. Wrong number of arguments to ID
  4159. ID has been called with the wrong number of
  4160. arguments (Page 3-2)
  4161. Zero denominator REDUCE cannot handle a zero denominator (Page 3-2)
  4162. 0**0 formed REDUCE cannot handle 0**0 (Page 3-2)
  4163. 0/0 formed REDUCE cannot handle 0/0 (Page 3-2)
  4164. <number1> represented by <number2>
  4165. Real <number1> has been converted to rational
  4166. <number2>. WARNING (Page 3-2)
  4167. F-1
  4168. F. VARIABLES IN REDUCE _________ __ ______
  4169. The following variables are defined in the basic REDUCE system. Variables
  4170. prefixed or suffixed with an asterisk are changeable, either by the user or
  4171. the system as appropriate. In particular, the mode switches (qv) are based
  4172. on a corresponding variable prefixed by an asterisk that is either true or
  4173. false depending on whether the switch is on or off. E.g., the switch COMP
  4174. corresponds to the internal variable !*COMP. Such switch variables are not
  4175. listed in this section.
  4176. A Reserved only in arguments of the G operator in the
  4177. high energy physics package to denote gamma5. May be
  4178. used freely elsewhere (Page 15-2)
  4179. CARDNO!* Value is the total number of lines produced
  4180. in a given FORTRAN output expression (Page 7-10)
  4181. FORTWIDTH!* Value is the current line width for FORTRAN output
  4182. (Page 7-10)
  4183. HIPOW!* Set by COEFF to highest power encountered (Page 7-13)
  4184. LOWPOW!* Set by COEFF to lowest power encountered (Page 7-13)
  4185. !*MODE Value is the current top level mode of the system.
  4186. May be accessed in either algebraic or symbolic
  4187. mode (Page 14-1)
  4188. G-1
  4189. G. KEYWORD INDEX _______ _____
  4190. Abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-1
  4191. Algebraic_Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
  4192. Allfac. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
  4193. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-5
  4194. Arbitrary_Precision_Real. . . . . . . . . . . . . . . . . . . . . . .8-9
  4195. Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-1
  4196. Assignment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-1
  4197. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3
  4198. Asymptotic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-6
  4199. Bigfloat. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8
  4200. Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6
  4201. Body. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
  4202. Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2
  4203. Bye . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
  4204. Call_By_Value . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
  4205. Call_by_value . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
  4206. Canonical_Form. . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1
  4207. Cardno!*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8
  4208. Character_Set . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  4209. Clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-3
  4210. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-4
  4211. Coeff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
  4212. Coefficient . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-8
  4213. Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-1
  4214. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .C-1
  4215. Comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4
  4216. Comp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
  4217. G-2
  4218. Compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
  4219. Compound_Statement. . . . . . . . . . . . . . . . . . . . . . . . . .4-2
  4220. . . . . . . . . . . . . . . . . . . . . . . . . . .4-6
  4221. Conditional_Statement . . . . . . . . . . . . . . . . . . . . . . . .4-2
  4222. Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
  4223. Cont. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
  4224. Cref. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-2
  4225. Cross_Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 16-2
  4226. Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-1
  4227. Define. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
  4228. Defn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4
  4229. Deg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-6
  4230. Degree. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-6
  4231. Den . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-6
  4232. Denominator . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-6
  4233. Depend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10
  4234. Det . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1
  4235. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
  4236. Df. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-2
  4237. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3
  4238. Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . .6-2
  4239. Dirac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
  4240. Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1
  4241. Div . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
  4242. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-5
  4243. Do. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3
  4244. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4
  4245. Dollar_Sign . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-1
  4246. Dot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-1
  4247. G-3
  4248. Ed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
  4249. Editdef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
  4250. End . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
  4251. Eps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
  4252. Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .E-1
  4253. Exclamation_Point . . . . . . . . . . . . . . . . . . . . . . . . . .2-2
  4254. Exp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-1
  4255. Expression. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-1
  4256. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-3
  4257. FORTRAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8
  4258. Factor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-3
  4259. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
  4260. Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-2
  4261. Factorize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-2
  4262. Fap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
  4263. Fasl. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
  4264. Faslout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
  4265. Fast_Loading. . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
  4266. File_Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
  4267. Fixp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2
  4268. Float . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2
  4269. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8
  4270. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-9
  4271. For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3
  4272. For_Each. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3
  4273. For_all . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-1
  4274. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-2
  4275. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-3
  4276. Fort. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8
  4277. Freeof. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2
  4278. G-4
  4279. Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
  4280. G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
  4281. Gamma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
  4282. Gamma_matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-1
  4283. Gcd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-4
  4284. Go. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7
  4285. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-8
  4286. Goto. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-8
  4287. Group_Statement . . . . . . . . . . . . . . . . . . . . . . . . . . .4-2
  4288. HIPOW!* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
  4289. High_Energy_Physics . . . . . . . . . . . . . . . . . . . . . . . . 15-1
  4290. History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
  4291. Identifier. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-2
  4292. If. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-2
  4293. In. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
  4294. Infix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-6
  4295. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-7
  4296. Infix_Operator. . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4
  4297. Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
  4298. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
  4299. Int . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3
  4300. Integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  4301. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2
  4302. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6
  4303. Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3
  4304. Interactive . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
  4305. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-1
  4306. I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
  4307. Kernel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1
  4308. G-5
  4309. Keyword_Index . . . . . . . . . . . . . . . . . . . . . . . . . . . .G-1
  4310. Korder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
  4311. LISP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
  4312. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
  4313. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4
  4314. LOWPOW!*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
  4315. Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7
  4316. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-8
  4317. Lambda. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3
  4318. Lcm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-5
  4319. Lcof. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-7
  4320. Leading_Coefficient . . . . . . . . . . . . . . . . . . . . . . . . .8-7
  4321. Leading_Term. . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-7
  4322. Let . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-3
  4323. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-1
  4324. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-2
  4325. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-3
  4326. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-4
  4327. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
  4328. Line_length . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-3
  4329. Linear. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-8
  4330. Linear_Operator . . . . . . . . . . . . . . . . . . . . . . . . . . .6-8
  4331. List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
  4332. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-5
  4333. Load. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
  4334. Loop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3
  4335. Lterm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-7
  4336. Main_Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-7
  4337. Mainvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-7
  4338. Mass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
  4339. Mat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
  4340. G-6
  4341. Match . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-4
  4342. Mathematical_Function . . . . . . . . . . . . . . . . . . . . . . . .6-1
  4343. Matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1
  4344. Max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-1
  4345. Mcd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-5
  4346. Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .E-1
  4347. Min . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-1
  4348. Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
  4349. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
  4350. Mode_Communication. . . . . . . . . . . . . . . . . . . . . . . . . 14-5
  4351. Modular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-9
  4352. Mshell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
  4353. Multiple_assignment_statement . . . . . . . . . . . . . . . . . . . .4-2
  4354. Nero. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8
  4355. Nodepend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10
  4356. Noncom. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-9
  4357. Noncommuting_Operator . . . . . . . . . . . . . . . . . . . . . . . .6-9
  4358. Nospur. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
  4359. Num . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-8
  4360. Number. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  4361. Numberp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-2
  4362. Numerator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-8
  4363. Numerical_Function. . . . . . . . . . . . . . . . . . . . . . . . . .6-1
  4364. Numval. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-2
  4365. Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
  4366. On. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
  4367. Operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4
  4368. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-7
  4369. G-7
  4370. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .B-1
  4371. Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-3
  4372. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
  4373. Ordp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-3
  4374. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-9
  4375. Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
  4376. Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-3
  4377. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-6
  4378. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
  4379. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1
  4380. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
  4381. Output_Declaration. . . . . . . . . . . . . . . . . . . . . . . . . .7-3
  4382. Part. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-13
  4383. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
  4384. Pause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
  4385. Polynomial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-1
  4386. Precedence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-7
  4387. Precedence_List . . . . . . . . . . . . . . . . . . . . . . . . . . .2-7
  4388. Prefix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-1
  4389. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-7
  4390. Prefix_Operator . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4
  4391. Pret. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-4
  4392. Prettyprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-4
  4393. Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
  4394. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
  4395. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-9
  4396. Procedure_Heading . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
  4397. Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3
  4398. Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  4399. Proper_Statement. . . . . . . . . . . . . . . . . . . . . . . . . . .4-1
  4400. Quit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
  4401. Quote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2
  4402. G-8
  4403. REDUCE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  4404. RLISP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  4405. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
  4406. Rat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
  4407. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-6
  4408. Rational_Coefficient. . . . . . . . . . . . . . . . . . . . . . . . .8-8
  4409. Rational_Function . . . . . . . . . . . . . . . . . . . . . . . . . .8-1
  4410. Real. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  4411. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6
  4412. Real_Coefficient. . . . . . . . . . . . . . . . . . . . . . . . . . .8-9
  4413. Reduct. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-8
  4414. Reductum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-8
  4415. Remainder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-5
  4416. Remfac. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-4
  4417. Rename. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
  4418. Repeat. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-5
  4419. Reserved. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A-1
  4420. Reserved_Variable . . . . . . . . . . . . . . . . . . . . . . . . . .2-3
  4421. Resultant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-6
  4422. Return. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-7
  4423. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-8
  4424. Save. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
  4425. Scalar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-1
  4426. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6
  4427. Selector. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
  4428. Semicolon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-1
  4429. Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-6
  4430. Share . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
  4431. Showtime. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-3
  4432. G-9
  4433. Shut. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
  4434. Side_effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-3
  4435. Simplification. . . . . . . . . . . . . . . . . . . . . . . . . . . .3-1
  4436. . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1
  4437. Solve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-5
  4438. Spur. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
  4439. Standard_form . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6
  4440. Standard_quotient . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
  4441. Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-3
  4442. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-1
  4443. String. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4
  4444. Structr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
  4445. Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
  4446. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
  4447. Structuring . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-1
  4448. Sub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-7
  4449. Subroutine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
  4450. Substitution. . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-4
  4451. Such_that . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-1
  4452. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-3
  4453. Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-3
  4454. Switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
  4455. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .D-1
  4456. Symbolic_Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1
  4457. Terminator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-1
  4458. Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8-1
  4459. Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-2
  4460. Tp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
  4461. Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
  4462. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
  4463. G-10
  4464. Truncation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-6
  4465. Until . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-5
  4466. Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
  4467. Variable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-3
  4468. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .F-1
  4469. Varname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
  4470. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
  4471. Vector. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-3
  4472. WS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-2
  4473. Weight. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-6
  4474. While . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-4
  4475. Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-2
  4476. Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-6
  4477. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-8
  4478. Ws. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1
  4479. Wtlevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9-6
  4480. % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4