r37.tex 918 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914
  1. % The REDUCE User's Manual --- LaTeX version.
  2. % Codemist Version with additional material in the same volume
  3. % To create this manual, the following steps are recommended:
  4. % latex r37
  5. % bibtex r37
  6. % latex r37
  7. % latex r37
  8. % makeindex r37
  9. % latex r37
  10. % dvipdfm r37
  11. %% Does not contain
  12. %% bibl.tex
  13. \documentclass[11pt,letterpaper]{book}
  14. \usepackage{makeidx}
  15. % \usepackage{times}
  16. \usepackage[dvipdfm]{graphicx}
  17. \usepackage[dvipdfm]{hyperref}
  18. \hyphenation{unique}
  19. \hyphenation{effect}
  20. \hyphenation{Stand-ard}
  21. \hyphenation{libr-ary}
  22. \hyphenation{direct-ory}
  23. \hyphenation{state-ment}
  24. \hyphenation{argu-ment}
  25. \hyphenation{oper-ators}
  26. \hyphenation{symb-olic}
  27. \hyphenation{needs}
  28. \hyphenation{GVARSLAST}
  29. \hyphenation{ODE-SOLVE}
  30. \hyphenation{hyper-geometric}
  31. \hyphenation{equat-ion}
  32. \hyphenation{equat-ions}
  33. \hyphenation{OFF}
  34. \hyphenation{Opt-ions}
  35. \hyphenation{execu-tion}
  36. \hyphenation{poly-nom-ials}
  37. \hyphenation{func-t-ions}
  38. \hyphenation{Inte-grals}
  39. \hyphenation{Stutt-gart}
  40. % More space in TOC requires this in book.sty
  41. %\def\l@section{\@dottedtocline{1}{1.5em}{2.8em}}
  42. %\def\l@subsection{\@dottedtocline{2}{4.3em}{3.2em}}
  43. %\def\l@subsubsection{\@dottedtocline{3}{7.5em}{4.2em}}
  44. %\def\l@paragraph{\@dottedtocline{4}{10.5em}{5em}}
  45. %\def\l@subparagraph{\@dottedtocline{5}{12.5em}{6em}}
  46. \setlength{\parindent}{0pt}
  47. \setlength{\parskip}{6pt}
  48. \setlength{\hfuzz}{5pt} % don't complain about tiny overfull boxes
  49. \setlength{\vfuzz}{1pt}
  50. \renewcommand{\sloppy}{\tolerance=9999\relax%}
  51. \setlength{\emergencystretch}{0.2\hsize}}
  52. \tolerance=1000
  53. \raggedbottom
  54. \newlength{\reduceboxwidth}
  55. \setlength{\reduceboxwidth}{4in}
  56. \newlength{\redboxwidth}
  57. \setlength{\redboxwidth}{3.5in}
  58. \newlength{\rboxwidth}
  59. \setlength{\rboxwidth}{2.6in}
  60. \newcommand{\REDUCE}{REDUCE}
  61. \newcommand{\RLISP}{RLISP}
  62. \newcommand{\underscore}{\_}
  63. \newcommand{\ttindex}[1]{{\renewcommand{\_}{\protect\underscore}%
  64. \index{#1@{\tt #1}}}}
  65. \newcommand{\COMPATNOTE}{{\em Compatibility Note:\ }}
  66. % \meta{...} is an alternative sentential form in descriptions using \it.
  67. \newcommand{\meta}[1]{\mbox{$\langle$\it#1\/$\rangle$}}
  68. % Will print out a heading in bold, and then indent the following text.
  69. \def\indented{\list{}{
  70. \itemindent\listparindent
  71. \rightmargin\leftmargin}\item[]}
  72. \let\endindented=\endlist
  73. \newenvironment{describe}[1]{\par{\bf #1}\begin{indented}}{\end{indented}}
  74. % Close up default vertical spacings:
  75. \setlength{\topsep}{0.5\baselineskip} % above and below environments
  76. \setlength{\itemsep}{\topsep}
  77. \setlength{\abovedisplayskip}{\topsep} % for "long" equations
  78. \setlength{\belowdisplayskip}{\topsep}
  79. \newcommand{\key}[1]{\fbox{\sf #1}}
  80. \newcommand{\extendedmanual}[1]{#1}
  81. \pagestyle{empty}
  82. \makeindex
  83. \begin{document}
  84. \pagestyle{empty}
  85. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BeginCodemist
  86. \vspace*{2.0in}
  87. \begin{center}
  88. {\Huge\bf {\REDUCE}} \\ [0.2cm]
  89. {\LARGE\bf User's and \\
  90. Contributed Packages Manual\vspace{0.4cm} \\
  91. Version 3.7}
  92. \vspace{0.5in}\large\bf
  93. Anthony C.\ Hearn \\
  94. Santa Monica, CA \\
  95. and Codemist Ltd.
  96. \vspace{0.1in}
  97. \bf Email: reduce@rand.org
  98. \vspace{0.5in}
  99. \large\bf February 1999
  100. \end{center}
  101. \newpage
  102. \vspace*{3.0in}
  103. \noindent Copyright \copyright 1999 Anthony C. Hearn. All rights reserved. \\
  104. \mbox{}\\
  105. %
  106. \noindent Registered system holders may reproduce all or any part of this
  107. publication for internal purposes, provided that the source of the
  108. material is clearly acknowledged, and the copyright notice is retained.
  109. \newpage
  110. \pagestyle{headings}
  111. \centerline{\bf \large Preface}
  112. This volume has been prepared by Codemist Ltd. from the {\LaTeX}
  113. documentation sources distributed with {\REDUCE} 3.7. It incorporates
  114. the User's Manual, and documentation for all the User Contributed
  115. Packages as a second Part. A common index and table of contents has been
  116. prepared. We hope that this single volume will be more convenient for
  117. {\REDUCE} users than having two unrelated documents. Particularly in
  118. Part 2 the text of the authors has been extensively edited and
  119. modified and so the responsibility for any errors rests with us.
  120. Parts I and III were written by Anthony C. Hearn. Part II is based on
  121. texts by:\\
  122. Werner Antweiler,
  123. Victor Adamchik,
  124. Joachim Apel,
  125. Alan Barnes,
  126. Andreas Bernig,
  127. Yu.~A.~Blinkov,
  128. Russell Bradford,
  129. Chris Cannam,
  130. Hubert Caprasse,
  131. C.~{Dicrescenzo},
  132. Alain Dresse,
  133. Ladislav Drska,
  134. James W.~Eastwood,
  135. John Fitch,
  136. Kerry Gaskell,
  137. Barbara L.~Gates,
  138. Karin Gatermann,
  139. Hans-Gert Gr\"abe,
  140. David Harper,
  141. David {H}artley,
  142. Anthony C.~Hearn,
  143. J.~A.~van Hulzen,
  144. V.~Ilyin,
  145. Stanley L.~Kameny,
  146. Fujio Kako,
  147. C.~Kazasov,
  148. Wolfram Koepf,
  149. A.~Kryukov,
  150. Richard Liska,
  151. Kevin McIsaac,
  152. Malcolm A.~H.~MacCallum,
  153. Herbert Melenk,
  154. H.~M.~M\"oller,
  155. Winfried Neun,
  156. Julian Padget,
  157. Matt Rebbeck,
  158. F.~Richard-Jung,
  159. A.~Rodionov,
  160. Carsten and Franziska Sch\"obel,
  161. {Rainer} Sch\"opf,
  162. Stephen Scowcroft,
  163. Eberhard Schr\"{u}fer,
  164. Fritz Schwarz,
  165. M.~Spiridonova,
  166. A.~Taranov,
  167. Lisa Temme,
  168. Walter Tietze,
  169. V.~Tomov,
  170. E.~Tournier,
  171. Philip A.~Tuckey,
  172. G.~\"{U}\c{c}oluk,
  173. Mathias Warns,
  174. Thomas Wolf,
  175. Francis J.~Wright
  176. and
  177. A.~Yu.~Zharkov.
  178. \noindent
  179. \rightline{February 1999} \\
  180. Codemist Ltd \\
  181. ``Alta'', Horsecombe Vale \\
  182. Combe Down \\
  183. Bath, England
  184. \newpage
  185. \tableofcontents
  186. \part{{\REDUCE} User's Manual}
  187. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EndCodemist
  188. %%\begin{titlepage}
  189. \vspace*{2.0in}
  190. \begin{center}
  191. {\Huge\bf {\REDUCE}} \\ [0.2cm]
  192. {\LARGE\bf User's Manual\vspace{0.4cm} \\
  193. Version 3.7}
  194. \vspace{0.5in}\large\bf
  195. Anthony C.\ Hearn \\
  196. Santa Monica, CA, USA
  197. \vspace{0.1in}
  198. \bf Email: reduce@rand.org
  199. \vspace{0.5in}
  200. \large\bf March 1999
  201. \end{center}
  202. %%\end{titlepage}
  203. \newpage
  204. \vspace*{3.0in}
  205. \noindent Copyright \copyright 1999 Anthony C. Hearn. All rights reserved. \\
  206. \mbox{}\\
  207. %
  208. \noindent Registered system holders may reproduce all or any part of this
  209. publication for internal purposes, provided that the source of the
  210. material is clearly acknowledged, and the copyright notice is retained.
  211. \pagestyle{headings}
  212. \chapter*{Abstract}
  213. \addcontentsline{toc}{chapter}{Abstract}
  214. This document provides the user with a description of the algebraic
  215. programming system {\REDUCE}. The capabilities of this system include:
  216. \begin{enumerate}
  217. \item expansion and ordering of polynomials and rational functions,
  218. \item substitutions and pattern matching in a wide variety of forms,
  219. \item automatic and user controlled simplification of expressions,
  220. \item calculations with symbolic matrices,
  221. \item arbitrary precision integer and real arithmetic,
  222. \item facilities for defining new functions and extending program syntax,
  223. \item analytic differentiation and integration,
  224. \item factorization of polynomials,
  225. \item facilities for the solution of a variety of algebraic equations,
  226. \item facilities for the output of expressions in a variety of formats,
  227. \item facilities for generating numerical programs from symbolic input,
  228. \item Dirac matrix calculations of interest to high energy physicists.
  229. \end{enumerate}
  230. \chapter*{Acknowledgment}
  231. The production of this version of the manual has been the result of the
  232. contributions of a large number of individuals who have taken the time and
  233. effort to suggest improvements to previous versions, and to draft new
  234. sections. Particular thanks are due to Gerry Rayna, who provided a draft
  235. rewrite of most of the first half of the manual. Other people who have
  236. made significant contributions have included John Fitch, Martin Griss,
  237. Stan Kameny, Jed Marti, Herbert Melenk, Don Morrison, Arthur Norman,
  238. Eberhard Schr\"ufer, Larry Seward and Walter Tietze. Finally, Richard
  239. Hitt produced a {\TeX} version of the {\REDUCE} 3.3 manual, which has been
  240. a useful guide for the production of the {\LaTeX} version of this manual.
  241. \chapter{Introductory Information}
  242. \index{Introduction}{\REDUCE} is a system for carrying out algebraic
  243. operations accurately, no matter how complicated the expressions become.
  244. It can manipulate polynomials in a variety of forms, both expanding and
  245. factoring them, and extract various parts of them as required. {\REDUCE} can
  246. also do differentiation and integration, but we shall only show trivial
  247. examples of this in this introduction. Other topics not
  248. considered include the use of arrays, the definition of procedures and
  249. operators, the specific routines for high energy physics calculations, the
  250. use of files to eliminate repetitious typing and for saving results, and
  251. the editing of the input text.
  252. Also not considered in any detail in this introduction are the many options
  253. that are available for varying computational procedures, output forms,
  254. number systems used, and so on.
  255. {\REDUCE} is designed to be an interactive system, so that the user can input
  256. an algebraic expression and see its value before moving on to the next
  257. calculation. For those systems that do not support interactive use, or
  258. for those calculations, especially long ones, for which a standard script
  259. can be defined, {\REDUCE} can also be used in batch mode. In this case,
  260. a sequence of commands can be given to {\REDUCE} and results obtained
  261. without any user interaction during the computation.
  262. In this introduction, we shall limit ourselves to the interactive use of
  263. {\REDUCE}, since this illustrates most completely the capabilities of the
  264. system. When {\REDUCE} is called, it begins by printing a banner message
  265. like:
  266. {\small\begin{verbatim}
  267. REDUCE 3.7, 15-Jan-99 ...
  268. \end{verbatim}}
  269. where the version number and the system release date will change from time
  270. to time. It then prompts the user for input by:
  271. {\small\begin{verbatim}
  272. 1:
  273. \end{verbatim}}
  274. You can now type a {\REDUCE} statement, terminated by a semicolon to indicate
  275. the end of the expression, for example:
  276. {\small\begin{verbatim}
  277. (x+y+z)^2;
  278. \end{verbatim}}
  279. This expression would normally be followed by another character (a
  280. \key{Return} on an ASCII keyboard) to ``wake up'' the system, which would
  281. then input the expression, evaluate it, and return the result:
  282. {\small\begin{verbatim}
  283. 2 2 2
  284. X + 2*X*Y + 2*X*Z + Y + 2*Y*Z + Z
  285. \end{verbatim}}
  286. Let us review this simple example to learn a little more about the way that
  287. {\REDUCE} works. First, we note that {\REDUCE} deals with variables, and
  288. constants like other computer languages, but that in evaluating the former,
  289. a variable can stand for itself. Expression evaluation normally follows
  290. the rules of high school algebra, so the only surprise in the above example
  291. might be that the expression was expanded. {\REDUCE} normally expands
  292. expressions where possible, collecting like terms and ordering the
  293. variables in a specific manner. However, expansion, ordering of variables,
  294. format of output and so on is under control of the user, and various
  295. declarations are available to manipulate these.
  296. Another characteristic of the above example is the use of lower case on
  297. input and upper case on output. In fact, input may be in either mode, but
  298. output is usually in lower case. To make the difference between input and
  299. output more distinct in this manual, all expressions intended for input
  300. will be shown in lower case and output in upper case. However, for
  301. stylistic reasons, we represent all single identifiers in the text in
  302. upper case.
  303. Finally, the numerical prompt can be used to reference the result in a
  304. later computation.
  305. As a further illustration of the system features, the user should try:
  306. {\small\begin{verbatim}
  307. for i:= 1:40 product i;
  308. \end{verbatim}}
  309. The result in this case is the value of 40!,
  310. {\small\begin{verbatim}
  311. 815915283247897734345611269596115894272000000000
  312. \end{verbatim}}
  313. You can also get the same result by saying
  314. {\small\begin{verbatim}
  315. factorial 40;
  316. \end{verbatim}}
  317. Since we want exact results in algebraic calculations, it is essential that
  318. integer arithmetic be performed to arbitrary precision, as in the above
  319. example. Furthermore, the {\tt FOR} statement in the above is illustrative of a
  320. whole range of combining forms that {\REDUCE} supports for the convenience of
  321. the user.
  322. Among the many options in {\REDUCE} is the use of other number systems, such
  323. as multiple precision floating point with any specified number of digits ---
  324. of use if roundoff in, say, the $100^{th}$ digit is all that can be tolerated.
  325. In many cases, it is necessary to use the results of one calculation in
  326. succeeding calculations. One way to do this is via an assignment for a
  327. variable, such as
  328. {\small\begin{verbatim}
  329. u := (x+y+z)^2;
  330. \end{verbatim}}
  331. If we now use {\tt U} in later calculations, the value of the right-hand
  332. side of the above will be used.
  333. The results of a given calculation are also saved in the variable
  334. {\tt WS}\ttindex{WS} (for WorkSpace), so this can be used in the next
  335. calculation for further processing.
  336. For example, the expression
  337. {\small\begin{verbatim}
  338. df(ws,x);
  339. \end{verbatim}}
  340. following the previous evaluation will calculate the derivative of
  341. {\tt (x+y+z)\verb|^|2} with respect to {\tt X}. Alternatively,
  342. {\small\begin{verbatim}
  343. int(ws,y);
  344. \end{verbatim}}
  345. would calculate the integral of the same expression with respect to y.
  346. {\REDUCE} is also capable of handling symbolic matrices. For example,
  347. {\small\begin{verbatim}
  348. matrix m(2,2);
  349. \end{verbatim}}
  350. declares m to be a two by two matrix, and
  351. {\small\begin{verbatim}
  352. m := mat((a,b),(c,d));
  353. \end{verbatim}}
  354. gives its elements values. Expressions that include {\tt M} and make
  355. algebraic sense may now be evaluated, such as {\tt 1/m} to give the
  356. inverse, {\tt 2*m - u*m\verb|^|2} to give us another matrix and {\tt det(m)}
  357. to give us the determinant of {\tt M}.
  358. {\REDUCE} has a wide range of substitution capabilities. The system knows
  359. about elementary functions, but does not automatically invoke many of their
  360. well-known properties. For example, products of trigonometrical functions
  361. are not converted automatically into multiple angle expressions, but if the
  362. user wants this, he can say, for example:
  363. {\small\begin{verbatim}
  364. (sin(a+b)+cos(a+b))*(sin(a-b)-cos(a-b))
  365. where cos(~x)*cos(~y) = (cos(x+y)+cos(x-y))/2,
  366. cos(~x)*sin(~y) = (sin(x+y)-sin(x-y))/2,
  367. sin(~x)*sin(~y) = (cos(x-y)-cos(x+y))/2;
  368. \end{verbatim}}
  369. where the tilde in front of the variables {\tt X} and {\tt Y} indicates
  370. that the rules apply for all values of those variables.
  371. The result of this calculation is
  372. {\small\begin{verbatim}
  373. -(COS(2*A) + SIN(2*B))
  374. \end{verbatim}}
  375. \extendedmanual{See also the user-contributed packages ASSIST
  376. (chapter~\ref{ASSIST}), CAMAL (chapter~\ref{CAMAL}) and TRIGSIMP
  377. (chapter~\ref{TRIGSIMP}).}
  378. Another very commonly used capability of the system, and an illustration
  379. of one of the many output modes of {\REDUCE}, is the ability to output
  380. results in a FORTRAN compatible form. Such results can then be used in a
  381. FORTRAN based numerical calculation. This is particularly useful as a way
  382. of generating algebraic formulas to be used as the basis of extensive
  383. numerical calculations.
  384. For example, the statements
  385. {\small\begin{verbatim}
  386. on fort;
  387. df(log(x)*(sin(x)+cos(x))/sqrt(x),x,2);
  388. \end{verbatim}}
  389. will result in the output
  390. {\small\begin{verbatim}
  391. ANS=(-4.*LOG(X)*COS(X)*X**2-4.*LOG(X)*COS(X)*X+3.*
  392. . LOG(X)*COS(X)-4.*LOG(X)*SIN(X)*X**2+4.*LOG(X)*
  393. . SIN(X)*X+3.*LOG(X)*SIN(X)+8.*COS(X)*X-8.*COS(X)-8.
  394. . *SIN(X)*X-8.*SIN(X))/(4.*SQRT(X)*X**2)
  395. \end{verbatim}}
  396. These algebraic manipulations illustrate the algebraic mode of {\REDUCE}.
  397. {\REDUCE} is based on Standard Lisp. A symbolic mode is also available for
  398. executing Lisp statements. These statements follow the syntax of Lisp,
  399. e.g.
  400. {\small\begin{verbatim}
  401. symbolic car '(a);
  402. \end{verbatim}}
  403. Communication between the two modes is possible.
  404. With this simple introduction, you are now in a position to study the
  405. material in the full {\REDUCE} manual in order to learn just how extensive
  406. the range of facilities really is. If further tutorial material is
  407. desired, the seven {\REDUCE} Interactive Lessons by David R. Stoutemyer are
  408. recommended. These are normally distributed with the system.
  409. \chapter{Structure of Programs}
  410. A {\REDUCE} program\index{Program structure} consists of a set of
  411. functional commands which are evaluated sequentially by the computer.
  412. These commands are built up from declarations, statements and expressions.
  413. Such entities are composed of sequences of numbers, variables, operators,
  414. strings, reserved words and delimiters (such as commas and parentheses),
  415. which in turn are sequences of basic characters.
  416. \section{The {\REDUCE} Standard Character Set}
  417. \index{Character set}The basic characters which are used to build
  418. {\REDUCE} symbols are the following:
  419. \begin{enumerate}
  420. \item The 26 letters {\tt a} through {\tt z}
  421. \item The 10 decimal digits {\tt 0} through {\tt 9}
  422. \item The special characters \_\_ ! " \$ \% ' ( ) * + , - . / : ; $<$ $>$
  423. = \{ \} $<$blank$>$
  424. \end{enumerate}
  425. With the exception of strings and characters preceded by an
  426. exclamation mark\index{Exclamation mark}, the case
  427. of characters is ignored: depending of the underlying LISP
  428. they will all be converted internally into lower case or
  429. upper case: {\tt ALPHA}, {\tt Alpha} and {\tt alpha}
  430. represent the same symbol. Most implementations allow you to switch
  431. this conversion off. The operating instructions for a particular
  432. implementation should be consulted on this point. For portability, we
  433. shall limit ourselves to the standard character set in this exposition.
  434. \section{Numbers}
  435. \index{Number}There are several different types of numbers available in
  436. \REDUCE. Integers consist of a signed or unsigned sequence of decimal
  437. digits written without a decimal point, for example:
  438. {\small\begin{verbatim}
  439. -2, 5396, +32
  440. \end{verbatim}}
  441. In principle, there is no practical limit on the number of digits
  442. permitted as exact arithmetic is used in most implementations. (You should
  443. however check the specific instructions for your particular system
  444. implementation to make sure that this is true.) For example, if you ask
  445. for the value of $2^{2000}$ you get it
  446. displayed as a number of 603 decimal digits, taking up nine lines of
  447. output on an interactive display. It should be borne in mind of course
  448. that computations with such long numbers can be quite slow.
  449. Numbers that aren't integers are usually represented as the quotient of
  450. two integers, in lowest terms: that is, as rational numbers.
  451. In essentially all versions of {\REDUCE} it is also possible (but not always
  452. desirable!) to ask {\REDUCE} to work with floating point approximations to
  453. numbers again, to any precision. Such numbers are called {\em real}.
  454. \index{Real} They can be input in two ways:
  455. \begin{enumerate}
  456. \item as a signed or unsigned sequence of any number of decimal digits
  457. with an embedded or trailing decimal point.
  458. \item as in 1. followed by a decimal exponent which is written as the
  459. letter {\tt E} followed by a signed or unsigned integer.
  460. \end{enumerate}
  461. e.g. {\tt 32. +32.0 0.32E2} and {\tt 320.E-1} are all representations of
  462. 32.
  463. The declaration {\tt SCIENTIFIC\_NOTATION}\ttindex{SCIENTIFIC\_NOTATION}
  464. controls the output format of floating point numbers. At
  465. the default settings, any number with five or less digits before the
  466. decimal point is printed in a fixed-point notation, e.g., {\tt 12345.6}.
  467. Numbers with more than five digits are printed in scientific notation,
  468. e.g., {\tt 1.234567E+5}. Similarly, by default, any number with eleven or
  469. more zeros after the decimal point is printed in scientific notation. To
  470. change these defaults, {\tt SCIENTIFIC\_NOTATION} can be used in one of two
  471. ways. {\tt SCIENTIFIC\_NOTATION} {\em m};, where {\em m\/} is a positive
  472. integer, sets the printing format so that a number with more than {\em m\/}
  473. digits before the decimal point, or {\em m\/} or more zeros after the
  474. decimal point, is printed in scientific notation. {\tt SCIENTIFIC\_NOTATION}
  475. \{{\em m,n}\}, with {\em m\/} and {\em n\/} both positive integers, sets the
  476. format so that a number with more than {\em m\/} digits before the decimal
  477. point, or {\em n\/} or more zeros after the decimal point is printed in
  478. scientific notation.
  479. {\it CAUTION:} The unsigned part of any number\index{Number} may {\em not\/}
  480. begin with a decimal point, as this causes confusion with the {\tt CONS} (.)
  481. operator, i.e., NOT ALLOWED: {\tt .5 -.23 +.12};
  482. use {\tt 0.5 -0.23 +0.12} instead.
  483. \section{Identifiers}
  484. Identifiers\index{Identifier} in {\REDUCE} consist of one or more
  485. alphanumeric characters (i.e. alphabetic letters or decimal
  486. digits) the first of which must be alphabetic. The maximum number of
  487. characters allowed is implementation dependent, although twenty-four is
  488. permitted in most implementations. In addition, the underscore character
  489. (\_) is considered a letter if it is {\it within} an identifier. For example,
  490. {\small\begin{verbatim}
  491. a az p1 q23p a_very_long_variable
  492. \end{verbatim}}
  493. are all identifiers, whereas
  494. {\small\begin{verbatim}
  495. _a
  496. \end{verbatim}}
  497. is not.
  498. A sequence of alphanumeric characters in which the first is a digit is
  499. interpreted as a product. For example, {\tt 2ab3c} is interpreted as
  500. {\tt 2*ab3c}. There is one exception to this: If the first letter after a
  501. digit is {\tt E}, the system will try to interpret that part of the
  502. sequence as a real number\index{Real}, which may fail in some cases. For
  503. example, {\tt 2E12} is the real number $2.0*10^{12}$, {\tt 2e3c} is
  504. 2000.0*C, and {\tt 2ebc} gives an error.
  505. Special characters, such as $-$, *, and blank, may be used in identifiers
  506. too, even as the first character, but each must be preceded by an
  507. exclamation mark in input. For example:
  508. {\small\begin{verbatim}
  509. light!-years d!*!*n good! morning
  510. !$sign !5goldrings
  511. \end{verbatim}}
  512. {\it CAUTION:} Many system identifiers have such special characters in their
  513. names (especially * and =). If the user accidentally picks the name of one
  514. of them for his own purposes it may have catastrophic consequences for his
  515. {\REDUCE} run. Users are therefore advised to avoid such names.
  516. Identifiers are used as variables, labels and to name arrays, operators
  517. and procedures.
  518. \subsection*{Restrictions}
  519. The reserved words listed in another section may not be used as
  520. identifiers. No spaces may appear within an identifier, and an identifier
  521. may not extend over a line of text. (Hyphenation of an identifier, by
  522. using a reserved character as a hyphen before an end-of-line character is
  523. possible in some versions of {\REDUCE}).
  524. \section{Variables}
  525. Every variable\index{Variable} is named by an identifier, and is given a
  526. specific type. The type is of no concern to the ordinary user. Most
  527. variables are allowed to have the default type, called {\em scalar}.
  528. These can receive, as values, the representation of any ordinary algebraic
  529. expression. In the absence of such a value, they stand for themselves.
  530. \subsection*{Reserved Variables}
  531. Several variables\index{Reserved variable} in {\REDUCE} have particular
  532. properties which should not be changed by the user. These variables
  533. include:
  534. \begin{list}{}{\renewcommand{\makelabel}[1]{{\tt#1}\hspace{\fill}}%
  535. \settowidth{\labelwidth}{\tt INFINITY}%
  536. \setlength{\labelsep}{1em}%
  537. \settowidth{\leftmargin}{\tt INFINITY\hspace*{\labelsep}}}
  538. \item[E] Intended to represent the base of
  539. \ttindex{E}
  540. the natural logarithms. {\tt log(e)}, if it occurs in an expression, is
  541. automatically replaced by 1. If {\tt ROUNDED}\ttindex{ROUNDED} is
  542. on, {\tt E} is replaced by the value of E to the current degree of
  543. floating point precision\index{Numerical precision}.
  544. \item[I] Intended to represent the square
  545. \ttindex{I}
  546. root of $-1$. {\tt i\verb|^|2} is replaced by $-1$, and appropriately for higher
  547. powers of {\tt I}. This applies only to the symbol {\tt I} used on the top
  548. level, not as a formal parameter in a procedure, a local variable, nor in
  549. the context {\tt for i:= ...}
  550. \item[INFINITY] Intended to represent $\infty$
  551. \ttindex{INFINITY}
  552. in limit and power series calculations for example. Note however that the
  553. current system does {\em not\/} do proper arithmetic on $\infty$. For example,
  554. {\tt infinity + infinity} is {\tt 2*infinity}.
  555. \item[NIL] In {\REDUCE} (algebraic mode only)
  556. taken as a synonym for zero. Therefore {\tt NIL} cannot be used as a
  557. variable.
  558. \item[PI] Intended to represent the circular
  559. \ttindex{PI}
  560. constant. With {\tt ROUNDED} on, it is replaced by the value of $\pi$ to
  561. the current degree of floating point precision.
  562. \item[T] Should not be used as a formal
  563. \ttindex{T}
  564. parameter or local variable in procedures, since conflict arises with the
  565. symbolic mode meaning of T as {\em true}.
  566. \end{list}
  567. Other reserved variables, such as {\tt LOW\_POW}, described in other sections,
  568. are listed in Appendix A.
  569. Using these reserved variables\index{Reserved variable} inappropriately
  570. will lead to errors.
  571. There are also internal variables used by {\REDUCE} that have similar
  572. restrictions. These usually have an asterisk in their names, so it is
  573. unlikely a casual user would use one. An example of such a variable is
  574. {\tt K!*} used in the asymptotic command package.
  575. Certain words are reserved in {\REDUCE}. They may only be used in the manner
  576. intended. A list of these is given in the section ``Reserved Identifiers''.
  577. There are, of course, an impossibly large number of such names to keep in
  578. mind. The reader may therefore want to make himself a copy of the list,
  579. deleting the names he doesn't think he is likely to use by mistake.
  580. \section{Strings}
  581. Strings\index{String} are used in {\tt WRITE} statements, in other
  582. output statements (such as error messages), and to name files. A string
  583. consists of any number of characters enclosed in double quotes. For example:
  584. {\small\begin{verbatim}
  585. "A String".
  586. \end{verbatim}}
  587. Lower case characters within a string are not converted to upper case.
  588. The string {\tt ""} represents the empty string. A double quote may be
  589. included in a string by preceding it by another double quote. Thus
  590. {\tt "a""b"} is the string {\tt a"b}, and {\tt """"} is the string {\tt "}.
  591. \section{Comments}
  592. Text can be included in program\index{Program} listings for the
  593. convenience of human readers, in such a way that {\REDUCE} pays no
  594. attention to it. There are two ways to do this:
  595. \begin{enumerate}
  596. \item Everything from the word {\tt COMMENT}\ttindex{COMMENT} to the next
  597. statement terminator, normally ; or \$, is ignored. Such comments
  598. can be placed anywhere a blank could properly appear. (Note that {\tt END}
  599. and $>>$ are {\em not\/} treated as {\tt COMMENT} delimiters!)
  600. \item Everything from the symbol {\tt \%}\index{Percent sign} to the end
  601. of the line on which it appears is ignored. Such comments can be placed
  602. as the last part of any line. Statement terminators have no special
  603. meaning in such comments. Remember to put a semicolon before the {\tt \%}
  604. if the earlier part of the line is intended to be so terminated. Remember
  605. also to begin each line of a multi-line {\tt \%} comment with a {\tt \%}
  606. sign.
  607. \end{enumerate}
  608. \section{Operators}
  609. \label{sec-operators}
  610. Operators\index{Operator} in {\REDUCE} are specified by name and type.
  611. There are two types, infix\index{Infix operator} and prefix.
  612. \index{Prefix operator} Operators can be purely abstract, just symbols
  613. with no properties; they can have values assigned (using {\tt :=} or
  614. simple {\tt LET} declarations) for specific arguments; they can have
  615. properties declared for some collection of arguments (using more general
  616. {\tt LET} declarations); or they can be fully defined (usually by a
  617. procedure declaration).
  618. Infix operators\index{Infix operator} have a definite precedence with
  619. respect to one another, and normally occur between their arguments.
  620. For example:
  621. \begin{quote}
  622. \begin{tabbing}
  623. {\tt a + b - c} \hspace{1.5in} \= (spaces optional) \\
  624. {\tt x<y and y=z} \> (spaces required where shown)
  625. \end{tabbing}
  626. \end{quote}
  627. Spaces can be freely inserted between operators and variables or operators
  628. and operators. They are required only where operator names are spelled out
  629. with letters (such as the {\tt AND} in the example) and must be unambiguously
  630. separated from another such or from a variable (like {\tt Y}). Wherever one
  631. space can be used, so can any larger number.
  632. Prefix operators occur to the left of their arguments, which are written as
  633. a list enclosed in parentheses and separated by commas, as with normal
  634. mathematical functions, e.g.,
  635. {\small\begin{verbatim}
  636. cos(u)
  637. df(x^2,x)
  638. q(v+w)
  639. \end{verbatim}}
  640. Unmatched parentheses, incorrect groupings of infix operators
  641. \index{Infix operator} and the like, naturally lead to syntax errors. The
  642. parentheses can be omitted (replaced by a space following the
  643. operator\index{Operator} name) if the operator is unary and the argument
  644. is a single symbol or begins with a prefix operator name:
  645. \begin{quote}
  646. \begin{tabbing}
  647. {\tt cos y} \hspace{1.75in} \= means cos(y) \\
  648. {\tt cos (-y)} \> -- parentheses necessary \\
  649. {\tt log cos y} \> means log(cos(y)) \\
  650. {\tt log cos (a+b)} \> means log(cos(a+b))
  651. \end{tabbing}
  652. \end{quote}
  653. but
  654. \begin{quote}
  655. \begin{tabbing}
  656. {\tt cos a*b} \hspace{1.6in} \= means (cos a)*b \\
  657. {\tt cos -y} \> is erroneous (treated as a variable \\
  658. \> ``cos'' minus the variable y)
  659. \end{tabbing}
  660. \end{quote}
  661. A unary prefix operator\index{Prefix operator} has a precedence
  662. \index{Operator precedence} higher than any infix operator, including
  663. unary infix operators. \index{Infix operator}
  664. In other words, {\REDUCE} will always interpret {\tt cos~y + 3} as
  665. {\tt (cos~y) + 3} rather than as {\tt cos(y + 3)}.
  666. Infix operators may also be used in a prefix format on input, e.g.,
  667. {\tt +(a,b,c)}. On output, however, such expressions will always be
  668. printed in infix form (i.e., {\tt a + b + c} for this example).
  669. A number of prefix operators are built into the system with predefined
  670. properties. Users may also add new operators and define their rules for
  671. simplification. The built in operators are described in another section.
  672. \subsection*{Built-In Infix Operators}
  673. The following infix operators\index{Infix operator} are built into the
  674. system. They are all defined internally as procedures.
  675. {\small\begin{verbatim}
  676. <infix operator>::= where|:=|or|and|member|memq|=|neq|eq|
  677. >=|>|<=|<|+|-|*|/|^|**|.
  678. \end{verbatim}}
  679. These operators may be further divided into the following subclasses:
  680. {\small\begin{verbatim}
  681. <assignment operator> ::= :=
  682. <logical operator> ::= or|and|member|memq
  683. <relational operator> ::= =|neq|eq|>=|>|<=|<
  684. <substitution operator> ::= where
  685. <arithmetic operator> ::= +|-|*|/|^|**
  686. <construction operator> ::= .
  687. \end{verbatim}}
  688. {\tt MEMQ} and {\tt EQ} are not used in the algebraic mode of
  689. {\REDUCE}. They are explained in the section on symbolic mode.
  690. {\tt WHERE} is described in the section on substitutions.
  691. In previous versions of {\REDUCE}, {\em not} was also defined as an infix
  692. operator. In the present version it is a regular prefix operator, and
  693. interchangeable with {\em null}.
  694. For compatibility with the intermediate language used by {\REDUCE}, each
  695. special character infix operator\index{Infix operator} has an alternative
  696. alphanumeric identifier associated with it. These identifiers may be used
  697. interchangeably with the corresponding special character names on input.
  698. This correspondence is as follows:
  699. \begin{quote}
  700. \begin{tabbing}
  701. {\tt := setq} \hspace{0.5in} \= (the assignment operator) \\
  702. {\tt = equal} \\
  703. {\tt >= geq} \\
  704. {\tt > greaterp} \\
  705. {\tt <= leq} \\
  706. {\tt < lessp} \\
  707. {\tt + plus} \\
  708. {\tt - difference} \> (if unary, {\tt minus}) \\
  709. {\tt * times} \\
  710. {\tt / quotient} \> (if unary, {\tt recip}) \\
  711. {\tt \verb|^| or ** expt} \> (raising to a power) \\
  712. {\tt . cons}
  713. \end{tabbing}
  714. \end{quote}
  715. Note: {\tt NEQ} is used to mean {\em not equal}. There is no special
  716. symbol provided for it.
  717. The above operators\index{Operator} are binary, except {\tt NOT} which is
  718. unary and {\tt +} and {\tt *} which are nary (i.e., taking an arbitrary
  719. number of arguments). In addition, {\tt -} and {\tt /} may be used as
  720. unary operators, e.g., /2 means the same as 1/2. Any other operator is
  721. parsed as a binary operator using a left association rule. Thus {\tt
  722. a/b/c} is interpreted as {\tt (a/b)/c}. There are two exceptions to this
  723. rule: {\tt :=} and {\tt .} are right associative. Example: {\tt a:=b:=c}
  724. is interpreted as {\tt a:=(b:=c)}. Unlike ALGOL and PASCAL, {\tt \verb|^|} is
  725. left associative. In other words, {\tt a\verb|^|b\verb|^|c} is interpreted as
  726. {\tt (a\verb|^|b)\verb|^|c}.
  727. The operators\index{Operator} {\tt $<$}, {\tt $<$=}, {\tt $>$}, {\tt $>$=}
  728. can only be used for making comparisons between numbers. No meaning is
  729. currently assigned to this kind of comparison between general expressions.
  730. Parentheses may be used to specify the order of combination. If
  731. parentheses are omitted then this order is by the ordering of the
  732. precedence list\index{Operator precedence} defined by the right-hand side
  733. of the {\tt <infix operator>}\index{Infix operator} table
  734. at the beginning of this section,
  735. from lowest to highest. In other words, {\tt WHERE} has the lowest
  736. precedence, and {\tt .} (the dot operator) the highest.
  737. \chapter{Expressions}
  738. {\REDUCE} expressions\index{Expression} may be of several types and consist
  739. of sequences of numbers, variables, operators, left and right parentheses
  740. and commas. The most common types are as follows:
  741. \section{Scalar Expressions}
  742. \index{Scalar}Using the arithmetic operations {\tt + - * / \verb|^|}
  743. (power) and parentheses, scalar expressions are composed from numbers,
  744. ordinary ``scalar'' variables (identifiers), array names with subscripts,
  745. operator or procedure names with arguments and statement expressions.
  746. {\it Examples:}
  747. {\small\begin{verbatim}
  748. x
  749. x^3 - 2*y/(2*z^2 - df(x,z))
  750. (p^2 + m^2)^(1/2)*log (y/m)
  751. a(5) + b(i,q)
  752. \end{verbatim}}
  753. The symbol ** may be used as an alternative to the caret symbol (\verb+^+)
  754. for forming powers, particularly in those systems that do not support a
  755. caret symbol.
  756. Statement expressions, usually in parentheses, can also form part of
  757. a scalar\index{Scalar} expression, as in the example
  758. {\small\begin{verbatim}
  759. w + (c:=x+y) + z .
  760. \end{verbatim}}
  761. When the algebraic value of an expression is needed, {\REDUCE} determines it,
  762. starting with the algebraic values of the parts, roughly as follows:
  763. Variables and operator symbols with an argument list have the algebraic
  764. values they were last assigned, or if never assigned stand for themselves.
  765. However, array elements have the algebraic values they were last assigned,
  766. or, if never assigned, are taken to be 0.
  767. Procedures are evaluated with the values of their actual parameters.
  768. In evaluating expressions, the standard rules of algebra are applied.
  769. Unfortunately, this algebraic evaluation of an expression is not as
  770. unambiguous as is numerical evaluation. This process is generally referred
  771. to as ``simplification''\index{Simplification} in the sense that the
  772. evaluation usually but not always produces a simplified form for the
  773. expression.
  774. There are many options available to the user for carrying out such
  775. simplification\index{Simplification}. If the user doesn't specify any
  776. method, the default method is used. The default evaluation of an
  777. expression involves expansion of the expression and collection of like
  778. terms, ordering of the terms, evaluation of derivatives and other
  779. functions and substitution for any expressions which have values assigned
  780. or declared (see assignments and {\tt LET} statements). In many cases,
  781. this is all that the user needs.
  782. The declarations by which the user can exercise some control over the way
  783. in which the evaluation is performed are explained in other sections. For
  784. example, if a real (floating point) number is encountered during
  785. evaluation, the system will normally convert it into a ratio of two
  786. integers. If the user wants to use real arithmetic, he can effect this by
  787. the command {\tt on rounded;}.\ttindex{ROUNDED} Other modes for
  788. coefficient arithmetic are described elsewhere.
  789. If an illegal action occurs during evaluation (such as division by zero)
  790. or functions are called with the wrong number of arguments, and so on, an
  791. appropriate error message is generated.
  792. % A list of such error messages is given in an appendix.
  793. \section{Integer Expressions}
  794. \index{Integer}These are expressions which, because of the values of the
  795. constants and variables in them, evaluate to whole numbers.
  796. {\it Examples:}
  797. {\small\begin{verbatim}
  798. 2, 37 * 999, (x + 3)^2 - x^2 - 6*x
  799. \end{verbatim}}
  800. are obviously integer expressions.
  801. {\small\begin{verbatim}
  802. j + k - 2 * j^2
  803. \end{verbatim}}
  804. is an integer expression when {\tt J} and {\tt K} have values that are
  805. integers, or if not integers are such that ``the variables and fractions
  806. cancel out'', as in
  807. {\small\begin{verbatim}
  808. k - 7/3 - j + 2/3 + 2*j^2.
  809. \end{verbatim}}
  810. \section{Boolean Expressions}
  811. \label{sec-boolean}
  812. A boolean expression\index{Boolean} returns a truth value. In the
  813. algebraic mode of {\REDUCE}, boolean expressions have the syntactical form:
  814. {\small\begin{verbatim}
  815. <expression> <relational operator> <expression>
  816. \end{verbatim}}
  817. or
  818. {\small\begin{verbatim}
  819. <boolean operator> (<arguments>)
  820. \end{verbatim}}
  821. or
  822. {\small\begin{verbatim}
  823. <boolean expression> <logical operator>
  824. <boolean expression>.
  825. \end{verbatim}}
  826. Parentheses can also be used to control the precedence of expressions.
  827. In addition to the logical and relational operators defined earlier as
  828. infix operators, the following boolean operators are also defined:\\
  829. \mbox{}\\
  830. \ttindex{EVENP}\ttindex{FIXP}\ttindex{FREEOF}\ttindex{NUMBERP}
  831. \ttindex{ORDP}\ttindex{PRIMEP}
  832. {\renewcommand{\arraystretch}{2}
  833. \begin{tabular}{lp{\redboxwidth}}
  834. {\tt EVENP(U)} & determines if the number {\tt U} is even or not; \\
  835. {\tt FIXP(U)} & determines if the expression {\tt U} is integer or not; \\
  836. {\tt FREEOF(U,V)} & determines if the expression
  837. {\tt U} does not contain the kernel {\tt V} anywhere in its
  838. structure; \\
  839. {\tt NUMBERP(U)} & determines if {\tt U} is a number or not; \\
  840. {\tt ORDP(U,V)} & determines if {\tt U} is ordered
  841. ahead of {\tt V} by some canonical ordering (based on the expression structure
  842. and an internal ordering of identifiers); \\
  843. {\tt PRIMEP(U)} & true if {\tt U} is a prime object. \\
  844. \end{tabular}}
  845. {\it Examples:}
  846. {\small\begin{verbatim}
  847. j<1
  848. x>0 or x=-2
  849. numberp x
  850. fixp x and evenp x
  851. numberp x and x neq 0
  852. \end{verbatim}}
  853. Boolean expressions can only appear directly within {\tt IF}, {\tt FOR},
  854. {\tt WHILE}, and {\tt UNTIL} statements, as described in other sections.
  855. Such expressions cannot be used in place of ordinary algebraic expressions,
  856. or assigned to a variable.
  857. NB: For those familiar with symbolic mode, the meaning of some of
  858. these operators is different in that mode. For example, {\tt NUMBERP} is
  859. true only for integers and reals in symbolic mode.
  860. When two or more boolean expressions are combined with {\tt AND}, they are
  861. evaluated one by one until a {\em false\/} expression is found. The rest are
  862. not evaluated. Thus
  863. {\small\begin{verbatim}
  864. numberp x and numberp y and x>y
  865. \end{verbatim}}
  866. does not attempt to make the {\tt x>y} comparison unless {\tt X} and {\tt Y}
  867. are both verified to be numbers.
  868. Similarly, evaluation of a sequence of boolean expressions connected by
  869. {\tt OR} stops as soon as a {\em true\/} expression is found.
  870. NB: In a boolean expression, and in a place where a boolean expression is
  871. expected, the algebraic value 0 is interpreted as {\em false}, while all
  872. other algebraic values are converted to {\em true}. So in algebraic mode
  873. a procedure can be written for direct usage in boolean expressions,
  874. returning say 1 or 0 as its value as in
  875. {\small\begin{verbatim}
  876. procedure polynomialp(u,x);
  877. if den(u)=1 and deg(u,x)>=1 then 1 else 0;
  878. \end{verbatim}}
  879. One can then use this in a boolean construct, such as
  880. {\small\begin{verbatim}
  881. if polynomialp(q,z) and not polynomialp(q,y) then ...
  882. \end{verbatim}}
  883. In addition, any procedure that does not have a defined return value
  884. (for example, a block without a {\tt RETURN} statement in it)
  885. has the boolean value {\em false}.
  886. \section{Equations}
  887. Equations\index{Equation} are a particular type of expression with the syntax
  888. {\small\begin{verbatim}
  889. <expression> = <expression>.
  890. \end{verbatim}}
  891. In addition to their role as boolean expressions, they can also be used as
  892. arguments to several operators (e.g., {\tt SOLVE}), and can be
  893. returned as values.
  894. Under normal circumstances, the right-hand-side of the equation is
  895. evaluated but not the left-hand-side. This also applies to any substitutions
  896. made by the {\tt SUB}\ttindex{SUB} operator. If both sides are to be
  897. evaluated, the switch {\tt EVALLHSEQP}\ttindex{EVALLHSEQP} should be
  898. turned on.
  899. To facilitate the handling of equations, two selectors, {\tt LHS}
  900. \ttindex{LHS} and {\tt RHS},\ttindex{RHS} which return the left- and
  901. right-hand sides of a equation\index{Equation} respectively, are provided.
  902. For example,
  903. {\small\begin{verbatim}
  904. lhs(a+b=c) -> a+b
  905. and
  906. rhs(a+b=c) -> c.
  907. \end{verbatim}}
  908. \section{Proper Statements as Expressions}
  909. Several kinds of proper statements\index{Proper statement} deliver
  910. an algebraic or numerical result of some kind, which can in turn be used as
  911. an expression or part of an expression. For example, an assignment
  912. statement itself has a value, namely the value assigned. So
  913. {\small\begin{verbatim}
  914. 2 * (x := a+b)
  915. \end{verbatim}}
  916. is equal to {\tt 2*(a+b)}, as well as having the ``side-effect''\index{Side
  917. effect} of assigning the value {\tt a+b} to {\tt X}. In context,
  918. {\small\begin{verbatim}
  919. y := 2 * (x := a+b);
  920. \end{verbatim}}
  921. sets {\tt X} to {\tt a+b} and {\tt Y} to {\tt 2*(a+b)}.
  922. The sections on the various proper statement\index{Proper statement} types
  923. indicate which of these statements are also useful as expressions.
  924. \chapter{Lists}
  925. A list\index{List} is an object consisting of a sequence of other objects
  926. (including lists themselves), separated by commas and surrounded by
  927. braces. Examples of lists are:
  928. {\small\begin{verbatim}
  929. {a,b,c}
  930. {1,a-b,c=d}
  931. {{a},{{b,c},d},e}.
  932. \end{verbatim}}
  933. The empty list is represented as
  934. {\small\begin{verbatim}
  935. {}.
  936. \end{verbatim}}
  937. \section{Operations on Lists}\index{List operation}
  938. Several operators in the system return their results as lists, and a user
  939. can create new lists using braces and commas. Alternatively, one can use
  940. the operator LIST to construct a list. An important class of operations
  941. on lists are MAP and SELECT operations. For details, please refer to the
  942. chapters on MAP, SELECT and the FOR command. See also the documentation
  943. on the ASSIST package.
  944. To facilitate the use of
  945. lists, a number of operators are also available for manipulating
  946. them. {\tt PART(<list>,n)}\ttindex{PART} for example will return the
  947. $n^{th}$ element of a list. {\tt LENGTH}\ttindex{LENGTH} will return the
  948. length of a list. Several operators are also defined uniquely for lists.
  949. For those familiar with them, these operators in fact mirror the
  950. operations defined for Lisp lists. These operators are as follows:
  951. \subsection{LIST}
  952. The operator LIST is an alternative to the usage of curly brackets. LIST
  953. accepts an arbitrary number of arguments and returns a list
  954. of its arguments. This operator is useful in cases where operators
  955. have to be passed as arguments. E.g.,
  956. {\small\begin{verbatim}
  957. list(a,list(list(b,c),d),e); -> {{a},{{b,c},d},e}
  958. \end{verbatim}}
  959. \subsection{FIRST}
  960. This operator\ttindex{FIRST} returns the first member of a list. An error
  961. occurs if the argument is not a list, or the list is empty.
  962. \subsection{SECOND}
  963. {\tt SECOND}\ttindex{SECOND} returns the second member of a list. An error
  964. occurs if the argument is not a list or has no second element.
  965. \subsection{THIRD}
  966. This operator\ttindex{THIRD} returns the third member of a list. An error
  967. occurs if the argument is not a list or has no third element.
  968. \subsection{REST}
  969. {\tt REST}\ttindex{REST} returns its argument with the first element
  970. removed. An error occurs if the argument is not a list, or is empty.
  971. \subsection{$.$ (Cons) Operator}
  972. This operator\ttindex{. (CONS)} adds (``conses'') an expression to the
  973. front of a list. For example:
  974. {\small\begin{verbatim}
  975. a . {b,c} -> {a,b,c}.
  976. \end{verbatim}}
  977. \subsection{APPEND}
  978. This operator\ttindex{APPEND} appends its first argument to its second to
  979. form a new list.
  980. {\it Examples:}
  981. {\small\begin{verbatim}
  982. append({a,b},{c,d}) -> {a,b,c,d}
  983. append({{a,b}},{c,d}) -> {{a,b},c,d}.
  984. \end{verbatim}}
  985. \subsection{REVERSE}
  986. The operator {\tt REVERSE}\ttindex{REVERSE} returns its argument with the
  987. elements in the reverse order. It only applies to the top level list, not
  988. any lower level lists that may occur. Examples are:\index{List operation}
  989. {\small\begin{verbatim}
  990. reverse({a,b,c}) -> {c,b,a}
  991. reverse({{a,b,c},d}) -> {d,{a,b,c}}.
  992. \end{verbatim}}
  993. \subsection{List Arguments of Other Operators}
  994. If an operator other than those specifically defined for lists is given a
  995. single argument that is a list, then the result of this operation will be
  996. a list in which that operator is applied to each element of the list. For
  997. example, the result of evaluating {\tt log\{a,b,c\}} is the expression
  998. {\tt \{LOG(A),LOG(B),LOG(C)\}}.
  999. There are two ways to inhibit this operator distribution. Firstly, the
  1000. switch {\tt LISTARGS},\ttindex{LISTARGS} if on, will globally inhibit
  1001. such distribution. Secondly, one can inhibit this distribution for a
  1002. specific operator by the declaration {\tt LISTARGP}.\ttindex{LISTARGP} For
  1003. example, with the declaration {\tt listargp log}, {\tt log\{a,b,c\}} would
  1004. evaluate to {\tt LOG(\{A,B,C\})}.
  1005. If an operator has more than one argument, no such distribution occurs.
  1006. \subsection{Caveats and Examples}
  1007. Some of the natural list operations such as {\it member} or {\it delete}
  1008. are available only after loading the package {\it ASSIST}.
  1009. Please note that a non-list as second argument to CONS
  1010. (a "dotted pair" in LISP terms) is not allowed
  1011. and causes an "invalid as list" error.
  1012. {\small\begin{verbatim}
  1013. a := 17 . 4;
  1014. ***** 17 4 invalid as list
  1015. \end{verbatim}}
  1016. Also, the initialization of a scalar variable is not the empty list --
  1017. one has to set list type variables explicitly, as in the following
  1018. example:
  1019. {\small\begin{verbatim}
  1020. load_package assist;
  1021. procedure lotto (n,m);
  1022. begin scalar list_1_n, luckies, hit;
  1023. list_1_n := {};
  1024. luckies := {};
  1025. for k:=1:n do list_1_n := k . list_1_n;
  1026. for k:=1:m do
  1027. << hit := part(list_1_n,random(n-k+1) + 1);
  1028. list_1_n := delete(hit,list_1_n);
  1029. luckies := hit . luckies >>;
  1030. return luckies;
  1031. end; % In Germany, try lotto (49,6);
  1032. \end{verbatim}}
  1033. {\it Another example:} Find all coefficients of a multivariate
  1034. polynomial with respect to a list of variables:
  1035. {\small\begin{verbatim}
  1036. procedure allcoeffs(q,lis); % q : polynomial, lis: list of vars
  1037. allcoeffs1 (list q,lis);
  1038. procedure allcoeffs1(q,lis);
  1039. if lis={} then q else
  1040. allcoeffs1(foreach qq in q join coeff(qq,first lis),rest lis);
  1041. \end{verbatim}}
  1042. \chapter{Statements}
  1043. A statement\index{Statement} is any combination of reserved words and
  1044. expressions, and has the syntax \index{Proper statement}
  1045. {\small\begin{verbatim}
  1046. <statement> ::= <expression>|<proper statement>
  1047. \end{verbatim}}
  1048. A {\REDUCE} program consists of a series of commands which are statements
  1049. followed by a terminator:\index{Terminator}\index{Semicolon}
  1050. \index{Dollar sign}
  1051. {\small\begin{verbatim}
  1052. <terminator> ::= ;|$
  1053. \end{verbatim}}
  1054. The division of the program into lines is arbitrary. Several statements
  1055. can be on one line, or one statement can be freely broken onto several
  1056. lines. If the program is run interactively, statements ending with ; or \$
  1057. are not processed until an end-of-line character is encountered. This
  1058. character can vary from system to system, but is normally the \key{Return}
  1059. key on an ASCII terminal. Specific systems may also use additional keys
  1060. as statement terminators.
  1061. If a statement is a proper statement\index{Proper statement}, the
  1062. appropriate action takes place.
  1063. Depending on the nature of the proper statement some result or response may
  1064. or may not be printed out, and the response may or may not depend on the
  1065. terminator used.
  1066. If a statement is an expression, it is evaluated. If the terminator is a
  1067. semicolon, the result is printed. If the terminator is a dollar sign, the
  1068. result is not printed. Because it is not usually possible to know in
  1069. advance how large an expression will be, no explicit format statements are
  1070. offered to the user. However, a variety of output declarations are
  1071. available so that the output can be produced in different forms. These
  1072. output declarations are explained in Section~\ref{sec-output}.
  1073. The following sub-sections describe the types of proper statements
  1074. \index{Proper statement} in {\REDUCE}.
  1075. \section{Assignment Statements}
  1076. These statements\index{Assignment} have the syntax
  1077. {\small\begin{verbatim}
  1078. <assignment statement> ::= <expression> := <expression>
  1079. \end{verbatim}}
  1080. The {\tt <expression>} on the left side is normally the name of a variable, an
  1081. operator symbol with its list of arguments filled in, or an array name with
  1082. the proper number of integer subscript values within the array bounds. For
  1083. example:
  1084. \begin{quote}
  1085. \begin{tabbing}
  1086. {\tt a1 := b + c} \\
  1087. {\tt h(l,m) := x-2*y} \hspace{1in} \= (where {\tt h} is an operator) \\
  1088. {\tt k(3,5) := x-2*y} \> (where {\tt k} is a 2-dim. array)
  1089. \end{tabbing}
  1090. \end{quote}
  1091. More general assignments\index{Assignment} such as {\tt a+b := c} are also
  1092. allowed. The effect of these is explained in Section~\ref{sec-gensubs}.
  1093. An assignment statement causes the expression on the right-hand-side to be
  1094. evaluated. If the left-hand-side is a variable, the value of the
  1095. right-hand-side is assigned to that unevaluated variable. If the
  1096. left-hand-side is an operator or array expression, the arguments of that
  1097. operator or array are evaluated, but no other simplification done. The
  1098. evaluated right-hand-side is then assigned to the resulting expression.
  1099. For example, if {\tt A} is a single-dimensional array, {\tt a(1+1) := b}
  1100. assigns the value {\tt B} to the array element {\tt a(2)}.
  1101. If a semicolon is used as the terminator when an assignment
  1102. \index{Assignment} is issued as a command (i.e. not as a part of a group
  1103. statement or procedure or other similar construct), the left-hand side
  1104. symbol of the assignment statement is printed out, followed by a
  1105. ``{\tt :=}'', followed by the value of the expression on the right.
  1106. It is also possible to write a multiple assignment statement:
  1107. \index{Multiple assignment statement}
  1108. {\small\begin{verbatim}
  1109. <expression> := ... := <expression> := <expression>
  1110. \end{verbatim}}
  1111. In this form, each {\tt <expression>} but the last is set to the value of
  1112. the last {\tt <expression>}. If a semicolon is used as a terminator, each
  1113. expression except the last is printed followed by a ``{\tt :=}'' ending
  1114. with the value of the last expression.
  1115. \subsection{Set Statement}
  1116. In some cases, it is desirable to perform an assignment in which {\em both\/}
  1117. the left- and right-hand sides of an assignment\index{Assignment} are
  1118. evaluated. In this case, the {\tt SET}\ttindex{SET} statement can be used
  1119. with the syntax:
  1120. {\small\begin{verbatim}
  1121. SET(<expression>,<expression>);
  1122. \end{verbatim}}
  1123. For example, the statements
  1124. {\small\begin{verbatim}
  1125. j := 23;
  1126. set(mkid(a,j),x);
  1127. \end{verbatim}}
  1128. assigns the value {\tt X} to {\tt A23}.
  1129. \section{Group Statements}
  1130. The group statement\index{Group statement} is a construct used where
  1131. {\REDUCE} expects a single statement, but a series of actions needs to be
  1132. performed. It is formed by enclosing one or more statements (of any kind)
  1133. between the symbols {\tt $<<$} and {\tt $>>$}, separated by semicolons or
  1134. dollar signs -- it doesn't matter which. The statements are executed one
  1135. after another.
  1136. Examples will be given in the sections on {\tt IF}\ttindex{IF} and other
  1137. types of statements in which the {\tt $<<$} \ldots {\tt $>>$} construct is
  1138. useful.
  1139. If the last statement in the enclosed group has a value, then that is also
  1140. the value of the group statement. Care must be taken not to have a
  1141. semicolon or dollar sign after the last grouped statement, if the value of
  1142. the group is relevant: such an extra terminator causes the group to have
  1143. the value NIL or zero.
  1144. \section{Conditional Statements}
  1145. The conditional statement\index{Conditional statement} has the following
  1146. syntax:
  1147. {\small\begin{verbatim}
  1148. <conditional statement> ::=
  1149. IF <boolean expression> THEN <statement> [ELSE <statement>]
  1150. \end{verbatim}}
  1151. The boolean expression is evaluated. If this is {\em true}, the first
  1152. {\tt <statement>} is executed. If it is {\em false}, the second is.
  1153. {\it Examples:}
  1154. {\small\begin{verbatim}
  1155. if x=5 then a:=b+c else d:=e+f
  1156. if x=5 and numberp y
  1157. then <<ff:=q1; a:=b+c>>
  1158. else <<ff:=q2; d:=e+f>>
  1159. \end{verbatim}}
  1160. Note the use of the group statement\index{Group statement}.
  1161. \\
  1162. Conditional statements associate to the right; i.e.,\ttindex{IF}
  1163. {\small\begin{verbatim}
  1164. IF <a> THEN <b> ELSE IF <c> THEN <d> ELSE <e>
  1165. \end{verbatim}}
  1166. is equivalent to:
  1167. {\small\begin{verbatim}
  1168. IF <a> THEN <b> ELSE (IF <c> THEN <d> ELSE <e>)
  1169. \end{verbatim}}
  1170. In addition, the construction
  1171. {\small\begin{verbatim}
  1172. IF <a> THEN IF <b> THEN <c> ELSE <d>
  1173. \end{verbatim}}
  1174. parses as
  1175. {\small\begin{verbatim}
  1176. IF <a> THEN (IF <b> THEN <c> ELSE <d>).
  1177. \end{verbatim}}
  1178. If the value of the conditional statement\index{Conditional
  1179. statement} is of primary interest, it is often called a conditional
  1180. expression instead. Its value is the value of whichever statement was
  1181. executed. (If the executed statement has no value, the conditional
  1182. expression has no value or the value 0, depending on how it is used.)
  1183. {\it Examples:}
  1184. {\small\begin{verbatim}
  1185. a:=if x<5 then 123 else 456;
  1186. b:=u + v^(if numberp z then 10*z else 1) + w;
  1187. \end{verbatim}}
  1188. If the value is of no concern, the {\tt ELSE} clause may be omitted if no
  1189. action is required in the {\em false\/} case.
  1190. {\small\begin{verbatim}
  1191. if x=5 then a:=b+c;
  1192. \end{verbatim}}
  1193. Note: As explained in Section~\ref{sec-boolean},a
  1194. if a scalar or numerical expression is used in place of
  1195. the boolean expression -- for example, a variable is written there -- the
  1196. {\em true\/} alternative is followed unless the expression has the value 0.
  1197. \section{FOR Statements}
  1198. The {\tt FOR} statement is used to define a variety of program
  1199. loops\index{Loop}. Its general syntax is as follows:\ttindex{UNTIL}
  1200. \ttindex{DO}\ttindex{PRODUCT}\ttindex{SUM}\ttindex{COLLECT}\ttindex{JOIN}
  1201. \begin{small}
  1202. \[ \mbox{\tt FOR} \left\{ \begin{array}{@{}ccc@{}}
  1203. \mbox{\tt \meta{var} := \meta{number} } \left\{ \begin{array}{@{}c@{}}
  1204. \mbox{\tt STEP \meta{number} UNTIL} \\
  1205. \mbox{\tt :}
  1206. \end{array}
  1207. \right\} \mbox{\tt \meta{number}} \\[3mm]
  1208. \multicolumn{1}{c}{\mbox{\tt EACH \meta{var}
  1209. \(\left\{
  1210. \begin{tabular}{@{}c@{}}
  1211. IN \\ ON
  1212. \end{tabular}
  1213. \right\}\)
  1214. \meta{list}}}
  1215. \end{array}
  1216. \right\} \mbox{\tt \meta{action} \meta{exprn}} \]
  1217. \end{small}%
  1218. %
  1219. where
  1220. \begin{center}
  1221. \tt \meta{action} ::= do|product|sum|collect|join.
  1222. \end{center}
  1223. The assignment\index{Assignment} form of the {\tt FOR} statement defines an
  1224. iteration over the indicated numerical range. If expressions that do not
  1225. evaluate to numbers are used in the designated places, an error will
  1226. result.
  1227. The {\tt FOR EACH}\ttindex{FOR EACH} form of the {\tt FOR} statement is
  1228. designed to iterate down a list. Again, an error will occur if a list is
  1229. not used.
  1230. The action {\tt DO}\ttindex{DO} means that {\tt <exprn>} is simply
  1231. evaluated and no value kept; the statement returning 0 in this case (or no
  1232. value at the top level). {\tt COLLECT} means that the results of
  1233. evaluating {\tt <exprn>} each time are linked together to make a list,
  1234. and {\tt JOIN} means that the values of {\tt <exprn>} are themselves
  1235. lists that are joined to make one list (similar to {\tt CONC} in Lisp).
  1236. Finally, {\tt PRODUCT}\ttindex{PRODUCT} and {\tt SUM}\ttindex{SUM}
  1237. form the respective combined value out of the values of {\tt <exprn>}.
  1238. In all cases, {\tt <exprn>} is evaluated algebraically within the
  1239. scope of the current value of {\tt <var>}. If {\tt <action>} is
  1240. {\tt DO}\ttindex{DO}, then nothing else happens. In other cases, {\tt
  1241. <action>} is a binary operator that causes a result to be built up and
  1242. returned by {\tt FOR}. In those cases, the loop\index{Loop} is
  1243. initialized to a default value ({\tt 0} for {\tt SUM},\ttindex{SUM} {\tt
  1244. 1} for {\tt PRODUCT},\ttindex{PRODUCT} and an empty list for the other
  1245. actions). The test for the end condition is made before any action is
  1246. taken. As in Pascal, if the variable is out of range in the assignment
  1247. case, or the {\tt <list>} is empty in the {\tt FOR EACH}\ttindex{FOR EACH}
  1248. case, {\tt <exprn>} is not evaluated at all.
  1249. {\it Examples:}
  1250. \begin{enumerate}
  1251. \item If {\tt A}, {\tt B} have been declared to be arrays, the following
  1252. stores $5^{2}$ through $10^{2}$ in {\tt A(5)} through {\tt A(10)}, and at
  1253. the same time stores the cubes in the {\tt B} array:
  1254. {\small\begin{verbatim}
  1255. for i := 5 step 1 until 10 do <<a(i):=i^2; b(i):=i^3>>
  1256. \end{verbatim}}
  1257. \item As a convenience, the common construction
  1258. {\small\begin{verbatim}
  1259. STEP 1 UNTIL
  1260. \end{verbatim}}
  1261. may be abbreviated to a colon. Thus, instead of the above we could write:
  1262. {\small\begin{verbatim}
  1263. for i := 5:10 do <<a(i):=i^2; b(i):=i^3>>
  1264. \end{verbatim}}
  1265. \item The following sets {\tt C} to the sum of the squares of 1,3,5,7,9;
  1266. and {\tt D} to the expression {\tt x*(x+1)*(x+2)*(x+3)*(x+4):}
  1267. {\small\begin{verbatim}
  1268. c := for j:=1 step 2 until 9 sum j^2;
  1269. d := for k:=0 step 1 until 4 product (x+k);
  1270. \end{verbatim}}
  1271. \item The following forms a list of the squares of the elements of the list
  1272. {\tt \{a,b,c\}:}\ttindex{FOR EACH}
  1273. {\small\begin{verbatim}
  1274. for each x in {a,b,c} collect x^2;
  1275. \end{verbatim}}
  1276. \item The following forms a list of the listed squares of the elements of the
  1277. list {\tt \{a,b,c\}}
  1278. (i.e., {\tt \{\{A\verb|^|2\},\{B\verb|^|2\},\{C\verb|^|2\}\}):}
  1279. {\small\begin{verbatim}
  1280. for each x in {a,b,c} collect {x^2};
  1281. \end{verbatim}}
  1282. \item The following also forms a list of the squares of the elements of
  1283. the list {\tt \{a,b,c\},} since the {\tt JOIN} operation joins the
  1284. individual lists into one list:\ttindex{FOR EACH}
  1285. {\small\begin{verbatim}
  1286. for each x in {a,b,c} join {x^2};
  1287. \end{verbatim}}
  1288. \end{enumerate}
  1289. The control variable used in the {\tt FOR} statement is actually a new
  1290. variable, not related to the variable of the same name outside the {\tt
  1291. FOR} statement. In other words, executing a statement {\tt for i:=} \ldots
  1292. doesn't change the system's assumption that $i^{2} = -1$.
  1293. Furthermore, in algebraic mode, the value of the control variable is
  1294. substituted in {\tt <exprn>} only if it occurs explicitly in that
  1295. expression. It will not replace a variable of the same name in the value
  1296. of that expression. For example:
  1297. {\small\begin{verbatim}
  1298. b := a; for a := 1:2 do write b;
  1299. \end{verbatim}}
  1300. prints {\tt A} twice, not 1 followed by 2.
  1301. \section{WHILE \ldots DO}
  1302. The\ttindex{WHILE} {\tt FOR \ldots DO}\ttindex{DO} feature allows easy
  1303. coding of a repeated operation in which the number of repetitions is known
  1304. in advance. If the criterion for repetition is more complicated, {\tt
  1305. WHILE \ldots DO} can often be used. Its syntax is:
  1306. {\small\begin{verbatim}
  1307. WHILE <boolean expression> DO <statement>
  1308. \end{verbatim}}
  1309. The {\tt WHILE \ldots DO} controls the single statement following {\tt DO}.
  1310. If several statements are to be repeated, as is almost always the case,
  1311. they must be grouped using the $<<$ \ldots $>>$ or {\tt BEGIN \ldots END}
  1312. as in the example below.
  1313. The {\tt WHILE} condition is tested each time {\em before\/} the action
  1314. following the {\tt DO} is attempted. If the condition is false to begin
  1315. with, the action is not performed at all. Make sure that what is to be
  1316. tested has an appropriate value initially.
  1317. {\it Example:}
  1318. Suppose we want to add up a series of terms, generated one by one, until
  1319. we reach a term which is less than 1/1000 in value. For our simple
  1320. example, let us suppose the first term equals 1 and each term is obtained
  1321. from the one before by taking one third of it and adding one third its
  1322. square. We would write:
  1323. {\small\begin{verbatim}
  1324. ex:=0; term:=1;
  1325. while num(term - 1/1000) >= 0 do
  1326. <<ex := ex+term; term:=(term + term^2)/3>>;
  1327. ex;
  1328. \end{verbatim}}
  1329. As long as {\tt TERM} is greater than or equal to ({\tt >=}) 1/1000 it will
  1330. be added to {\tt EX} and the next {\tt TERM} calculated. As soon as {\tt
  1331. TERM} becomes less than 1/1000 the {\tt WHILE} test fails and the {\tt
  1332. TERM} will not be added.
  1333. \section{REPEAT \ldots UNTIL}
  1334. \ttindex{REPEAT} {\tt REPEAT \ldots UNTIL} is very similar in purpose to
  1335. {\tt WHILE \ldots DO}. Its syntax is:
  1336. {\small\begin{verbatim}
  1337. REPEAT <statement> UNTIL <boolean expression>
  1338. \end{verbatim}}
  1339. (PASCAL users note: Only a single statement -- usually a group statement
  1340. -- is allowed between the {\tt REPEAT} and the {\tt UNTIL.)}
  1341. There are two essential differences:
  1342. \begin{enumerate}
  1343. \item The test is performed {\em after\/} the controlled statement (or group of
  1344. statements) is executed, so the controlled statement is always executed at
  1345. least once.
  1346. \item The test is a test for when to stop rather than when to continue, so its
  1347. ``polarity'' is the opposite of that in {\tt WHILE \ldots DO.}
  1348. \end{enumerate}
  1349. As an example, we rewrite the example from the {\tt WHILE \ldots DO} section:
  1350. \begin{samepage}
  1351. {\small\begin{verbatim}
  1352. ex:=0; term:=1;
  1353. repeat <<ex := ex+term; term := (term + term^2)/3>>
  1354. until num(term - 1/1000) < 0;
  1355. ex;
  1356. \end{verbatim}}
  1357. \end{samepage}
  1358. In this case, the answer will be the same as before, because in neither
  1359. case is a term added to {\tt EX} which is less than 1/1000.
  1360. \section{Compound Statements}
  1361. \index{Compound statement}Often the desired process can best (or only) be
  1362. described as a series of steps to be carried out one after the other. In
  1363. many cases, this can be achieved by use of the group statement\index{Group
  1364. statement}. However, each step often provides some intermediate
  1365. result, until at the end we have the final result wanted. Alternatively,
  1366. iterations on the steps are needed that are not possible with constructs
  1367. such as {\tt WHILE}\ttindex{WHILE} or {\tt REPEAT}\ttindex{REPEAT}
  1368. statements. In such cases the steps of the process must be
  1369. enclosed between the words {\tt BEGIN} and {\tt END}\ttindex{BEGIN \ldots
  1370. END} forming what is technically called a {\em block\/}\index{Block} or
  1371. {\em compound\/} statement. Such a compound statement can in fact be used
  1372. wherever a group statement appears. The converse is not true: {\tt BEGIN
  1373. \ldots END} can be used in ways that {\tt $<<$} \ldots {\tt $>>$} cannot.
  1374. If intermediate results must be formed, local variables must be provided
  1375. in which to store them. {\em Local\/} means that their values are deleted as
  1376. soon as the block's operations are complete, and there is no conflict with
  1377. variables outside the block that happen to have the same name. Local
  1378. variables are created by a {\tt SCALAR}\ttindex{SCALAR} declaration
  1379. immediately after the {\tt BEGIN}:
  1380. {\small\begin{verbatim}
  1381. scalar a,b,c,z;
  1382. \end{verbatim}}
  1383. If more convenient, several {\tt SCALAR} declarations can be given one after
  1384. another:
  1385. {\small\begin{verbatim}
  1386. scalar a,b,c;
  1387. scalar z;
  1388. \end{verbatim}}
  1389. In place of {\tt SCALAR} one can also use the declarations
  1390. {\tt INTEGER}\ttindex{INTEGER} or {\tt REAL}\ttindex{REAL}. In the present
  1391. version of {\REDUCE} variables declared {\tt INTEGER} are expected to have
  1392. only integer values, and are initialized to 0. {\tt REAL}
  1393. variables on the other hand are currently treated as algebraic mode {\tt
  1394. SCALAR}s.
  1395. {\it CAUTION:} {\tt INTEGER}, {\tt REAL} and {\tt SCALAR} declarations can
  1396. only be given immediately after a {\tt BEGIN}. An error will result if
  1397. they are used after other statements in a block (including {\tt ARRAY} and
  1398. {\tt OPERATOR} declarations, which are global in scope), or outside the
  1399. top-most block (e.g., at the top level). All variables declared {\tt
  1400. SCALAR} are automatically initialized to zero in algebraic mode ({\tt NIL}
  1401. in symbolic mode).
  1402. Any symbols not declared as local variables in a block refer to the
  1403. variables of the same name in the current calling environment. In
  1404. particular, if they are not so declared at a higher level (e.g., in a
  1405. surrounding block or as parameters in a calling procedure), their values can
  1406. be permanently changed.
  1407. Following the {\tt SCALAR}\ttindex{SCALAR} declaration(s), if any, write the
  1408. statements to be executed, one after the other, separated by delimiters
  1409. (e.g., {\tt ;} or {\tt \$}) (it doesn't matter which). However, from a
  1410. stylistic point of view, {\tt ;} is preferred.
  1411. The last statement in the body, just before {\tt END}, need not have a
  1412. terminator (since the {\tt BEGIN \ldots END} are in a sense brackets
  1413. confining the block statements). The last statement must also be the
  1414. command {\tt RETURN}\ttindex{RETURN} followed by the variable or
  1415. expression whose value is to be the value returned by the procedure. If
  1416. the {\tt RETURN} is omitted (or nothing is written after the word
  1417. {\tt RETURN}) the procedure will have no value or the value zero, depending
  1418. on how it is used (and {\tt NIL} in symbolic mode). Remember to put a
  1419. terminator after the {\tt END}.
  1420. {\it Example:}
  1421. Given a previously assigned integer value for {\tt N}, the following block
  1422. will compute the Legendre polynomial of degree {\tt N} in the variable
  1423. {\tt X}:
  1424. {\small\begin{verbatim}
  1425. begin scalar seed,deriv,top,fact;
  1426. seed:=1/(y^2 - 2*x*y +1)^(1/2);
  1427. deriv:=df(seed,y,n);
  1428. top:=sub(y=0,deriv);
  1429. fact:=for i:=1:n product i;
  1430. return top/fact
  1431. end;
  1432. \end{verbatim}}
  1433. \subsection{Compound Statements with GO TO}
  1434. It is possible to have more complicated structures inside the {\tt BEGIN
  1435. \ldots END}\ttindex{BEGIN \ldots END} brackets than indicated in the
  1436. previous example. That the individual lines of the program need not be
  1437. assignment\index{Assignment} statements, but could be almost any other
  1438. kind of statement or command, needs no explanation. For example,
  1439. conditional statements, and {\tt WHILE}\ttindex{WHILE} and {\tt REPEAT}
  1440. \ttindex{REPEAT} constructions, have an obvious role in defining more
  1441. intricate blocks.
  1442. If these structured constructs don't suffice, it is possible to use labels
  1443. \index{Label} and {\tt GO} {\tt TO}s\ttindex{GO TO} within a compound
  1444. statement,\index{Compound statement} and also to use {\tt RETURN}
  1445. \ttindex{RETURN} in places within the block other than just before the
  1446. {\tt END}. The following subsections discuss these matters in detail.
  1447. For many readers the following example, presenting one possible definition
  1448. of a process to calculate the factorial of {\tt N} for preassigned {\tt N}
  1449. will suffice:
  1450. {\it Example:}
  1451. {\small\begin{verbatim}
  1452. begin scalar m;
  1453. m:=1;
  1454. l: if n=0 then return m;
  1455. m:=m*n;
  1456. n:=n-1;
  1457. go to l
  1458. end;
  1459. \end{verbatim}}
  1460. \subsection{Labels and GO TO Statements}
  1461. \index{Label}\ttindex{GO TO}Within a {\tt BEGIN \ldots END} compound
  1462. statement it is possible to label statements, and transfer to them out of
  1463. sequence using {\tt GO} {\tt TO} statements. Only statements on the top
  1464. level inside compound statements can be labeled, not ones inside
  1465. subsidiary constructions like {\tt $<<$} \ldots {\tt $>>$}, {\tt IF} \ldots
  1466. {\tt THEN} \ldots , {\tt WHILE} \ldots {\tt DO} \ldots , etc.
  1467. Labels and {\tt GO TO} statements have the syntax:
  1468. {\small\begin{verbatim}
  1469. <go to statement> ::= GO TO <label> | GOTO <label>
  1470. <label> ::= <identifier>
  1471. <labeled statement> ::= <label>:<statement>
  1472. \end{verbatim}}
  1473. Note that statement names cannot be used as labels.
  1474. While {\tt GO TO} is an unconditional transfer, it is frequently used
  1475. in conditional statements such as
  1476. {\small\begin{verbatim}
  1477. if x>5 then go to abcd;
  1478. \end{verbatim}}
  1479. giving the effect of a conditional transfer.
  1480. Transfers using {\tt GO TO}s can only occur within the block in which the
  1481. {\tt GO TO} is used. In other words, you cannot transfer from an inner
  1482. block to an outer block using a {\tt GO TO}. However, if a group statement
  1483. occurs within a compound statement, it is possible to jump out of that group
  1484. statement to a point within the compound statement using a {\tt GO TO}.
  1485. \subsection{RETURN Statements}
  1486. The value corresponding to a {\tt BEGIN \ldots END} compound statement,
  1487. \ttindex{BEGIN \ldots END} such as a procedure body, is normally 0 ({\tt
  1488. NIL} in symbolic mode). By executing a {\tt RETURN}\ttindex{RETURN}
  1489. statement in the compound statement a different value can be returned.
  1490. After a {\tt RETURN} statement is executed, no further statements within
  1491. the compound statement are executed.
  1492. {\tt Examples:}
  1493. {\small\begin{verbatim}
  1494. return x+y;
  1495. return m;
  1496. return;
  1497. \end{verbatim}}
  1498. Note that parentheses are not required around the {\tt x+y}, although they
  1499. are permitted. The last example is equivalent to {\tt return 0} or {\tt
  1500. return nil}, depending on whether the block is used as part of an
  1501. expression or not.
  1502. Since {\tt RETURN}\ttindex{RETURN} actually moves up only one
  1503. block\index{Block} level, in a sense the casual user is not expected to
  1504. understand, we tabulate some cautions concerning its use.
  1505. \begin{enumerate}
  1506. \item {\tt RETURN} can be used on the top level inside the compound
  1507. statement, i.e. as one of the statements bracketed together by the {\tt
  1508. BEGIN \ldots END}\ttindex{BEGIN \ldots END}
  1509. \item {\tt RETURN} can be used within a top level {\tt $<<$} \ldots {\tt
  1510. $>>$} construction within the compound statement. In this case, the {\tt
  1511. RETURN} transfers control out of both the group statement and the compound
  1512. statement.
  1513. \item {\tt RETURN} can be used within an {\tt IF} \ldots {\tt THEN} \ldots
  1514. {\tt ELSE} \ldots on the top level within the compound statement.
  1515. \end{enumerate}
  1516. NOTE: At present, there is no construct provided to permit early
  1517. termination of a {\tt FOR}\ttindex{FOR}, {\tt WHILE}\ttindex{WHILE},
  1518. or {\tt REPEAT}\ttindex{REPEAT} statement. In particular, the use of
  1519. {\tt RETURN} in such cases results in a syntax error. For example,
  1520. {\small\begin{verbatim}
  1521. begin scalar y;
  1522. y := for i:=0:99 do if a(i)=x then return b(i);
  1523. ...
  1524. \end{verbatim}}
  1525. will lead to an error.
  1526. \chapter{Commands and Declarations}
  1527. A command\index{Command} is an order to the system to do something. Some
  1528. commands cause visible results (such as calling for input or output);
  1529. others, usually called declarations\index{Declaration}, set options,
  1530. define properties of variables, or define procedures. Commands are
  1531. formally defined as a statement followed by a terminator
  1532. {\small\begin{verbatim}
  1533. <command> ::= <statement> <terminator>
  1534. <terminator> ::= ;|$
  1535. \end{verbatim}}
  1536. Some {\REDUCE} commands and declarations are described in the following
  1537. sub-sections.
  1538. \section{Array Declarations}
  1539. Array\ttindex{ARRAY} declarations in {\REDUCE} are similar to FORTRAN
  1540. dimension statements. For example:
  1541. {\small\begin{verbatim}
  1542. array a(10),b(2,3,4);
  1543. \end{verbatim}}
  1544. Array indices each range from 0 to the value declared. An element of an
  1545. array is referred to in standard FORTRAN notation, e.g. {\tt A(2)}.
  1546. We can also use an expression for defining an array bound, provided the
  1547. value of the expression is a positive integer. For example, if {\tt X} has the
  1548. value 10 and {\tt Y} the value 7 then
  1549. {\tt array c(5*x+y)} is the same as {\tt array c(57)}.
  1550. If an array is referenced by an index outside its range, an error occurs.
  1551. If the array is to be one-dimensional, and the bound a number or a variable
  1552. (not a more general expression) the parentheses may be omitted:
  1553. {\small\begin{verbatim}
  1554. array a 10, c 57;
  1555. \end{verbatim}}
  1556. The operator {\tt LENGTH}\ttindex{LENGTH} applied to an array name
  1557. returns a list of its dimensions.
  1558. All array elements are initialized to 0 at declaration time. In other words,
  1559. an array element has an {\em instant evaluation\/}\index{Instant evaluation}
  1560. property and cannot stand for itself. If this is required, then an
  1561. operator should be used instead.
  1562. Array declarations can appear anywhere in a program. Once a symbol is
  1563. declared to name an array, it can not also be used as a variable, or to
  1564. name an operator or a procedure. It can however be re-declared to be an
  1565. array, and its size may be changed at that time. An array name can also
  1566. continue to be used as a parameter in a procedure, or a local variable in
  1567. a compound statement, although this use is not recommended, since it can
  1568. lead to user confusion over the type of the variable.
  1569. Arrays once declared are global in scope, and so can then be referenced
  1570. anywhere in the program. In other words, unlike arrays in most other
  1571. languages, a declaration within a block (or a procedure) does not limit
  1572. the scope of the array to that block, nor does the array go away on
  1573. exiting the block (use {\tt CLEAR} instead for this purpose).
  1574. \section{Mode Handling Declarations}\index{Mode}
  1575. The {\tt ON}\ttindex{ON} and {\tt OFF}\ttindex{OFF} declarations are
  1576. available to the user for controlling various system options. Each option
  1577. is represented by a {\em switch\/}\index{Switch} name. {\tt ON} and {\tt OFF}
  1578. take a list of switch names as argument and turn them on and off
  1579. respectively, e.g.,
  1580. {\small\begin{verbatim}
  1581. on time;
  1582. \end{verbatim}}
  1583. causes the system to print a message after each command giving the elapsed
  1584. CPU time since the last command, or since {\tt TIME}\ttindex{TIME} was
  1585. last turned off, or the session began. Another useful switch with
  1586. interactive use is {\tt DEMO},\ttindex{DEMO} which causes the system to
  1587. pause after each command in a file (with the exception of comments)
  1588. until a \key{Return} is typed on the terminal. This
  1589. enables a user to set up a demonstration file and step through it command
  1590. by command.
  1591. As with most declarations, arguments to {\tt ON} and {\tt OFF} may be
  1592. strung together separated by commas. For example,
  1593. {\small\begin{verbatim}
  1594. off time,demo;
  1595. \end{verbatim}}
  1596. will turn off both the time messages and the demonstration switch.
  1597. We note here that while most {\tt ON} and {\tt OFF} commands are obeyed
  1598. almost instantaneously, some trigger time-consuming actions such as
  1599. reading in necessary modules from secondary storage.
  1600. A diagnostic message is printed if {\tt ON}\ttindex{ON} or {\tt OFF}
  1601. \ttindex{OFF} are used with a switch that is not known to the system. For
  1602. example, if you misspell {\tt DEMO} and type
  1603. {\small\begin{verbatim}
  1604. on demq;
  1605. \end{verbatim}}
  1606. you will get the message\index{Switch}
  1607. {\small\begin{verbatim}
  1608. ***** DEMQ not defined as switch.
  1609. \end{verbatim}}
  1610. \section{END}
  1611. The identifier {\tt END}\ttindex{END} has two separate uses.
  1612. 1) Its use in a {\tt BEGIN \ldots END} bracket has been discussed in
  1613. connection with compound statements.
  1614. 2) Files to be read using {\tt IN} should end with an extra {\tt END};
  1615. command. The reason for this is explained in the section on the {\tt IN}
  1616. command. This use of {\tt END} does not allow an immediately
  1617. preceding {\tt END} (such as the {\tt END} of a procedure definition), so
  1618. we advise using {\tt ;END;} there.
  1619. %3) A command {\tt END}; entered at the top level transfers control to the
  1620. %Lisp system\index{Lisp} which is the host of the {\REDUCE} system. All
  1621. %files opened by {\tt IN} or {\tt OUT} statements are closed in the
  1622. %process. {\tt END;} does not stop {\REDUCE}. Those familiar with Lisp can
  1623. %experiment with typing identifiers and ({\tt <function name> <argument
  1624. %list>}) lists to see the value returned by Lisp. (No terminators, other
  1625. %than the RETURN key, should be used.) The data structures created during
  1626. %the {\REDUCE} run are accessible.
  1627. %You remain in this Lisp mode until you explicitly re-enter {\REDUCE} by
  1628. %saying {\tt (BEGIN)} at the Lisp top level. In most systems, a Lisp error
  1629. %also returns you to {\REDUCE} (exceptions are noted in the operating
  1630. %instructions for your particular {\REDUCE} implementation). In either
  1631. %case, you will return to {\REDUCE} in the same mode, algebraic or
  1632. %symbolic, that you were in before the {\tt END};. If you are in
  1633. %Lisp mode\index{Lisp mode} by mistake -- which is usually the case,
  1634. %the result of typing more {\tt END}s\ttindex{END} than {\tt BEGIN}s --
  1635. %type {\tt (BEGIN)} in parentheses and hit the RETURN key.
  1636. \section{BYE Command}\ttindex{BYE}
  1637. The command {\tt BYE}; (or alternatively {\tt QUIT};)\ttindex{QUIT}
  1638. stops the execution
  1639. of {\REDUCE}, closes all open output files, and returns you to the calling
  1640. program (usually the operating system). Your {\REDUCE} session is
  1641. normally destroyed.
  1642. \section{SHOWTIME Command}\ttindex{SHOWTIME}
  1643. {\tt SHOWTIME}; prints the elapsed time since the last call of this
  1644. command or, on its first call, since the current {\REDUCE} session began.
  1645. The time is normally given in milliseconds and gives the time as measured
  1646. by a system clock. The operations covered by this measure are system
  1647. dependent.
  1648. \section{DEFINE Command}
  1649. The command {\tt DEFINE}\ttindex{DEFINE} allows a user to supply a new name for
  1650. any identifier or replace it by any well-formed expression. Its argument
  1651. is a list of expressions of the form
  1652. {\small\begin{verbatim}
  1653. <identifier> = <number>|<identifier>|<operator>|
  1654. <reserved word>|<expression>
  1655. \end{verbatim}}
  1656. {\it Example:}
  1657. {\small\begin{verbatim}
  1658. define be==,x=y+z;
  1659. \end{verbatim}}
  1660. means that {\tt BE} will be interpreted as an equal sign, and {\tt X}
  1661. as the expression {\tt y+z} from then on. This renaming is done at parse
  1662. time, and therefore takes precedence over any other replacement declared
  1663. for the same identifier. It stays in effect until the end of the
  1664. {\REDUCE} run.
  1665. The identifiers {\tt ALGEBRAIC} and {\tt SYMBOLIC} have properties which
  1666. prevent {\tt DEFINE}\ttindex{DEFINE} from being used on them. To define
  1667. {\tt ALG} to be a synonym for {\tt ALGEBRAIC}, use the more complicated
  1668. construction
  1669. {\small\begin{verbatim}
  1670. put('alg,'newnam,'algebraic);
  1671. \end{verbatim}}
  1672. \chapter{Built-in Prefix Operators}
  1673. In the following subsections are descriptions of the most useful prefix
  1674. \index{Prefix}
  1675. operators built into {\REDUCE} that are not defined in other sections (such
  1676. as substitution operators). Some are fully defined internally as
  1677. procedures; others are more nearly abstract operators, with only some of
  1678. their properties known to the system.
  1679. In many cases, an operator is described by a prototypical header line as
  1680. follows. Each formal parameter is given a name and followed by its allowed
  1681. type. The names of classes referred to in the definition are printed in
  1682. lower case, and parameter names in upper case. If a parameter type is not
  1683. commonly used, it may be a specific set enclosed in brackets {\tt \{} \ldots
  1684. {\tt \}}.
  1685. Operators that accept formal parameter lists of arbitrary length have the
  1686. parameter and type class enclosed in square brackets indicating that zero
  1687. or more occurrences of that argument are permitted. Optional parameters
  1688. and their type classes are enclosed in angle brackets.
  1689. \section{Numerical Operators}\index{Numerical operator}
  1690. {\REDUCE} includes a number of functions that are analogs of those found
  1691. in most numerical systems. With numerical arguments, such functions
  1692. return the expected result. However, they may also be called with
  1693. non-numerical arguments. In such cases, except where noted, the system
  1694. attempts to simplify the expression as far as it can. In such cases, a
  1695. residual expression involving the original operator usually remains.
  1696. These operators are as follows:
  1697. \subsection{ABS}
  1698. {\tt ABS}\ttindex{ABS} returns the absolute value
  1699. of its single argument, if that argument has a numerical value.
  1700. A non-numerical argument is returned as an absolute value, with an overall
  1701. numerical coefficient taken outside the absolute value operator. For example:
  1702. {\small\begin{verbatim}
  1703. abs(-3/4) -> 3/4
  1704. abs(2a) -> 2*ABS(A)
  1705. abs(i) -> 1
  1706. abs(-x) -> ABS(X)
  1707. \end{verbatim}}
  1708. \subsection{CEILING}\ttindex{CEILING}
  1709. This operator returns the ceiling (i.e., the least integer greater than
  1710. the given argument) if its single argument has a numerical value. A
  1711. non-numerical argument is returned as an expression in the original
  1712. operator. For example:
  1713. {\small\begin{verbatim}
  1714. ceiling(-5/4) -> -1
  1715. ceiling(-a) -> CEILING(-A)
  1716. \end{verbatim}}
  1717. \subsection{CONJ}\ttindex{CONJ}
  1718. This returns the complex conjugate
  1719. of an expression, if that argument has an numerical value. A
  1720. non-numerical argument is returned as an expression in the operators
  1721. {\tt REPART}\ttindex{REPART} and {\tt IMPART}\ttindex{IMPART}. For example:
  1722. {\small\begin{verbatim}
  1723. conj(1+i) -> 1-I
  1724. conj(a+i*b) -> REPART(A) - REPART(B)*I - IMPART(A)*I
  1725. - IMPART(B)
  1726. \end{verbatim}}
  1727. \subsection{FACTORIAL}\ttindex{FACTORIAL}
  1728. If the single argument of {\tt FACTORIAL} evaluates to a non-negative
  1729. integer, its factorial is returned. Otherwise an expression involving
  1730. {\tt FACTORIAL} is returned. For example:
  1731. {\small\begin{verbatim}
  1732. factorial(5) -> 120
  1733. factorial(a) -> FACTORIAL(A)
  1734. \end{verbatim}}
  1735. \subsection{FIX}\ttindex{FIX}
  1736. This operator returns the fixed value (i.e., the integer part of
  1737. the given argument) if its single argument has a numerical value. A
  1738. non-numerical argument is returned as an expression in the original
  1739. operator. For example:
  1740. {\small\begin{verbatim}
  1741. fix(-5/4) -> -1
  1742. fix(a) -> FIX(A)
  1743. \end{verbatim}}
  1744. \subsection{FLOOR}\ttindex{FLOOR}
  1745. This operator returns the floor (i.e., the greatest integer less than
  1746. the given argument) if its single argument has a numerical value. A
  1747. non-numerical argument is returned as an expression in the original
  1748. operator. For example:
  1749. {\small\begin{verbatim}
  1750. floor(-5/4) -> -2
  1751. floor(a) -> FLOOR(A)
  1752. \end{verbatim}}
  1753. \subsection{IMPART}\ttindex{IMPART}
  1754. This operator returns the imaginary part of an expression, if that argument
  1755. has an numerical value. A non-numerical argument is returned as an expression
  1756. in the operators {\tt REPART}\ttindex{REPART} and {\tt IMPART}. For example:
  1757. {\small\begin{verbatim}
  1758. impart(1+i) -> 1
  1759. impart(a+i*b) -> REPART(B) + IMPART(A)
  1760. \end{verbatim}}
  1761. \subsection{MAX/MIN}
  1762. {\tt MAX} and {\tt MIN}\ttindex{MAX}\ttindex{MIN} can take an arbitrary
  1763. number of expressions as their arguments. If all arguments evaluate to
  1764. numerical values, the maximum or minimum of the argument list is returned.
  1765. If any argument is non-numeric, an appropriately reduced expression is
  1766. returned. For example:
  1767. {\small\begin{verbatim}
  1768. max(2,-3,4,5) -> 5
  1769. min(2,-2) -> -2.
  1770. max(a,2,3) -> MAX(A,3)
  1771. min(x) -> X
  1772. \end{verbatim}}
  1773. {\tt MAX} or {\tt MIN} of an empty list returns 0.
  1774. \subsection{NEXTPRIME}\ttindex{NEXTPRIME}
  1775. {\tt NEXTPRIME} returns the next prime greater than its integer argument,
  1776. using a probabilistic algorithm. A type error occurs if the value of the
  1777. argument is not an integer. For example:
  1778. {\small\begin{verbatim}
  1779. nextprime(5) -> 7
  1780. nextprime(-2) -> 2
  1781. nextprime(-7) -> -5
  1782. nextprime 1000000 -> 1000003
  1783. \end{verbatim}}
  1784. whereas {\tt nextprime(a)} gives a type error.
  1785. \subsection{RANDOM}\ttindex{RANDOM}
  1786. {\tt random(}{\em n\/}{\tt)} returns a random number $r$ in the range $0
  1787. \leq r < n$. A type error occurs if the value of the argument is not a
  1788. positive integer in algebraic mode, or positive number in symbolic mode.
  1789. For example:
  1790. {\small\begin{verbatim}
  1791. random(5) -> 3
  1792. random(1000) -> 191
  1793. \end{verbatim}}
  1794. whereas {\tt random(a)} gives a type error.
  1795. \subsection{RANDOM\_NEW\_SEED}\ttindex{RANDOM\_NEW\_SEED}
  1796. {\tt random\_new\_seed(}{\em n\/}{\tt)} reseeds the random number generator
  1797. to a sequence determined by the integer argument $n$. It can be used to
  1798. ensure that a repeatable pseudo-random sequence will be delivered
  1799. regardless of any previous use of {\tt RANDOM}, or can be called early in
  1800. a run with an argument derived from something variable (such as the time
  1801. of day) to arrange that different runs of a REDUCE program will use
  1802. different random sequences. When a fresh copy of REDUCE is first created
  1803. it is as if {\tt random\_new\_seed(1)} has been obeyed.
  1804. A type error occurs if the value of the argument is not a positive integer.
  1805. \subsection{REPART}\ttindex{REPART}
  1806. This returns the real part of an expression, if that argument has an
  1807. numerical value. A non-numerical argument is returned as an expression in
  1808. the operators {\tt REPART} and {\tt IMPART}\ttindex{IMPART}. For example:
  1809. {\small\begin{verbatim}
  1810. repart(1+i) -> 1
  1811. repart(a+i*b) -> REPART(A) - IMPART(B)
  1812. \end{verbatim}}
  1813. \subsection{ROUND}\ttindex{ROUND}
  1814. This operator returns the rounded value (i.e, the nearest integer) of its
  1815. single argument if that argument has a numerical value. A non-numeric
  1816. argument is returned as an expression in the original operator. For
  1817. example:
  1818. {\small\begin{verbatim}
  1819. round(-5/4) -> -1
  1820. round(a) -> ROUND(A)
  1821. \end{verbatim}}
  1822. \subsection{SIGN}\ttindex{SIGN}
  1823. {\tt SIGN} tries to evaluate the sign of its argument. If this
  1824. is possible {\tt SIGN} returns one of 1, 0 or -1. Otherwise, the result
  1825. is the original form or a simplified variant. For example:
  1826. {\small\begin{verbatim}
  1827. sign(-5) -> -1
  1828. sign(-a^2*b) -> -SIGN(B)
  1829. \end{verbatim}}
  1830. Note that even powers of formal expressions are assumed to be
  1831. positive only as long as the switch {\tt COMPLEX} is off.
  1832. \section{Mathematical Functions}
  1833. {\REDUCE} knows that the following represent mathematical functions
  1834. \index{Mathematical function} that can
  1835. take arbitrary scalar expressions as their single argument:
  1836. {\small\begin{verbatim}
  1837. ACOS ACOSH ACOT ACOTH ACSC ACSCH ASEC ASECH ASIN ASINH
  1838. ATAN ATANH ATAN2 COS COSH COT COTH CSC CSCH DILOG EI EXP
  1839. HYPOT LN LOG LOGB LOG10 SEC SECH SIN SINH SQRT TAN TANH
  1840. \end{verbatim}}
  1841. \ttindex{ACOS}\ttindex{ACOSH}\ttindex{ACOT}
  1842. \ttindex{ACOTH}\ttindex{ACSC}\ttindex{ACSCH}\ttindex{ASEC}
  1843. \ttindex{ASECH}\ttindex{ASIN}
  1844. \ttindex{ASINH}\ttindex{ATAN}\ttindex{ATANH}
  1845. \ttindex{ATAN2}\ttindex{COS}
  1846. \ttindex{COSH}\ttindex{COT}\ttindex{COTH}\ttindex{CSC}
  1847. \ttindex{CSCH}\ttindex{DILOG}\ttindex{Ei}\ttindex{EXP}
  1848. \ttindex{HYPOT}\ttindex{LN}\ttindex{LOG}\ttindex{LOGB}\ttindex{LOG10}
  1849. \ttindex{SEC}\ttindex{SECH}\ttindex{SIN}
  1850. \ttindex{SINH}\ttindex{SQRT}\ttindex{TAN}\ttindex{TANH}
  1851. where {\tt LOG} is the natural logarithm (and equivalent to {\tt LN}),
  1852. and {\tt LOGB} has two arguments of which the second is the logarithmic base.
  1853. The derivatives of all these functions are also known to the system.
  1854. {\REDUCE} knows various elementary identities and properties
  1855. of these functions. For example:
  1856. {\small\begin{verbatim}
  1857. cos(-x) = cos(x) sin(-x) = - sin (x)
  1858. cos(n*pi) = (-1)^n sin(n*pi) = 0
  1859. log(e) = 1 e^(i*pi/2) = i
  1860. log(1) = 0 e^(i*pi) = -1
  1861. log(e^x) = x e^(3*i*pi/2) = -i
  1862. \end{verbatim}}
  1863. Beside these identities, there are a lot of simplifications
  1864. for elementary functions
  1865. defined in the {\REDUCE} system as rulelists. In order to
  1866. view these, the SHOWRULES operator can be used, e.g.
  1867. {\small\begin{verbatim}
  1868. SHOWRULES tan;
  1869. {tan(~n*arbint(~i)*pi + ~(~ x)) => tan(x) when fixp(n),
  1870. tan(~x)
  1871. => trigquot(sin(x),cos(x)) when knowledge_about(sin,x,tan)
  1872. ,
  1873. ~x + ~(~ k)*pi
  1874. tan(----------------)
  1875. ~d
  1876. x k 1
  1877. => - cot(---) when x freeof pi and abs(---)=---,
  1878. d d 2
  1879. ~(~ w) + ~(~ k)*pi w + remainder(k,d)*pi
  1880. tan(--------------------) => tan(-----------------------)
  1881. ~(~ d) d
  1882. k
  1883. when w freeof pi and ratnump(---) and fixp(k)
  1884. d
  1885. k
  1886. and abs(---)>=1,
  1887. d
  1888. tan(atan(~x)) => x,
  1889. 2
  1890. df(tan(~x),~x) => 1 + tan(x) }
  1891. \end{verbatim}}
  1892. For further simplification, especially of expressions involving
  1893. trigonometric functions, see the TRIGSIMP\ttindex{TRIGSIMP} package
  1894. documentation.
  1895. Functions not listed above may be defined in the special functions
  1896. package SPECFN\ttindex{SPECFN}.
  1897. The user can add further rules for the reduction of expressions involving
  1898. these operators by using the {\tt LET}\ttindex{LET} command.
  1899. % The square root function can be input using the name {\tt SQRT}, or the
  1900. % power operation {\tt \verb|^|(1/2)}. On output, unsimplified square roots
  1901. % are normally represented by the operator {\tt SQRT} rather than a
  1902. % fractional power.
  1903. In many cases it is desirable to expand product arguments of logarithms,
  1904. or collect a sum of logarithms into a single logarithm. Since these are
  1905. inverse operations, it is not possible to provide rules for doing both at
  1906. the same time and preserve the {\REDUCE} concept of idempotent evaluation.
  1907. As an alternative, REDUCE provides two switches {\tt EXPANDLOGS}
  1908. \ttindex{EXPANDLOGS} and {\tt COMBINELOGS}\ttindex{COMBINELOGS} to carry
  1909. out these operations. Both are off by default. Thus to expand {\tt
  1910. LOG(X*Y)} into a sum of logs, one can say
  1911. {\small\begin{verbatim}
  1912. ON EXPANDLOGS; LOG(X*Y);
  1913. \end{verbatim}}
  1914. and to combine this sum into a single log:
  1915. {\small\begin{verbatim}
  1916. ON COMBINELOGS; LOG(X) + LOG(Y);
  1917. \end{verbatim}}
  1918. At the present time, it is possible to have both switches on at once,
  1919. which could lead to infinite recursion. However, an expression is
  1920. switched from one form to the other in this case. Users should not rely
  1921. on this behavior, since it may change in the next release.
  1922. The current version of {\REDUCE} does a poor job of simplifying surds. In
  1923. particular, expressions involving the product of variables raised to
  1924. non-integer powers do not usually have their powers combined internally,
  1925. even though they are printed as if those powers were combined. For
  1926. example, the expression
  1927. {\small\begin{verbatim}
  1928. x^(1/3)*x^(1/6);
  1929. \end{verbatim}}
  1930. will print as
  1931. {\small\begin{verbatim}
  1932. SQRT(X)
  1933. \end{verbatim}}
  1934. but will have an internal form containing the two exponentiated terms.
  1935. If you now subtract {\tt sqrt(x)} from this expression, you will {\em not\/}
  1936. get zero. Instead, the confusing form
  1937. {\small\begin{verbatim}
  1938. SQRT(X) - SQRT(X)
  1939. \end{verbatim}}
  1940. will result. To combine such exponentiated terms, the switch
  1941. {\tt COMBINEEXPT}\ttindex{COMBINEEXPT} should be turned on.
  1942. The square root function can be input using the name {\tt SQRT}, or the
  1943. power operation {\tt \verb|^|(1/2)}. On output, unsimplified square roots
  1944. are normally represented by the operator {\tt SQRT} rather than a
  1945. fractional power. With the default system switch settings, the argument
  1946. of a square root is first simplified, and any divisors of the expression
  1947. that are perfect squares taken outside the square root argument. The
  1948. remaining expression is left under the square root.
  1949. % However, if the switch {\tt REDUCED}\ttindex{REDUCED} is on,
  1950. % multiplicative factors in the argument of the square root are also
  1951. % separated, becoming individual square roots. Thus with {\tt REDUCED} off,
  1952. Thus the expression
  1953. {\small\begin{verbatim}
  1954. sqrt(-8a^2*b)
  1955. \end{verbatim}}
  1956. becomes
  1957. {\small\begin{verbatim}
  1958. 2*a*sqrt(-2*b).
  1959. \end{verbatim}}
  1960. % whereas with {\tt REDUCED} on, it would become
  1961. % {\small\begin{verbatim}
  1962. % 2*a*i*sqrt(2)*sqrt(b) .
  1963. % \end{verbatim}}
  1964. % The switch {\tt REDUCED}\ttindex{REDUCED} also applies to other rational
  1965. % powers in addition to square roots.
  1966. Note that such simplifications can cause trouble if {\tt A} is eventually
  1967. given a value that is a negative number. If it is important that the
  1968. positive property of the square root and higher even roots always be
  1969. preserved, the switch {\tt PRECISE}\ttindex{PRECISE} should be set on
  1970. (the default value).
  1971. This causes any non-numerical factors taken out of surds to be represented
  1972. by their absolute value form.
  1973. With % both {\tt REDUCED} and
  1974. {\tt PRECISE} on then, the above example would become
  1975. {\small\begin{verbatim}
  1976. 2*abs(a)*sqrt(-2*b).
  1977. \end{verbatim}}
  1978. The statement that {\REDUCE} knows very little about these functions
  1979. applies only in the mathematically exact {\tt off rounded} mode. If
  1980. {\tt ROUNDED}\ttindex{ROUNDED} is on, any of the functions
  1981. {\small\begin{verbatim}
  1982. ACOS ACOSH ACOT ACOTH ACSC ACSCH ASEC ASECH ASIN ASINH
  1983. ATAN ATANH ATAN2 COS COSH COT COTH CSC CSCH EXP HYPOT
  1984. LN LOG LOGB LOG10 SEC SECH SIN SINH SQRT TAN TANH
  1985. \end{verbatim}}
  1986. \ttindex{ACOS}\ttindex{ACOSH}\ttindex{ACOT}\ttindex{ACOTH}
  1987. \ttindex{ACSC}\ttindex{ACSCH}\ttindex{ASEC}\ttindex{ASECH}
  1988. \ttindex{ASIN}\ttindex{ASINH}\ttindex{ATAN}\ttindex{ATANH}
  1989. \ttindex{ATAN2}\ttindex{COS}\ttindex{COSH}\ttindex{COT}
  1990. \ttindex{COTH}\ttindex{CSC}\ttindex{CSCH}\ttindex{EXP}\ttindex{HYPOT}
  1991. \ttindex{LN}\ttindex{LOG}\ttindex{LOGB}\ttindex{LOG10}\ttindex{SEC}
  1992. \ttindex{SECH}\ttindex{SIN}\ttindex{SINH}\ttindex{SQRT}\ttindex{TAN}
  1993. \ttindex{TANH}
  1994. when given a numerical argument has its value calculated to the current
  1995. degree of floating point precision. In addition, real (non-integer
  1996. valued) powers of numbers will also be evaluated.
  1997. If the {\tt COMPLEX} switch is turned on in addition to {\tt ROUNDED},
  1998. these functions will also calculate a real or complex result, again to
  1999. the current degree of floating point precision,
  2000. if given complex arguments. For example, with {\tt on rounded,complex;}
  2001. {\small\begin{verbatim}
  2002. 2.3^(5.6i) -> -0.0480793490914 - 0.998843519372*I
  2003. cos(2+3i) -> -4.18962569097 - 9.10922789376*I
  2004. \end{verbatim}}
  2005. \section{DF Operator}
  2006. The operator {\tt DF}\ttindex{DF} is used to represent partial
  2007. differentiation\index{Differentiation} with respect
  2008. to one or more variables. It is used with the syntax:
  2009. {\small\begin{verbatim}
  2010. DF(EXPRN:algebraic[,VAR:kernel<,NUM:integer>]):algebraic.
  2011. \end{verbatim}}
  2012. The first argument is the expression to be differentiated. The remaining
  2013. arguments specify the differentiation variables and the number of times
  2014. they are applied.
  2015. The number {\tt NUM} may be omitted if it is 1. For example,
  2016. \begin{quote}
  2017. \begin{tabbing}
  2018. {\tt df(y,x1,2,x2,x3,2)} \= = $\partial^{5}y/\partial x_{1}^{2} \
  2019. \partial x_{2}\partial x_{3}^{2}.$\kill
  2020. {\tt df(y,x)} \> = $\partial y/\partial x$ \\
  2021. {\tt df(y,x,2)} \> = $\partial^{2}y/\partial x^{2}$ \\
  2022. {\tt df(y,x1,2,x2,x3,2)} \> = $\partial^{5}y/\partial x_{1}^{2} \
  2023. \partial x_{2}\partial x_{3}^{2}.$
  2024. \end{tabbing}
  2025. \end{quote}
  2026. The evaluation of {\tt df(y,x)} proceeds as follows: first, the values of
  2027. {\tt Y} and {\tt X} are found. Let us assume that {\tt X} has no assigned
  2028. value, so its value is {\tt X}. Each term or other part of the value of
  2029. {\tt Y} that contains the variable {\tt X} is differentiated by the
  2030. standard rules. If {\tt Z} is another variable, not {\tt X} itself, then
  2031. its derivative with respect to {\tt X} is taken to be 0, unless {\tt Z}
  2032. has previously been declared to {\tt DEPEND} on {\tt X}, in which
  2033. case the derivative is reported as the symbol {\tt df(z,x)}.
  2034. \subsection{Adding Differentiation Rules}
  2035. The {\tt LET}\ttindex{LET} statement can be used to introduce
  2036. rules for differentiation of user-defined operators. Its general form is
  2037. {\small\begin{verbatim}
  2038. FOR ALL <var1>,...,<varn>
  2039. LET DF(<operator><varlist>,<vari>)=<expression>
  2040. \end{verbatim}}
  2041. where {\tt <varlist>} ::= ({\tt <var1>},\dots,{\tt <varn>}), and
  2042. {\tt <var1>},...,{\tt <varn>} are the dummy variable arguments of
  2043. {\tt <operator>}.
  2044. An analogous form applies to infix operators.
  2045. {\it Examples:}
  2046. {\small\begin{verbatim}
  2047. for all x let df(tan x,x)= 1 + tan(x)^2;
  2048. \end{verbatim}}
  2049. (This is how the tan differentiation rule appears in the {\REDUCE}
  2050. source.)
  2051. {\small\begin{verbatim}
  2052. for all x,y let df(f(x,y),x)=2*f(x,y),
  2053. df(f(x,y),y)=x*f(x,y);
  2054. \end{verbatim}}
  2055. Notice that all dummy arguments of the relevant operator must be declared
  2056. arbitrary by the {\tt FOR ALL} command, and that rules may be supplied for
  2057. operators with any number of arguments. If no differentiation rule
  2058. appears for an argument in an operator, the differentiation routines will
  2059. return as result an expression in terms of {\tt DF}\ttindex{DF}. For
  2060. example, if the rule for the differentiation with respect to the second
  2061. argument of {\tt F} is not supplied, the evaluation of {\tt df(f(x,z),z)}
  2062. would leave this expression unchanged. (No {\tt DEPEND} declaration
  2063. is needed here, since {\tt f(x,z)} obviously ``depends on'' {\tt Z}.)
  2064. Once such a rule has been defined for a given operator, any future
  2065. differentiation\index{Differentiation} rules for that operator must be
  2066. defined with the same number of arguments for that operator, otherwise we
  2067. get the error message
  2068. {\small\begin{verbatim}
  2069. Incompatible DF rule argument length for <operator>
  2070. \end{verbatim}}
  2071. \section{INT Operator}
  2072. {\tt INT}\ttindex{INT} is an operator in {\REDUCE} for indefinite
  2073. integration\index{Integration}\index{Indefinite integration} using a
  2074. combination of the Risch-Norman algorithm and pattern matching. It is
  2075. used with the syntax:
  2076. {\small\begin{verbatim}
  2077. INT(EXPRN:algebraic,VAR:kernel):algebraic.
  2078. \end{verbatim}}
  2079. This will return correctly the indefinite integral for expressions comprising
  2080. polynomials, log functions, exponential functions and tan and atan. The
  2081. arbitrary constant is not represented. If the integral cannot be done in
  2082. closed terms, it returns a formal integral for the answer in one of two ways:
  2083. \begin{enumerate}
  2084. \item It returns the input, {\tt INT(\ldots,\ldots)} unchanged.
  2085. \item It returns an expression involving {\tt INT}s of some
  2086. other functions (sometimes more complicated than
  2087. the original one, unfortunately).
  2088. \end{enumerate}
  2089. Rational functions can be integrated when the denominator is factorizable
  2090. by the program. In addition it will attempt to integrate expressions
  2091. involving error functions, dilogarithms and other trigonometric
  2092. expressions. In these cases it might not always succeed in finding the
  2093. solution, even if one exists.
  2094. {\it Examples:}
  2095. {\small\begin{verbatim}
  2096. int(log(x),x) -> X*(LOG(X) - 1),
  2097. int(e^x,x) -> E**X.
  2098. \end{verbatim}}
  2099. The program checks that the second argument is a variable and gives an
  2100. error if it is not.
  2101. {\it Note:} If the {\tt int} operator is called with 4 arguments,
  2102. {\REDUCE} will implicitly call the definite integration package (DEFINT)
  2103. and this package will interpret the third and fourth arguments as the lower
  2104. and upper limit of integration, respectively. For details, consult
  2105. the documentation on the DEFINT package.
  2106. \subsection{Options}
  2107. The switch {\tt TRINT} when on will trace the operation of the algorithm. It
  2108. produces a great deal of output in a somewhat illegible form, and is not
  2109. of much interest to the general user. It is normally off.
  2110. If the switch {\tt FAILHARD} is on the algorithm will terminate with an
  2111. error if the integral cannot be done in closed terms, rather than return a
  2112. formal integration form. {\tt FAILHARD} is normally off.
  2113. The switch {\tt NOLNR} suppresses the use of the linear properties of
  2114. integration in cases when the integral cannot be found in closed terms.
  2115. It is normally off.
  2116. \subsection{Advanced Use}
  2117. If a function appears in the integrand that is not one of the functions
  2118. {\tt EXP, ERF, TAN, ATAN, LOG, DILOG}\ttindex{EXP}\ttindex{ERF}
  2119. \ttindex{TAN}\ttindex{ATAN}\ttindex{LOG}\ttindex{DILOG}
  2120. then the algorithm will make an
  2121. attempt to integrate the argument if it can, differentiate it and reach a
  2122. known function. However the answer cannot be guaranteed in this case. If
  2123. a function is known to be algebraically independent of this set it can be
  2124. flagged transcendental by
  2125. {\small\begin{verbatim}
  2126. flag('(trilog),'transcendental);
  2127. \end{verbatim}}
  2128. in which case this function will be added to the permitted field
  2129. descriptors for a genuine decision procedure. If this is done the user is
  2130. responsible for the mathematical correctness of his actions.
  2131. The standard version does not deal with algebraic extensions. Thus
  2132. integration of expressions involving square roots and other like things
  2133. can lead to trouble. A contributed package that supports integration of
  2134. functions involving square roots is available, however
  2135. (ALGINT\extendedmanual{, chapter~\ref{ALGINT}}).
  2136. In addition there is a definite integration
  2137. package, DEFINT\extendedmanual{( chapter~\ref{DEFINT})}.
  2138. \subsection{References}
  2139. A. C. Norman \& P. M. A. Moore, ``Implementing the New Risch
  2140. Algorithm'', Proc. 4th International Symposium on Advanced
  2141. Comp. Methods in Theor. Phys., CNRS, Marseilles, 1977.
  2142. S. J. Harrington, ``A New Symbolic Integration System in Reduce'',
  2143. Comp. Journ. 22 (1979) 2.
  2144. A. C. Norman \& J. H. Davenport, ``Symbolic Integration --- The Dust
  2145. Settles?'', Proc. EUROSAM 79, Lecture Notes in Computer
  2146. Science 72, Springer-Verlag, Berlin Heidelberg New York
  2147. (1979) 398-407.
  2148. %\subsection{Definite Integration} \index{Definite integration}
  2149. %
  2150. %If {\tt INT} is used with the syntax
  2151. %
  2152. %{\small\begin{verbatim}
  2153. % INT(EXPRN:algebraic,VAR:kernel,LOWER:algebraic,UPPER:algebraic):algebraic.
  2154. %\end{verbatim}}
  2155. %
  2156. %The definite integral of {\tt EXPRN} with respect to {\tt VAR} is
  2157. %calculated between the limits {\tt LOWER} and {\tt UPPER}. In the present
  2158. %system, this is calculated either by pattern matching, or by first finding
  2159. %the indefinite integral, and then substituting the limits into this.
  2160. \section{LENGTH Operator}
  2161. {\tt LENGTH}\ttindex{LENGTH} is a generic operator for finding the
  2162. length of various objects in the system. The meaning depends on the type
  2163. of the object. In particular, the length of an algebraic expression is
  2164. the number of additive top-level terms its expanded representation.
  2165. {\it Examples:}
  2166. {\small\begin{verbatim}
  2167. length(a+b) -> 2
  2168. length(2) -> 1.
  2169. \end{verbatim}}
  2170. Other objects that support a length operator include arrays, lists and
  2171. matrices. The explicit meaning in these cases is included in the description
  2172. of these objects.
  2173. \section{MAP Operator}\ttindex{MAP}
  2174. The {\tt MAP} operator applies a uniform evaluation pattern to all members
  2175. of a composite structure: a matrix, a list, or the arguments of an
  2176. operator expression. The evaluation pattern can be a unary procedure, an
  2177. operator, or an algebraic expression with one free variable.
  2178. It is used with the syntax:
  2179. {\small\begin{verbatim}
  2180. MAP(U:function,V:object)
  2181. \end{verbatim}}
  2182. Here {\tt object} is a list, a matrix or an operator expression.
  2183. {\tt Function} can be one of the following:
  2184. \begin{enumerate}
  2185. \item the name of an operator for a single argument: the operator
  2186. is evaluated once with each element of {\tt object} as its single argument;
  2187. \item an algebraic expression with exactly one free variable, that is
  2188. a variable preceded by the tilde symbol. The expression
  2189. is evaluated for each element of {\tt object}, where the element is
  2190. substituted for the free variable;
  2191. \item a replacement rule of the form {\tt var => rep}
  2192. where {\tt var} is a variable (a kernel without a subscript)
  2193. and {\tt rep} is an expression that contains {\tt var}.
  2194. {\tt Rep} is evaluated for each element of {\tt object} where
  2195. the element is substituted for {\tt var}. {\tt Var} may be
  2196. optionally preceded by a tilde.
  2197. \end{enumerate}
  2198. The rule form for {\tt function} is needed when more than
  2199. one free variable occurs.
  2200. Examples:
  2201. {\small\begin{verbatim}
  2202. map(abs,{1,-2,a,-a}) -> {1,2,ABS(A),ABS(A)}
  2203. map(int(~w,x), mat((x^2,x^5),(x^4,x^5))) ->
  2204. [ 3 6 ]
  2205. [ x x ]
  2206. [---- ----]
  2207. [ 3 6 ]
  2208. [ ]
  2209. [ 5 6 ]
  2210. [ x x ]
  2211. [---- ----]
  2212. [ 5 6 ]
  2213. map(~w*6, x^2/3 = y^3/2 -1) -> 2*X^2=3*(Y^3-2)
  2214. \end{verbatim}}
  2215. You can use {\tt MAP} in nested expressions. However, you cannot
  2216. apply {\tt MAP} to a non-composed object, e.g. an identifier or a number.
  2217. \section{MKID Operator}\ttindex{MKID}
  2218. In many applications, it is useful to create a set of identifiers for
  2219. naming objects in a consistent manner. In most cases, it is sufficient to
  2220. create such names from two components. The operator {\tt MKID} is provided
  2221. for this purpose. Its syntax is:
  2222. {\small\begin{verbatim}
  2223. MKID(U:id,V:id|non-negative integer):id
  2224. \end{verbatim}}
  2225. for example
  2226. {\small\begin{verbatim}
  2227. mkid(a,3) -> A3
  2228. mkid(apple,s) -> APPLES
  2229. \end{verbatim}}
  2230. while {\tt mkid(a+b,2)} gives an error.
  2231. The {\tt SET}\ttindex{SET} operator can be used to give a value to the
  2232. identifiers created by {\tt MKID}, for example
  2233. {\small\begin{verbatim}
  2234. set(mkid(a,3),3);
  2235. \end{verbatim}}
  2236. will give {\tt A3} the value 2.
  2237. \section{PF Operator}\ttindex{PF}
  2238. {\tt PF(<exp>,<var>)} transforms the expression {\tt <exp>} into a list of
  2239. partial fractions with respect to the main variable, {\tt <var>}. {\tt PF}
  2240. does a complete partial fraction decomposition, and as the algorithms used
  2241. are fairly unsophisticated (factorization and the extended Euclidean
  2242. algorithm), the code may be unacceptably slow in complicated cases.
  2243. {\it Example:}
  2244. Given {\tt 2/((x+1)\verb|^|2*(x+2))} in the workspace,
  2245. {\tt pf(ws,x);} gives the result
  2246. {\small\begin{verbatim}
  2247. 2 - 2 2
  2248. {-------,-------,--------------} .
  2249. X + 2 X + 1 2
  2250. X + 2*X + 1
  2251. \end{verbatim}}
  2252. If you want the denominators in factored form, use {\tt off exp;}.
  2253. Thus, with {\tt 2/((x+1)\verb|^|2*(x+2))} in the workspace, the commands
  2254. {\tt off exp; pf(ws,x);} give the result
  2255. {\small\begin{verbatim}
  2256. 2 - 2 2
  2257. {-------,-------,----------} .
  2258. X + 2 X + 1 2
  2259. (X + 1)
  2260. \end{verbatim}}
  2261. To recombine the terms, {\tt FOR EACH \ldots SUM} can be used. So with
  2262. the above list in the workspace, {\tt for each j in ws sum j;} returns the
  2263. result
  2264. {\small\begin{verbatim}
  2265. 2
  2266. ------------------
  2267. 2
  2268. (X + 2)*(X + 1)
  2269. \end{verbatim}}
  2270. Alternatively, one can use the operations on lists to extract any desired
  2271. term.
  2272. \section{SELECT Operator}\ttindex{SELECT}
  2273. \ttindex{map}\ttindex{list}
  2274. The {\tt SELECT} operator extracts from a list,
  2275. or from the arguments of an n--ary operator, elements corresponding
  2276. to a boolean predicate. It is used with the syntax:
  2277. {\small\begin{verbatim}
  2278. SELECT(U:function,V:list)
  2279. \end{verbatim}}
  2280. {\tt Function} can be one of the following forms:
  2281. \begin{enumerate}
  2282. \item the name of an operator for a single argument: the operator
  2283. is evaluated once with each element of {\tt object} as its single argument;
  2284. \item an algebraic expression with exactly one free variable, that is
  2285. a variable preceded by the tilde symbol. The expression
  2286. is evaluated for each element of \meta{object}, where the element is
  2287. substituted for the free variable;
  2288. \item a replacement rule of the form \meta{var $=>$ rep}
  2289. where {\tt var} is a variable (a kernel without subscript)
  2290. and {\tt rep} is an expression that contains {\tt var}.
  2291. {\tt Rep} is evaluated for each element of {\tt object} where
  2292. the element is substituted for {\tt var}. {\tt var} may be
  2293. optionally preceded by a tilde.
  2294. \end{enumerate}
  2295. The rule form for {\tt function} is needed when more than
  2296. one free variable occurs.
  2297. The result of evaluating {\tt function} is
  2298. interpreted as a boolean value corresponding to the conventions of
  2299. {\REDUCE}. These values are composed with the leading operator of the
  2300. input expression.
  2301. {\it Examples:}
  2302. {\small\begin{verbatim}
  2303. select( ~w>0 , {1,-1,2,-3,3}) -> {1,2,3}
  2304. select(evenp deg(~w,y),part((x+y)^5,0):=list)
  2305. -> {X^5 ,10*X^3*Y^2 ,5*X*Y^4}
  2306. select(evenp deg(~w,x),2x^2+3x^3+4x^4) -> 4X^4 + 2X^2
  2307. \end{verbatim}}
  2308. \section{SOLVE Operator}\ttindex{SOLVE}
  2309. SOLVE is an operator for solving one or more simultaneous algebraic
  2310. equations. It is used with the syntax:
  2311. {\small\begin{verbatim}
  2312. SOLVE(EXPRN:algebraic[,VAR:kernel|,VARLIST:list of kernels])
  2313. :list.
  2314. \end{verbatim}}
  2315. {\tt EXPRN} is of the form {\tt <expression>} or
  2316. \{ {\tt <expression1>},{\tt <expression2>}, \dots \}. Each expression is an
  2317. algebraic equation, or is the difference of the two sides of the equation.
  2318. The second argument is either a kernel or a list of kernels representing
  2319. the unknowns in the system. This argument may be omitted if the number of
  2320. distinct, non-constant, top-level kernels equals the number of unknowns,
  2321. in which case these kernels are presumed to be the unknowns.
  2322. For one equation, {\tt SOLVE}\ttindex{SOLVE} recursively uses
  2323. factorization and decomposition, together with the known inverses of
  2324. {\tt LOG}, {\tt SIN}, {\tt COS}, {\tt \verb|^|}, {\tt ACOS}, {\tt ASIN}, and
  2325. linear, quadratic, cubic, quartic, or binomial factors. Solutions
  2326. of equations built with exponentials or logarithms are often
  2327. expressed in terms of Lambert's {\tt W} function.\index{Lambert's W}
  2328. This function is (partially) implemented in the special functions package.
  2329. Linear equations are solved by the multi-step elimination method due to
  2330. Bareiss, unless the switch {\tt CRAMER}\ttindex{CRAMER} is on, in which
  2331. case Cramer's method is used. The Bareiss method is usually more
  2332. efficient unless the system is large and dense.
  2333. Non-linear equations are solved using the Groebner basis package.
  2334. \index{Groebner} Users should note that this can be quite a
  2335. time consuming process.
  2336. {\it Examples:}
  2337. {\small\begin{verbatim}
  2338. solve(log(sin(x+3))^5 = 8,x);
  2339. solve(a*log(sin(x+3))^5 - b, sin(x+3));
  2340. solve({a*x+y=3,y=-2},{x,y});
  2341. \end{verbatim}}
  2342. {\tt SOLVE} returns a list of solutions. If there is one unknown, each
  2343. solution is an equation for the unknown. If a complete solution was
  2344. found, the unknown will appear by itself on the left-hand side of the
  2345. equation. On the other hand, if the solve package could not find a
  2346. solution, the ``solution'' will be an equation for the unknown in terms
  2347. of the operator {\tt ROOT\_OF}\ttindex{ROOT\_OF}. If there
  2348. are several unknowns, each solution will be a list of equations for the
  2349. unknowns. For example,
  2350. {\small\begin{verbatim}
  2351. solve(x^2=1,x); -> {X=-1,X=1}
  2352. solve(x^7-x^6+x^2=1,x)
  2353. 6
  2354. -> {X=ROOT_OF(X_ + X_ + 1,X_,TAG_1),X=1}
  2355. solve({x+3y=7,y-x=1},{x,y}) -> {{X=1,Y=2}}.
  2356. \end{verbatim}}
  2357. The TAG argument is used to uniquely identify those particular solutions.
  2358. Solution multiplicities are stored in the global variable {\tt
  2359. ROOT\_MULTIPLICITIES} rather than the solution list. The value of this
  2360. variable is a list of the multiplicities of the solutions for the last
  2361. call of {\tt SOLVE}. \ttindex{SOLVE} For example,
  2362. {\small\begin{verbatim}
  2363. solve(x^2=2x-1,x); root_multiplicities;
  2364. \end{verbatim}}
  2365. gives the results
  2366. {\small\begin{verbatim}
  2367. {X=1}
  2368. {2}
  2369. \end{verbatim}}
  2370. If you want the multiplicities explicitly displayed, the switch
  2371. {\tt MULTIPLICITIES}\ttindex{MULTIPLICITIES} can be turned on. For example
  2372. {\small\begin{verbatim}
  2373. on multiplicities; solve(x^2=2x-1,x);
  2374. \end{verbatim}}
  2375. yields the result
  2376. {\small\begin{verbatim}
  2377. {X=1,X=1}
  2378. \end{verbatim}}
  2379. \subsection{Handling of Undetermined Solutions}
  2380. When {\tt SOLVE} cannot find a solution to an equation, it normally
  2381. returns an equation for the relevant indeterminates in terms of the
  2382. operator {\tt ROOT\_OF}.\ttindex{ROOT\_OF} For example, the expression
  2383. {\small\begin{verbatim}
  2384. solve(cos(x) + log(x),x);
  2385. \end{verbatim}}
  2386. returns the result
  2387. {\small\begin{verbatim}
  2388. {X=ROOT_OF(COS(X_) + LOG(X_),X_,TAG_1)} .
  2389. \end{verbatim}}
  2390. An expression with a top-level {\tt ROOT\_OF} operator is implicitly a
  2391. list with an unknown number of elements (since we don't always know how
  2392. many solutions an equation has). If a substitution is made into such an
  2393. expression, closed form solutions can emerge. If this occurs, the {\tt
  2394. ROOT\_OF} construct is replaced by an operator {\tt ONE\_OF}.\ttindex{ONE\_OF}
  2395. At this point it is of course possible to transform the result of the
  2396. original {\tt SOLVE} operator expression into a standard {\tt SOLVE}
  2397. solution. To effect this, the operator {\tt EXPAND\_CASES}
  2398. \ttindex{EXPAND\_CASES} can be used.
  2399. The following example shows the use of these facilities:
  2400. \extendedmanual{\newpage}
  2401. {\small\begin{verbatim}
  2402. solve(-a*x^3+a*x^2+x^4-x^3-4*x^2+4,x);
  2403. 2 3
  2404. {X=ROOT_OF(A*X_ - X_ + 4*X_ + 4,X_,TAG_2),X=1}
  2405. sub(a=-1,ws);
  2406. {X=ONE_OF({2,-1,-2},TAG_2),X=1}
  2407. expand_cases ws;
  2408. {X=2,X=-1,X=-2,X=1}
  2409. \end{verbatim}}
  2410. \subsection{Solutions of Equations Involving Cubics and Quartics}
  2411. Since roots of cubics and quartics can often be very messy, a switch
  2412. {\tt FULLROOTS}\ttindex{FULLROOTS} is available, that, when off (the
  2413. default), will prevent the production of a result in closed form. The
  2414. {\tt ROOT\_OF} construct will be used in this case instead.
  2415. In constructing the solutions of cubics and quartics, trigonometrical
  2416. forms are used where appropriate. This option is under the control of a
  2417. switch {\tt TRIGFORM},\ttindex{TRIGFORM} which is normally on.
  2418. The following example illustrates the use of these facilities:
  2419. {\small\begin{verbatim}
  2420. let xx = solve(x^3+x+1,x);
  2421. xx;
  2422. 3
  2423. {X=ROOT_OF(X_ + X_ + 1,X_)}
  2424. on fullroots;
  2425. xx;
  2426. - SQRT(31)*I
  2427. ATAN(---------------)
  2428. 3*SQRT(3)
  2429. {X=(I*(SQRT(3)*SIN(-----------------------)
  2430. 3
  2431. \end{verbatim}}
  2432. \newpage
  2433. {\small\begin{verbatim}
  2434. - SQRT(31)*I
  2435. ATAN(---------------)
  2436. 3*SQRT(3)
  2437. - COS(-----------------------)))/SQRT(3),
  2438. 3
  2439. - SQRT(31)*I
  2440. ATAN(---------------)
  2441. 3*SQRT(3)
  2442. X=( - I*(SQRT(3)*SIN(-----------------------)
  2443. 3
  2444. - SQRT(31)*I
  2445. ATAN(---------------)
  2446. 3*SQRT(3)
  2447. + COS(-----------------------)))/SQRT(
  2448. 3
  2449. 3),
  2450. - SQRT(31)*I
  2451. ATAN(---------------)
  2452. 3*SQRT(3)
  2453. 2*COS(-----------------------)*I
  2454. 3
  2455. X=----------------------------------}
  2456. SQRT(3)
  2457. off trigform;
  2458. xx;
  2459. 2/3
  2460. {X=( - (SQRT(31) - 3*SQRT(3)) *SQRT(3)*I
  2461. 2/3 2/3
  2462. - (SQRT(31) - 3*SQRT(3)) - 2 *SQRT(3)*I
  2463. 2/3 1/3 1/3
  2464. + 2 )/(2*(SQRT(31) - 3*SQRT(3)) *6
  2465. 1/6
  2466. *3 ),
  2467. 2/3
  2468. X=((SQRT(31) - 3*SQRT(3)) *SQRT(3)*I
  2469. 2/3 2/3
  2470. - (SQRT(31) - 3*SQRT(3)) + 2 *SQRT(3)*I
  2471. 2/3 1/3 1/3
  2472. + 2 )/(2*(SQRT(31) - 3*SQRT(3)) *6
  2473. 1/6
  2474. *3 ),
  2475. 2/3 2/3
  2476. (SQRT(31) - 3*SQRT(3)) - 2
  2477. X=-------------------------------------}
  2478. 1/3 1/3 1/6
  2479. (SQRT(31) - 3*SQRT(3)) *6 *3
  2480. \end{verbatim}}
  2481. \subsection{Other Options}
  2482. If {\tt SOLVESINGULAR}\ttindex{SOLVESINGULAR} is on (the default setting),
  2483. degenerate systems such as {\tt x+y=0}, {\tt 2x+2y=0} will be solved by
  2484. introducing appropriate arbitrary constants.
  2485. The consistent singular equation 0=0 or equations involving functions with
  2486. multiple inverses may introduce unique new indeterminant kernels
  2487. {\tt ARBCOMPLEX(j)}, or {\tt ARBINT(j)}, ($j$=1,2,...), % {\tt ARBREAL(j)},
  2488. representing arbitrary complex or integer numbers respectively. To
  2489. automatically select the principal branches, do {\tt off allbranch;} .
  2490. \ttindex{ALLBRANCH} To avoid the introduction of new indeterminant kernels
  2491. do {\tt OFF ARBVARS}\ttindex{ARBVARS} -- then no equations are generated for the free
  2492. variables and their original names are used to express the solution forms.
  2493. To suppress solutions of consistent singular equations do
  2494. {\tt OFF SOLVESINGULAR}.
  2495. To incorporate additional inverse functions do, for example:
  2496. {\small\begin{verbatim}
  2497. put('sinh,'inverse,'asinh);
  2498. put('asinh,'inverse,'sinh);
  2499. \end{verbatim}}
  2500. together with any desired simplification rules such as
  2501. {\small\begin{verbatim}
  2502. for all x let sinh(asinh(x))=x, asinh(sinh(x))=x;
  2503. \end{verbatim}}
  2504. For completeness, functions with non-unique inverses should be treated as
  2505. {\tt \verb|^|}, {\tt SIN}, and {\tt COS} are in the {\tt SOLVE}
  2506. \ttindex{SOLVE} module source.
  2507. Arguments of {\tt ASIN} and {\tt ACOS} are not checked to ensure that the
  2508. absolute value of the real part does not exceed 1; and arguments of
  2509. {\tt LOG} are not checked to ensure that the absolute value of the imaginary
  2510. part does not exceed $\pi$; but checks (perhaps involving user response
  2511. for non-numerical arguments) could be introduced using
  2512. {\tt LET}\ttindex{LET} statements for these operators.
  2513. \subsection{Parameters and Variable Dependency}
  2514. The proper design of a variable sequence
  2515. supplied as a second argument to {\tt SOLVE} is important
  2516. for the structure of the solution of an equation system.
  2517. Any unknown in the system
  2518. not in this list is considered totally free. E.g.\ the call
  2519. {\small\begin{verbatim}
  2520. solve({x=2*z,z=2*y},{z});
  2521. \end{verbatim}}
  2522. produces an empty list as a result because there is no function
  2523. $z=z(x,y)$ which fulfills both equations for arbitrary $x$ and $y$ values.
  2524. In such a case the share variable {\tt requirements}\ttindex{requirements}
  2525. displays a set of restrictions for the parameters of the system:
  2526. {\small\begin{verbatim}
  2527. requirements;
  2528. {x - 4*y}
  2529. \end{verbatim}}
  2530. The non-existence of a formal solution is caused by a
  2531. contradiction which disappears only if the parameters
  2532. of the initial system are set such that all members
  2533. of the requirements list take the value zero.
  2534. For a linear system the set is complete: a solution
  2535. of the requirements list makes the initial
  2536. system solvable. E.g.\ in the above case a substitution
  2537. $x=4y$ makes the equation set consistent. For a non-linear
  2538. system only one inconsistency is detected. If such a system
  2539. has more than one inconsistency, you must reduce them
  2540. one after the other.
  2541. \footnote{
  2542. The difference between linear and non--linear
  2543. inconsistent systems is based on the algorithms which
  2544. produce this information as a side effect when attempting
  2545. to find a formal solution; example:
  2546. $solve(\{x=a,x=b,y=c,y=d\},\{x,y\}$ gives a set $\{a-b,c-d\}$
  2547. while $solve(\{x^2=a,x^2=b,y^2=c,y^2=d\},\{x,y\}$ leads to $\{a-b\}$.
  2548. }
  2549. The set shows you also the dependency among the parameters: here
  2550. one of $x$ and $y$ is free and a formal solution of the system can be
  2551. computed by adding it to the variable list of {\tt solve}.
  2552. The requirement set is not unique -- there may be other such sets.
  2553. A system with parameters may have a formal solution, e.g.\
  2554. {\small\begin{verbatim}
  2555. solve({x=a*z+1,0=b*z-y},{z,x});
  2556. y a*y + b
  2557. {{z=---,x=---------}}
  2558. b b
  2559. \end{verbatim}}
  2560. which is not valid for all possible values of the parameters.
  2561. The variable {\tt assumptions}\ttindex{assumptions} contains then a list of
  2562. restrictions: the solutions are valid only as long
  2563. as none of these expressions vanishes. Any zero of one of them
  2564. represents a special case that is not covered by the
  2565. formal solution. In the above case the value is
  2566. \extendedmanual{\newpage}
  2567. {\small\begin{verbatim}
  2568. assumptions;
  2569. {b}
  2570. \end{verbatim}}
  2571. which excludes formally the case $b=0$; obviously this special
  2572. parameter value makes the system singular. The set of assumptions
  2573. is complete for both, linear and non--linear systems.
  2574. {\tt SOLVE} rearranges the variable sequence
  2575. to reduce the (expected) computing time. This behavior is controlled
  2576. by the switch {\tt varopt}\ttindex{varopt}, which is on by default.
  2577. If it is turned off, the supplied variable sequence is used
  2578. or the system kernel ordering is taken if the variable
  2579. list is omitted. The effect is demonstrated by an example:
  2580. {\small\begin{verbatim}
  2581. s:= {y^3+3x=0,x^2+y^2=1};
  2582. solve(s,{y,x});
  2583. 6 2
  2584. {{y=root_of(y_ + 9*y_ - 9,y_),
  2585. 3
  2586. - y
  2587. x=-------}}
  2588. 3
  2589. off varopt; solve(s,{y,x});
  2590. 6 4 2
  2591. {{x=root_of(x_ - 3*x_ + 12*x_ - 1,x_),
  2592. 4 2
  2593. x*( - x + 2*x - 10)
  2594. y=-----------------------}}
  2595. 3
  2596. \end{verbatim}}
  2597. In the first case, {\tt solve} forms the solution as a set of
  2598. pairs $(y_i,x(y_i))$ because the degree of $x$ is higher --
  2599. such a rearrangement makes the internal computation of the Gr\"obner basis
  2600. generally faster. For the second case the explicitly given variable sequence
  2601. is used such that the solution has now the form $(x_i,y(x_i))$.
  2602. Controlling the variable sequence is especially important if
  2603. the system has one or more free variables.
  2604. As an alternative to turning off {\tt varopt}, a partial dependency among
  2605. the variables can be declared using the {\tt depend}\index{depend}
  2606. statement: {\tt solve} then rearranges the variable sequence but keeps any
  2607. variable ahead of those on which it depends.
  2608. \extendedmanual{\newpage}
  2609. {\small\begin{verbatim}
  2610. on varopt;
  2611. s:={a^3+b,b^2+c}$
  2612. solve(s,{a,b,c});
  2613. 3 6
  2614. {{a=arbcomplex(1),b= - a ,c= - a }}
  2615. depend a,c; depend b,c; solve(s,{a,b,c});
  2616. {{c=arbcomplex(2),
  2617. 6
  2618. a=root_of(a_ + c,a_),
  2619. 3
  2620. b= - a }}
  2621. \end{verbatim}}
  2622. Here {\tt solve} is forced to put $c$ after $a$ and after $b$, but
  2623. there is no obstacle to interchanging $a$ and $b$.
  2624. \section{Even and Odd Operators}\index{Even operator}\index{Odd operator}
  2625. An operator can be declared to be {\em even\/} or {\em odd\/} in its first
  2626. argument by the declarations {\tt EVEN}\ttindex{EVEN} and
  2627. {\tt ODD}\ttindex{ODD} respectively. Expressions involving an operator
  2628. declared in this manner are transformed if the first argument contains a
  2629. minus sign. Any other arguments are not affected. In addition, if say
  2630. {\tt F} is declared odd, then {\tt f(0)} is replaced by zero unless
  2631. {\tt F} is also declared {\em non zero\/} by the declaration
  2632. {\tt NONZERO}\ttindex{NONZERO}. For example, the declarations
  2633. {\small\begin{verbatim}
  2634. even f1; odd f2;
  2635. \end{verbatim}}
  2636. mean that
  2637. {\small\begin{verbatim}
  2638. f1(-a) -> F1(A)
  2639. f2(-a) -> -F2(A)
  2640. f1(-a,-b) -> F1(A,-B)
  2641. f2(0) -> 0.
  2642. \end{verbatim}}
  2643. To inhibit the last transformation, say {\tt nonzero f2;}.
  2644. \section{Linear Operators}\index{Linear operator}
  2645. An operator can be declared to be linear in its first argument over powers
  2646. of its second argument. If an operator {\tt F} is so declared, {\tt F} of
  2647. any sum is broken up into sums of {\tt F}s, and any factors that are not
  2648. powers of the variable are taken outside. This means that {\tt F} must
  2649. have (at least) two arguments. In addition, the second argument must be
  2650. an identifier (or more generally a kernel), not an expression.
  2651. {\it Example:}
  2652. If {\tt F} were declared linear, then
  2653. {\small\begin{verbatim}
  2654. 5
  2655. f(a*x^5+b*x+c,x) -> F(X ,X)*A + F(X,X)*B + F(1,X)*C
  2656. \end{verbatim}}
  2657. More precisely, not only will the variable and its powers remain within the
  2658. scope of the {\tt F} operator, but so will any variable and its powers that
  2659. had been declared to {\tt DEPEND} on the prescribed variable; and so would
  2660. any expression that contains that variable or a dependent variable on any
  2661. level, e.g. {\tt cos(sin(x))}.
  2662. To declare operators {\tt F} and {\tt G} to be linear operators,
  2663. use:\ttindex{LINEAR}
  2664. {\small\begin{verbatim}
  2665. linear f,g;
  2666. \end{verbatim}}
  2667. The analysis is done of the first argument with respect to the second; any
  2668. other arguments are ignored. It uses the following rules of evaluation:
  2669. \begin{quote}
  2670. \begin{tabbing}
  2671. {\tt f(0) -> 0} \\
  2672. {\tt f(-y,x) -> -F(Y,X)} \\
  2673. {\tt f(y+z,x) -> F(Y,X)+F(Z,X)} \\
  2674. {\tt f(y*z,x) -> Z*F(Y,X)} \hspace{0.5in}\= if Z does not depend on X \\
  2675. {\tt f(y/z,x) -> F(Y,X)/Z} \> if Z does not depend on X
  2676. \end{tabbing}
  2677. \end{quote}
  2678. To summarize, {\tt Y} ``depends'' on the indeterminate {\tt X} in the above
  2679. if either of the following hold:
  2680. \begin{enumerate}
  2681. \item {\tt Y} is an expression that contains {\tt X} at any level as a
  2682. variable, e.g.: {\tt cos(sin(x))}
  2683. \item Any variable in the expression {\tt Y} has been declared dependent on
  2684. {\tt X} by use of the declaration {\tt DEPEND}.
  2685. \end{enumerate}
  2686. The use of such linear operators\index{Linear operator} can be seen in the
  2687. paper Fox, J.A. and A. C. Hearn, ``Analytic Computation of Some Integrals
  2688. in Fourth Order Quantum Electrodynamics'' Journ. Comp. Phys. 14 (1974)
  2689. 301-317, which contains a complete listing of a program for definite
  2690. integration\index{Integration} of some expressions that arise in fourth
  2691. order quantum electrodynamics.
  2692. \section{Non-Commuting Operators}\index{Non-commuting operator}
  2693. An operator can be declared to be non-commutative under multiplication by
  2694. the declaration {\tt NONCOM}.\ttindex{NONCOM}
  2695. {\it Example:}
  2696. After the declaration \\
  2697. {\tt noncom u,v;}\\
  2698. the expressions {\tt
  2699. u(x)*u(y)-u(y)*u(x)} and {\tt u(x)*v(y)-v(y)*u(x)} will remain unchanged
  2700. on simplification, and in particular will not simplify to zero.
  2701. Note that it is the operator ({\tt U} and {\tt V} in the above example)
  2702. and not the variable that has the non-commutative property.
  2703. The {\tt LET}\ttindex{LET} statement may be used to introduce rules of
  2704. evaluation for such operators. In particular, the boolean operator
  2705. {\tt ORDP}\ttindex{ORDP} is useful for introducing an ordering on such
  2706. expressions.
  2707. {\it Example:}
  2708. The rule
  2709. {\small\begin{verbatim}
  2710. for all x,y such that x neq y and ordp(x,y)
  2711. let u(x)*u(y)= u(y)*u(x)+comm(x,y);
  2712. \end{verbatim}}
  2713. would introduce the commutator of {\tt u(x)} and {\tt u(y)} for all
  2714. {\tt X} and {\tt Y}. Note that since {\tt ordp(x,x)} is {\em true}, the
  2715. equality check is necessary in the degenerate case to avoid a circular
  2716. loop in the rule.
  2717. \section{Symmetric and Antisymmetric Operators}
  2718. An operator can be declared to be symmetric with respect to its arguments
  2719. by the declaration {\tt SYMMETRIC}.\ttindex{SYMMETRIC} For example
  2720. {\small\begin{verbatim}
  2721. symmetric u,v;
  2722. \end{verbatim}}
  2723. means that any expression involving the top level operators {\tt U} or
  2724. {\tt V} will have its arguments reordered to conform to the internal order
  2725. used by {\REDUCE}. The user can change this order for kernels by the
  2726. command {\tt KORDER}.
  2727. For example, {\tt u(x,v(1,2))} would become {\tt u(v(2,1),x)}, since
  2728. numbers are ordered in decreasing order, and expressions are ordered in
  2729. decreasing order of complexity.
  2730. Similarly the declaration {\tt ANTISYMMETRIC}\ttindex{ANTISYMMETRIC}
  2731. declares an operator antisymmetric. For example,
  2732. {\small\begin{verbatim}
  2733. antisymmetric l,m;
  2734. \end{verbatim}}
  2735. means that any expression involving the top level operators {\tt L} or
  2736. {\tt M} will have its arguments reordered to conform to the internal order
  2737. of the system, and the sign of the expression changed if there are an odd
  2738. number of argument interchanges necessary to bring about the new order.
  2739. For example, {\tt l(x,m(1,2))} would become {\tt -l(-m(2,1),x)} since one
  2740. interchange occurs with each operator. An expression like {\tt l(x,x)}
  2741. would also be replaced by 0.
  2742. \section{Declaring New Prefix Operators}
  2743. The user may add new prefix\index{Prefix} operators to the system by
  2744. using the declaration {\tt OPERATOR}. For example:
  2745. {\small\begin{verbatim}
  2746. operator h,g1,arctan;
  2747. \end{verbatim}}
  2748. adds the prefix operators {\tt H}, {\tt G1} and {\tt ARCTAN} to the system.
  2749. This allows symbols like {\tt h(w), h(x,y,z), g1(p+q), arctan(u/v)} to be
  2750. used in expressions, but no meaning or properties of the operator are
  2751. implied. The same operator symbol can be used equally well as a 0-, 1-, 2-,
  2752. 3-, etc.-place operator.
  2753. To give a meaning to an operator symbol, or express some of its
  2754. properties, {\tt LET}\ttindex{LET} statements can be used, or the operator
  2755. can be given a definition as a procedure.
  2756. If the user forgets to declare an identifier as an operator, the system
  2757. will prompt the user to do so in interactive mode, or do it automatically
  2758. in non-interactive mode. A diagnostic message will also be printed if an
  2759. identifier is declared {\tt OPERATOR} more than once.
  2760. Operators once declared are global in scope, and so can then be referenced
  2761. anywhere in the program. In other words, a declaration within a block (or
  2762. a procedure) does not limit the scope of the operator to that block, nor
  2763. does the operator go away on exiting the block (use {\tt CLEAR} instead
  2764. for this purpose).
  2765. \section{Declaring New Infix Operators}
  2766. Users can add new infix operators by using the declarations
  2767. {\tt INFIX}\ttindex{INFIX} and {\tt PRECEDENCE}.\ttindex{PRECEDENCE}
  2768. For example,
  2769. {\small\begin{verbatim}
  2770. infix mm;
  2771. precedence mm,-;
  2772. \end{verbatim}}
  2773. The declaration {\tt infix mm;} would allow one to use the symbol
  2774. {\tt MM} as an infix operator:
  2775. \begin{quote}
  2776. \hspace{0.2in} {\tt a mm b} \hspace{0.3in} instead of \hspace{0.3in}
  2777. {\tt mm(a,b)}.
  2778. \end{quote}
  2779. The declaration {\tt precedence mm,-;} says that {\tt MM} should be
  2780. inserted into the infix operator precedence list just {\em after\/}
  2781. the $-$ operator. This gives it higher precedence than $-$ and lower
  2782. precedence than * . Thus
  2783. \begin{quote}
  2784. \hspace{0.2in}{\tt a - b mm c - d}\hspace{.3in} means \hspace{.3in}
  2785. {\tt a - (b mm c) - d},
  2786. \end{quote}
  2787. while
  2788. \begin{quote}
  2789. \hspace{0.2in}{\tt a * b mm c * d}\hspace{.3in} means \hspace{.3in}
  2790. {\tt (a * b) mm (c * d)}.
  2791. \end{quote}
  2792. Both infix and prefix\index{Prefix} operators have no transformation
  2793. properties unless {\tt LET}\ttindex{LET} statements or procedure
  2794. declarations are used to assign a meaning.
  2795. We should note here that infix operators so defined are always binary:
  2796. \begin{quote}
  2797. \hspace{0.2in}{\tt a mm b mm c}\hspace{.3in} means \hspace{.3in}
  2798. {\tt (a mm b) mm c}.
  2799. \end{quote}
  2800. \section{Creating/Removing Variable Dependency}
  2801. There are several facilities in {\REDUCE}, such as the differentiation
  2802. \index{Differentiation}
  2803. operator and the linear operator\index{Linear operator} facility, that
  2804. can utilize knowledge of the dependency between various variables, or
  2805. kernels. Such dependency may be expressed by the command {\tt
  2806. DEPEND}.\ttindex{DEPEND} This takes an arbitrary number of arguments and
  2807. sets up a dependency of the first argument on the remaining arguments.
  2808. For example,
  2809. {\small\begin{verbatim}
  2810. depend x,y,z;
  2811. \end{verbatim}}
  2812. says that {\tt X} is dependent on both {\tt Y} and {\tt Z}.
  2813. {\small\begin{verbatim}
  2814. depend z,cos(x),y;
  2815. \end{verbatim}}
  2816. says that {\tt Z} is dependent on {\tt COS(X)} and {\tt Y}.
  2817. Dependencies introduced by {\tt DEPEND} can be removed by {\tt NODEPEND}.
  2818. \ttindex{NODEPEND} The arguments of this are the same as for {\tt DEPEND}.
  2819. For example, given the above dependencies,
  2820. {\small\begin{verbatim}
  2821. nodepend z,cos(x);
  2822. \end{verbatim}}
  2823. says that {\tt Z} is no longer dependent on {\tt COS(X)}, although it remains
  2824. dependent on {\tt Y}.
  2825. \chapter{Display and Structuring of Expressions}\index{Display}
  2826. \index{Structuring}
  2827. In this section, we consider a variety of commands and operators that
  2828. permit the user to obtain various parts of algebraic expressions and also
  2829. display their structure in a variety of forms. Also presented are some
  2830. additional concepts in the {\REDUCE} design that help the user gain a better
  2831. understanding of the structure of the system.
  2832. \section{Kernels}\index{Kernel}
  2833. {\REDUCE} is designed so that each operator in the system has an
  2834. evaluation (or simplification)\index{Simplification} function associated
  2835. with it that transforms the expression into an internal canonical form.
  2836. \index{Canonical form} This form, which bears little resemblance to the
  2837. original expression, is described in detail in Hearn, A. C., ``{\REDUCE} 2:
  2838. A System and Language for Algebraic Manipulation,'' Proc. of the Second
  2839. Symposium on Symbolic and Algebraic Manipulation, ACM, New York (1971)
  2840. 128-133.
  2841. The evaluation function may transform its arguments in one of two
  2842. alternative ways. First, it may convert the expression into other
  2843. operators in the system, leaving no functions of the original operator for
  2844. further manipulation. This is in a sense true of the evaluation functions
  2845. associated with the operators {\tt +}, {\tt *} and {\tt /} , for example,
  2846. because the canonical form\index{Canonical form} does not include these
  2847. operators explicitly. It is also true of an operator such as the
  2848. determinant operator {\tt DET}\ttindex{DET} because the relevant
  2849. evaluation function calculates the appropriate determinant, and the
  2850. operator {\tt DET} no longer appears. On the other hand, the evaluation
  2851. process may leave some residual functions of the relevant operator. For
  2852. example, with the operator {\tt COS}, a residual expression like {\tt
  2853. COS(X)} may remain after evaluation unless a rule for the reduction of
  2854. cosines into exponentials, for example, were introduced. These residual
  2855. functions of an operator are termed {\em kernels\/}\index{Kernel} and are
  2856. stored uniquely like variables. Subsequently, the kernel is carried
  2857. through the calculation as a variable unless transformations are
  2858. introduced for the operator at a later stage.
  2859. In those cases where the evaluation process leaves an operator expression
  2860. with non-trivial arguments, the form of the argument can vary depending on
  2861. the state of the system at the point of evaluation. Such arguments are
  2862. normally produced in expanded form with no terms factored or grouped in
  2863. any way. For example, the expression {\tt cos(2*x+2*y)} will normally be
  2864. returned in the same form. If the argument {\tt 2*x+2*y} were evaluated
  2865. at the top level, however, it would be printed as {\tt 2*(X+Y)}. If it is
  2866. desirable to have the arguments themselves in a similar form, the switch
  2867. {\tt INTSTR}\ttindex{INTSTR} (for ``internal structure''), if on, will
  2868. cause this to happen.
  2869. In cases where the arguments of the kernel operators may be reordered, the
  2870. system puts them in a canonical order, based on an internal intrinsic
  2871. ordering of the variables. However, some commands allow arguments in the
  2872. form of kernels, and the user has no way of telling what internal order the
  2873. system will assign to these arguments. To resolve this difficulty, we
  2874. introduce the notion of a {\em kernel form\/}\index{kernel form} as an
  2875. expression that transforms to a kernel on evaluation.
  2876. Examples of kernel forms are:
  2877. {\small\begin{verbatim}
  2878. a
  2879. cos(x*y)
  2880. log(sin(x))
  2881. \end{verbatim}}
  2882. whereas
  2883. {\small\begin{verbatim}
  2884. a*b
  2885. (a+b)^4
  2886. \end{verbatim}}
  2887. are not.
  2888. We see that kernel forms can usually be used as generalized variables, and
  2889. most algebraic properties associated with variables may also be associated
  2890. with kernels.
  2891. \section{The Expression Workspace}\index{Workspace}
  2892. Several mechanisms are available for saving and retrieving previously
  2893. evaluated expressions. The simplest of these refers to the last algebraic
  2894. expression simplified. When an assignment of an algebraic expression is
  2895. made, or an expression is evaluated at the top level, (i.e., not inside a
  2896. compound statement or procedure) the results of the evaluation are
  2897. automatically saved in a variable {\tt WS} that we shall refer to as the
  2898. workspace. (More precisely, the expression is assigned to the variable
  2899. {\tt WS} that is then available for further manipulation.)
  2900. {\it Example:}
  2901. If we evaluate the expression {\tt (x+y)\verb|^|2} at the top level and next
  2902. wish to differentiate it with respect to {\tt Y}, we can simply say
  2903. {\small\begin{verbatim}
  2904. df(ws,y);
  2905. \end{verbatim}}
  2906. to get the desired answer.
  2907. If the user wishes to assign the workspace to a variable or expression for
  2908. later use, the {\tt SAVEAS}\ttindex{SAVEAS} statement can be used. It
  2909. has the syntax
  2910. {\small\begin{verbatim}
  2911. SAVEAS <expression>
  2912. \end{verbatim}}
  2913. For example, after the differentiation in the last example, the workspace
  2914. holds the expression {\tt 2*x+2*y}. If we wish to assign this to the
  2915. variable {\tt Z} we can now say
  2916. {\small\begin{verbatim}
  2917. saveas z;
  2918. \end{verbatim}}
  2919. If the user wishes to save the expression in a form that allows him to use
  2920. some of its variables as arbitrary parameters, the {\tt FOR ALL}
  2921. command can be used.
  2922. {\it Example:}
  2923. {\small\begin{verbatim}
  2924. for all x saveas h(x);
  2925. \end{verbatim}}
  2926. with the above expression would mean that {\tt h(z)} evaluates to {\tt
  2927. 2*Y+2*Z}.
  2928. A further method for referencing more than the last expression is described
  2929. in the section on interactive use of {\REDUCE}.
  2930. \section{Output of Expressions}
  2931. A considerable degree of flexibility is available in {\REDUCE} in the
  2932. printing of expressions generated during calculations. No explicit format
  2933. statements are supplied, as these are in most cases of little use in
  2934. algebraic calculations, where the size of output or its composition is not
  2935. generally known in advance. Instead, {\REDUCE} provides a series of mode
  2936. options to the user that should enable him to produce his output in a
  2937. comprehensible and possibly pleasing form.
  2938. The most extreme option offered is to suppress the output entirely from
  2939. any top level evaluation. This is accomplished by turning off the switch
  2940. {\tt OUTPUT}\ttindex{OUTPUT} which is normally on. It is useful for
  2941. limiting output when loading large files or producing ``clean'' output from
  2942. the prettyprint programs.
  2943. In most circumstances, however, we wish to view the output, so we need to
  2944. know how to format it appropriately. As we mentioned earlier, an
  2945. algebraic expression is normally printed in an expanded form, filling the
  2946. whole output line with terms. Certain output declarations,\index{Output
  2947. declaration} however, can be used to affect this format. To begin with,
  2948. we look at an operator for changing the length of the output line.
  2949. \subsection{LINELENGTH Operator}\ttindex{LINELENGTH}
  2950. This operator is used with the syntax
  2951. {\small\begin{verbatim}
  2952. LINELENGTH(NUM:integer):integer
  2953. \end{verbatim}}
  2954. and sets the output line length to the integer {\tt NUM}. It returns the
  2955. previous output line length (so that it can be stored for later resetting
  2956. of the output line if needed).
  2957. \subsection{Output Declarations}
  2958. We now describe a number of switches and declarations that are available
  2959. for controlling output formats. It should be noted, however, that the
  2960. transformation of large expressions to produce these varied output formats
  2961. can take a lot of computing time and space. If a user wishes to speed up
  2962. the printing of the output in such cases, he can turn off the switch {\tt
  2963. PRI}.\ttindex{PRI} If this is done, then output is produced in one fixed
  2964. format, which basically reflects the internal form of the expression, and
  2965. none of the options below apply. {\tt PRI} is normally on.
  2966. With {\tt PRI} on, the output declarations\index{Output declaration}
  2967. and switches available are as follows:
  2968. \subsubsection{ORDER Declaration}
  2969. The declaration {\tt ORDER}\ttindex{ORDER} may be used to order variables
  2970. on output. The syntax is:
  2971. {\small\begin{verbatim}
  2972. order v1,...vn;
  2973. \end{verbatim}}
  2974. where the {\tt vi} are kernels. Thus,
  2975. {\small\begin{verbatim}
  2976. order x,y,z;
  2977. \end{verbatim}}
  2978. orders {\tt X} ahead of {\tt Y}, {\tt Y} ahead of {\tt Z} and all three
  2979. ahead of other variables not given an order. {\tt order nil;} resets the
  2980. output order to the system default. The order of variables may be changed
  2981. by further calls of {\tt ORDER}, but then the reordered variables would
  2982. have an order lower than those in earlier {\tt ORDER}\ttindex{ORDER} calls.
  2983. Thus,
  2984. {\small\begin{verbatim}
  2985. order x,y,z;
  2986. order y,x;
  2987. \end{verbatim}}
  2988. would order {\tt Z} ahead of {\tt Y} and {\tt X}. The default ordering is
  2989. usually alphabetic.
  2990. \subsubsection{FACTOR Declaration}
  2991. This declaration takes a list of identifiers or kernels\index{Kernel}
  2992. as argument. {\tt FACTOR}\ttindex{FACTOR} is not a factoring command
  2993. (use {\tt FACTORIZE} or the {\tt FACTOR} switch for this purpose); rather it
  2994. is a separation command. All terms involving fixed powers of the declared
  2995. expressions are printed as a product of the fixed powers and a sum of the
  2996. rest of the terms.
  2997. All expressions involving a given prefix operator may also be factored by
  2998. putting the operator name in the list of factored identifiers. For example:
  2999. {\small\begin{verbatim}
  3000. factor x,cos,sin(x);
  3001. \end{verbatim}}
  3002. causes all powers of {\tt X} and {\tt SIN(X)} and all functions of
  3003. {\tt COS} to be factored.
  3004. Note that {\tt FACTOR} does not affect the order of its arguments. You
  3005. should also use {\tt ORDER} if this is important.
  3006. The declaration {\tt remfac v1,...,vn;}\ttindex{REMFAC} removes the
  3007. factoring flag from the expressions {\tt v1} through {\tt vn}.
  3008. \subsection{Output Control Switches}
  3009. \label{sec-output}
  3010. In addition to these declarations, the form of the output can be modified
  3011. by switching various output control switches using the declarations
  3012. {\tt ON} and {\tt OFF}. We shall illustrate the use of these switches by an
  3013. example, namely the printing of the expression
  3014. {\small\begin{verbatim}
  3015. x^2*(y^2+2*y)+x*(y^2+z)/(2*a) .
  3016. \end{verbatim}}
  3017. The relevant switches are as follows:
  3018. \subsubsection{ALLFAC Switch}
  3019. This switch will cause the system to search the whole expression, or any
  3020. sub-expression enclosed in parentheses, for simple multiplicative factors
  3021. and print them outside the parentheses. Thus our expression with {\tt ALLFAC}
  3022. \ttindex{ALLFAC}
  3023. off will print as
  3024. {\small\begin{verbatim}
  3025. 2 2 2 2
  3026. (2*X *Y *A + 4*X *Y*A + X*Y + X*Z)/(2*A)
  3027. \end{verbatim}}
  3028. and with {\tt ALLFAC} on as
  3029. {\small\begin{verbatim}
  3030. 2 2
  3031. X*(2*X*Y *A + 4*X*Y*A + Y + Z)/(2*A) .
  3032. \end{verbatim}}
  3033. {\tt ALLFAC} is normally on, and is on in the following examples, except
  3034. where otherwise stated.
  3035. \subsubsection{DIV Switch}\ttindex{DIV}
  3036. This switch makes the system search the denominator of an expression for
  3037. simple factors that it divides into the numerator, so that rational
  3038. fractions and negative powers appear in the output. With {\tt DIV} on, our
  3039. expression would print as
  3040. {\small\begin{verbatim}
  3041. 2 2 (-1) (-1)
  3042. X*(X*Y + 2*X*Y + 1/2*Y *A + 1/2*A *Z) .
  3043. \end{verbatim}}
  3044. {\tt DIV} is normally off.
  3045. \subsubsection{LIST Switch}\ttindex{LIST}
  3046. This switch causes the system to print each term in any sum on a separate
  3047. line. With {\tt LIST} on, our expression prints as
  3048. {\small\begin{verbatim}
  3049. 2
  3050. X*(2*X*Y *A
  3051. + 4*X*Y*A
  3052. 2
  3053. + Y
  3054. + Z)/(2*A) .
  3055. \end{verbatim}}
  3056. {\tt LIST} is normally off.
  3057. \subsubsection{NOSPLIT Switch}\ttindex{NOSPLIT}
  3058. Under normal circumstances, the printing routines try to break an expression
  3059. across lines at a natural point. This is a fairly expensive process. If
  3060. you are not overly concerned about where the end-of-line breaks come, you
  3061. can speed up the printing of expressions by turning off the switch
  3062. {\tt NOSPLIT}. This switch is normally on.
  3063. \subsubsection{RAT Switch}\ttindex{RAT}
  3064. This switch is only useful with expressions in which variables are
  3065. factored with {\tt FACTOR}. With this mode, the overall denominator of the
  3066. expression is printed with each factored sub-expression. We assume a prior
  3067. declaration {\tt factor x;} in the following output. We first print the
  3068. expression with {\tt RAT off}:
  3069. {\small\begin{verbatim}
  3070. 2 2
  3071. (2*X *Y*A*(Y + 2) + X*(Y + Z))/(2*A) .
  3072. \end{verbatim}}
  3073. With {\tt RAT} on the output becomes:
  3074. \extendedmanual{\newpage}
  3075. {\small\begin{verbatim}
  3076. 2 2
  3077. X *Y*(Y + 2) + X*(Y + Z)/(2*A) .
  3078. \end{verbatim}}
  3079. {\tt RAT} is normally off.
  3080. Next, if we leave {\tt X} factored, and turn on both {\tt DIV} and
  3081. {\tt RAT}, the result becomes
  3082. {\small\begin{verbatim}
  3083. 2 (-1) 2
  3084. X *Y*(Y + 2) + 1/2*X*A *(Y + Z) .
  3085. \end{verbatim}}
  3086. Finally, with {\tt X} factored, {\tt RAT} on and {\tt ALLFAC}\ttindex{ALLFAC}
  3087. off we retrieve the original structure
  3088. {\small\begin{verbatim}
  3089. 2 2 2
  3090. X *(Y + 2*Y) + X*(Y + Z)/(2*A) .
  3091. \end{verbatim}}
  3092. \subsubsection{RATPRI Switch}\ttindex{RATPRI}
  3093. If the numerator and denominator of an expression can each be printed in
  3094. one line, the output routines will print them in a two dimensional
  3095. notation, with numerator and denominator on separate lines and a line of
  3096. dashes in between. For example, {\tt (a+b)/2} will print as
  3097. {\small\begin{verbatim}
  3098. A + B
  3099. -----
  3100. 2
  3101. \end{verbatim}}
  3102. Turning this switch off causes such expressions to be output in a linear
  3103. form.
  3104. \subsubsection{REVPRI Switch}\ttindex{REVPRI}
  3105. The normal ordering of terms in output is from highest to lowest power.
  3106. In some situations (e.g., when a power series is output), the opposite
  3107. ordering is more convenient. The switch {\tt REVPRI} if on causes such a
  3108. reverse ordering of terms. For example, the expression
  3109. {\tt y*(x+1)\verb|^|2+(y+3)\verb|^|2} will normally print as
  3110. {\small\begin{verbatim}
  3111. 2 2
  3112. X *Y + 2*X*Y + Y + 7*Y + 9
  3113. \end{verbatim}}
  3114. whereas with {\tt REVPRI} on, it will print as
  3115. {\small\begin{verbatim}
  3116. 2 2
  3117. 9 + 7*Y + Y + 2*X*Y + X *Y.
  3118. \end{verbatim}}
  3119. \subsection{WRITE Command}\ttindex{WRITE}
  3120. In simple cases no explicit output\index{Output} command is necessary in
  3121. {\REDUCE}, since the value of any expression is automatically printed if a
  3122. semicolon is used as a delimiter. There are, however, several situations
  3123. in which such a command is useful.
  3124. In a {\tt FOR}, {\tt WHILE}, or {\tt REPEAT} statement it may be desired
  3125. to output something each time the statement within the loop construct is
  3126. repeated.
  3127. It may be desired for a procedure to output intermediate results or other
  3128. information while it is running. It may be desired to have results labeled
  3129. in special ways, especially if the output is directed to a file or device
  3130. other than the terminal.
  3131. The {\tt WRITE} command consists of the word {\tt WRITE} followed by one
  3132. or more items separated by commas, and followed by a terminator. There
  3133. are three kinds of items that can be used:
  3134. \begin{enumerate}
  3135. \item Expressions (including variables and constants). The expression is
  3136. evaluated, and the result is printed out.
  3137. \item Assignments. The expression on the right side of the {\tt :=}
  3138. operator is evaluated, and is assigned to the variable on the left; then
  3139. the symbol on the left is printed, followed by a ``{\tt :=}'', followed by
  3140. the value of the expression on the right -- almost exactly the way an
  3141. assignment followed by a semicolon prints out normally. (The difference is
  3142. that if the {\tt WRITE} is in a {\tt FOR} statement and the left-hand side
  3143. of the assignment is an array position or something similar containing the
  3144. variable of the {\tt FOR} iteration, then the value of that variable is
  3145. inserted in the printout.)
  3146. \item Arbitrary strings of characters, preceded and followed by double-quote
  3147. marks (e.g., {\tt "string"}).
  3148. \end{enumerate}
  3149. The items specified by a single {\tt WRITE} statement print side by side
  3150. on one line. (The line is broken automatically if it is too long.) Strings
  3151. print exactly as quoted. The {\tt WRITE} command itself however does not
  3152. return a value.
  3153. The print line is closed at the end of a {\tt WRITE} command evaluation.
  3154. Therefore the command {\tt WRITE "";} (specifying nothing to be printed
  3155. except the empty string) causes a line to be skipped.
  3156. {\it Examples:}
  3157. \begin{enumerate}
  3158. \item If {\tt A} is {\tt X+5}, {\tt B} is itself, {\tt C} is 123, {\tt M} is
  3159. an array, and {\tt Q}=3, then
  3160. {\small\begin{verbatim}
  3161. write m(q):=a," ",b/c," THANK YOU";
  3162. \end{verbatim}}
  3163. will set {\tt M(3)} to {\tt x+5} and print
  3164. {\small\begin{verbatim}
  3165. M(Q) := X + 5 B/123 THANK YOU
  3166. \end{verbatim}}
  3167. The blanks between the {\tt 5} and {\tt B}, and the
  3168. {\tt 3} and {\tt T}, come from the blanks in the quoted strings.
  3169. \item To print a table of the squares of the integers from 1 to 20:
  3170. {\small\begin{verbatim}
  3171. for i:=1:20 do write i," ",i^2;
  3172. \end{verbatim}}
  3173. \item To print a table of the squares of the integers from 1 to 20, and at
  3174. the same time store them in positions 1 to 20 of an array {\tt A:}
  3175. {\small\begin{verbatim}
  3176. for i:=1:20 do <<a(i):=i^2; write i," ",a(i)>>;
  3177. \end{verbatim}}
  3178. This will give us two columns of numbers. If we had used
  3179. {\small\begin{verbatim}
  3180. for i:=1:20 do write i," ",a(i):=i^2;
  3181. \end{verbatim}}
  3182. we would also get {\tt A(}i{\tt ) := } repeated on each line.
  3183. \item The following more complete example calculates the famous f and g
  3184. series, first reported in Sconzo, P., LeSchack, A. R., and Tobey, R.,
  3185. ``Symbolic Computation of f and g Series by Computer'', Astronomical Journal
  3186. 70 (May 1965).
  3187. {\small\begin{verbatim}
  3188. x1:= -sig*(mu+2*eps)$
  3189. x2:= eps - 2*sig^2$
  3190. x3:= -3*mu*sig$
  3191. f:= 1$
  3192. g:= 0$
  3193. for i:= 1 step 1 until 10 do begin
  3194. f1:= -mu*g+x1*df(f,eps)+x2*df(f,sig)+x3*df(f,mu);
  3195. write "f(",i,") := ",f1;
  3196. g1:= f+x1*df(g,eps)+x2*df(g,sig)+x3*df(g,mu);
  3197. write "g(",i,") := ",g1;
  3198. f:=f1$
  3199. g:=g1$
  3200. end;
  3201. \end{verbatim}}
  3202. A portion of the output, to illustrate the printout from the {\tt WRITE}
  3203. command, is as follows:
  3204. {\small\begin{verbatim}
  3205. ... <prior output> ...
  3206. 2
  3207. F(4) := MU*(3*EPS - 15*SIG + MU)
  3208. G(4) := 6*SIG*MU
  3209. 2
  3210. F(5) := 15*SIG*MU*( - 3*EPS + 7*SIG - MU)
  3211. 2
  3212. G(5) := MU*(9*EPS - 45*SIG + MU)
  3213. ... <more output> ...
  3214. \end{verbatim}}
  3215. \end{enumerate}
  3216. \subsection{Suppression of Zeros}
  3217. It is sometimes annoying to have zero assignments (i.e. assignments of the
  3218. form {\tt <expression> := 0}) printed, especially in printing large arrays
  3219. with many zero elements. The output from such assignments can be
  3220. suppressed by turning on the switch {\tt NERO}.\ttindex{NERO}
  3221. \subsection{{FORTRAN} Style Output Of Expressions}
  3222. It is naturally possible to evaluate expressions numerically in {\REDUCE} by
  3223. giving all variables and sub-expressions numerical values. However, as we
  3224. pointed out elsewhere the user must declare real arithmetical operation by
  3225. turning on the switch {\tt ROUNDED}\ttindex{ROUNDED}. However, it should be
  3226. remembered that arithmetic in {\REDUCE} is not particularly fast, since
  3227. results are interpreted rather than evaluated in a compiled form. The user
  3228. with a large amount of numerical computation after all necessary algebraic
  3229. manipulations have been performed is therefore well advised to perform
  3230. these calculations in a FORTRAN\index{FORTRAN} or similar system. For
  3231. this purpose, {\REDUCE} offers facilities for users to produce FORTRAN
  3232. compatible files for numerical processing.
  3233. First, when the switch {\tt FORT}\ttindex{FORT} is on, the system will
  3234. print expressions in a FORTRAN notation. Expressions begin in column
  3235. seven. If an expression extends over one line, a continuation mark (.)
  3236. followed by a blank appears on subsequent cards. After a certain number
  3237. of lines have been produced (according to the value of the variable {\tt
  3238. CARD\_NO}),\ttindex{CARD\_NO} a new expression is started. If the
  3239. expression printed arises from an assignment to a variable, the variable
  3240. is printed as the name of the expression. Otherwise the expression is
  3241. given the default name {\tt ANS}. An error occurs if identifiers or
  3242. numbers are outside the bounds permitted by FORTRAN.
  3243. A second option is to use the {\tt WRITE} command to produce other programs.
  3244. {\it Example:}
  3245. The following {\REDUCE} statements
  3246. {\small\begin{verbatim}
  3247. on fort;
  3248. out "forfil";
  3249. write "C this is a fortran program";
  3250. write " 1 format(e13.5)";
  3251. write " u=1.23";
  3252. write " v=2.17";
  3253. write " w=5.2";
  3254. x:=(u+v+w)^11;
  3255. write "C it was foolish to expand this expression";
  3256. write " print 1,x";
  3257. write " end";
  3258. shut "forfil";
  3259. off fort;
  3260. \end{verbatim}}
  3261. will generate a file {\tt forfil} that contains:
  3262. {\small
  3263. {\small\begin{verbatim}
  3264. c this is a fortran program
  3265. 1 format(e13.5)
  3266. u=1.23
  3267. v=2.17
  3268. w=5.2
  3269. ans1=1320.*u**3*v*w**7+165.*u**3*w**8+55.*u**2*v**9+495.*u
  3270. . **2*v**8*w+1980.*u**2*v**7*w**2+4620.*u**2*v**6*w**3+
  3271. . 6930.*u**2*v**5*w**4+6930.*u**2*v**4*w**5+4620.*u**2*v**3*
  3272. . w**6+1980.*u**2*v**2*w**7+495.*u**2*v*w**8+55.*u**2*w**9+
  3273. . 11.*u*v**10+110.*u*v**9*w+495.*u*v**8*w**2+1320.*u*v**7*w
  3274. . **3+2310.*u*v**6*w**4+2772.*u*v**5*w**5+2310.*u*v**4*w**6
  3275. . +1320.*u*v**3*w**7+495.*u*v**2*w**8+110.*u*v*w**9+11.*u*w
  3276. . **10+v**11+11.*v**10*w+55.*v**9*w**2+165.*v**8*w**3+330.*
  3277. . v**7*w**4+462.*v**6*w**5+462.*v**5*w**6+330.*v**4*w**7+
  3278. . 165.*v**3*w**8+55.*v**2*w**9+11.*v*w**10+w**11
  3279. x=u**11+11.*u**10*v+11.*u**10*w+55.*u**9*v**2+110.*u**9*v*
  3280. . w+55.*u**9*w**2+165.*u**8*v**3+495.*u**8*v**2*w+495.*u**8
  3281. . *v*w**2+165.*u**8*w**3+330.*u**7*v**4+1320.*u**7*v**3*w+
  3282. . 1980.*u**7*v**2*w**2+1320.*u**7*v*w**3+330.*u**7*w**4+462.
  3283. . *u**6*v**5+2310.*u**6*v**4*w+4620.*u**6*v**3*w**2+4620.*u
  3284. . **6*v**2*w**3+2310.*u**6*v*w**4+462.*u**6*w**5+462.*u**5*
  3285. . v**6+2772.*u**5*v**5*w+6930.*u**5*v**4*w**2+9240.*u**5*v
  3286. . **3*w**3+6930.*u**5*v**2*w**4+2772.*u**5*v*w**5+462.*u**5
  3287. . *w**6+330.*u**4*v**7+2310.*u**4*v**6*w+6930.*u**4*v**5*w
  3288. . **2+11550.*u**4*v**4*w**3+11550.*u**4*v**3*w**4+6930.*u**
  3289. . 4*v**2*w**5+2310.*u**4*v*w**6+330.*u**4*w**7+165.*u**3*v
  3290. . **8+1320.*u**3*v**7*w+4620.*u**3*v**6*w**2+9240.*u**3*v**
  3291. . 5*w**3+11550.*u**3*v**4*w**4+9240.*u**3*v**3*w**5+4620.*u
  3292. . **3*v**2*w**6+ans1
  3293. c it was foolish to expand this expression
  3294. print 1,x
  3295. end
  3296. \end{verbatim}}
  3297. }
  3298. If the arguments of a {\tt WRITE} statement include an expression that
  3299. requires continuation records, the output will need editing, since the
  3300. output routine prints the arguments of {\tt WRITE} sequentially, and the
  3301. continuation mechanism therefore generates its auxiliary variables after
  3302. the preceding expression has been printed.
  3303. Finally, since there is no direct analog of {\em list\/} in FORTRAN,
  3304. a comment line of the form
  3305. {\small\begin{verbatim}
  3306. c ***** invalid fortran construct (list) not printed
  3307. \end{verbatim}}
  3308. will be printed if you try to print a list with {\tt FORT} on.
  3309. \subsubsection{{FORTRAN} Output Options}\index{Output}\index{FORTRAN}
  3310. There are a number of methods available to change the default format of the
  3311. FORTRAN output.
  3312. The breakup of the expression into subparts is such that the number of
  3313. continuation lines produced is less than a given number. This number can
  3314. be modified by the assignment
  3315. {\small\begin{verbatim}
  3316. card_no := <number>;
  3317. \end{verbatim}}
  3318. where {\tt <number>} is the {\em total\/} number of cards allowed in a
  3319. statement. The default value of {\tt CARD\_NO} is 20.
  3320. The width of the output expression is also adjustable by the assignment
  3321. {\small\begin{verbatim}
  3322. fort_width := <integer>;
  3323. \end{verbatim}}
  3324. \ttindex{FORT\_WIDTH} which sets the total width of a given line to
  3325. {\tt <integer>}. The initial FORTRAN output width is 70.
  3326. {\REDUCE} automatically inserts a decimal point after each isolated integer
  3327. coefficient in a FORTRAN expression (so that, for example, 4 becomes
  3328. {\tt 4.} ). To prevent this, set the {\tt PERIOD}\ttindex{PERIOD}
  3329. mode switch to {\tt OFF}.
  3330. FORTRAN output is normally produced in lower case. If upper case is desired,
  3331. the switch {\tt FORTUPPER}\ttindex{FORTUPPER} should be turned on.
  3332. Finally, the default name {\tt ANS} assigned to an unnamed expression and
  3333. its subparts can be changed by the operator {\tt VARNAME}.
  3334. \ttindex{VARNAME} This takes a single identifier as argument, which then
  3335. replaces {\tt ANS} as the expression name. The value of {\tt VARNAME} is
  3336. its argument.
  3337. Further facilities for the production of FORTRAN and other language output
  3338. are provided by the SCOPE and GENTRAN
  3339. packages\extendedmanual{described in chapters~\ref{GENTRAN} and \ref{SCOPE}}.
  3340. \subsection{Saving Expressions for Later Use as Input}
  3341. \index{Saving an expression}
  3342. It is often useful to save an expression on an external file for use later
  3343. as input in further calculations. The commands for opening and closing
  3344. output files are explained elsewhere. However, we see in the examples on
  3345. output of expressions that the standard ``natural'' method of printing
  3346. expressions is not compatible with the input syntax. So to print the
  3347. expression in an input compatible form we must inhibit this natural style
  3348. by turning off the switch {\tt NAT}.\ttindex{NAT} If this is done, a
  3349. dollar sign will also be printed at the end of the expression.
  3350. {\it Example:}
  3351. The following sequence of commands
  3352. {\small\begin{verbatim}
  3353. off nat; out "out"; x := (y+z)^2; write "end";
  3354. shut "out"; on nat;
  3355. \end{verbatim}}
  3356. will generate a file {\tt out} that contains
  3357. {\small\begin{verbatim}
  3358. X := Y**2 + 2*Y*Z + Z**2$
  3359. END$
  3360. \end{verbatim}}
  3361. \subsection{Displaying Expression Structure}\index{Displaying structure}
  3362. In those cases where the final result has a complicated form, it is often
  3363. convenient to display the skeletal structure of the answer. The operator
  3364. {\tt STRUCTR},\ttindex{STRUCTR} that takes a single expression as argument,
  3365. will do this for you. Its syntax is:
  3366. {\small\begin{verbatim}
  3367. STRUCTR(EXPRN:algebraic[,ID1:identifier[,ID2:identifier]]);
  3368. \end{verbatim}}
  3369. The structure is printed effectively as a tree, in which the subparts are
  3370. laid out with auxiliary names. If the optional {\tt ID1} is absent, the
  3371. auxiliary names are prefixed by the root {\tt ANS}. This root may be
  3372. changed by the operator {\tt VARNAME}\ttindex{VARNAME}. If the
  3373. optional {\tt ID1} is present, and is an array name, the subparts are
  3374. named as elements of that array, otherwise {\tt ID1} is used as the root
  3375. prefix. (The second optional argument {\tt ID2} is explained later.)
  3376. The {\tt EXPRN} can be either a scalar or a matrix expression. Use of any
  3377. other will result in an error.
  3378. {\it Example:}
  3379. Let us suppose that the workspace contains
  3380. {\tt ((A+B)\verb|^|2+C)\verb|^|3+D}.
  3381. Then the input {\tt STRUCTR WS;} will (with {\tt EXP} off) result in the
  3382. output:\newpage
  3383. {\small\begin{verbatim}
  3384. ANS3
  3385. where
  3386. 3
  3387. ANS3 := ANS2 + D
  3388. 2
  3389. ANS2 := ANS1 + C
  3390. ANS1 := A + B
  3391. \end{verbatim}}
  3392. The workspace remains unchanged after this operation, since {\tt STRUCTR}
  3393. \ttindex{STRUCTR} in the default situation returns
  3394. no value (if {\tt STRUCTR} is used as a sub-expression, its value is taken
  3395. to be 0). In addition, the sub-expressions are normally only displayed
  3396. and not retained. If you wish to access the sub-expressions with their
  3397. displayed names, the switch {\tt SAVESTRUCTR}\ttindex{SAVESTRUCTR} should be
  3398. turned on. In this case, {\tt STRUCTR} returns a list whose first element
  3399. is a representation for the expression, and subsequent elements are the
  3400. sub-expression relations. Thus, with {\tt SAVESTRUCTR} on, {\tt STRUCTR WS}
  3401. in the above example would return
  3402. \vspace{-11pt}
  3403. {\small\begin{verbatim}
  3404. 3 2
  3405. {ANS3,ANS3=ANS2 + D,ANS2=ANS1 + C,ANS1=A + B}
  3406. \end{verbatim}}
  3407. The {\tt PART}\ttindex{PART} operator can
  3408. be used to retrieve the required parts of the expression. For example, to
  3409. get the value of {\tt ANS2} in the above, one could say:
  3410. {\small\begin{verbatim}
  3411. part(ws,3,2);
  3412. \end{verbatim}}
  3413. If {\tt FORT} is on, then the results are printed in the reverse order; the
  3414. algorithm in fact guaranteeing that no sub-expression will be referenced
  3415. before it is defined. The second optional argument {\tt ID2} may also be
  3416. used in this case to name the actual expression (or expressions in the
  3417. case of a matrix argument).
  3418. {\it Example:}
  3419. Let us suppose that {\tt M}, a 2 by 1 matrix, contains the elements {\tt
  3420. ((a+b)\verb|^|2 + c)\verb|^|3 + d} and {\tt (a + b)*(c + d)} respectively,
  3421. and that {\tt V} has been declared to be an array. With {\tt EXP} off and
  3422. {\tt FORT} on, the statement {\tt structr(2*m,v,k);} will result in the output
  3423. {\small\begin{verbatim}
  3424. V(1)=A+B
  3425. V(2)=V(1)**2+C
  3426. V(3)=V(2)**3+D
  3427. V(4)=C+D
  3428. K(1,1)=2.*V(3)
  3429. K(2,1)=2.*V(1)*V(4)
  3430. \end{verbatim}}
  3431. \section{Changing the Internal Order of Variables}
  3432. The internal ordering of variables (more specifically kernels) can have
  3433. a significant effect on the space and time associated with a calculation.
  3434. In its default state, {\REDUCE} uses a specific order for this which may
  3435. vary between sessions. However, it is possible for the user to change
  3436. this internal order by means of the declaration
  3437. {\tt KORDER}\ttindex{KORDER}. The syntax for this is:
  3438. {\small\begin{verbatim}
  3439. korder v1,...,vn;
  3440. \end{verbatim}}
  3441. where the {\tt Vi} are kernels\index{Kernel}. With this declaration, the
  3442. {\tt Vi} are ordered internally ahead of any other kernels in the system.
  3443. {\tt V1} has the highest order, {\tt V2} the next highest, and so on. A
  3444. further call of {\tt KORDER} replaces a previous one. {\tt KORDER NIL;}
  3445. resets the internal order to the system default.
  3446. Unlike the {\tt ORDER}\ttindex{ORDER} declaration, that has a purely
  3447. cosmetic effect on the way results are printed, the use of {\tt KORDER}
  3448. can have a significant effect on computation time. In critical cases
  3449. then, the user can experiment with the ordering of the variables used to
  3450. determine the optimum set for a given problem.
  3451. \section{Obtaining Parts of Algebraic Expressions}
  3452. There are many occasions where it is desirable to obtain a specific part
  3453. of an expression, or even change such a part to another expression. A
  3454. number of operators are available in {\REDUCE} for this purpose, and will be
  3455. described in this section. In addition, operators for obtaining specific
  3456. parts of polynomials and rational functions (such as a denominator) are
  3457. described in another section.
  3458. \subsection{COEFF Operator}\ttindex{COEFF}
  3459. Syntax:
  3460. {\small\begin{verbatim}
  3461. COEFF(EXPRN:polynomial,VAR:kernel)
  3462. \end{verbatim}}
  3463. {\tt COEFF} is an operator that partitions {\tt EXPRN} into its various
  3464. coefficients with respect to {\tt VAR} and returns them as a list, with
  3465. the coefficient independent of {\tt VAR} first.
  3466. Under normal circumstances, an error results if {\tt EXPRN} is not a
  3467. polynomial in {\tt VAR}, although the coefficients themselves can be
  3468. rational as long as they do not depend on {\tt VAR}. However, if the
  3469. switch {\tt RATARG}\ttindex{RATARG} is on, denominators are not checked for
  3470. dependence on {\tt VAR}, and are taken to be part of the coefficients.
  3471. {\it Example:}
  3472. {\small\begin{verbatim}
  3473. coeff((y^2+z)^3/z,y);
  3474. \end{verbatim}}
  3475. returns the result
  3476. {\small\begin{verbatim}
  3477. 2
  3478. {Z ,0,3*Z,0,3,0,1/Z}.
  3479. \end{verbatim}}
  3480. whereas
  3481. {\small\begin{verbatim}
  3482. coeff((y^2+z)^3/y,y);
  3483. \end{verbatim}}
  3484. gives an error if {\tt RATARG} is off, and the result
  3485. {\small\begin{verbatim}
  3486. 3 2
  3487. {Z /Y,0,3*Z /Y,0,3*Z/Y,0,1/Y}
  3488. \end{verbatim}}
  3489. if {\tt RATARG} is on.
  3490. The length of the result of {\tt COEFF} is the highest power of {\tt VAR}
  3491. encountered plus 1. In the above examples it is 7. In addition, the
  3492. variable {\tt HIGH\_POW}\ttindex{HIGH\_POW} is set to the highest non-zero
  3493. power found in {\tt EXPRN} during the evaluation, and {\tt LOW\_POW}
  3494. \ttindex{LOW\_POW} to the lowest non-zero power, or zero if there is a
  3495. constant term. If {\tt EXPRN} is a constant, then {\tt HIGH\_POW} and
  3496. {\tt LOW\_POW} are both set to zero.
  3497. \subsection{COEFFN Operator}\ttindex{COEFFN}
  3498. The {\tt COEFFN} operator is designed to give the user a particular
  3499. coefficient of a variable in a polynomial, as opposed to {\tt COEFF} that
  3500. returns all coefficients. {\tt COEFFN} is used with the syntax
  3501. {\small\begin{verbatim}
  3502. COEFFN(EXPRN:polynomial,VAR:kernel,N:integer)
  3503. \end{verbatim}}
  3504. It returns the $n^{th}$ coefficient of {\tt VAR} in the polynomial
  3505. {\tt EXPRN}.
  3506. \subsection{PART Operator}\ttindex{PART}
  3507. Syntax:
  3508. {\small\begin{verbatim}
  3509. PART(EXPRN:algebraic[,INTEXP:integer])
  3510. \end{verbatim}}
  3511. This operator works on the form of the expression as printed {\em or as it
  3512. would have been printed at that point in the calculation\/} bearing in mind
  3513. all the relevant switch settings at that point. The reader therefore
  3514. needs some familiarity with the way that expressions are represented in
  3515. prefix form in {\REDUCE} to use these operators effectively. Furthermore,
  3516. it is assumed that {\tt PRI} is {\tt ON} at that point in the calculation.
  3517. The reason for this is that with {\tt PRI} off, an expression is printed
  3518. by walking the tree representing the expression internally. To save
  3519. space, it is never actually transformed into the equivalent prefix
  3520. expression as occurs when {\tt PRI} is on. However, the operations on
  3521. polynomials described elsewhere can be equally well used in this case to
  3522. obtain the relevant parts.
  3523. The evaluation proceeds recursively down the integer expression list. In
  3524. other words,
  3525. {\small\begin{verbatim}
  3526. PART(<expression>,<integer1>,<integer2>)
  3527. -> PART(PART(<expression>,<integer1>),<integer2>)
  3528. \end{verbatim}}
  3529. and so on, and
  3530. {\small\begin{verbatim}
  3531. PART(<expression>) -> <expression>.
  3532. \end{verbatim}}
  3533. {\tt INTEXP} can be any expression that evaluates to an integer. If the
  3534. integer is positive, then that term of the expression is found. If the
  3535. integer is 0, the operator is returned. Finally, if the integer is
  3536. negative, the counting is from the tail of the expression rather than the
  3537. head.
  3538. For example, if the expression {\tt a+b} is printed as {\tt A+B} (i.e.,
  3539. the ordering of the variables is alphabetical), then
  3540. {\small\begin{verbatim}
  3541. part(a+b,2) -> B
  3542. part(a+b,-1) -> B
  3543. and
  3544. part(a+b,0) -> PLUS
  3545. \end{verbatim}}
  3546. An operator {\tt ARGLENGTH}\ttindex{ARGLENGTH} is available to determine
  3547. the number of arguments of the top level operator in an expression. If
  3548. the expression does not contain a top level operator, then $-1$ is returned.
  3549. For example,
  3550. {\small\begin{verbatim}
  3551. arglength(a+b+c) -> 3
  3552. arglength(f()) -> 0
  3553. arglength(a) -> -1
  3554. \end{verbatim}}
  3555. \subsection{Substituting for Parts of Expressions}
  3556. {\tt PART} may also be used to substitute for a given part of an
  3557. expression. In this case, the {\tt PART} construct appears on the
  3558. left-hand side of an assignment statement, and the expression to replace
  3559. the given part on the right-hand side.
  3560. For example, with the normal settings of the {\REDUCE} switches:
  3561. {\small\begin{verbatim}
  3562. xx := a+b;
  3563. part(xx,2) := c; -> A+C
  3564. part(c+d,0) := -; -> C-D
  3565. \end{verbatim}}
  3566. Note that {\tt xx} in the above is not changed by this substitution. In
  3567. addition, unlike expressions such as array and matrix elements that have
  3568. an {\em instant evaluation\/}\index{Instant evaluation} property, the values
  3569. of {\tt part(xx,2)} and {\tt part(c+d,0)} are also not changed.
  3570. \chapter{Polynomials and Rationals}
  3571. Many operations in computer algebra are concerned with polynomials
  3572. \index{Polynomial} and rational functions\index{Rational function}. In
  3573. this section, we review some of the switches and operators available for
  3574. this purpose. These are in addition to those that work on general
  3575. expressions (such as {\tt DF} and {\tt INT}) described elsewhere. In the
  3576. case of operators, the arguments are first simplified before the
  3577. operations are applied. In addition, they operate only on arguments of
  3578. prescribed types, and produce a type mismatch error if given arguments
  3579. which cannot be interpreted in the required mode with the current switch
  3580. settings. For example, if an argument is required to be a kernel and
  3581. {\tt a/2} is used (with no other rules for {\tt A}), an error
  3582. {\small\begin{verbatim}
  3583. A/2 invalid as kernel
  3584. \end{verbatim}}
  3585. will result.
  3586. With the exception of those that select various parts of a polynomial or
  3587. rational function, these operations have potentially significant effects on
  3588. the space and time associated with a given calculation. The user should
  3589. therefore experiment with their use in a given calculation in order to
  3590. determine the optimum set for a given problem.
  3591. One such operation provided by the system is an operator {\tt LENGTH}
  3592. \ttindex{LENGTH} which returns the number of top level terms in the
  3593. numerator of its argument. For example,
  3594. {\small\begin{verbatim}
  3595. length ((a+b+c)^3/(c+d));
  3596. \end{verbatim}}
  3597. has the value 10. To get the number of terms in the denominator, one
  3598. would first select the denominator by the operator {\tt DEN}\ttindex{DEN}
  3599. and then call {\tt LENGTH}, as in
  3600. {\small\begin{verbatim}
  3601. length den ((a+b+c)^3/(c+d));
  3602. \end{verbatim}}
  3603. Other operations currently supported, the relevant switches and operators,
  3604. and the required argument and value modes of the latter, follow.
  3605. \section{Controlling the Expansion of Expressions}
  3606. The switch {\tt EXP}\ttindex{EXP} controls the expansion of expressions. If
  3607. it is off, no expansion of powers or products of expressions occurs.
  3608. Users should note however that in this case results come out in a normal
  3609. but not necessarily canonical form. This means that zero expressions
  3610. simplify to zero, but that two equivalent expressions need not necessarily
  3611. simplify to the same form.
  3612. {\it Example:} With {\tt EXP} on, the two expressions
  3613. {\small\begin{verbatim}
  3614. (a+b)*(a+2*b)
  3615. \end{verbatim}}
  3616. and
  3617. {\small\begin{verbatim}
  3618. a^2+3*a*b+2*b^2
  3619. \end{verbatim}}
  3620. will both simplify to the latter form. With {\tt EXP}
  3621. off, they would remain unchanged, unless the complete factoring {\tt
  3622. (ALLFAC)} option were in force. {\tt EXP} is normally on.
  3623. Several operators that expect a polynomial as an argument behave
  3624. differently when {\tt EXP} is off, since there is often only one term at
  3625. the top level. For example, with {\tt EXP} off
  3626. {\small\begin{verbatim}
  3627. length((a+b+c)^3/(c+d));
  3628. \end{verbatim}}
  3629. returns the value 1.
  3630. \section{Factorization of Polynomials}\index{Factorization}
  3631. {\REDUCE} is capable of factorizing univariate and multivariate polynomials
  3632. that have integer coefficients, finding all factors that also have integer
  3633. coefficients. The package for doing this was written by Dr. Arthur C.
  3634. Norman and Ms. P. Mary Ann Moore at The University of Cambridge. It is
  3635. described in P. M. A. Moore and A. C. Norman, ``Implementing a Polynomial
  3636. Factorization and GCD Package'', Proc. SYMSAC '81, ACM (New York) (1981),
  3637. 109-116.
  3638. The easiest way to use this facility is to turn on the switch
  3639. {\tt FACTOR},\ttindex{FACTOR} which causes all expressions to be output in
  3640. a factored form. For example, with {\tt FACTOR} on, the expression
  3641. {\tt A\verb|^|2-B\verb|^|2} is returned as {\tt (A+B)*(A-B)}.
  3642. It is also possible to factorize a given expression explicitly. The
  3643. operator {\tt FACTORIZE}\ttindex{FACTORIZE} that invokes this facility is
  3644. used with the syntax
  3645. {\small\begin{verbatim}
  3646. FACTORIZE(EXPRN:polynomial[,INTEXP:prime integer]):list,
  3647. \end{verbatim}}
  3648. the optional argument of which will be described later. Thus to find and
  3649. display all factors of the cyclotomic polynomial $x^{105}-1$, one could
  3650. write:
  3651. {\small\begin{verbatim}
  3652. factorize(x^105-1);
  3653. \end{verbatim}}
  3654. The result is a list of factor,exponent pairs.
  3655. In the above example, there is no overall numerical factor in the result,
  3656. so the results will consist only of polynomials in x. The number of such
  3657. polynomials can be found by using the operator {\tt LENGTH}.\ttindex{LENGTH}
  3658. If there is a numerical factor, as in factorizing $12x^{2}-12$,
  3659. that factor will appear as the first member of the result.
  3660. It will however not be factored further. Prime factors of such numbers
  3661. can be found, using a probabilistic algorithm, by turning on the switch
  3662. {\tt IFACTOR}.\ttindex{IFACTOR} For example,
  3663. {\small\begin{verbatim}
  3664. on ifactor; factorize(12x^2-12);
  3665. \end{verbatim}}
  3666. would result in the output
  3667. {\small\begin{verbatim}
  3668. {{2,2},{3,1},{X + 1,1},{X - 1,1}}.
  3669. \end{verbatim}}
  3670. If the first argument of {\tt FACTORIZE} is an integer, it will be
  3671. decomposed into its prime components, whether or not {\tt IFACTOR} is on.
  3672. Note that the {\tt IFACTOR} switch only affects the result of {\tt FACTORIZE}.
  3673. It has no effect if the {\tt FACTOR}\ttindex{FACTOR} switch is also on.
  3674. The order in which the factors occur in the result (with the exception of
  3675. a possible overall numerical coefficient which comes first) can be system
  3676. dependent and should not be relied on. Similarly it should be noted that
  3677. any pair of individual factors can be negated without altering their
  3678. product, and that {\REDUCE} may sometimes do that.
  3679. The factorizer works by first reducing multivariate problems to univariate
  3680. ones and then solving the univariate ones modulo small primes. It normally
  3681. selects both evaluation points and primes using a random number generator
  3682. that should lead to different detailed behavior each time any particular
  3683. problem is tackled. If, for some reason, it is known that a certain
  3684. (probably univariate) factorization can be performed effectively with a
  3685. known prime, {\tt P} say, this value of {\tt P} can be handed to
  3686. {\tt FACTORIZE}\ttindex{FACTORIZE} as a second
  3687. argument. An error will occur if a non-prime is provided to {\tt FACTORIZE} in
  3688. this manner. It is also an error to specify a prime that divides the
  3689. discriminant of the polynomial being factored, but users should note that
  3690. this condition is not checked by the program, so this capability should be
  3691. used with care.
  3692. Factorization can be performed over a number of polynomial coefficient
  3693. domains in addition to integers. The particular description of the relevant
  3694. domain should be consulted to see if factorization is supported. For
  3695. example, the following statements will factorize $x^{4}+1$ modulo 7:
  3696. {\small\begin{verbatim}
  3697. setmod 7;
  3698. on modular;
  3699. factorize(x^4+1);
  3700. \end{verbatim}}
  3701. The factorization module is provided with a trace facility that may be useful
  3702. as a way of monitoring progress on large problems, and of satisfying
  3703. curiosity about the internal workings of the package. The most simple use
  3704. of this is enabled by issuing the {\REDUCE} command\ttindex{TRFAC}
  3705. {\tt on trfac;} .
  3706. Following this, all calls to the factorizer will generate informative
  3707. messages reporting on such things as the reduction of multivariate to
  3708. univariate cases, the choice of a prime and the reconstruction of full
  3709. factors from their images. Further levels of detail in the trace are
  3710. intended mainly for system tuners and for the investigation of suspected
  3711. bugs. For example, {\tt TRALLFAC} gives tracing information at all levels
  3712. of detail. The switch that can be set by {\tt on timings;} makes it
  3713. possible for one who is familiar with the algorithms used to determine
  3714. what part of the factorization code is consuming the most resources.
  3715. {\tt on overview}; reduces the amount of detail presented in other forms of
  3716. trace. Other forms of trace output are enabled by directives of the form
  3717. {\small\begin{verbatim}
  3718. symbolic set!-trace!-factor(<number>,<filename>);
  3719. \end{verbatim}}
  3720. where useful numbers are 1, 2, 3 and 100, 101, ... . This facility is
  3721. intended to make it possible to discover in fairly great detail what just
  3722. some small part of the code has been doing --- the numbers refer mainly to
  3723. depths of recursion when the factorizer calls itself, and to the split
  3724. between its work forming and factorizing images and reconstructing full
  3725. factors from these. If {\tt NIL} is used in place of a filename the trace
  3726. output requested is directed to the standard output stream. After use of
  3727. this trace facility the generated trace files should be closed by calling
  3728. {\small\begin{verbatim}
  3729. symbolic close!-trace!-files();
  3730. \end{verbatim}}
  3731. {\it NOTE:} Using the factorizer with {\tt MCD}\ttindex{MCD} off will
  3732. result in an error.
  3733. \section{Cancellation of Common Factors}
  3734. Facilities are available in {\REDUCE} for cancelling common factors in the
  3735. numerators and denominators of expressions, at the option of the user. The
  3736. system will perform this greatest common divisor computation if the switch
  3737. {\tt GCD}\ttindex{GCD} is on. ({\tt GCD} is normally off.)
  3738. A check is automatically made, however, for common variable and numerical
  3739. products in the numerators and denominators of expressions, and the
  3740. appropriate cancellations made.
  3741. When {\tt GCD} is on, and {\tt EXP} is off, a check is made for square
  3742. free factors in an expression. This includes separating out and
  3743. independently checking the content of a given polynomial where
  3744. appropriate. (For an explanation of these terms, see Anthony C. Hearn,
  3745. ``Non-Modular Computation of Polynomial GCDs Using Trial Division'', Proc.
  3746. EUROSAM 79, published as Lecture Notes on Comp. Science, Springer-Verlag,
  3747. Berlin, No 72 (1979) 227-239.)
  3748. {\it Example:} With {\tt EXP}\ttindex{EXP} off and {\tt GCD}\ttindex{GCD}
  3749. on,
  3750. the polynomial {\tt a*c+a*d+b*c+b*d} would be returned as {\tt (A+B)*(C+D)}.
  3751. Under normal circumstances, GCDs are computed using an algorithm described
  3752. in the above paper. It is also possible in {\REDUCE} to compute GCDs using
  3753. an alternative algorithm, called the EZGCD Algorithm, which uses modular
  3754. arithmetic. The switch {\tt EZGCD}\ttindex{EZGCD}, if on in addition to
  3755. {\tt GCD}, makes this happen.
  3756. In non-trivial cases, the EZGCD algorithm is almost always better
  3757. than the basic algorithm, often by orders of magnitude. We therefore
  3758. {\em strongly\/} advise users to use the {\tt EZGCD} switch where they have the
  3759. resources available for supporting the package.
  3760. For a description of the EZGCD algorithm, see J. Moses and D.Y.Y. Yun,
  3761. ``The EZ GCD Algorithm'', Proc. ACM 1973, ACM, New York (1973) 159-166.
  3762. {\it NOTE:}
  3763. This package shares code with the factorizer, so a certain amount of trace
  3764. information can be produced using the factorizer trace switches.
  3765. \subsection{Determining the GCD of Two Polynomials}
  3766. This operator, used with the syntax
  3767. {\small\begin{verbatim}
  3768. GCD(EXPRN1:polynomial,EXPRN2:polynomial):polynomial,
  3769. \end{verbatim}}
  3770. returns the greatest common divisor of the two polynomials {\tt EXPRN1} and
  3771. {\tt EXPRN2}.
  3772. {\it Examples:}
  3773. {\small\begin{verbatim}
  3774. gcd(x^2+2*x+1,x^2+3*x+2) -> X+1
  3775. gcd(2*x^2-2*y^2,4*x+4*y) -> 2*X+2*Y
  3776. gcd(x^2+y^2,x-y) -> 1.
  3777. \end{verbatim}}
  3778. \section{Working with Least Common Multiples}
  3779. Greatest common divisor calculations can often become expensive if
  3780. extensive work with large rational expressions is required. However, in
  3781. many cases, the only significant cancellations arise from the fact that
  3782. there are often common factors in the various denominators which are
  3783. combined when two rationals are added. Since these denominators tend to be
  3784. smaller and more regular in structure than the numerators, considerable
  3785. savings in both time and space can occur if a full GCD check is made when
  3786. the denominators are combined and only a partial check when numerators are
  3787. constructed. In other words, the true least common multiple of the
  3788. denominators is computed at each step. The switch {\tt LCM}\ttindex{LCM}
  3789. is available for this purpose, and is normally on.
  3790. In addition, the operator {\tt LCM},\ttindex{LCM} used with the syntax
  3791. {\small\begin{verbatim}
  3792. LCM(EXPRN1:polynomial,EXPRN2:polynomial):polynomial,
  3793. \end{verbatim}}
  3794. returns the least common multiple of the two polynomials {\tt EXPRN1} and
  3795. {\tt EXPRN2}.
  3796. {\it Examples:}
  3797. {\small\begin{verbatim}
  3798. lcm(x^2+2*x+1,x^2+3*x+2) -> X**3 + 4*X**2 + 5*X + 2
  3799. lcm(2*x^2-2*y^2,4*x+4*y) -> 4*(X**2 - Y**2)
  3800. \end{verbatim}}
  3801. \section{Controlling Use of Common Denominators}
  3802. When two rational functions are added, {\REDUCE} normally produces an
  3803. expression over a common denominator. However, if the user does not want
  3804. denominators combined, he or she can turn off the switch {\tt MCD}
  3805. \ttindex{MCD} which controls this process. The latter switch is
  3806. particularly useful if no greatest common divisor calculations are
  3807. desired, or excessive differentiation of rational functions is required.
  3808. {\it CAUTION:} With {\tt MCD} off, results are not guaranteed to come out in
  3809. either normal or canonical form. In other words, an expression equivalent
  3810. to zero may in fact not be simplified to zero. This option is therefore
  3811. most useful for avoiding expression swell during intermediate parts of a
  3812. calculation.
  3813. {\tt MCD}\ttindex{MCD} is normally on.
  3814. \section{REMAINDER Operator}\ttindex{REMAINDER}
  3815. This operator is used with the syntax
  3816. {\small\begin{verbatim}
  3817. REMAINDER(EXPRN1:polynomial,EXPRN2:polynomial):polynomial.
  3818. \end{verbatim}}
  3819. It returns the remainder when {\tt EXPRN1} is divided by {\tt EXPRN2}. This
  3820. is the true remainder based on the internal ordering of the variables, and
  3821. not the pseudo-remainder. The pseudo-remainder \ttindex{PSEUDO\_REMAINDER}
  3822. and in general pseudo-division \ttindex{PSEUDO\_DIVIDE} of polynomials
  3823. can be calculated after loading the {\tt polydiv} package.
  3824. Please refer to the documentation of this package for details.
  3825. {\it Examples:}
  3826. {\small\begin{verbatim}
  3827. remainder((x+y)*(x+2*y),x+3*y) -> 2*Y**2
  3828. remainder(2*x+y,2) -> Y.
  3829. \end{verbatim}}
  3830. {\it CAUTION:} In the default case, remainders are calculated over the
  3831. integers. If you need the remainder with respect to another domain, it
  3832. must be declared explicitly.
  3833. {\it Example:}
  3834. {\small\begin{verbatim}
  3835. remainder(x^2-2,x+sqrt(2)); -> X^2 - 2
  3836. load_package arnum;
  3837. defpoly sqrt2**2-2;
  3838. remainder(x^2-2,x+sqrt2); -> 0
  3839. \end{verbatim}}
  3840. \section{RESULTANT Operator}\ttindex{RESULTANT}
  3841. This is used with the syntax
  3842. {\small\begin{verbatim}
  3843. RESULTANT(EXPRN1:polynomial,EXPRN2:polynomial,VAR:kernel):
  3844. polynomial.
  3845. \end{verbatim}}
  3846. It computes the resultant of the two given polynomials with respect to the
  3847. given variable, the coefficients of the polynomials can be taken from any
  3848. domain. The result can be identified as the determinant of a
  3849. Sylvester matrix, but can often also be thought of informally as the
  3850. result obtained when the given variable is eliminated between the two input
  3851. polynomials. If the two input polynomials have a non-trivial GCD their
  3852. resultant vanishes.
  3853. The switch {\tt Bezout}\ttindex{Bezout} controls the computation of the
  3854. resultants. It is off by default. In this case a subresultant algorithm
  3855. is used. If the switch Bezout is turned on, the resultant is computed via
  3856. the Bezout Matrix. However, in the latter case, only polynomial coefficients
  3857. are permitted.
  3858. \begin{samepage}
  3859. The sign conventions used by the resultant function follow those in R.
  3860. Loos, ``Computing in Algebraic Extensions'' in ``Computer Algebra --- Symbolic
  3861. and Algebraic Computation'', Second Ed., Edited by B. Buchberger, G.E.
  3862. Collins and R. Loos, Springer-Verlag, 1983. Namely, with {\tt A} and {\tt B}
  3863. not dependent on {\tt X}:
  3864. {\small\begin{verbatim}
  3865. deg(p)*deg(q)
  3866. resultant(p(x),q(x),x)= (-1) *resultant(q,p,x)
  3867. deg(p)
  3868. resultant(a,p(x),x) = a
  3869. resultant(a,b,x) = 1
  3870. \end{verbatim}}
  3871. \end{samepage}
  3872. {\it Examples:}
  3873. \begin{samepage}
  3874. {\small\begin{verbatim}
  3875. 2
  3876. resultant(x/r*u+y,u*y,u) -> - y
  3877. \end{verbatim}}
  3878. \end{samepage}
  3879. {\it calculation in an algebraic extension:}
  3880. \begin{samepage}
  3881. {\small\begin{verbatim}
  3882. load arnum;
  3883. defpoly sqrt2**2 - 2;
  3884. resultant(x + sqrt2,sqrt2 * x +1,x) -> -1
  3885. \end{verbatim}}
  3886. \end{samepage}
  3887. {\it or in a modular domain:}
  3888. \begin{samepage}
  3889. {\small\begin{verbatim}
  3890. setmod 17;
  3891. on modular;
  3892. resultant(2x+1,3x+4,x) -> 5
  3893. \end{verbatim}}
  3894. \end{samepage}
  3895. \section{DECOMPOSE Operator}\ttindex{DECOMPOSE}
  3896. The {\tt DECOMPOSE} operator takes a multivariate polynomial as argument,
  3897. and returns an expression and a list of equations from which the
  3898. original polynomial can be found by composition. Its syntax is:
  3899. {\small\begin{verbatim}
  3900. DECOMPOSE(EXPRN:polynomial):list.
  3901. \end{verbatim}}
  3902. For example:
  3903. {\small\begin{verbatim}
  3904. decompose(x^8-88*x^7+2924*x^6-43912*x^5+263431*x^4-
  3905. 218900*x^3+65690*x^2-7700*x+234)
  3906. 2 2 2
  3907. -> {U + 35*U + 234, U=V + 10*V, V=X - 22*X}
  3908. 2
  3909. decompose(u^2+v^2+2u*v+1) -> {W + 1, W=U + V}
  3910. \end{verbatim}}
  3911. Users should note however that, unlike factorization, this decomposition
  3912. is not unique.
  3913. \section{INTERPOL operator}\ttindex{INTERPOL}
  3914. Syntax:
  3915. {\small\begin{verbatim}
  3916. INTERPOL(<values>,<variable>,<points>);
  3917. \end{verbatim}}
  3918. where {\tt <values>} and {\tt <points>} are lists of equal length and
  3919. {\tt <variable>} is an algebraic expression (preferably a kernel).
  3920. {\tt INTERPOL} generates an interpolation polynomial {\em f\/} in the given
  3921. variable of degree length({\tt <values>})-1. The unique polynomial {\em f\/}
  3922. is defined by the property that for corresponding elements {\em v\/} of
  3923. {\tt <values>} and {\em p\/} of {\tt <points>} the relation $f(p)=v$ holds.
  3924. The Aitken-Neville interpolation algorithm is used which guarantees a
  3925. stable result even with rounded numbers and an ill-conditioned problem.
  3926. \section{Obtaining Parts of Polynomials and Rationals}
  3927. These operators select various parts of a polynomial or rational function
  3928. structure. Except for the cost of rearrangement of the structure, these
  3929. operations take very little time to perform.
  3930. For those operators in this section that take a kernel {\tt VAR} as their
  3931. second argument, an error results if the first expression is not a
  3932. polynomial in {\tt VAR}, although the coefficients themselves can be
  3933. rational as long as they do not depend on {\tt VAR}. However, if the
  3934. switch {\tt RATARG}\ttindex{RATARG} is on, denominators are not checked
  3935. for dependence on {\tt VAR}, and are taken to be part of the coefficients.
  3936. \subsection{DEG Operator}\ttindex{DEG}
  3937. This operator is used with the syntax
  3938. {\small\begin{verbatim}
  3939. DEG(EXPRN:polynomial,VAR:kernel):integer.
  3940. \end{verbatim}}
  3941. It returns the leading degree\index{Degree} of the polynomial {\tt EXPRN}
  3942. in the variable {\tt VAR}. If {\tt VAR} does not occur as a variable in
  3943. {\tt EXPRN}, 0 is returned.
  3944. {\it Examples:}
  3945. {\small\begin{verbatim}
  3946. deg((a+b)*(c+2*d)^2,a) -> 1
  3947. deg((a+b)*(c+2*d)^2,d) -> 2
  3948. deg((a+b)*(c+2*d)^2,e) -> 0.
  3949. \end{verbatim}}
  3950. Note also that if {\tt RATARG} is on,
  3951. {\small\begin{verbatim}
  3952. deg((a+b)^3/a,a) -> 3
  3953. \end{verbatim}}
  3954. since in this case, the denominator {\tt A} is considered part of the
  3955. coefficients of the numerator in {\tt A}. With {\tt RATARG} off, however,
  3956. an error would result in this case.
  3957. \subsection{DEN Operator}\ttindex{DEN}
  3958. This is used with the syntax:
  3959. {\small\begin{verbatim}
  3960. DEN(EXPRN:rational):polynomial.
  3961. \end{verbatim}}
  3962. It returns the denominator of the rational expression {\tt EXPRN}. If
  3963. {\tt EXPRN} is a polynomial, 1 is returned.
  3964. {\it Examples:}
  3965. {\small\begin{verbatim}
  3966. den(x/y^2) -> Y**2
  3967. den(100/6) -> 3
  3968. [since 100/6 is first simplified to 50/3]
  3969. den(a/4+b/6) -> 12
  3970. den(a+b) -> 1
  3971. \end{verbatim}}
  3972. \subsection{LCOF Operator}\ttindex{LCOF}
  3973. LCOF is used with the syntax
  3974. {\small\begin{verbatim}
  3975. LCOF(EXPRN:polynomial,VAR:kernel):polynomial.
  3976. \end{verbatim}}
  3977. It returns the leading coefficient\index{Leading coefficient} of the
  3978. polynomial {\tt EXPRN} in the variable {\tt VAR}. If {\tt VAR} does not
  3979. occur as a variable in {\tt EXPRN}, {\tt EXPRN} is returned.
  3980. \extendedmanual{\newpage}
  3981. {\it Examples:}
  3982. {\small\begin{verbatim}
  3983. lcof((a+b)*(c+2*d)^2,a) -> C**2+4*C*D+4*D**2
  3984. lcof((a+b)*(c+2*d)^2,d) -> 4*(A+B)
  3985. lcof((a+b)*(c+2*d),e) -> A*C+2*A*D+B*C+2*B*D
  3986. \end{verbatim}}
  3987. \subsection{LPOWER Operator}\ttindex{LPOWER}
  3988. \begin{samepage}
  3989. Syntax:
  3990. {\small\begin{verbatim}
  3991. LPOWER(EXPRN:polynomial,VAR:kernel):polynomial.
  3992. \end{verbatim}}
  3993. LPOWER returns the leading power of {\tt EXPRN} with respect to {\tt VAR}.
  3994. If {\tt EXPRN} does not depend on {\tt VAR}, 1 is returned.
  3995. \end{samepage}
  3996. {\it Examples:}
  3997. {\small\begin{verbatim}
  3998. lpower((a+b)*(c+2*d)^2,a) -> A
  3999. lpower((a+b)*(c+2*d)^2,d) -> D**2
  4000. lpower((a+b)*(c+2*d),e) -> 1
  4001. \end{verbatim}}
  4002. \subsection{LTERM Operator}\ttindex{LTERM}
  4003. \begin{samepage}
  4004. Syntax:
  4005. {\small\begin{verbatim}
  4006. LTERM(EXPRN:polynomial,VAR:kernel):polynomial.
  4007. \end{verbatim}}
  4008. LTERM returns the leading term of {\tt EXPRN} with respect to {\tt VAR}.
  4009. If {\tt EXPRN} does not depend on {\tt VAR}, {\tt EXPRN} is returned.
  4010. \end{samepage}
  4011. {\it Examples:}
  4012. {\small\begin{verbatim}
  4013. lterm((a+b)*(c+2*d)^2,a) -> A*(C**2+4*C*D+4*D**2)
  4014. lterm((a+b)*(c+2*d)^2,d) -> 4*D**2*(A+B)
  4015. lterm((a+b)*(c+2*d),e) -> A*C+2*A*D+B*C+2*B*D
  4016. \end{verbatim}}
  4017. {\COMPATNOTE} In some earlier versions of REDUCE, {\tt LTERM} returned
  4018. {\tt 0} if the {\tt EXPRN} did not depend on {\tt VAR}. In the present
  4019. version, {\tt EXPRN} is always equal to {\tt LTERM(EXPRN,VAR)} $+$ {\tt
  4020. REDUCT(EXPRN,VAR)}.
  4021. \subsection{MAINVAR Operator}\ttindex{MAINVAR}
  4022. Syntax:
  4023. {\small\begin{verbatim}
  4024. MAINVAR(EXPRN:polynomial):expression.
  4025. \end{verbatim}}
  4026. Returns the main variable (based on the internal polynomial representation)
  4027. of {\tt EXPRN}. If {\tt EXPRN} is a domain element, 0 is returned.
  4028. {\it Examples:}
  4029. Assuming {\tt A} has higher kernel order than {\tt B}, {\tt C}, or {\tt D}:
  4030. {\small\begin{verbatim}
  4031. mainvar((a+b)*(c+2*d)^2) -> A
  4032. mainvar(2) -> 0
  4033. \end{verbatim}}
  4034. \subsection{NUM Operator}\ttindex{NUM}
  4035. Syntax:
  4036. {\small\begin{verbatim}
  4037. NUM(EXPRN:rational):polynomial.
  4038. \end{verbatim}}
  4039. Returns the numerator of the rational expression {\tt EXPRN}. If {\tt EXPRN}
  4040. is a polynomial, that polynomial is returned.
  4041. {\it Examples:}
  4042. {\small\begin{verbatim}
  4043. num(x/y^2) -> X
  4044. num(100/6) -> 50
  4045. num(a/4+b/6) -> 3*A+2*B
  4046. num(a+b) -> A+B
  4047. \end{verbatim}}
  4048. \subsection{REDUCT Operator}\ttindex{REDUCT}
  4049. Syntax:
  4050. {\small\begin{verbatim}
  4051. REDUCT(EXPRN:polynomial,VAR:kernel):polynomial.
  4052. \end{verbatim}}
  4053. Returns the reductum of {\tt EXPRN} with respect to {\tt VAR} (i.e., the
  4054. part of {\tt EXPRN} left after the leading term is removed). If {\tt
  4055. EXPRN} does not depend on the variable {\tt VAR}, 0 is returned.
  4056. {\it Examples:}
  4057. {\small\begin{verbatim}
  4058. reduct((a+b)*(c+2*d),a) -> B*(C + 2*D)
  4059. reduct((a+b)*(c+2*d),d) -> C*(A + B)
  4060. reduct((a+b)*(c+2*d),e) -> 0
  4061. \end{verbatim}}
  4062. {\COMPATNOTE} In some earlier versions of REDUCE, {\tt REDUCT} returned
  4063. {\tt EXPRN} if it did not depend on {\tt VAR}. In the present version, {\tt
  4064. EXPRN} is always equal to {\tt LTERM(EXPRN,VAR)} $+$ {\tt
  4065. REDUCT(EXPRN,VAR)}.
  4066. \section{Polynomial Coefficient Arithmetic}\index{Coefficient}
  4067. {\REDUCE} allows for a variety of numerical domains for the numerical
  4068. coefficients of polynomials used in calculations. The default mode is
  4069. integer arithmetic, although the possibility of using real coefficients
  4070. \index{Real coefficient} has been discussed elsewhere. Rational
  4071. coefficients have also been available by using integer coefficients in
  4072. both the numerator and denominator of an expression, using the {\tt ON
  4073. DIV}\ttindex{DIV} option to print the coefficients as rationals.
  4074. However, {\REDUCE} includes several other coefficient options in its basic
  4075. version which we shall describe in this section. All such coefficient
  4076. modes are supported in a table-driven manner so that it is
  4077. straightforward to extend the range of possibilities. A description of
  4078. how to do this is given in R.J. Bradford, A.C. Hearn, J.A. Padget and
  4079. E. Schr\"ufer, ``Enlarging the {\REDUCE} Domain of Computation,'' Proc. of
  4080. SYMSAC '86, ACM, New York (1986), 100--106.
  4081. \subsection{Rational Coefficients in Polynomials}\index{Coefficient}
  4082. \index{Rational coefficient}
  4083. Instead of treating rational numbers as the numerator and denominator of a
  4084. rational expression, it is also possible to use them as polynomial
  4085. coefficients directly. This is accomplished by turning on the switch
  4086. {\tt RATIONAL}.\ttindex{RATIONAL}
  4087. {\it Example:} With {\tt RATIONAL} off, the input expression {\tt a/2}
  4088. would be converted into a rational expression, whose numerator was {\tt A}
  4089. and denominator 2. With {\tt RATIONAL} on, the same input would become a
  4090. rational expression with numerator {\tt 1/2*A} and denominator {\tt 1}.
  4091. Thus the latter can be used in operations that require polynomial input
  4092. whereas the former could not.
  4093. \subsection{Real Coefficients in Polynomials}\index{Coefficient}
  4094. \index{Real coefficient}
  4095. The switch {\tt ROUNDED}\ttindex{ROUNDED} permits the use of arbitrary
  4096. sized real coefficients in polynomial expressions. The actual precision
  4097. of these coefficients can be set by the operator {\tt PRECISION}.
  4098. \ttindex{PRECISION} For example, {\tt precision 50;} sets the precision to
  4099. fifty decimal digits. The default precision is system dependent and can
  4100. be found by {\tt precision 0;}. In this mode, denominators are
  4101. automatically made monic, and an appropriate adjustment is made to the
  4102. numerator.
  4103. {\it Example:} With {\tt ROUNDED} on, the input expression {\tt a/2} would
  4104. be converted into a rational expression whose numerator is {\tt 0.5*A} and
  4105. denominator {\tt 1}.
  4106. Internally, {\REDUCE} uses floating point numbers up to the precision
  4107. supported by the underlying machine hardware, and so-called {\em
  4108. bigfloats} for higher precision or whenever necessary to represent numbers
  4109. whose value cannot be represented in floating point. The internal
  4110. precision is two decimal digits greater than the external precision to
  4111. guard against roundoff inaccuracies. Bigfloats represent the fraction and
  4112. exponent parts of a floating-point number by means of (arbitrary
  4113. precision) integers, which is a more precise representation in many cases
  4114. than the machine floating point arithmetic, but not as efficient. If a
  4115. case arises where use of the machine arithmetic leads to problems, a user
  4116. can force {\REDUCE} to use the bigfloat representation at all precisions by
  4117. turning on the switch {\tt ROUNDBF}.\ttindex{ROUNDBF} In rare cases,
  4118. this switch is turned on by the system, and the user informed by the
  4119. message
  4120. {\small\begin{verbatim}
  4121. ROUNDBF turned on to increase accuracy
  4122. \end{verbatim}}
  4123. Rounded numbers are normally printed to the specified precision. However,
  4124. if the user wishes to print such numbers with less precision, the printing
  4125. precision can be set by the command {\tt PRINT\_PRECISION}.
  4126. \ttindex{PRINT\_PRECISION} For example, {\tt print\_precision 5;} will
  4127. cause such numbers to be printed with five digits maximum.
  4128. Under normal circumstances when {\tt ROUNDED} is on, {\REDUCE} converts the
  4129. number 1.0 to the integer 1. If this is not desired, the switch
  4130. {\tt NOCONVERT}\ttindex{NOCONVERT} can be turned on.
  4131. Numbers that are stored internally as bigfloats are normally printed with
  4132. a space between every five digits to improve readability. If this
  4133. feature is not required, it can be suppressed by turning off the switch
  4134. {\tt BFSPACE}.\ttindex{BFSPACE}
  4135. Further information on the bigfloat arithmetic may be found in T. Sasaki,
  4136. ``Manual for Arbitrary Precision Real Arithmetic System in {\REDUCE}'',
  4137. Department of Computer Science, University of Utah, Technical Note No.
  4138. TR-8 (1979).
  4139. When a real number is input, it is normally truncated to the precision in
  4140. effect at the time the number is read. If it is desired to keep the full
  4141. precision of all numbers input, the switch {\tt ADJPREC}\ttindex{ADJPREC}
  4142. (for {\em adjust precision\/}) can be turned on. While on, {\tt ADJPREC}
  4143. will automatically increase the precision, when necessary, to match that
  4144. of any integer or real input, and a message printed to inform the user of
  4145. the precision increase.
  4146. When {\tt ROUNDED} is on, rational numbers are normally converted to
  4147. rounded representation. However, if a user wishes to keep such numbers in
  4148. a rational form until used in an operation that returns a real number,
  4149. the switch {\tt ROUNDALL}\ttindex{ROUNDALL} can be turned off. This
  4150. switch is normally on.
  4151. Results from rounded calculations are returned in rounded form with two
  4152. exceptions: if the result is recognized as {\tt 0} or {\tt 1} to the
  4153. current precision, the integer result is returned.
  4154. \subsection{Modular Number Coefficients in Polynomials}\index{Coefficient}
  4155. \index{Modular coefficient}
  4156. {\REDUCE} includes facilities for manipulating polynomials whose
  4157. coefficients are computed modulo a given base. To use this option, two
  4158. commands must be used; {\tt SETMOD} {\tt <integer>},\ttindex{SETMOD} to set
  4159. the prime modulus, and {\tt ON MODULAR}\ttindex{MODULAR} to cause the
  4160. actual modular calculations to occur.
  4161. For example, with {\tt setmod 3;} and {\tt on modular;}, the polynomial
  4162. {\tt (a+2*b)\verb|^|3} would become {\tt A\verb|^|3+2*B\verb|^|3}.
  4163. The argument of {\tt SETMOD} is evaluated algebraically, except that
  4164. non-modular (integer) arithmetic is used. Thus the sequence
  4165. {\small\begin{verbatim}
  4166. setmod 3; on modular; setmod 7;
  4167. \end{verbatim}}
  4168. will correctly set the modulus to 7.
  4169. Modular numbers are by default represented by integers in the interval
  4170. [0,p-1] where p is the current modulus. Sometimes it is more convenient
  4171. to use an equivalent symmetric representation in the interval
  4172. [-p/2+1,p/2], or more precisely
  4173. [-floor((p-1)/2), ceiling((p-1)/2)],
  4174. especially if the modular numbers map objects that include
  4175. negative quantities. The switch {\tt BALANCED\_MOD}\ttindex{BALANCED\_MOD}
  4176. allows you to select the symmetric representation for output.
  4177. Users should note that the modular calculations are on the polynomial
  4178. coefficients only. It is not currently possible to reduce the exponents
  4179. since no check for a prime modulus is made (which would allow
  4180. $x^{p-1}$ to be reduced to 1 mod p). Note also that any division by a
  4181. number not co-prime with the modulus will result in the error ``Invalid
  4182. modular division''.
  4183. \subsection{Complex Number Coefficients in Polynomials}\index{Coefficient}
  4184. \index{Complex coefficient}
  4185. Although {\REDUCE} routinely treats the square of the variable {\em i\/} as
  4186. equivalent to $-1$, this is not sufficient to reduce expressions involving
  4187. {\em i\/} to lowest terms, or to factor such expressions over the complex
  4188. numbers. For example, in the default case,
  4189. {\small\begin{verbatim}
  4190. factorize(a^2+1);
  4191. \end{verbatim}}
  4192. gives the result
  4193. {\small\begin{verbatim}
  4194. {{A**2+1,1}}
  4195. \end{verbatim}}
  4196. and
  4197. {\small\begin{verbatim}
  4198. (a^2+b^2)/(a+i*b)
  4199. \end{verbatim}}
  4200. is not reduced further. However, if the switch
  4201. {\tt COMPLEX}\ttindex{COMPLEX} is turned on, full complex arithmetic is then
  4202. carried out. In other words, the above factorization will give the result
  4203. {\small\begin{verbatim}
  4204. {{A + I,1},{A - I,1}}
  4205. \end{verbatim}}
  4206. and the quotient will be reduced to {\tt A-I*B}.
  4207. The switch {\tt COMPLEX} may be combined with {\tt ROUNDED} to give complex
  4208. real numbers; the appropriate arithmetic is performed in this case.
  4209. Complex conjugation is used to remove complex numbers from denominators of
  4210. expressions. To do this if {\tt COMPLEX} is off, you must turn the switch
  4211. {\tt RATIONALIZE}\ttindex{RATIONALIZE} on.
  4212. \chapter{Substitution Commands}\index{Substitution}
  4213. An important class of commands in {\REDUCE} define
  4214. substitutions for variables and expressions to be made during the
  4215. evaluation of expressions. Such substitutions use the prefix operator
  4216. {\tt SUB}, various forms of the command {\tt LET}, and rule sets.
  4217. \section{SUB Operator}\ttindex{SUB}
  4218. Syntax:
  4219. {\small\begin{verbatim}
  4220. SUB(<substitution_list>,EXPRN1:algebraic):algebraic
  4221. \end{verbatim}}
  4222. where {\tt <substitution\_list>} is a list of one or more equations of the
  4223. form
  4224. {\small\begin{verbatim}
  4225. VAR:kernel=EXPRN:algebraic
  4226. \end{verbatim}}
  4227. or a kernel that evaluates to such a list.
  4228. The {\tt SUB} operator gives the algebraic result of replacing every
  4229. occurrence of the variable {\tt VAR} in the expression {\tt EXPRN1} by the
  4230. expression {\tt EXPRN}. Specifically, {\tt EXPRN1} is first evaluated
  4231. using all available rules. Next the substitutions are made, and finally
  4232. the substituted expression is reevaluated. When more than one variable
  4233. occurs in the substitution list, the substitution is performed by
  4234. recursively walking down the tree representing {\tt EXPRN1}, and replacing
  4235. every {\tt VAR} found by the appropriate {\tt EXPRN}. The {\tt EXPRN} are
  4236. not themselves searched for any occurrences of the various {\tt VAR}s.
  4237. The trivial case {\tt SUB(EXPRN1)} returns the algebraic value of
  4238. {\tt EXPRN1}.
  4239. {\it Examples:}
  4240. {\small\begin{verbatim}
  4241. 2 2
  4242. sub({x=a+y,y=y+1},x^2+y^2) -> A + 2*A*Y + 2*Y + 2*Y + 1
  4243. \end{verbatim}}
  4244. and with {\tt s := \{x=a+y,y=y+1\}},
  4245. {\small\begin{verbatim}
  4246. 2 2
  4247. sub(s,x^2+y^2) -> A + 2*A*Y + 2*Y + 2*Y + 1
  4248. \end{verbatim}}
  4249. Note that the global assignments {\tt x:=a+y}, etc., do not take place.
  4250. {\tt EXPRN1} can be any valid algebraic expression whose type is such that
  4251. a substitution process is defined for it (e.g., scalar expressions, lists
  4252. and matrices). An error will occur if an expression of an invalid type
  4253. for substitution occurs either in {\tt EXPRN} or {\tt EXPRN1}.
  4254. The braces around the substitution list may also be omitted, as in:
  4255. {\small\begin{verbatim}
  4256. 2 2
  4257. sub(x=a+y,y=y+1,x^2+y^2) -> A + 2*A*Y + 2*Y + 2*Y + 1
  4258. \end{verbatim}}
  4259. \section{LET Rules}\ttindex{LET}
  4260. Unlike substitutions introduced via {\tt SUB}, {\tt LET}
  4261. rules are global in scope and stay in effect until replaced or {\tt CLEAR}ed.
  4262. The simplest use of the {\tt LET} statement is in the form
  4263. {\small\begin{verbatim}
  4264. LET <substitution list>
  4265. \end{verbatim}}
  4266. where {\tt <substitution list>} is a list of rules separated by commas, each
  4267. of the form:
  4268. {\small\begin{verbatim}
  4269. <variable> = <expression>
  4270. \end{verbatim}}
  4271. or
  4272. {\small\begin{verbatim}
  4273. <prefix operator>(<argument>,...,<argument>) = <expression>
  4274. \end{verbatim}}
  4275. or
  4276. {\small\begin{verbatim}
  4277. <argument> <infix operator>,..., <argument> = <expression>
  4278. \end{verbatim}}
  4279. For example,
  4280. {\small\begin{verbatim}
  4281. let {x = y^2,
  4282. h(u,v) = u - v,
  4283. cos(pi/3) = 1/2,
  4284. a*b = c,
  4285. l+m = n,
  4286. w^3 = 2*z - 3,
  4287. z^10 = 0}
  4288. \end{verbatim}}
  4289. The list brackets can be left out if preferred. The above rules could
  4290. also have been entered as seven separate {\tt LET} statements.
  4291. After such {\tt LET} rules have been input, {\tt X} will always be
  4292. evaluated as the square of {\tt Y}, and so on. This is so even if at the
  4293. time the {\tt LET} rule was input, the variable {\tt Y} had a value other
  4294. than {\tt Y}. (In contrast, the assignment {\tt x:=y\verb|^|2} will set {\tt X}
  4295. equal to the square of the current value of {\tt Y}, which could be quite
  4296. different.)
  4297. The rule {\tt let a*b=c} means that whenever {\tt A} and {\tt B} are both
  4298. factors in an expression their product will be replaced by {\tt C}. For
  4299. example, {\tt a\verb|^|5*b\verb|^|7*w} would be replaced by
  4300. {\tt c\verb|^|5*b\verb|^|2*w}.
  4301. The rule for {\tt l+m} will not only replace all occurrences of {\tt l+m}
  4302. by {\tt N}, but will also normally replace {\tt L} by {\tt n-m}, but not
  4303. {\tt M} by {\tt n-l}. A more complete description of this case is given
  4304. in Section~\ref{sec-gensubs}.
  4305. The rule pertaining to {\tt w\verb|^|3} will apply to any power of {\tt W}
  4306. greater than or equal to the third.
  4307. Note especially the last example, {\tt let z\verb|^|10=0}. This declaration
  4308. means, in effect: ignore the tenth or any higher power of {\tt Z}. Such
  4309. declarations, when appropriate, often speed up a computation to a
  4310. considerable degree. (See\index{Asymptotic command}
  4311. Section~\ref{sec-asymp} for more details.)
  4312. Any new operators occurring in such {\tt LET} rules will be automatically
  4313. declared {\tt OPERATOR} by the system, if the rules are being read from a
  4314. file. If they are being entered interactively, the system will ask
  4315. {\tt DECLARE} ... {\tt OPERATOR?} . Answer {\tt Y} or {\tt N} and hit
  4316. \key{Return}.
  4317. In each of these examples, substitutions are only made for the explicit
  4318. expressions given; i.e., none of the variables may be considered arbitrary
  4319. in any sense. For example, the command
  4320. {\small\begin{verbatim}
  4321. let h(u,v) = u - v;
  4322. \end{verbatim}}
  4323. will cause {\tt h(u,v)} to evaluate to {\tt U - V}, but will not affect
  4324. {\tt h(u,z)} or {\tt H} with any arguments other than precisely the
  4325. symbols {\tt U,V}.
  4326. These simple {\tt LET} rules are on the same logical level as assignments
  4327. made with the := operator. An assignment {\tt x := p+q} cancels a rule
  4328. {\tt let x = y\verb|^|2} made earlier, and vice versa.
  4329. {\it CAUTION:} A recursive rule such as
  4330. {\small\begin{verbatim}
  4331. let x = x + 1;
  4332. \end{verbatim}}
  4333. is erroneous, since any subsequent evaluation of {\tt X} would lead to a
  4334. non-terminating chain of substitutions:
  4335. {\small\begin{verbatim}
  4336. x -> x + 1 -> (x + 1) + 1 -> ((x + 1) + 1) + 1 -> ...
  4337. \end{verbatim}}
  4338. Similarly, coupled substitutions such as
  4339. {\small\begin{verbatim}
  4340. let l = m + n, n = l + r;
  4341. \end{verbatim}}
  4342. would lead to the same error. As a result, if you try to evaluate an {\tt X},
  4343. {\tt L} or {\tt N} defined as above, you will get an error such as
  4344. {\small\begin{verbatim}
  4345. X improperly defined in terms of itself
  4346. \end{verbatim}}
  4347. Array and matrix elements can appear on the left-hand side of a {\tt LET}
  4348. statement. However, because of their {\em instant evaluation\/}
  4349. \index{Instant evaluation} property, it is the value of the element that
  4350. is substituted for, rather than the element itself. E.g.,
  4351. {\small\begin{verbatim}
  4352. array a(5);
  4353. a(2) := b;
  4354. let a(2) = c;
  4355. \end{verbatim}}
  4356. results in {\tt B} being substituted by {\tt C}; the assignment for
  4357. {\tt a(2)} does not change.
  4358. Finally, if an error occurs in any equation in a {\tt LET} statement
  4359. (including generalized statements involving {\tt FOR ALL} and {\tt SUCH
  4360. THAT)}, the remaining rules are not evaluated.
  4361. \subsection{FOR ALL \ldots LET}\ttindex{FOR ALL}
  4362. If a substitution for all possible values of a given argument of an
  4363. operator is required, the declaration {\tt FOR ALL} may be used. The
  4364. syntax of such a command is
  4365. {\small\begin{verbatim}
  4366. FOR ALL <variable>,...,<variable>
  4367. <LET statement> <terminator>
  4368. \end{verbatim}}
  4369. e.g.,
  4370. {\small\begin{verbatim}
  4371. for all x,y let h(x,y) = x-y;
  4372. for all x let k(x,y) = x^y;
  4373. \end{verbatim}}
  4374. The first of these declarations would cause {\tt h(a,b)} to be evaluated
  4375. as {\tt A-B}, {\tt h(u+v,u+w)} to be {\tt V-W}, etc. If the operator
  4376. symbol {\tt H} is used with more or fewer argument places, not two, the
  4377. {\tt LET} would have no effect, and no error would result.
  4378. The second declaration would cause {\tt k(a,y)} to be evaluated as
  4379. {\tt a\verb|^|y}, but would have no effect on {\tt k(a,z)} since the rule
  4380. didn't say {\tt FOR ALL Y} ... .
  4381. Where we used {\tt X} and {\tt Y} in the examples, any variables could
  4382. have been used. This use of a variable doesn't affect the value it may
  4383. have outside the {\tt LET} statement. However, you should remember what
  4384. variables you actually used. If you want to delete the rule subsequently,
  4385. you must use the same variables in the {\tt CLEAR} command.
  4386. It is possible to use more complicated expressions as a template for a
  4387. {\tt LET} statement, as explained in the section on substitutions for
  4388. general expressions. In nearly all cases, the rule will be accepted, and
  4389. a consistent application made by the system. However, if there is a sole
  4390. constant or a sole free variable on the left-hand side of a rule (e.g.,
  4391. {\tt let 2=3} or {\tt for all x let x=2)}, then the system is unable to
  4392. handle the rule, and the error message
  4393. {\small\begin{verbatim}
  4394. Substitution for ... not allowed
  4395. \end{verbatim}}
  4396. will be issued. Any variable listed in the {\tt FOR ALL} part will have
  4397. its symbol preceded by an equal sign: {\tt X} in the above example will
  4398. appear as {\tt =X}. An error will also occur if a variable in the
  4399. {\tt FOR ALL} part is not properly matched on both sides of the {\tt LET}
  4400. equation.
  4401. \subsection{FOR ALL \ldots SUCH THAT \ldots LET}
  4402. \ttindex{FOR ALL}\ttindex{SUCH THAT}
  4403. If a substitution is desired for more than a single value of a variable in
  4404. an operator or other expression, but not all values, a conditional form of
  4405. the {\tt FOR ALL \ldots LET} declaration can be used.
  4406. {\it Example:}
  4407. {\small\begin{verbatim}
  4408. for all x such that numberp x and x<0 let h(x)=0;
  4409. \end{verbatim}}
  4410. will cause {\tt h(-5)} to be evaluated as 0, but {\tt H} of a positive
  4411. integer, or of an argument that is not an integer at all, would not be
  4412. affected. Any boolean expression can follow the {\tt SUCH THAT} keywords.
  4413. \subsection{Removing Assignments and Substitution Rules}\ttindex{CLEAR}
  4414. The user may remove all assignments and substitution rules from any
  4415. expression by the command {\tt CLEAR}, in the form
  4416. {\small\begin{verbatim}
  4417. CLEAR <expression>,...,<expression><terminator>
  4418. \end{verbatim}}
  4419. e.g.
  4420. {\small\begin{verbatim}
  4421. clear x, h(x,y);
  4422. \end{verbatim}}
  4423. Because of their {\em instant evaluation\/} property, array and matrix elements
  4424. cannot be cleared with {\tt CLEAR}. For example, if {\tt A} is an array,
  4425. you must say
  4426. {\small\begin{verbatim}
  4427. a(3) := 0;
  4428. \end{verbatim}}
  4429. rather than
  4430. {\small\begin{verbatim}
  4431. clear a(3);
  4432. \end{verbatim}}
  4433. to ``clear'' element {\tt a(3)}.
  4434. On the other hand, a whole array (or matrix) {\tt A} can be cleared by the
  4435. command {\tt clear a}; This means much more than resetting to 0 all the
  4436. elements of {\tt A}. The fact that {\tt A} is an array, and what its
  4437. dimensions are, are forgotten, so {\tt A} can be redefined as another type
  4438. of object, for example an operator.
  4439. The more general types of {\tt LET} declarations can also be deleted by
  4440. using {\tt CLEAR}. Simply repeat the {\tt LET} rule to be deleted, using
  4441. {\tt CLEAR} in place of {\tt LET}, and omitting the equal sign and
  4442. right-hand part. The same dummy variables must be used in the {\tt FOR
  4443. ALL} part, and the boolean expression in the {\tt SUCH THAT} part must be
  4444. written the same way. (The placing of blanks doesn't have to be
  4445. identical.)
  4446. {\it Example:} The {\tt LET} rule
  4447. {\small\begin{verbatim}
  4448. for all x such that numberp x and x<0 let h(x)=0;
  4449. \end{verbatim}}
  4450. can be erased by the command
  4451. {\small\begin{verbatim}
  4452. for all x such that numberp x and x<0 clear h(x);
  4453. \end{verbatim}}
  4454. \subsection{Overlapping LET Rules}
  4455. {\tt CLEAR} is not the only way to delete a {\tt LET} rule. A new {\tt
  4456. LET} rule identical to the first, but with a different expression after
  4457. the equal sign, replaces the first. Replacements are also made in other
  4458. cases where the existing rule would be in conflict with the new rule. For
  4459. example, a rule for {\tt x\verb|^|4} would replace a rule for {\tt x\verb|^|5}.
  4460. The user should however be cautioned against having several {\tt LET}
  4461. rules in effect that relate to the same expression. No guarantee can be
  4462. given as to which rules will be applied by {\REDUCE} or in what order. It
  4463. is best to {\tt CLEAR} an old rule before entering a new related {\tt LET}
  4464. rule.
  4465. \subsection{Substitutions for General Expressions}
  4466. \label{sec-gensubs}
  4467. The examples of substitutions discussed in other sections have involved
  4468. very simple rules. However, the substitution mechanism used in {\REDUCE} is
  4469. very general, and can handle arbitrarily complicated rules without
  4470. difficulty.
  4471. The general substitution mechanism used in {\REDUCE} is discussed in Hearn, A.
  4472. C., ``{\REDUCE}, A User-Oriented Interactive System for Algebraic
  4473. Simplification,'' Interactive Systems for Experimental Applied Mathematics,
  4474. (edited by M. Klerer and J. Reinfelds), Academic Press, New York (1968),
  4475. 79-90, and Hearn. A. C., ``The Problem of Substitution,'' Proc. 1968 Summer
  4476. Institute on Symbolic Mathematical Computation, IBM Programming Laboratory
  4477. Report FSC 69-0312 (1969). For the reasons given in these
  4478. references, {\REDUCE} does not attempt to implement a general pattern
  4479. matching algorithm. However, the present system uses far more sophisticated
  4480. techniques than those discussed in the above papers. It is now possible for
  4481. the rules appearing in arguments of {\tt LET} to have the form
  4482. {\small\begin{verbatim}
  4483. <substitution expression> = <expression>
  4484. \end{verbatim}}
  4485. where any rule to which a sensible meaning can be assigned is permitted.
  4486. However, this meaning can vary according to the form of {\tt <substitution
  4487. expression>}. The semantic rules associated with the application of the
  4488. substitution are completely consistent, but somewhat complicated by the
  4489. pragmatic need to perform such substitutions as efficiently as possible.
  4490. The following rules explain how the majority of the cases are handled.
  4491. To begin with, the {\tt <substitution expression>} is first partly
  4492. simplified by collecting like terms and putting identifiers (and kernels)
  4493. in the system order. However, no substitutions are performed on any part
  4494. of the expression with the exception of expressions with the {\em instant
  4495. evaluation\/} property, such as array and matrix elements, whose actual
  4496. values are used. It should also be noted that the system order used is
  4497. not changeable by the user, even with the {\tt KORDER} command. Specific
  4498. cases are then handled as follows:
  4499. \begin{enumerate}
  4500. \item If the resulting simplified rule has a left-hand side that is an
  4501. identifier, an expression with a top-level algebraic operator or a power,
  4502. then the rule is added without further change to the appropriate table.
  4503. \item If the operator * appears at the top level of the simplified left-hand
  4504. side, then any constant arguments in that expression are moved to the
  4505. right-hand side of the rule. The remaining left-hand side is then added
  4506. to the appropriate table. For example,
  4507. {\small\begin{verbatim}
  4508. let 2*x*y=3
  4509. \end{verbatim}}
  4510. becomes
  4511. {\small\begin{verbatim}
  4512. let x*y=3/2
  4513. \end{verbatim}}
  4514. so that {\tt x*y} is added to the product substitution table, and when
  4515. this rule is applied, the expression {\tt x*y} becomes 3/2, but {\tt X} or
  4516. {\tt Y} by themselves are not replaced.
  4517. \item If the operators {\tt +}, {\tt -} or {\tt /} appear at the top level
  4518. of the simplified left-hand side, all but the first term is moved to the
  4519. right-hand side of the rule. Thus the rules
  4520. {\small\begin{verbatim}
  4521. let l+m=n, x/2=y, a-b=c
  4522. \end{verbatim}}
  4523. become
  4524. {\small\begin{verbatim}
  4525. let l=n-m, x=2*y, a=c+b.
  4526. \end{verbatim}}
  4527. \end{enumerate}
  4528. One problem that can occur in this case is that if a quantified expression
  4529. is moved to the right-hand side, a given free variable might no longer
  4530. appear on the left-hand side, resulting in an error because of the
  4531. unmatched free variable. E.g.,
  4532. {\small\begin{verbatim}
  4533. for all x,y let f(x)+f(y)=x*y
  4534. \end{verbatim}}
  4535. would become
  4536. {\small\begin{verbatim}
  4537. for all x,y let f(x)=x*y-f(y)
  4538. \end{verbatim}}
  4539. which no longer has {\tt Y} on both sides.
  4540. The fact that array and matrix elements are evaluated in the left-hand side
  4541. of rules can lead to confusion at times. Consider for example the
  4542. statements
  4543. {\small\begin{verbatim}
  4544. array a(5); let x+a(2)=3; let a(3)=4;
  4545. \end{verbatim}}
  4546. The left-hand side of the first rule will become {\tt X}, and the second
  4547. 0. Thus the first rule will be instantiated as a substitution for
  4548. {\tt X}, and the second will result in an error.
  4549. The order in which a list of rules is applied is not easily understandable
  4550. without a detailed knowledge of the system simplification protocol. It is
  4551. also possible for this order to change from release to release, as improved
  4552. substitution techniques are implemented. Users should therefore assume
  4553. that the order of application of rules is arbitrary, and program
  4554. accordingly.
  4555. After a substitution has been made, the expression being evaluated is
  4556. reexamined in case a new allowed substitution has been generated. This
  4557. process is continued until no more substitutions can be made.
  4558. As mentioned elsewhere, when a substitution expression appears in a
  4559. product, the substitution is made if that expression divides the product.
  4560. For example, the rule
  4561. {\small\begin{verbatim}
  4562. let a^2*c = 3*z;
  4563. \end{verbatim}}
  4564. would cause {\tt a\verb|^|2*c*x} to be replaced by {\tt 3*Z*X} and
  4565. {\tt a\verb|^|2*c\verb|^|2} by {\tt 3*Z*C}. If the substitution is desired only
  4566. when the substitution expression appears in a product with the explicit
  4567. powers supplied in the rule, the command {\tt MATCH} should be used
  4568. instead.\ttindex{MATCH}
  4569. For example,
  4570. {\small\begin{verbatim}
  4571. match a^2*c = 3*z;
  4572. \end{verbatim}}
  4573. would cause {\tt a\verb|^|2*c*x} to be replaced by {\tt 3*Z*X}, but
  4574. {\tt a\verb|^|2*c\verb|^|2} would not be replaced. {\tt MATCH} can also be used
  4575. with the {\tt FOR ALL} constructions described above.
  4576. To remove substitution rules of the type discussed in this section, the
  4577. {\tt CLEAR}\ttindex{CLEAR} command can be used, combined, if necessary,
  4578. with the same {\tt FOR ALL} clause with which the rule was defined, for
  4579. example:
  4580. {\small\begin{verbatim}
  4581. for all x clear log(e^x),e^log(x),cos(w*t+theta(x));
  4582. \end{verbatim}}
  4583. Note, however, that the arbitrary variable names in this case {\em must\/}
  4584. be the same as those used in defining the substitution.
  4585. \section{Rule Lists} \index{Rule lists}
  4586. Rule lists offer an alternative approach to defining substitutions that is
  4587. different from either {\tt SUB} or {\tt LET}. In fact, they provide the
  4588. best features of both, since they have all the capabilities of {\tt LET},
  4589. but the rules can also be applied locally as is possible with {\tt SUB}.
  4590. In time, they will be used more and more in {\REDUCE}. However, since they
  4591. are relatively new, much of the {\REDUCE} code you see uses the older
  4592. constructs.
  4593. A rule list is a list of {\em rules\/} that have the syntax
  4594. {\small\begin{verbatim}
  4595. <expression> => <expression> (WHEN <boolean expression>)
  4596. \end{verbatim}}
  4597. For example,
  4598. {\small\begin{verbatim}
  4599. {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
  4600. cos(~n*pi) => (-1)^n when remainder(n,2)=0}
  4601. \end{verbatim}}
  4602. The tilde preceding a variable marks that variable as {\em free\/} for that
  4603. rule, much as a variable in a {\tt FOR ALL} clause in a {\tt LET}
  4604. statement. The first occurrence of that variable in each relevant rule
  4605. must be so marked on input, otherwise inconsistent results can occur.
  4606. For example, the rule list
  4607. {\small\begin{verbatim}
  4608. {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
  4609. cos(x)^2 => (1+cos(2x))/2}
  4610. \end{verbatim}}
  4611. designed to replace products of cosines, would not be correct, since the
  4612. second rule would only apply to the explicit argument {\tt X}. Later
  4613. occurrences in the same rule may also be marked, but this is optional
  4614. (internally, all such rules are stored with each relevant variable
  4615. explicitly marked). The optional {\tt WHEN}\ttindex{WHEN} clause allows
  4616. constraints to be placed on the application of the rule, much as the {\tt
  4617. SUCH THAT} clause in a {\tt LET} statement.
  4618. A rule list may be named, for example
  4619. {\small\begin{verbatim}
  4620. trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
  4621. cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
  4622. sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
  4623. cos(~x)^2 => (1+cos(2*x))/2,
  4624. sin(~x)^2 => (1-cos(2*x))/2};
  4625. \end{verbatim}}
  4626. Such named rule lists may be inspected as needed. E.g., the command
  4627. {\tt trig1;} would cause the above list to be printed.
  4628. Rule lists may be used in two ways. They can be globally instantiated by
  4629. means of the command {\tt LET}.\ttindex{LET} For example,
  4630. {\small\begin{verbatim}
  4631. let trig1;
  4632. \end{verbatim}}
  4633. would cause the above list of rules to be globally active from then on until
  4634. cancelled by the command {\tt CLEARRULES},\ttindex{CLEARRULES} as in
  4635. {\small\begin{verbatim}
  4636. clearrules trig1;
  4637. \end{verbatim}}
  4638. {\tt CLEARRULES} has the syntax
  4639. {\small\begin{verbatim}
  4640. CLEARRULES <rule list>|<name of rule list>(,...) .
  4641. \end{verbatim}}
  4642. The second way to use rule lists is to invoke them locally by means of a
  4643. {\tt WHERE}\ttindex{WHERE} clause. For example
  4644. {\small\begin{verbatim}
  4645. cos(a)*cos(b+c)
  4646. where {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2};
  4647. \end{verbatim}}
  4648. or
  4649. {\small\begin{verbatim}
  4650. cos(a)*sin(b) where trigrules;
  4651. \end{verbatim}}
  4652. The syntax of an expression with a {\tt WHERE} clause is:
  4653. {\small\begin{verbatim}
  4654. <expression>
  4655. WHERE <rule>|<rule list>(,<rule>|<rule list> ...)
  4656. \end{verbatim}}
  4657. so the first example above could also be written
  4658. {\small\begin{verbatim}
  4659. cos(a)*cos(b+c)
  4660. where cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2;
  4661. \end{verbatim}}
  4662. The effect of this construct is that the rule list(s) in the {\tt WHERE}
  4663. clause only apply to the expression on the left of {\tt WHERE}. They have
  4664. no effect outside the expression. In particular, they do not affect
  4665. previously defined {\tt WHERE} clauses or {\tt LET} statements. For
  4666. example, the sequence
  4667. {\small\begin{verbatim}
  4668. let a=2;
  4669. a where a=>4;
  4670. a;
  4671. \end{verbatim}}
  4672. would result in the output
  4673. {\small\begin{verbatim}
  4674. 4
  4675. 2
  4676. \end{verbatim}}
  4677. Although {\tt WHERE} has a precedence less than any other infix operator,
  4678. it still binds higher than keywords such as {\tt ELSE}, {\tt THEN},
  4679. {\tt DO}, {\tt REPEAT} and so on. Thus the expression
  4680. {\small\begin{verbatim}
  4681. if a=2 then 3 else a+2 where a=3
  4682. \end{verbatim}}
  4683. will parse as
  4684. {\small\begin{verbatim}
  4685. if a=2 then 3 else (a+2 where a=3)
  4686. \end{verbatim}}
  4687. {\tt WHERE} may be used to introduce auxiliary variables in symbolic mode
  4688. expressions, as described in Section~\ref{sec-lambda}. However, the
  4689. symbolic mode use has different semantics, so expressions do not carry
  4690. from one mode to the other.
  4691. \COMPATNOTE In order to provide compatibility with older versions of rule
  4692. lists released through the Network Library, it is currently possible to use
  4693. an equal sign interchangeably with the replacement sign {\tt =>} in rules
  4694. and {\tt LET} statements. However, since this will change in future
  4695. versions, the replacement sign is preferable in rules and the equal sign
  4696. in non-rule-based {\tt LET} statements.
  4697. \subsection*{Advanced Use of Rule Lists}
  4698. Some advanced features of the rule list mechanism make it possible to
  4699. write more complicated rules than those discussed so far, and in many
  4700. cases to write more compact rule lists. These features are:
  4701. \begin{itemize}
  4702. \item Free operators
  4703. \item Double slash operator
  4704. \item Double tilde variables.
  4705. \end{itemize}
  4706. A {\bf free operator} in the left hand side of a pattern will match any
  4707. operator with the same number of arguments. The free operator is written
  4708. in the same style as a variable. For example, the implementation of the
  4709. product rule of differentiation can be written as:
  4710. {\small\begin{verbatim}
  4711. operator diff, !~f, !~g;
  4712. prule := {diff(~f(~x) * ~g(~x),x) =>
  4713. diff(f(x),x) * g(x) + diff(g(x),x) * f(x)};
  4714. let prule;
  4715. diff(sin(z)*cos(z),z);
  4716. cos(z)*diff(sin(z),z) + diff(cos(z),z)*sin(z)
  4717. \end{verbatim}}
  4718. The {\bf double slash operator} may be used as an alternative to a single
  4719. slash (quotient) in order to match quotients properly. E.g., in the
  4720. example of the Gamma function above, one can use:
  4721. {\small\begin{verbatim}
  4722. gammarule :=
  4723. {gamma(~z)//(~c*gamma(~zz)) => gamma(z)/(c*gamma(zz-1)*zz)
  4724. when fixp(zz -z) and (zz -z) >0,
  4725. gamma(~z)//gamma(~zz) => gamma(z)/(gamma(zz-1)*zz)
  4726. when fixp(zz -z) and (zz -z) >0};
  4727. let gammarule;
  4728. gamma(z)/gamma(z+3);
  4729. 1
  4730. ----------------------
  4731. 3 2
  4732. z + 6*z + 11*z + 6
  4733. \end{verbatim}}
  4734. The above example suffers from the fact that two rules had to be
  4735. written in order to perform the required operation. This can be simplified
  4736. by the use of {\bf double tilde variables}. E.g. the rule list
  4737. {\small\begin{verbatim}
  4738. GGrule := {
  4739. gamma(~z)//(~~c*gamma(~zz)) => gamma(z)/(c*gamma(zz-1)*zz)
  4740. when fixp(zz -z) and (zz -z) >0};
  4741. \end{verbatim}}
  4742. will implement the same operation in a much more compact way.
  4743. In general, double tilde variables are bound to the neutral element
  4744. with respect to the operation in which they are used.
  4745. \begin{tabular}{lll}
  4746. Pattern given & Argument used & Binding \\
  4747. \\
  4748. \symbol{126}z + \symbol{126}\symbol{126}y & x & z=x; y=0 \\
  4749. \symbol{126}z + \symbol{126}\symbol{126}y & x+3 & z=x; y=3 or z=3; y=x \\
  4750. \\
  4751. \symbol{126}z * \symbol{126}\symbol{126}y & x & z=x; y=1\\
  4752. \symbol{126}z * \symbol{126}\symbol{126}y & x*3 & z=x; y=3 or z=3; y=x\\
  4753. \\
  4754. \symbol{126}z / \symbol{126}\symbol{126}y & x & z=x; y=1\\
  4755. \symbol{126}z / \symbol{126}\symbol{126}y & x/3 & z=x; y=3 \\
  4756. \\
  4757. \end{tabular}
  4758. Remarks: A double tilde variable as the numerator of a pattern is not allowed.
  4759. Also, using double tilde variables may lead to recursion errors when the
  4760. zero case is not handled properly.
  4761. {\small\begin{verbatim}
  4762. let f(~~a * ~x,x) => a * f(x,x) when freeof (a,x);
  4763. f(z,z);
  4764. ***** f(z,z) improperly defined in terms of itself
  4765. % BUT:
  4766. let ff(~~a * ~x,x)
  4767. => a * ff(x,x) when freeof (a,x) and a neq 1;
  4768. ff(z,z);
  4769. ff(z,z)
  4770. ff(3*z,z);
  4771. 3*ff(z,z)
  4772. \end{verbatim}}
  4773. \subsection*{Displaying Rules Associated with an Operator}
  4774. The operator {\tt SHOWRULES}\ttindex{SHOWRULES} takes a single identifier
  4775. as argument, and returns in rule-list form the operator rules associated
  4776. with that argument. For example:
  4777. {\small\begin{verbatim}
  4778. showrules log;
  4779. {LOG(E) => 1,
  4780. LOG(1) => 0,
  4781. ~X
  4782. LOG(E ) => ~X,
  4783. 1
  4784. DF(LOG(~X),~X) => ----}
  4785. ~X
  4786. \end{verbatim}}
  4787. Such rules can then be manipulated further as with any list. For example
  4788. {\tt rhs first ws;} has the value {\tt 1}. Note that an operator may
  4789. have other properties that cannot be displayed in such a form, such as the
  4790. fact it is an odd function, or has a definition defined as a procedure.
  4791. \subsection*{Order of Application of Rules}
  4792. If rules have overlapping domains, their order of application is
  4793. important. In general, it is very difficult to specify this order
  4794. precisely, so that it is best to assume that the order is arbitrary.
  4795. However, if only one operator is involved, the order of application of the
  4796. rules for this operator can be determined from the following:
  4797. \begin{enumerate}
  4798. \item Rules containing at least one free variable apply before all rules
  4799. without free variables.
  4800. \item Rules activated in the most recent {\tt LET}
  4801. command are applied first.
  4802. \item {\tt LET} with several entries generate
  4803. the same order of application as a corresponding sequence of commands with
  4804. one rule or rule set each.
  4805. \item Within a rule set, the rules containing at least
  4806. one free variable are applied in their given order.
  4807. In other words, the first member of the list is applied first.
  4808. \item Consistent with the first item, any rule in a rule list that
  4809. contains no free variables is applied after all rules containing free
  4810. variables.
  4811. \end{enumerate}
  4812. {\it Example:} The following rule set enables the computation of exact
  4813. values of the Gamma function:
  4814. {\small\begin{verbatim}
  4815. operator gamma,gamma_error;
  4816. gamma_rules :=
  4817. {gamma(~x)=>sqrt(pi)/2 when x=1/2,
  4818. gamma(~n)=>factorial(n-1) when fixp n and n>0,
  4819. gamma(~n)=>gamma_error(n) when fixp n,
  4820. gamma(~x)=>(x-1)*gamma(x-1) when fixp(2*x) and x>1,
  4821. gamma(~x)=>gamma(x+1)/x when fixp(2*x)};
  4822. \end{verbatim}}
  4823. Here, rule by rule, cases of known or definitely uncomputable values
  4824. are sorted out; e.g. the rule leading to the error expression
  4825. will be applied for negative integers only, since the positive
  4826. integers are caught by the preceding rule, and the
  4827. last rule will apply for negative odd multiples of $1/2$ only.
  4828. Alternatively the first rule could have been written as
  4829. {\small\begin{verbatim}
  4830. gamma(1/2) => sqrt(pi)/2,
  4831. \end{verbatim}}
  4832. but then the case $x=1/2$ should be excluded in the {\tt WHEN} part of the
  4833. last rule explicitly because a rule without free variables cannot take
  4834. precedence over the other rules.
  4835. \section{Asymptotic Commands} \index{Asymptotic command}
  4836. \label{sec-asymp}
  4837. In expansions of polynomials involving variables that are known to be
  4838. small, it is often desirable to throw away all powers of these variables
  4839. beyond a certain point to avoid unnecessary computation. The command {\tt
  4840. LET} may be used to do this. For example, if only powers of {\tt X} up to
  4841. {\tt x\verb|^|7} are needed, the command
  4842. {\small\begin{verbatim}
  4843. let x^8 = 0;
  4844. \end{verbatim}}
  4845. will cause the system to delete all powers of {\tt X} higher than 7.
  4846. {\it CAUTION:} This particular simplification works differently from most
  4847. substitution mechanisms in {\REDUCE} in that it is applied during
  4848. polynomial manipulation rather than to the whole evaluated expression.
  4849. Thus, with the above rule in effect, {\tt x\verb|^|10/x\verb|^|5} would give the
  4850. result zero, since the numerator would simplify to zero. Similarly
  4851. {\tt x\verb|^|20/x\verb|^|10} would give a {\tt Zero divisor} error message,
  4852. since both numerator and denominator would first simplify to zero.
  4853. The method just described is not adequate when expressions involve several
  4854. variables having different degrees of smallness. In this case, it is
  4855. necessary to supply an asymptotic weight to each variable and count up the
  4856. total weight of each product in an expanded expression before deciding
  4857. whether to keep the term or not. There are two associated commands in the
  4858. system to permit this type of asymptotic constraint. The command {\tt WEIGHT}
  4859. \ttindex{WEIGHT}
  4860. takes a list of equations of the form
  4861. {\small\begin{verbatim}
  4862. <kernel form> = <number>
  4863. \end{verbatim}}
  4864. where {\tt <number>} must be a positive integer (not just evaluate to a
  4865. positive integer). This command assigns the weight {\tt <number>} to the
  4866. relevant kernel form. A check is then made in all algebraic evaluations
  4867. to see if the total weight of the term is greater than the weight level
  4868. assigned to the calculation. If it is, the term is deleted. To compute
  4869. the total weight of a product, the individual weights of each kernel form
  4870. are multiplied by their corresponding powers and then added.
  4871. The weight level of the system is initially set to 1. The user may change
  4872. this setting by the command\ttindex{WTLEVEL}
  4873. {\small\begin{verbatim}
  4874. wtlevel <number>;
  4875. \end{verbatim}}
  4876. which sets {\tt <number>} as the new weight level of the system.
  4877. {\tt <number>} must evaluate to a positive integer. WTLEVEL will also
  4878. allow NIL as an argument, in which case the current weight level is returned.
  4879. \chapter{File Handling Commands}\index{File handling}
  4880. In many applications, it is desirable to load previously prepared {\REDUCE}
  4881. files into the system, or to write output on other files. {\REDUCE} offers
  4882. four commands for this purpose, namely, {\tt IN}, {\tt OUT}, {\tt SHUT},
  4883. {\tt LOAD}, and {\tt LOAD\_PACKAGE}. The first\ttindex{IN}\ttindex{OUT}
  4884. \ttindex{SHUT} three operators are described here; {\tt LOAD} and {\tt
  4885. LOAD\_PACKAGE} are discussed in Section~\ref{sec-load}.
  4886. \section{IN Command}\ttindex{IN}
  4887. This command takes a list of file names as argument and directs the system
  4888. to input\index{Input} each file (that should contain {\REDUCE} statements
  4889. and commands) into the system. File names can either be an identifier or
  4890. a string. The explicit format of these will be system dependent and, in
  4891. many cases, site dependent. The explicit instructions for the
  4892. implementation being used should therefore be consulted for further
  4893. details. For example:
  4894. {\small\begin{verbatim}
  4895. in f1,"ggg.rr.s";
  4896. \end{verbatim}}
  4897. will first load file {\tt F1}, then {\tt ggg.rr.s}. When a semicolon is
  4898. used as the terminator of the IN statement, the statements in the file are
  4899. echoed on the terminal or written on the current output file. If \$
  4900. \index{Command terminator} is used as the terminator, the input is not
  4901. shown. Echoing of all or part of the input file can be prevented, even if
  4902. a semicolon was used, by placing an {\tt off echo;}\ttindex{ECHO} command
  4903. in the input file.
  4904. Files to be read using {\tt IN} should end with {\tt ;END;}. Note the two
  4905. semicolons! First of all, this is protection against obscure difficulties
  4906. the user will have if there are, by mistake, more {\tt BEGIN}s than
  4907. {\tt END}s on the file. Secondly, it triggers some file control book-keeping
  4908. which may improve system efficiency. If {\tt END} is omitted, an error
  4909. message {\tt "End-of-file read"} will occur.
  4910. \section{OUT Command}\ttindex{OUT}
  4911. This command takes a single file name as argument, and directs output to
  4912. that file from then on, until another {\tt OUT} changes the output file,
  4913. or {\tt SHUT} closes it. Output can go to only one file at a time,
  4914. although many can be open. If the file has previously been used for
  4915. output during the current job, and not {\tt SHUT},\ttindex{SHUT} the new
  4916. output is appended to the end of the file. Any existing file is erased
  4917. before its first use for output in a job, or if it had been {\tt SHUT}
  4918. before the new {\tt OUT}.
  4919. To output on the terminal without closing the output file, the reserved
  4920. file name T (for terminal) may be used. For example,
  4921. {\tt out ofile;} will direct output to the file {\tt OFILE} and
  4922. {\tt out t;} will direct output to the user's terminal.
  4923. The output sent to the file will be in the same form that it would have on
  4924. the terminal. In particular {\tt x\verb|^|2} would appear on two lines, an
  4925. {\tt X} on the lower line and a 2 on the line above. If the purpose of the
  4926. output file is to save results to be read in later, this is not an
  4927. appropriate form. We first must turn off the {\tt NAT} switch that
  4928. specifies that output should be in standard mathematical notation.
  4929. {\it Example:} To create a file {\tt ABCD} from which it will be possible
  4930. to read -- using {\tt IN} -- the value of the expression {\tt XYZ}:
  4931. {\small\begin{verbatim}
  4932. off echo$ % needed if your input is from a file.
  4933. off nat$ % output in IN-readable form. Each expression
  4934. % printed will end with a $ .
  4935. out abcd$ % output to new file
  4936. linelength 72$ % for systems with fixed input line length.
  4937. xyz:=xyz; % will output "XYZ := " followed by the value
  4938. % of XYZ
  4939. write ";end"$ % standard for ending files for IN
  4940. shut abcd$ % save ABCD, return to terminal output
  4941. on nat$ % restore usual output form
  4942. \end{verbatim}}
  4943. \section{SHUT Command}\ttindex{SHUT}
  4944. This command takes a list of names of files that have been previously
  4945. opened via an {\tt OUT} statement and closes them. Most systems require this
  4946. action by the user before he ends the {\REDUCE} job (if not sooner),
  4947. otherwise the output may be lost. If a file is shut and a further {\tt OUT}
  4948. command issued for the same file, the file is erased before the new output
  4949. is written.
  4950. If it is the current output file that is shut, output will switch to the
  4951. terminal. Attempts to shut files that have not been opened by {\tt OUT},
  4952. or an input file, will lead to errors.
  4953. \chapter{Commands for Interactive Use}\index{Interactive use}
  4954. {\REDUCE} is designed as an interactive system, but naturally it can also
  4955. operate in a batch processing or background mode by taking its input
  4956. command by command from the relevant input stream. There is a basic
  4957. difference, however, between interactive and batch use of the system. In
  4958. the former case, whenever the system discovers an ambiguity at some point
  4959. in a calculation, such as a forgotten type assignment for instance, it asks
  4960. the user for the correct interpretation. In batch operation, it is not
  4961. practical to terminate the calculation at such points and require
  4962. resubmission of the job, so the system makes the most obvious guess of the
  4963. user's intentions and continues the calculation.
  4964. There is also a difference in the handling of errors. In the former case,
  4965. the computation can continue since the user has the opportunity to correct
  4966. the mistake. In batch mode, the error may lead to consequent erroneous
  4967. (and possibly time consuming) computations. So in the default case, no
  4968. further evaluation occurs, although the remainder of the input is checked
  4969. for syntax errors. A message {\tt "Continuing with parsing only"}
  4970. informs the user that this is happening. On the other hand, the switch
  4971. {\tt ERRCONT},\ttindex{ERRCONT} if on, will cause the system to continue
  4972. evaluating expressions after such errors occur.
  4973. When a syntactical error occurs, the place where the system detected the
  4974. error is marked with three dollar signs (\$\$\$). In interactive mode, the
  4975. user can then use {\tt ED}\ttindex{ED} to correct the error, or retype the
  4976. command. When a non-syntactical error occurs in interactive mode, the
  4977. command being evaluated at the time the last error occurred is saved, and
  4978. may later be reevaluated by the command {\tt RETRY}.\ttindex{RETRY}
  4979. \section{Referencing Previous Results}
  4980. It is often useful to be able to reference results of previous
  4981. computations during a {\REDUCE} session. For this purpose, {\REDUCE}
  4982. maintains a history\index{History} of all interactive inputs and the
  4983. results of all interactive computations during a given session. These
  4984. results are referenced by the command number that {\REDUCE} prints
  4985. automatically in interactive mode. To use an input expression in a new
  4986. computation, one writes {\tt input(}$n${\tt )},\ttindex{INPUT} where
  4987. $n$ is the command number. To use an output expression, one writes {\tt
  4988. WS(}$n${\tt )}.\ttindex{WS} {\tt WS} references the previous command.
  4989. E.g., if command number 1 was {\tt INT(X-1,X)}; and the result of command
  4990. number 7 was {\tt X-1}, then
  4991. {\small\begin{verbatim}
  4992. 2*input(1)-ws(7)^2;
  4993. \end{verbatim}}
  4994. would give the result {\tt -1}, whereas
  4995. {\small\begin{verbatim}
  4996. 2*ws(1)-ws(7)^2;
  4997. \end{verbatim}}
  4998. would yield the same result, but {\em without\/} a recomputation of the
  4999. integral.
  5000. The operator {\tt DISPLAY}\ttindex{DISPLAY} is available to display previous
  5001. inputs. If its argument is a positive integer, {\it n} say, then the
  5002. previous n inputs are displayed. If its argument is {\tt ALL} (or in fact
  5003. any non-numerical expression), then all previous inputs are displayed.
  5004. \section{Interactive Editing}
  5005. It is possible when working interactively to edit any {\REDUCE} input that
  5006. comes from the user's terminal, and also some user-defined procedure
  5007. definitions. At the top level, one can access any previous command string
  5008. by the command {\tt ed(}$n${\tt )},\ttindex{ED} where n is the desired
  5009. command number as prompted by the system in interactive mode. {\tt ED};
  5010. (i.e. no argument) accesses the previous command.
  5011. After {\tt ED} has been called, you can now edit the displayed string using a
  5012. string editor with the following commands:
  5013. \begin{tabular}{lp{\rboxwidth}}
  5014. {\tt~~~~~ B} & move pointer to beginning \\
  5015. {\tt~~~~~ C<character>} & replace next character by
  5016. {\em character} \\
  5017. {\tt~~~~~ D} & delete next character \\
  5018. {\tt~~~~~ E} & end editing and reread text \\
  5019. {\tt~~~~~ F<character>} & move pointer to next
  5020. occurrence of {\em character} \\[1.7pt]
  5021. {\tt~~~~~ I<string><escape>} &
  5022. insert {\em string\/} in front of pointer \\
  5023. {\tt~~~~~ K<character>} & delete all characters
  5024. until {\em character} \\
  5025. {\tt~~~~~ P} & print string from current pointer \\
  5026. {\tt~~~~~ Q} & give up with error exit \\
  5027. {\tt~~~~~ S<string><escape>} &
  5028. search for first occurrence of {\em string},
  5029. positioning pointer just before it \\
  5030. {\tt~~~~~ space} or {\tt X} & move pointer right
  5031. one character.
  5032. \end{tabular}
  5033. The above table can be displayed online by typing a question mark followed
  5034. by a carriage return to the editor. The editor prompts with an angle
  5035. bracket. Commands can be combined on a single line, and all command
  5036. sequences must be followed by a carriage return to become effective.
  5037. Thus, to change the command {\tt x := a+1;} to {\tt x := a+2}; and cause
  5038. it to be executed, the following edit command sequence could be used:
  5039. {\small\begin{verbatim}
  5040. f1c2e<return>.
  5041. \end{verbatim}}
  5042. The interactive editor may also be used to edit a user-defined procedure that
  5043. has not been compiled. To do this, one says:
  5044. \ttindex{EDITDEF}
  5045. {\small\begin{verbatim}
  5046. editdef <id>;
  5047. \end{verbatim}}
  5048. where {\tt <id>} is the name of the procedure. The procedure definition
  5049. will then be displayed in editing mode, and may then be edited and
  5050. redefined on exiting from the editor.
  5051. Some versions of {\REDUCE} now include input editing that uses the
  5052. capabilities of modern window systems. Please consult your system
  5053. dependent documentation to see if this is possible. Such editing
  5054. techniques are usually much easier to use then {\tt ED} or {\tt EDITDEF}.
  5055. \section{Interactive File Control}
  5056. If input is coming from an external file, the system treats it as a batch
  5057. processed calculation. If the user desires interactive
  5058. \index{Interactive use} response in this case, he can include the command
  5059. {\tt on int};\ttindex{INT} in the file. Likewise, he can issue the
  5060. command {\tt off int}; in the main program if he does not desire continual
  5061. questioning from the system. Regardless of the setting of {\tt INT},
  5062. input commands from a file are not kept in the system, and so cannot be
  5063. edited using {\tt ED}. However, many implementations of {\REDUCE} provide
  5064. a link to an external system editor that can be used for such editing.
  5065. The specific instructions for the particular implementation should be
  5066. consulted for information on this.
  5067. Two commands are available in {\REDUCE} for interactive use of files. {\tt
  5068. PAUSE};\ttindex{PAUSE} may be inserted at any point in an input file. When
  5069. this command is encountered on input, the system prints the message {\tt
  5070. CONT?} on the user's terminal and halts. If the user responds {\tt Y}
  5071. (for yes), the calculation continues from that point in the file. If the
  5072. user responds {\tt N} (for no), control is returned to the terminal, and
  5073. the user can input further statements and commands. Later on he can use
  5074. the command {\tt cont;}\ttindex{CONT} to transfer control back to the
  5075. point in the file following the last {\tt PAUSE} encountered. A top-level
  5076. {\tt pause;}\ttindex{PAUSE} from the user's terminal has no effect.
  5077. \chapter{Matrix Calculations} \index{Matrix calculations}
  5078. A very powerful feature of {\REDUCE} is the ease with which matrix
  5079. calculations can be performed. To extend our syntax to this class of
  5080. calculations we need to add another prefix operator, {\tt MAT},
  5081. \ttindex{MAT} and a further
  5082. variable and expression type as follows:
  5083. \section{MAT Operator}\ttindex{MAT}
  5084. This prefix operator is used to represent $n\times m$ matrices. {\tt
  5085. MAT} has {\em n} arguments interpreted as rows of the matrix, each of
  5086. which is a list of {\em m} expressions representing elements in that row.
  5087. For example, the matrix
  5088. \[ \left( \begin{array}{lcr} a & b & c \\ d & e & f \end{array} \right) \]
  5089. would be written as {\tt mat((a,b,c),(d,e,f))}.
  5090. Note that the single column matrix
  5091. \[ \left( \begin{array}{c} x \\ y \end{array} \right) \]
  5092. becomes {\tt mat((x),(y))}. The inside parentheses are required to
  5093. distinguish it from the single row matrix
  5094. \[ \left( \begin{array}{lr} x & y \end{array} \right) \]
  5095. that would be written as {\tt mat((x,y))}.
  5096. \section{Matrix Variables}
  5097. An identifier may be declared a matrix variable by the declaration {\tt
  5098. MATRIX}.\ttindex{MATRIX}
  5099. The size of the matrix may be declared explicitly in the matrix
  5100. declaration, or by default in assigning such a variable to a matrix
  5101. expression. For example,
  5102. {\small\begin{verbatim}
  5103. matrix x(2,1),y(3,4),z;
  5104. \end{verbatim}}
  5105. declares {\tt X} to be a 2 x 1 (column) matrix, {\tt Y} to be a 3 x 4
  5106. matrix and {\tt Z} a matrix whose size is to be declared later.
  5107. Matrix declarations can appear anywhere in a program. Once a symbol is
  5108. declared to name a matrix, it can not also be used to name an array,
  5109. operator or a procedure, or used as an ordinary variable. It can however
  5110. be redeclared to be a matrix, and its size may be changed at that time.
  5111. Note however that matrices once declared are {\em global\/} in scope, and so
  5112. can then be referenced anywhere in the program. In other words, a
  5113. declaration within a block (or a procedure) does not limit the scope of
  5114. the matrix to that block, nor does the matrix go away on exiting the block
  5115. (use {\tt CLEAR} instead for this purpose). An element of a matrix is
  5116. referred to in the expected manner; thus {\tt x(1,1)} gives the first
  5117. element of the matrix {\tt X} defined above. References to elements of a
  5118. matrix whose size has not yet been declared leads to an error. All
  5119. elements of a matrix whose size is declared are initialized to 0. As a
  5120. result, a matrix element has an {\em instant evaluation\/}\index{Instant
  5121. evaluation} property and cannot stand for itself. If this is required,
  5122. then an operator should be used to name the matrix elements as in:
  5123. {\small\begin{verbatim}
  5124. matrix m; operator x; m := mat((x(1,1),x(1,2));
  5125. \end{verbatim}}
  5126. \section{Matrix Expressions}
  5127. These follow the normal rules of matrix algebra as defined by the
  5128. following syntax:\ttindex{MAT}
  5129. {\small\begin{verbatim}
  5130. <matrix expression> ::=
  5131. MAT<matrix description>|<matrix variable>|
  5132. <scalar expression>*<matrix expression>|
  5133. <matrix expression>*<matrix expression>
  5134. <matrix expression>+<matrix expression>|
  5135. <matrix expression>^<integer>|
  5136. <matrix expression>/<matrix expression>
  5137. \end{verbatim}}
  5138. Sums and products of matrix expressions must be of compatible size;
  5139. otherwise an error will result during their evaluation. Similarly, only
  5140. square matrices may be raised to a power. A negative power is computed as
  5141. the inverse of the matrix raised to the corresponding positive power.
  5142. {\tt a/b} is interpreted as {\tt a*b\verb|^|(-1)}.
  5143. {\it Examples:}
  5144. Assuming {\tt X} and {\tt Y} have been declared as matrices, the following
  5145. are matrix expressions
  5146. {\small\begin{verbatim}
  5147. y
  5148. y^2*x-3*y^(-2)*x
  5149. y + mat((1,a),(b,c))/2
  5150. \end{verbatim}}
  5151. The computation of the quotient of two matrices normally uses a two-step
  5152. elimination method due to Bareiss. An alternative method using Cramer's
  5153. method is also available. This is usually less efficient than the Bareiss
  5154. method unless the matrices are large and dense, although we have no solid
  5155. statistics on this as yet. To use Cramer's method instead, the switch
  5156. {\tt CRAMER}\ttindex{CRAMER} should be turned on.
  5157. \section{Operators with Matrix Arguments}
  5158. The operator {\tt LENGTH}\ttindex{LENGTH} applied to a matrix returns a
  5159. list of the number of rows and columns in the matrix. Other operators
  5160. useful in matrix calculations are defined in the following subsections.
  5161. Attention is also drawn to the LINALG
  5162. \extendedmanual{(chapter~\ref{LINALG})} and NORMFORM
  5163. \extendedmanual{(chapter~\ref{NORMFORM})} packages.
  5164. \subsection{DET Operator}\ttindex{DET}
  5165. Syntax:
  5166. {\small\begin{verbatim}
  5167. DET(EXPRN:matrix_expression):algebraic.
  5168. \end{verbatim}}
  5169. The operator {\tt DET} is used to represent the determinant of a square
  5170. matrix expression. E.g.,
  5171. {\small\begin{verbatim}
  5172. det(y^2)
  5173. \end{verbatim}}
  5174. is a scalar expression whose value is the determinant of the square of the
  5175. matrix {\tt Y}, and
  5176. {\small\begin{verbatim}
  5177. det mat((a,b,c),(d,e,f),(g,h,j));
  5178. \end{verbatim}}
  5179. is a scalar expression whose value is the determinant of the matrix
  5180. \[ \left( \begin{array}{lcr} a & b & c \\ d & e & f \\ g & h & j
  5181. \end{array} \right) \]
  5182. Determinant expressions have the {\em instant evaluation\/} property.
  5183. \index{Instant evaluation} In other words, the statement
  5184. {\small\begin{verbatim}
  5185. let det mat((a,b),(c,d)) = 2;
  5186. \end{verbatim}}
  5187. sets the {\em value\/} of the determinant to 2, and does not set up a rule
  5188. for the determinant itself.
  5189. \subsection{MATEIGEN Operator}\ttindex{MATEIGEN}
  5190. Syntax:
  5191. {\small\begin{verbatim}
  5192. MATEIGEN(EXPRN:matrix_expression,ID):list.
  5193. \end{verbatim}}
  5194. {\tt MATEIGEN} calculates the eigenvalue equation and the corresponding
  5195. eigenvectors of a matrix, using the variable {\tt ID} to denote the
  5196. eigenvalue. A square free decomposition of the characteristic polynomial
  5197. is carried out. The result is a list of lists of 3 elements, where the
  5198. first element is a square free factor of the characteristic polynomial,
  5199. the second its multiplicity and the third the corresponding eigenvector
  5200. (as an {\em n} by 1 matrix). If the square free decomposition was
  5201. successful, the product of the first elements in the lists is the minimal
  5202. polynomial. In the case of degeneracy, several eigenvectors can exist for
  5203. the same eigenvalue, which manifests itself in the appearance of more than
  5204. one arbitrary variable in the eigenvector. To extract the various parts
  5205. of the result use the operations defined on lists.
  5206. {\it Example:}
  5207. The command
  5208. {\small\begin{verbatim}
  5209. mateigen(mat((2,-1,1),(0,1,1),(-1,1,1)),eta);
  5210. \end{verbatim}}
  5211. gives the output
  5212. {\small\begin{verbatim}
  5213. {{ETA - 1,2,
  5214. [ARBCOMPLEX(1)]
  5215. [ ]
  5216. [ARBCOMPLEX(1)]
  5217. [ ]
  5218. [ 0 ]
  5219. },
  5220. {ETA - 2,1,
  5221. [ 0 ]
  5222. [ ]
  5223. [ARBCOMPLEX(2)]
  5224. [ ]
  5225. [ARBCOMPLEX(2)]
  5226. }}
  5227. \end{verbatim}}
  5228. \subsection{TP Operator}\ttindex{TP}
  5229. Syntax:
  5230. {\small\begin{verbatim}
  5231. TP(EXPRN:matrix_expression):matrix.
  5232. \end{verbatim}}
  5233. This operator takes a single matrix argument and returns its transpose.
  5234. \subsection{Trace Operator}\ttindex{TRACE}
  5235. Syntax:
  5236. {\small\begin{verbatim}
  5237. TRACE(EXPRN:matrix_expression):algebraic.
  5238. \end{verbatim}}
  5239. The operator {\tt TRACE} is used to represent the trace of a square matrix.
  5240. \subsection{Matrix Cofactors}\ttindex{COFACTOR}
  5241. Syntax:
  5242. {\small\begin{verbatim}
  5243. COFACTOR(EXPRN:matrix_expression,ROW:integer,COLUMN:integer):
  5244. algebraic
  5245. \end{verbatim}}
  5246. The operator {\tt COFACTOR} returns the cofactor of the element in row
  5247. {\tt ROW} and column {\tt COLUMN} of the matrix {\tt MATRIX}. Errors occur
  5248. if {\tt ROW} or {\tt COLUMN} do not simplify to integer expressions or if
  5249. {\tt MATRIX} is not square.
  5250. \subsection{NULLSPACE Operator}\ttindex{NULLSPACE}
  5251. Syntax:
  5252. {\small\begin{verbatim}
  5253. NULLSPACE(EXPRN:matrix_expression):list
  5254. \end{verbatim}}
  5255. {\tt NULLSPACE} calculates for a matrix {\tt A} a list of linear
  5256. independent vectors (a basis) whose linear combinations satisfy the
  5257. equation $A x = 0$. The basis is provided in a form such that as many
  5258. upper components as possible are isolated.
  5259. Note that with {\tt b := nullspace a} the expression {\tt length b} is the
  5260. {\em nullity\/} of A, and that {\tt second length a - length b} calculates the
  5261. {\em rank\/} of A. The rank of a matrix expression can also be found more
  5262. directly by the {\tt RANK} operator described below.
  5263. {\it Example:} The command
  5264. {\small\begin{verbatim}
  5265. nullspace mat((1,2,3,4),(5,6,7,8));
  5266. \end{verbatim}}
  5267. gives the output
  5268. {\small\begin{verbatim}
  5269. {
  5270. [ 1 ]
  5271. [ ]
  5272. [ 0 ]
  5273. [ ]
  5274. [ - 3]
  5275. [ ]
  5276. [ 2 ]
  5277. ,
  5278. [ 0 ]
  5279. [ ]
  5280. [ 1 ]
  5281. [ ]
  5282. [ - 2]
  5283. [ ]
  5284. [ 1 ]
  5285. }
  5286. \end{verbatim}}
  5287. In addition to the {\REDUCE} matrix form, {\tt NULLSPACE} accepts as input a
  5288. matrix given as a list of lists, that is interpreted as a row matrix. If
  5289. that form of input is chosen, the vectors in the result will be
  5290. represented by lists as well. This additional input syntax facilitates
  5291. the use of {\tt NULLSPACE} in applications different from classical linear
  5292. algebra.
  5293. \subsection{RANK Operator}\ttindex{RANK}
  5294. Syntax:
  5295. {\small\begin{verbatim}
  5296. RANK(EXPRN:matrix_expression):integer
  5297. \end{verbatim}}
  5298. {\tt RANK} calculates the rank of its argument, that, like {\tt NULLSPACE}
  5299. can either be a standard matrix expression, or a list of lists, that can
  5300. be interpreted either as a row matrix or a set of equations.
  5301. {\tt Example:}
  5302. {\small\begin{verbatim}
  5303. rank mat((a,b,c),(d,e,f));
  5304. \end{verbatim}}
  5305. returns the value 2.
  5306. \section{Matrix Assignments} \index{Matrix assignment}
  5307. Matrix expressions may appear in the right-hand side of assignment
  5308. statements. If the left-hand side of the assignment, which must be a
  5309. variable, has not already been declared a matrix, it is declared by default
  5310. to the size of the right-hand side. The variable is then set to the value
  5311. of the right-hand side.
  5312. Such an assignment may be used very conveniently to find the solution of a
  5313. set of linear equations. For example, to find the solution of the
  5314. following set of equations
  5315. {\small\begin{verbatim}
  5316. a11*x(1) + a12*x(2) = y1
  5317. a21*x(1) + a22*x(2) = y2
  5318. \end{verbatim}}
  5319. we simply write
  5320. {\small\begin{verbatim}
  5321. x := 1/mat((a11,a12),(a21,a22))*mat((y1),(y2));
  5322. \end{verbatim}}
  5323. \section{Evaluating Matrix Elements}
  5324. Once an element of a matrix has been assigned, it may be referred to in
  5325. standard array element notation. Thus {\tt y(2,1)} refers to the element
  5326. in the second row and first column of the matrix {\tt Y}.
  5327. \chapter{Procedures}\ttindex{PROCEDURE}
  5328. It is often useful to name a statement for repeated use in calculations
  5329. with varying parameters, or to define a complete evaluation procedure for
  5330. an operator. {\REDUCE} offers a procedural declaration for this purpose. Its
  5331. general syntax is:
  5332. {\small\begin{verbatim}
  5333. [<procedural type>] PROCEDURE <name>[<varlist>];<statement>;
  5334. \end{verbatim}}
  5335. where
  5336. {\small\begin{verbatim}
  5337. <varlist> ::= (<variable>,...,<variable>)
  5338. \end{verbatim}}
  5339. This will be explained more fully in the following sections.
  5340. In the algebraic mode of {\REDUCE} the {\tt <procedure type>} can be
  5341. omitted, since the default is {\tt ALGEBRAIC}. Procedures of type {\tt
  5342. INTEGER} or {\tt REAL} may also be used. In the former case, the system
  5343. checks that the value of the procedure is an integer. At present, such
  5344. checking is not done for a real procedure, although this will change in
  5345. the future when a more complete type checking mechanism is installed.
  5346. Users should therefore only use these types when appropriate. An empty
  5347. variable list may also be omitted.
  5348. All user-defined procedures are automatically declared to be operators.
  5349. In order to allow users relatively easy access to the whole {\REDUCE} source
  5350. program, system procedures are not protected against user redefinition. If
  5351. a procedure is redefined, a message
  5352. {\small\begin{verbatim}
  5353. *** <procedure name> REDEFINED
  5354. \end{verbatim}}
  5355. is printed. If this occurs, and the user is not redefining his own
  5356. procedure, he is well advised to rename it, and possibly start over
  5357. (because he has {\em already\/} redefined some internal procedure whose correct
  5358. functioning may be required for his job!)
  5359. All required procedures should be defined at the top level, since they
  5360. have global scope throughout a program. In particular, an attempt to
  5361. define a procedure within a procedure will cause an error to occur.
  5362. \section{Procedure Heading}\index{Procedure heading}
  5363. Each procedure has a heading consisting of the word {\tt PROCEDURE}
  5364. (optionally preceded by the word {\tt ALGEBRAIC}), followed by the name of
  5365. the procedure to be defined, and followed by its formal parameters -- the
  5366. symbols that will be used in the body of the definition to illustrate
  5367. what is to be done. There are three cases:
  5368. \begin{enumerate}
  5369. \item No parameters. Simply follow the procedure name with a terminator
  5370. (semicolon or dollar sign).
  5371. {\small\begin{verbatim}
  5372. procedure abc;
  5373. \end{verbatim}}
  5374. When such a procedure is used in an expression or command, {\tt abc()}, with
  5375. empty parentheses, must be written.
  5376. \item One parameter. Enclose it in parentheses {\em or\/} just leave at
  5377. least one space, then follow with a terminator.
  5378. {\small\begin{verbatim}
  5379. procedure abc(x);
  5380. \end{verbatim}}
  5381. or
  5382. {\small\begin{verbatim}
  5383. procedure abc x;
  5384. \end{verbatim}}
  5385. \item More than one parameter. Enclose them in parentheses, separated by
  5386. commas, then follow with a terminator.
  5387. {\small\begin{verbatim}
  5388. procedure abc(x,y,z);
  5389. \end{verbatim}}
  5390. \end{enumerate}
  5391. Referring to the last example, if later in some expression being evaluated
  5392. the symbols {\tt abc(u,p*q,123)} appear, the operations of the procedure
  5393. body will be carried out as if {\tt X} had the same value as {\tt U} does,
  5394. {\tt Y} the same value as {\tt p*q} does, and {\tt Z} the value 123. The
  5395. values of {\tt X}, {\tt Y}, {\tt Z}, after the procedure body operations
  5396. are completed are unchanged. So, normally, are the values of {\tt U},
  5397. {\tt P}, {\tt Q}, and (of course) 123. (This is technically referred to as
  5398. call by value.)\index{Call by value}
  5399. The reader will have noted the word {\em normally\/} a few lines earlier. The
  5400. call by value protections can be bypassed if necessary, as described
  5401. elsewhere.
  5402. \section{Procedure Body}\index{Procedure body}
  5403. Following the delimiter that ends the procedure heading must be a {\em
  5404. single} statement defining the action to be performed or the value to be
  5405. delivered. A terminator must follow the statement. If it is a semicolon,
  5406. the name of the procedure just defined is printed. It is not printed if a
  5407. dollar sign is used.
  5408. If the result wanted is given by a formula of some kind, the body is just
  5409. that formula, using the variables in the procedure heading.
  5410. {\it Simple Example:}
  5411. If {\tt f(x)} is to mean {\tt (x+5)*(x+6)/(x+7)}, the entire procedure
  5412. definition could read
  5413. {\small\begin{verbatim}
  5414. procedure f x; (x+5)*(x+6)/(x+7);
  5415. \end{verbatim}}
  5416. Then {\tt f(10)} would evaluate to 240/17, {\tt f(a-6)} to
  5417. {\tt A*(A-1)/(A+1)}, and so on.
  5418. {\it More Complicated Example:}
  5419. Suppose we need a function {\tt p(n,x)} that, for any positive integer
  5420. {\tt N}, is the Legendre polynomial\index{Legendre polynomials} of order
  5421. {\em n}. We can define this operator using the
  5422. textbook formula defining these functions:
  5423. \begin{displaymath}
  5424. p_n(x) = \displaystyle{1\over{n!}}\
  5425. \displaystyle{d^n\over dy^n}\ \displaystyle{{1\over{(y^2 - 2xy + 1)
  5426. ^{{1\over2}}}}}\Bigg\vert_{y=0}
  5427. \end{displaymath}
  5428. Put into words, the Legendre polynomial $p_n(x)$ is the result of
  5429. substituting $y=0$ in the $n^{th}$ partial derivative with respect to $y$
  5430. of a certain fraction involving $x$ and $y$, then dividing that by $n!$.
  5431. This verbal formula can easily be written in {\REDUCE}:
  5432. {\small\begin{verbatim}
  5433. procedure p(n,x);
  5434. sub(y=0,df(1/(y^2-2*x*y+1)^(1/2),y,n))
  5435. /(for i:=1:n product i);
  5436. \end{verbatim}}
  5437. Having input this definition, the expression evaluation
  5438. {\small\begin{verbatim}
  5439. 2p(2,w);
  5440. \end{verbatim}}
  5441. would result in the output
  5442. {\small\begin{verbatim}
  5443. 2
  5444. 3*W - 1 .
  5445. \end{verbatim}}
  5446. If the desired process is best described as a series of steps, then a group
  5447. or compound statement can be used.
  5448. \extendedmanual{\newpage}
  5449. {\it Example:}
  5450. The above Legendre polynomial example can be rewritten as a series of steps
  5451. instead of a single formula as follows:
  5452. {\small\begin{verbatim}
  5453. procedure p(n,x);
  5454. begin scalar seed,deriv,top,fact;
  5455. seed:=1/(y^2 - 2*x*y +1)^(1/2);
  5456. deriv:=df(seed,y,n);
  5457. top:=sub(y=0,deriv);
  5458. fact:=for i:=1:n product i;
  5459. return top/fact
  5460. end;
  5461. \end{verbatim}}
  5462. Procedures may also be defined recursively. In other words, the procedure
  5463. body\index{Procedure body} can include references to the procedure name
  5464. itself, or to other procedures that themselves reference the given
  5465. procedure. As an example, we can define the Legendre polynomial through
  5466. its standard recurrence relation:
  5467. {\small\begin{verbatim}
  5468. procedure p(n,x);
  5469. if n<0 then rederr "Invalid argument to P(N,X)"
  5470. else if n=0 then 1
  5471. else if n=1 then x
  5472. else ((2*n-1)*x*p(n-1,x)-(n-1)*p(n-2,x))/n;
  5473. \end{verbatim}}
  5474. The operator {\tt REDERR}\ttindex{REDERR} in the above example provides
  5475. for a simple error exit from an algebraic procedure (and also a block).
  5476. It can take a string as argument.
  5477. It should be noted however that all the above definitions of {\tt p(n,x)} are
  5478. quite inefficient if extensive use is to be made of such polynomials, since
  5479. each call effectively recomputes all lower order polynomials. It would be
  5480. better to store these expressions in an array, and then use say the
  5481. recurrence relation to compute only those polynomials that have not already
  5482. been derived. We leave it as an exercise for the reader to write such a
  5483. definition.
  5484. \section{Using LET Inside Procedures}
  5485. By using {\tt LET}\ttindex{LET} instead of an assignment in the procedure
  5486. body\index{Procedure body} it is possible to bypass the call-by-value
  5487. \index{Call by value} protection. If {\tt X} is a formal parameter or local
  5488. variable of the procedure (i.e. is in the heading or in a local
  5489. declaration), and {\tt LET} is used instead of {\tt :=} to make an
  5490. assignment to {\tt X}, e.g.
  5491. {\small\begin{verbatim}
  5492. let x = 123;
  5493. \end{verbatim}}
  5494. then it is the variable that is the value of {\tt X} that is changed.
  5495. This effect also occurs with local variables defined in a block. If the
  5496. value of {\tt X} is not a variable, but a more general expression, then it
  5497. is that expression that is used on the left-hand side of the {\tt LET}
  5498. statement. For example, if {\tt X} had the value {\tt p*q}, it is as if
  5499. {\tt let p*q = 123} had been executed.
  5500. \section{LET Rules as Procedures}
  5501. The {\tt LET}\ttindex{LET} statement offers an alternative syntax and
  5502. semantics for procedure definition.
  5503. In place of
  5504. {\small\begin{verbatim}
  5505. procedure abc(x,y,z); <procedure body>;
  5506. \end{verbatim}}
  5507. one can write
  5508. {\small\begin{verbatim}
  5509. for all x,y,z let abc(x,y,z) = <procedure body>;
  5510. \end{verbatim}}
  5511. There are several differences to note.
  5512. If the procedure body contains an assignment to one of the formal
  5513. parameters, e.g.
  5514. {\small\begin{verbatim}
  5515. x := 123;
  5516. \end{verbatim}}
  5517. in the {\tt PROCEDURE} case it is a variable holding a copy of the first
  5518. actual argument that is changed. The actual argument is not changed.
  5519. In the {\tt LET} case, the actual argument is changed. Thus, if {\tt ABC}
  5520. is defined using {\tt LET}, and {\tt abc(u,v,w)} is evaluated, the value
  5521. of {\tt U} changes to 123. That is, the {\tt LET} form of definition
  5522. allows the user to bypass the protections that are enforced by the call
  5523. by value conventions of standard {\tt PROCEDURE} definitions.
  5524. {\it Example:} We take our earlier {\tt FACTORIAL}\ttindex{FACTORIAL}
  5525. procedure and write it as a {\tt LET} statement.
  5526. {\small\begin{verbatim}
  5527. for all n let factorial n =
  5528. begin scalar m,s;
  5529. m:=1; s:=n;
  5530. l1: if s=0 then return m;
  5531. m:=m*s;
  5532. s:=s-1;
  5533. go to l1
  5534. end;
  5535. \end{verbatim}}
  5536. The reader will notice that we introduced a new local variable, {\tt S},
  5537. and set it equal to {\tt N}. The original form of the procedure contained
  5538. the statement {\tt n:=n-1;}. If the user asked for the value of {\tt
  5539. factorial(5)} then {\tt N} would correspond to, not just have the value
  5540. of, 5, and {\REDUCE} would object to trying to execute the statement
  5541. 5 := $5-1$.
  5542. If {\tt PQR} is a procedure with no parameters,
  5543. {\small\begin{verbatim}
  5544. procedure pqr;
  5545. <procedure body>;
  5546. \end{verbatim}}
  5547. it can be written as a {\tt LET} statement quite simply:
  5548. {\small\begin{verbatim}
  5549. let pqr = <procedure body>;
  5550. \end{verbatim}}
  5551. To call {\em procedure\/} {\tt PQR}, if defined in the latter form, the empty
  5552. parentheses would not be used: use {\tt PQR} not {\tt PQR()} where a call
  5553. on the procedure is needed.
  5554. The two notations for a procedure with no arguments can be combined. {\tt PQR}
  5555. can be defined in the standard {\tt PROCEDURE} form. Then a {\tt LET}
  5556. statement
  5557. {\small\begin{verbatim}
  5558. let pqr = pqr();
  5559. \end{verbatim}}
  5560. would allow a user to use {\tt PQR} instead of {\tt PQR()} in calling the
  5561. procedure.
  5562. A feature available with {\tt LET}-defined procedures and not with procedures
  5563. defined in the standard way is the possibility of defining partial
  5564. functions.\index{Function}
  5565. {\small\begin{verbatim}
  5566. for all x such that numberp x let uvw(x)=<procedure body>;
  5567. \end{verbatim}}
  5568. Now {\tt UVW} of an integer would be calculated as prescribed by the procedure
  5569. body, while {\tt UVW} of a general argument, such as {\tt Z} or {\tt p+q}
  5570. (assuming these evaluate to themselves) would simply stay {\tt uvw(z)}
  5571. or {\tt uvw(p+q)} as the case may be.
  5572. \section{REMEMBER Statement}\ttindex{REMEMBER}
  5573. Setting the remember option for an algebraic procedure by
  5574. {\small\begin{verbatim}
  5575. REMEMBER (PROCNAME:procedure);
  5576. \end{verbatim}}
  5577. saves all intermediate results of such procedure evaluations, including
  5578. recursive calls. Subsequent calls to the procedure can then be determined
  5579. from the saved results, and thus the number of evaluations (or the
  5580. complexity) can be reduced. This mode of evalation costs extra memory, of
  5581. course. In addition, the procedure must be free of side--effects.
  5582. The following examples show the effect of the remember statement
  5583. on two well--known examples.
  5584. \begin{samepage}
  5585. {\small\begin{verbatim}
  5586. procedure H(n); % Hofstadter's function
  5587. if numberp n then
  5588. << cnn := cnn +1; % counts the calls
  5589. if n < 3 then 1 else H(n-H(n-1))+H(n-H(n-2))>>;
  5590. remember h;
  5591. > << cnn := 0; H(100); cnn>>;
  5592. 100
  5593. % H has been called 100 times only.
  5594. procedure A(m,n); % Ackermann function
  5595. if m=0 then n+1 else
  5596. if n=0 then A(m-1,1) else
  5597. A(m-1,A(m,n-1));
  5598. remember a;
  5599. A(3,3);
  5600. \end{verbatim}}
  5601. \end{samepage}
  5602. \chapter{User Contributed Packages} \index{User packages}
  5603. \label{chap-user}
  5604. The complete {\REDUCE} system includes a number of packages contributed by
  5605. users that are provided as a service to the user community. Questions
  5606. regarding these packages should be directed to their individual authors.
  5607. All such packages have been precompiled as part of the installation process.
  5608. However, many must be specifically loaded before they can be used. (Those
  5609. that are loaded automatically are so noted in their description.) You should
  5610. also consult the user notes for your particular implementation for further
  5611. information on whether this is necessary. If it is, the relevant command is
  5612. {\tt LOAD\_PACKAGE},\ttindex{LOAD\_PACKAGE} which takes a list of one or
  5613. more package names as argument, for example:
  5614. {\small\begin{verbatim}
  5615. load_package algint;
  5616. \end{verbatim}}
  5617. although this syntax may vary from implementation to implementation.
  5618. Nearly all these packages come with separate documentation and test files
  5619. (except those noted here that have no additional documentation), which is
  5620. included, along with the source of the package, in the {\REDUCE} system
  5621. distribution. These items should be studied for any additional details on
  5622. the use of a particular package.
  5623. Part 2 of this manual contains short documentation for the packages
  5624. \begin{itemize}
  5625. %%
  5626. %%The packages available in the current release of {\REDUCE} are as follows:
  5627. %%
  5628. \item
  5629. {ALGINT: Integration of square roots} (chapter~\ref{ALGINT});\ttindex{ALGINT}
  5630. %%
  5631. %%This package, which is an extension of the basic integration package
  5632. %%distributed with {\REDUCE}, will analytically integrate a wide range of
  5633. %%expressions involving square roots where the answer exists in that class
  5634. %%of functions. It is an implementation of the work described in J.H.
  5635. %%Davenport, ``On the Integration of Algebraic Functions", LNCS 102,
  5636. %%Springer Verlag, 1981. Both this and the source code should be consulted
  5637. %%for a more detailed description of this work.
  5638. %%
  5639. %%Once the {\tt ALGINT} package has been loaded, using {\tt LOAD\_PACKAGE},
  5640. %%one enters an expression for integration, as with the regular integrator,
  5641. %%for example:
  5642. %%{\small\begin{verbatim}
  5643. %% int(sqrt(x+sqrt(x**2+1))/x,x);
  5644. %%\end{verbatim}}
  5645. %%If one later wishes to integrate expressions without using the facilities of
  5646. %%this package, the switch {\tt ALGINT}\ttindex{ALGINT} should be turned
  5647. %%off. This is turned on automatically when the package is loaded.
  5648. %%
  5649. %%The switches supported by the standard integrator (e.g., {\tt TRINT})
  5650. %%\ttindex{TRINT} are also supported by this package. In addition, the
  5651. %%switch {\tt TRA},\ttindex{TRA} if on, will give further tracing
  5652. %%information about the specific functioning of the algebraic integrator.
  5653. %%
  5654. %%There is no additional documentation for this package.
  5655. %%
  5656. %%Author: James H. Davenport.
  5657. %%
  5658. \item
  5659. {APPLYSYM: Infinitesimal symmetries of differential equations}
  5660. (chapter~\ref{APPLYSYM});\ttindex{APPLYSYM}
  5661. %%\ttindex{APPLYSYM}
  5662. %%
  5663. %%This package provides programs APPLYSYM, QUASILINPDE and DETRAFO for
  5664. %%computing with infinitesimal symmetries of differential equations.
  5665. %%
  5666. %%Author: Thomas Wolf.
  5667. %%
  5668. \item
  5669. {ARNUM: An algebraic number package} (chapter~\ref{ARNUM});\ttindex{ARNUM}
  5670. %%
  5671. %%This package provides facilities for handling algebraic numbers as
  5672. %%polynomial coefficients in {\REDUCE} calculations. It includes facilities for
  5673. %%introducing indeterminates to represent algebraic numbers, for calculating
  5674. %%splitting fields, and for factoring and finding greatest common divisors
  5675. %%in such domains.
  5676. %%
  5677. %%Author: Eberhard Schr\"ufer.
  5678. %%
  5679. \item
  5680. {ASSIST: Useful utilities for various applications}
  5681. (chapter~\ref{ASSIST});\ttindex{ASSIST}
  5682. %%
  5683. %%ASSIST contains a large number of additional general purpose functions
  5684. %%that allow a user to better adapt \REDUCE\ to various calculational
  5685. %%strategies and to make the programming task more straightforward and more
  5686. %%efficient.
  5687. %%
  5688. %%Author: Hubert Caprasse.
  5689. %%
  5690. \item
  5691. {AVECTOR: A vector algebra and calculus package}
  5692. (chapter~\ref{AVECTOR});\ttindex{AVECTOR}
  5693. %%
  5694. %%This package provides REDUCE with the ability to perform vector algebra
  5695. %%using the same notation as scalar algebra. The basic algebraic operations
  5696. %%are supported, as are differentiation and integration of vectors with
  5697. %%respect to scalar variables, cross product and dot product, component
  5698. %%manipulation and application of scalar functions (e.g. cosine) to a vector
  5699. %%to yield a vector result.
  5700. %%
  5701. %%Author: David Harper.
  5702. %%
  5703. \item
  5704. {BOOLEAN: A package for boolean algebra} (chapter~\ref{BOOLEAN});
  5705. \ttindex{BOOLEAN}
  5706. %%
  5707. %%This package supports the computation with boolean expressions in the
  5708. %%propositional calculus. The data objects are composed from algebraic
  5709. %%expressions connected by the infix boolean operators {\bf and}, {\bf or},
  5710. %%{\bf implies}, {\bf equiv}, and the unary prefix operator {\bf not}.
  5711. %%{\bf Boolean} allows you to simplify expressions built from these
  5712. %%operators, and to test properties like equivalence, subset property etc.
  5713. %%
  5714. %%Author: Herbert Melenk.
  5715. %%
  5716. \item
  5717. {CALI: A package for computational commutative algebra}
  5718. (chapter~\ref{CALI});\ttindex{CALI}
  5719. %%\ttindex{CALI}
  5720. %%
  5721. %%This package contains algorithms for computations in commutative algebra
  5722. %%closely related to the Gr\"obner algorithm for ideals and modules. Its
  5723. %%heart is a new implementation of the Gr\"obner algorithm that also allows
  5724. %%for the computation of syzygies. This implementation is also applicable to
  5725. %%submodules of free modules with generators represented as rows of a matrix.
  5726. %%
  5727. %%Author: Hans-Gert Gr\"abe.
  5728. %%
  5729. \item
  5730. {CAMAL: Calculations in celestial mechanics} (chapter~\ref{CAMAL});
  5731. \ttindex{CAMAL}
  5732. %%
  5733. %%This packages implements in REDUCE the Fourier transform procedures of the
  5734. %%CAMAL package for celestial mechanics.
  5735. %%
  5736. %%Author: John P. Fitch.
  5737. %%
  5738. \item
  5739. {CHANGEVR: Change of Independent Variable(s) in DEs}
  5740. (chapter~\ref{CHANGEVR});\ttindex{CHANGEVR}
  5741. %%
  5742. %%This package provides facilities for changing the independent variables in
  5743. %%a differential equation. It is basically the application of the chain rule.
  5744. %%
  5745. %%Author: G. \"{U}\c{c}oluk.
  5746. %%
  5747. \item
  5748. {COMPACT: Package for compacting expressions} (chapter~\ref{COMPACT});
  5749. \ttindex{COMPACT}
  5750. %%
  5751. %%COMPACT is a package of functions for the reduction of a polynomial in the
  5752. %%presence of side relations. COMPACT applies the side relations to the
  5753. %%polynomial so that an equivalent expression results with as few terms as
  5754. %%possible. For example, the evaluation of
  5755. %%{\small\begin{verbatim}
  5756. %% compact(s*(1-sin x^2)+c*(1-cos x^2)+sin x^2+cos x^2,
  5757. %% {cos x^2+sin x^2=1});
  5758. %%\end{verbatim}}
  5759. %%yields the result\pagebreak[1]
  5760. %%\begin{samepage}
  5761. %%{\small\begin{verbatim}
  5762. %% 2 2
  5763. %% SIN(X) *C + COS(X) *S + 1 .
  5764. %%\end{verbatim}}
  5765. %%
  5766. %%Author: Anthony C. Hearn.
  5767. %%\end{samepage}
  5768. %%
  5769. \item
  5770. {CONTFR: Approximation of a number by continued fractions}
  5771. (chapter~\ref{CONTFR});\ttindex{CONTFR}
  5772. %%
  5773. %%This package provides for the simultaneous approximation of a real number
  5774. %%by a continued fraction and a rational number with optional user
  5775. %%controlled precision (upper bound for numerator).
  5776. %%
  5777. %%To use this package, the {\bf misc} package should be loaded. One can then
  5778. %%use the operator\ttindex{continued\_fraction} to calculate the required
  5779. %%sequence. For example:
  5780. %%{\small\begin{verbatim}
  5781. %%
  5782. %% continued_fraction pi; ->
  5783. %%
  5784. %% 1146408
  5785. %% {---------,{3,7,15,1,292,1,1,1,2,1}}
  5786. %% 364913
  5787. %%\end{verbatim}}
  5788. %%
  5789. %%There is no further documentation for this package.
  5790. %%
  5791. %%Author: Herbert Melenk.
  5792. %%
  5793. \item
  5794. {CRACK: Solving overdetermined systems of PDEs or ODEs}
  5795. (chapter~\ref{CRACK});\ttindex{CRACK}
  5796. %%
  5797. %%CRACK is a package for solving overdetermined systems of partial or
  5798. %%ordinary differential equations (PDEs, ODEs). Examples of programs which
  5799. %%make use of CRACK for investigating ODEs (finding symmetries, first
  5800. %%integrals, an equivalent Lagrangian or a ``differential factorization'') are
  5801. %%included.
  5802. %%
  5803. %%Authors: Andreas Brand, Thomas Wolf.
  5804. %%
  5805. \item
  5806. {CVIT: Fast calculation of Dirac gamma matrix traces}
  5807. (chapter~\ref{CVIT});\ttindex{CVIT}
  5808. %%
  5809. %%This package provides an alternative method for computing traces of Dirac
  5810. %%gamma matrices, based on an algorithm by Cvitanovich that treats gamma
  5811. %%matrices as 3-j symbols.
  5812. %%
  5813. %%Authors: V.Ilyin, A.Kryukov, A.Rodionov, A.Taranov.
  5814. %%
  5815. \item
  5816. {DEFINT: A definite integration interface for REDUCE}
  5817. (chapter~\ref{DEFINT});\ttindex{DEFINT}
  5818. %%
  5819. %%This package finds the definite integral of an expression in a stated
  5820. %%interval. It uses several techniques, including an innovative approach
  5821. %%based on the Meijer G-function, and contour integration.
  5822. %%
  5823. %%Authors: Kerry Gaskell, Stanley M. Kameny, Winfried Neun.
  5824. %%
  5825. \item
  5826. {DESIR: Differential linear homogeneous equation solutions in the
  5827. neighborhood of irregular and regular singular points}
  5828. (chapter~\ref{DESIR});\ttindex{DESIR}
  5829. %%
  5830. %%This package enables the basis of formal solutions to be computed for an
  5831. %%ordinary homogeneous differential equation with polynomial coefficients
  5832. %%over Q of any order, in the neighborhood of zero (regular or irregular
  5833. %%singular point, or ordinary point).
  5834. %%
  5835. %%Documentation for this package is in plain text.
  5836. %%
  5837. %%Authors: C. Dicrescenzo, F. Richard-Jung, E. Tournier.
  5838. %%
  5839. \item
  5840. {DFPART: Derivatives of generic functions}
  5841. (chapter~\ref{DFPART});\ttindex{DFPART}
  5842. %%
  5843. %%This package supports computations with total and partial derivatives of
  5844. %%formal function objects. Such computations can be useful in the context
  5845. %%of differential equations or power series expansions.
  5846. %%
  5847. %%Author: Herbert Melenk.
  5848. %%
  5849. \item
  5850. {DUMMY: Canonical form of expressions with dummy variables}
  5851. (chapter~\ref{DUMMY});\ttindex{DUMMY}
  5852. %%
  5853. %%This package allows a user to find the canonical form of expressions
  5854. %%involving dummy variables. In that way, the simplification of
  5855. %%polynomial expressions can be fully done. The indeterminates are general
  5856. %%operator objects endowed with as few properties as possible. In that way
  5857. %%the package may be used in a large spectrum of applications.
  5858. %%
  5859. %%Author: Alain Dresse.
  5860. %%
  5861. \item
  5862. {EXCALC: A differential geometry package} (chapter~\ref{EXCALC});
  5863. \ttindex{EXCALC}
  5864. %%
  5865. %%EXCALC is designed for easy use by all who are familiar with the calculus
  5866. %%of Modern Differential Geometry. The program is currently able to handle
  5867. %%scalar-valued exterior forms, vectors and operations between them, as well
  5868. %%as non-scalar valued forms (indexed forms). It is thus an ideal tool for
  5869. %%studying differential equations, doing calculations in general relativity
  5870. %%and field theories, or doing simple things such as calculating the
  5871. %%Laplacian of a tensor field for an arbitrary given frame.
  5872. %%
  5873. %%Author: Eberhard Schr\"ufer.
  5874. %%
  5875. \item
  5876. {FPS: Automatic calculation of formal power series}
  5877. (chapter~\ref{FPS});\ttindex{FPS}
  5878. %%
  5879. %%This package can expand a specific class of functions into their
  5880. %%corresponding Laurent-Puiseux series.
  5881. %%
  5882. %%Authors: Wolfram Koepf and Winfried Neun.
  5883. %%
  5884. \item
  5885. {FIDE: Finite difference method for partial differential equations}
  5886. (chapter~\ref{FIDE});\ttindex{FIDE}
  5887. %%
  5888. %%This package performs automation of the process of numerically
  5889. %%solving partial differential equations systems (PDES) by means of
  5890. %%computer algebra. For PDES solving, the finite difference method is applied.
  5891. %%The computer algebra system REDUCE and the numerical programming
  5892. %%language FORTRAN are used in the presented methodology. The main aim of
  5893. %%this methodology is to speed up the process of preparing numerical
  5894. %%programs for solving PDES. This process is quite often, especially for
  5895. %%complicated systems, a tedious and time consuming task.
  5896. %%
  5897. %%Documentation for this package is in plain text.
  5898. %%
  5899. %%Author: Richard Liska.
  5900. %%
  5901. \item
  5902. {GENTRAN: A code generation package} (chapter~\ref{GENTRAN});
  5903. \ttindex{GENTRAN}
  5904. %%
  5905. %%GENTRAN is an automatic code GENerator and TRANslator. It constructs
  5906. %%complete numerical programs based on sets of algorithmic specifications
  5907. %%and symbolic expressions. Formatted FORTRAN, RATFOR, PASCAL or C code can be
  5908. %%generated through a series of interactive commands or under the control of
  5909. %%a template processing routine. Large expressions can be automatically
  5910. %%segmented into subexpressions of manageable size, and a special
  5911. %%file-handling mechanism maintains stacks of open I/O channels to allow
  5912. %%output to be sent to any number of files simultaneously and to facilitate
  5913. %%recursive invocation of the whole code generation process.
  5914. %%
  5915. %%Author: Barbara L. Gates.
  5916. %%
  5917. \item
  5918. {GNUPLOT: Display of functions and surfaces}
  5919. (chapter~\ref{GNUPLOT});\ttindex{PLOT}\ttindex{GNUPLOT}
  5920. %%
  5921. %%This package is an interface to the popular GNUPLOT package.
  5922. %%It allows you to display functions in 2D and surfaces in 3D
  5923. %%on a variety of output devices including X terminals, PC monitors, and
  5924. %%postscript and Latex printer files.
  5925. %%
  5926. %%NOTE: The GNUPLOT package may not be included in all versions of REDUCE.
  5927. %%
  5928. %%Author: Herbert Melenk.
  5929. %%
  5930. \item
  5931. {GROEBNER: A Gr\"obner basis package} (chapter~\ref{GROEBNER});
  5932. \ttindex{GROEBNER}
  5933. %%
  5934. %%GROEBNER\ttindex{GROEBNER} is a package for the computation of Gr\"obner
  5935. %%Bases using the Buchberger algorithm and related methods
  5936. %%for polynomial ideals and modules. It can be used over a variety of
  5937. %%different coefficient domains, and for different variable and term
  5938. %%orderings.
  5939. %%
  5940. %%Gr\"obner Bases can be used for various purposes in commutative
  5941. %%algebra, e.g. for elimination of variables,\index{Variable elimination}
  5942. %%converting surd expressions to implicit polynomial form,
  5943. %%computation of dimensions, solution of polynomial equation systems
  5944. %%\index{Polynomial equations} etc.
  5945. %%The package is also used internally by the {\tt SOLVE}\ttindex{SOLVE}
  5946. %%operator.
  5947. %%
  5948. %%Authors: Herbert Melenk, H.M. M\"oller and Winfried Neun.
  5949. %%
  5950. \item
  5951. {IDEALS: Arithmetic for polynomial ideals} (chapter~\ref{IDEALS});
  5952. \ttindex{IDEALS}
  5953. %%
  5954. %%This package implements the basic arithmetic for polynomial ideals by
  5955. %%exploiting the Gr\"obner bases package of REDUCE. In order to save
  5956. %%computing time all intermediate Gr\"obner bases are stored internally such
  5957. %%that time consuming repetitions are inhibited.
  5958. %%
  5959. %%Author: Herbert Melenk.
  5960. %%
  5961. \item
  5962. {INEQ: Support for solving inequalities} (chapter~\ref{INEQ});\ttindex{INEQ}
  5963. %%
  5964. %%This package supports the operator {\bf ineq\_solve} that
  5965. %%tries to solves single inequalities and sets of coupled inequalities.
  5966. %%
  5967. %%Author: Herbert Melenk.
  5968. %%
  5969. \item
  5970. {INVBASE: A package for computing involutive bases}
  5971. (chapter~\ref{INVBASE});\ttindex{INVBASE}
  5972. %%
  5973. %%Involutive bases are a new tool for solving problems in connection with
  5974. %%multivariate polynomials, such as solving systems of polynomial equations
  5975. %%and analyzing polynomial ideals. An involutive basis of polynomial ideal
  5976. %%is nothing but a special form of a redundant Gr\"obner basis. The
  5977. %%construction of involutive bases reduces the problem of solving polynomial
  5978. %%systems to simple linear algebra.
  5979. %%
  5980. %%Authors: A.Yu. Zharkov and Yu.A. Blinkov.
  5981. %%
  5982. \item
  5983. {LAPLACE: Laplace and inverse Laplace transforms}
  5984. (chapter~\ref{LAPLACE});\ttindex{LAPLACE}
  5985. %%
  5986. %%This package can calculate ordinary and inverse Laplace transforms of
  5987. %%expressions. Documentation is in plain text.
  5988. %%
  5989. %%Authors: C. Kazasov, M. Spiridonova, V. Tomov.
  5990. %%
  5991. \item
  5992. {LIE: Functions for the classification of real n-dimensional Lie
  5993. algebras} (chapter~\ref{LIE});\ttindex{LIE}
  5994. %%algebras}
  5995. %%\ttindex{LIE}
  5996. %%
  5997. %%{\bf LIE} is a package of functions for the classification of real
  5998. %%n-dimensional Lie algebras. It consists of two modules: {\bf liendmc1}
  5999. %%and {\bf lie1234}. With the help of the functions in the {\bf liendmcl}
  6000. %%module, real n-dimensional Lie algebras $L$ with a derived algebra
  6001. %%$L^{(1)}$ of dimension 1 can be classified.
  6002. %%
  6003. %%Authors: Carsten and Franziska Sch\"obel.
  6004. %%
  6005. \item
  6006. {LIMITS: A package for finding limits} (chapter~\ref{LIMITS});\ttindex{LIMITS}
  6007. %%
  6008. %%LIMITS is a fast limit package for REDUCE for functions which are
  6009. %%continuous except for computable poles and singularities, based on some
  6010. %%earlier work by Ian Cohen and John P. Fitch. The Truncated Power Series
  6011. %%package is used for non-critical points, at which the value of the
  6012. %%function is the constant term in the expansion around that point.
  6013. %%L'H\^opital's rule is used in critical cases, with preprocessing of
  6014. %%$\infty - \infty$ forms and reformatting of product forms in order to
  6015. %%be able to apply l'H\^opital's rule. A limited amount of bounded arithmetic
  6016. %%is also employed where applicable.
  6017. %%
  6018. %%This package defines a {\tt LIMIT} operator, called with the syntax:
  6019. %%{\small\begin{verbatim}
  6020. %% LIMIT(EXPRN:algebraic,VAR:kernel,LIMPOINT:algebraic):
  6021. %% algebraic.
  6022. %%\end{verbatim}}
  6023. %%For example:
  6024. %%{\small\begin{verbatim}
  6025. %% limit(x*sin(1/x),x,infinity) -> 1
  6026. %% limit(sin x/x^2,x,0) -> INFINITY
  6027. %%\end{verbatim}}
  6028. %%Direction-dependent limit operators {\tt LIMIT!+} and {\tt LIMIT!-} are
  6029. %%also defined.
  6030. %%
  6031. %%This package loads automatically.
  6032. %%
  6033. %%Author: Stanley L. Kameny.
  6034. %%
  6035. \item
  6036. {LINALG: Linear algebra package} (chapter~\ref{LINALG});\ttindex{LINALG}
  6037. %%
  6038. %%This package provides a selection of functions that are useful
  6039. %%in the world of linear algebra.
  6040. %%
  6041. %%Author: Matt Rebbeck.
  6042. %%
  6043. \item
  6044. {MODSR: Modular solve and roots} (chapter~\ref{MODSR});\ttindex{MODSR}
  6045. %%
  6046. %%This package supports solve (M\_SOLVE) and roots (M\_ROOTS) operators for
  6047. %%modular polynomials and modular polynomial systems. The moduli need not
  6048. %%be primes. M\_SOLVE requires a modulus to be set. M\_ROOTS takes the
  6049. %%modulus as a second argument. For example:
  6050. %%
  6051. %%{\small\begin{verbatim}
  6052. %%on modular; setmod 8;
  6053. %%m_solve(2x=4); -> {{X=2},{X=6}}
  6054. %%m_solve({x^2-y^3=3});
  6055. %% -> {{X=0,Y=5}, {X=2,Y=1}, {X=4,Y=5}, {X=6,Y=1}}
  6056. %%m_solve({x=2,x^2-y^3=3}); -> {{X=2,Y=1}}
  6057. %%off modular;
  6058. %%m_roots(x^2-1,8); -> {1,3,5,7}
  6059. %%m_roots(x^3-x,7); -> {0,1,6}
  6060. %%\end{verbatim}}
  6061. %%
  6062. %%There is no further documentation for this package.
  6063. %%
  6064. %%Author: Herbert Melenk.
  6065. %%
  6066. \item
  6067. {NCPOLY: Non--commutative polynomial ideals}
  6068. (chapter~\ref{NCPOLY});\ttindex{NCPOLY}
  6069. %%\ttindex{NCPOLY}
  6070. %%
  6071. %%This package allows the user to set up automatically a consistent
  6072. %%environment for computing in an algebra where the non--commutativity is
  6073. %%defined by Lie-bracket commutators. The package uses the {REDUCE} {\bf
  6074. %%noncom} mechanism for elementary polynomial arithmetic; the commutator
  6075. %%rules are automatically computed from the Lie brackets.
  6076. %%
  6077. %%Authors: Herbert Melenk and Joachim Apel.
  6078. %%
  6079. \item
  6080. {NORMFORM: Computation of matrix normal forms}
  6081. (chapter~\ref{NORMFORM});\ttindex{NORMFORM}
  6082. %%
  6083. %%This package contains routines for computing the following
  6084. %%normal forms of matrices:
  6085. %%\begin{itemize}
  6086. %%\item smithex\_int
  6087. %%\item smithex
  6088. %%\item frobenius
  6089. %%\item ratjordan
  6090. %%\item jordansymbolic
  6091. %%\item jordan.
  6092. %%\end{itemize}
  6093. %%
  6094. %%Author: Matt Rebbeck.
  6095. %%
  6096. \item
  6097. {NUMERIC: Solving numerical problems} (chapter~\ref{NUMERIC});\ttindex{NUMERIC}
  6098. %%\ttindex{NUM\_SOLVE}\index{Newton's method}\ttindex{NUM\_ODESOLVE}
  6099. %%\ttindex{BOUNDS}\index{Chebyshev fit}
  6100. %%\ttindex{NUM\_MIN}\index{Minimum}\ttindex{NUM\_INT}\index{Quadrature}
  6101. %%This package implements basic algorithms of numerical analysis.
  6102. %%These include:
  6103. %%\begin{itemize}
  6104. %%\item solution of algebraic equations by Newton's method
  6105. %%{\small\begin{verbatim}
  6106. %% num_solve({sin x=cos y, x + y = 1},{x=1,y=2})
  6107. %%\end{verbatim}}
  6108. %%\item solution of ordinary differential equations
  6109. %%{\small\begin{verbatim}
  6110. %% num_odesolve(df(y,x)=y,y=1,x=(0 .. 1), iterations=5)
  6111. %%\end{verbatim}}
  6112. %%\item bounds of a function over an interval
  6113. %%{\small\begin{verbatim}
  6114. %% bounds(sin x+x,x=(1 .. 2));
  6115. %%\end{verbatim}}
  6116. %%\item minimizing a function (Fletcher Reeves steepest descent)
  6117. %%{\small\begin{verbatim}
  6118. %% num_min(sin(x)+x/5, x);
  6119. %%\end{verbatim}}
  6120. %%\item Chebyshev curve fitting
  6121. %%{\small\begin{verbatim}
  6122. %% chebyshev_fit(sin x/x,x=(1 .. 3),5);
  6123. %%\end{verbatim}}
  6124. %%\item numerical quadrature
  6125. %%{\small\begin{verbatim}
  6126. %% num_int(sin x,x=(0 .. pi));
  6127. %%\end{verbatim}}
  6128. %%\end{itemize}
  6129. %%
  6130. %%Author: Herbert Melenk.
  6131. %%
  6132. \item
  6133. {ODESOLVE: Ordinary differential equations solver}
  6134. (chapter~\ref{ODESOLVE});\ttindex{ODESOLVE}
  6135. %%
  6136. %%The ODESOLVE package is a solver for ordinary differential equations. At
  6137. %%the present time it has very limited capabilities. It can handle only a
  6138. %%single scalar equation presented as an algebraic expression or equation,
  6139. %%and it can solve only first-order equations of simple types, linear
  6140. %%equations with constant coefficients and Euler equations. These solvable
  6141. %%types are exactly those for which Lie symmetry techniques give no useful
  6142. %%information. For example, the evaluation of
  6143. %%{\small\begin{verbatim}
  6144. %% depend(y,x);
  6145. %% odesolve(df(y,x)=x**2+e**x,y,x);
  6146. %%\end{verbatim}}
  6147. %%yields the result
  6148. %%{\small\begin{verbatim}
  6149. %% X 3
  6150. %% 3*E + 3*ARBCONST(1) + X
  6151. %% {Y=---------------------------}
  6152. %% 3
  6153. %%\end{verbatim}}
  6154. %%
  6155. %%Main Author: Malcolm A.H. MacCallum.
  6156. %%
  6157. %%Other contributors: Francis Wright, Alan Barnes.
  6158. %%
  6159. \item
  6160. {ORTHOVEC: Manipulation of scalars and vectors}
  6161. (chapter~\ref{ORTHOVEC});\ttindex{ORTHOVEC}
  6162. %%
  6163. %%ORTHOVEC is a collection of REDUCE procedures and operations which
  6164. %%provide a simple-to-use environment for the manipulation of scalars and
  6165. %%vectors. Operations include addition, subtraction, dot and cross
  6166. %%products, division, modulus, div, grad, curl, laplacian, differentiation,
  6167. %%integration, and Taylor expansion.
  6168. %%
  6169. %%Author: James W. Eastwood.
  6170. %%
  6171. \item
  6172. {PHYSOP: Operator calculus in quantum theory}
  6173. (chapter~\ref{PHYSOP});\ttindex{PHYSOP}
  6174. %%
  6175. %%This package has been designed to meet the requirements of theoretical
  6176. %%physicists looking for a computer algebra tool to perform complicated
  6177. %%calculations in quantum theory with expressions containing operators.
  6178. %%These operations consist mainly of the calculation of commutators between
  6179. %%operator expressions and in the evaluations of operator matrix elements in
  6180. %%some abstract space.
  6181. %%
  6182. %%Author: Mathias Warns.
  6183. %%
  6184. \item
  6185. {PM: A REDUCE pattern matcher} (chapter~\ref{PM});\ttindex{PM}
  6186. %%
  6187. %%PM is a general pattern matcher similar in style to those found in systems
  6188. %%such as SMP and Mathematica, and is based on the pattern matcher described
  6189. %%in Kevin McIsaac, ``Pattern Matching Algebraic Identities'', SIGSAM Bulletin,
  6190. %%19 (1985), 4-13.
  6191. %%
  6192. %%Documentation for this package is in plain text.
  6193. %%
  6194. %%Author: Kevin McIsaac.
  6195. %%
  6196. \item
  6197. {RANDPOLY: A random polynomial generator} (chapter~\ref{RANDPOLY});
  6198. \ttindex{RANDPOLY}
  6199. %%
  6200. %%This package is based on a port of the Maple random polynomial
  6201. %%generator together with some support facilities for the generation
  6202. %%of random numbers and anonymous procedures.
  6203. %%
  6204. %%Author: Francis J. Wright.
  6205. %%
  6206. \item
  6207. {REACTEQN: Support for chemical reaction equation systems}
  6208. (chapter~\ref{REACTEQN});\ttindex{REACTEQN}
  6209. %%
  6210. %%This package allows a user to transform chemical reaction systems into
  6211. %%ordinary differential equation systems (ODE) corresponding to the laws of
  6212. %%pure mass action.
  6213. %%
  6214. %%Documentation for this package is in plain text.
  6215. %%
  6216. %%Author: Herbert Melenk.
  6217. %%
  6218. \item
  6219. {RESET: Code to reset REDUCE to its initial state}
  6220. (chapter~\ref{RESET});\ttindex{RESET}
  6221. %%
  6222. %%This package defines a command command RESETREDUCE that works through the
  6223. %%history of previous commands, and clears any values which have been
  6224. %%assigned, plus any rules, arrays and the like. It also sets the various
  6225. %%switches to their initial values. It is not complete, but does work for
  6226. %%most things that cause a gradual loss of space. It would be relatively
  6227. %%easy to make it interactive, so allowing for selective resetting.
  6228. %%
  6229. %%There is no further documentation on this package.
  6230. %%
  6231. %%Author: John Fitch.
  6232. %%
  6233. \item
  6234. {RESIDUE: A residue package} (chapter~\ref{RESIDUE});\ttindex{RESIDUE}
  6235. %%
  6236. %%This package supports the calculation of residues of arbitrary
  6237. %%expressions.
  6238. %%
  6239. %%Author: Wolfram Koepf.
  6240. %%
  6241. \item
  6242. {RLFI: REDUCE LaTeX formula interface} (chapter~\ref{RLFI});\ttindex{RLFI}
  6243. %%
  6244. %%This package adds \LaTeX syntax to REDUCE. Text generated by REDUCE in
  6245. %%this mode can be directly used in \LaTeX source documents. Various
  6246. %%mathematical constructions are supported by the interface including
  6247. %%subscripts, superscripts, font changing, Greek letters, divide-bars,
  6248. %%integral and sum signs, derivatives, and so on.
  6249. %%
  6250. %%Author: Richard Liska.
  6251. %%
  6252. \item
  6253. {RSOLVE: Rational/integer polynomial solvers} (chapter~\ref{RSOLVE});\ttindex{RSOLVE}
  6254. %%
  6255. %%This package provides operators that compute the exact rational zeros
  6256. %%of a single univariate polynomial using fast modular methods. The
  6257. %%algorithm used is that described by R. Loos (1983): Computing rational
  6258. %%zeros of integral polynomials by $p$-adic expansion, {\it SIAM J.
  6259. %%Computing}, {\bf 12}, 286--293.
  6260. %%
  6261. %%Author: Francis J. Wright.
  6262. %%
  6263. \item
  6264. {ROOTS: A REDUCE root finding package} (chapter~\ref{ROOTS});\ttindex{ROOTS}
  6265. %%
  6266. %%This root finding package can be used to find some or all of the roots of a
  6267. %%univariate polynomial with real or complex coefficients, to the accuracy
  6268. %%specified by the user.
  6269. %%
  6270. %%It is designed so that it can be used as an independent package, or it may
  6271. %%be called from {\tt SOLVE} if {\tt ROUNDED} is on. For example,
  6272. %%the evaluation of
  6273. %%{\small\begin{verbatim}
  6274. %% on rounded,complex;
  6275. %% solve(x**3+x+5,x);
  6276. %%\end{verbatim}}
  6277. %%yields the result
  6278. %%{\small\begin{verbatim}
  6279. %% {X= - 1.51598,X=0.75799 + 1.65035*I,X=0.75799 - 1.65035*I}
  6280. %%\end{verbatim}}
  6281. %%
  6282. %%This package loads automatically.
  6283. %%
  6284. %%Author: Stanley L. Kameny.
  6285. %%
  6286. \item
  6287. {SCOPE: REDUCE source code optimization package}
  6288. (chapter~\ref{SCOPE});\ttindex{SCOPE}
  6289. %%
  6290. %%SCOPE is a package for the production of an optimized form of a set of
  6291. %%expressions. It applies an heuristic search for common (sub)expressions
  6292. %%to almost any set of proper REDUCE assignment statements. The
  6293. %%output is obtained as a sequence of assignment statements. GENTRAN is
  6294. %%used to facilitate expression output.
  6295. %%
  6296. %%Author: J.A. van Hulzen.
  6297. %%
  6298. \item
  6299. {SETS: A basic set theory package} (chapter~\ref{SETS});\ttindex{SETS}
  6300. %%
  6301. %%The SETS package provides algebraic-mode support for set operations on
  6302. %%lists regarded as sets (or representing explicit sets) and on implicit
  6303. %%sets represented by identifiers.
  6304. %%
  6305. %%Author: Francis J. Wright.
  6306. %%
  6307. \item
  6308. {SPDE: A package for finding symmetry groups of {PDE}'s}
  6309. (chapter~\ref{SPDE});\ttindex{SPDE}
  6310. %%
  6311. %%The package SPDE provides a set of functions which may be used to
  6312. %%determine the symmetry group of Lie- or point-symmetries of a given system
  6313. %%of partial differential equations. In many cases the determining system is
  6314. %%solved completely automatically. In other cases the user has to provide
  6315. %%additional input information for the solution algorithm to terminate.
  6316. %%
  6317. %%Author: Fritz Schwarz.
  6318. %%
  6319. \item
  6320. {SPECFN: Package for special functions} (chapter~\ref{SPECFN});
  6321. \ttindex{SPECFN}
  6322. %%
  6323. %%\index{Gamma function} \ttindex{Gamma}
  6324. %%\index{Digamma function} \ttindex{Digamma}
  6325. %%\index{Polygamma functions} \ttindex{Polygamma}
  6326. %%\index{Pochhammer's symbol} \ttindex{Pochhammer}
  6327. %%\index{Euler numbers} \ttindex{Euler}
  6328. %%\index{Bernoulli numbers} \ttindex{Bernoulli}
  6329. %%\index{Zeta function (Riemann's)} \ttindex{Zeta}
  6330. %%\index{Bessel functions}\ttindex{BesselJ}\ttindex{BesselY}
  6331. %% \ttindex{BesselK}\ttindex{BesselI}
  6332. %%\index{Hankel functions}\ttindex{Hankel1}\ttindex{Hankel2}
  6333. %%\index{Kummer functions}\ttindex{KummerM}\ttindex{KummerU}
  6334. %%\index{Struve functions}\ttindex{StruveH}\ttindex{StruveL}
  6335. %%\index{Lommel functions}\ttindex{Lommel1}\ttindex{Lommel2}
  6336. %%\index{Polygamma functions}\ttindex{Polygamma}
  6337. %%\index{Beta function} \ttindex{Beta}
  6338. %%\index{Whittaker functions}\ttindex{WhittakerM}
  6339. %% \ttindex{WhittakerW}
  6340. %%\index{Dilogarithm function} \ttindex{Dilog}
  6341. %%\index{Psi function} \ttindex{Psi}
  6342. %%\index{Orthogonal polynomials}
  6343. %%\index{Hermite polynomials} \ttindex{HermiteP}
  6344. %%\index{Jacobi's polynomials} \ttindex{JacobiP}
  6345. %%\index{Legendre polynomials} \ttindex{LegendreP}
  6346. %%\index{Laguerre polynomials} \ttindex{LaguerreP}
  6347. %%\index{Chebyshev polynomials} \ttindex{ChebyshevT}\ttindex{ChebyshevU}
  6348. %%\index{Gegenbauer polynomials}\ttindex{GegenbauerP}
  6349. %%\index{Euler polynomials} \ttindex{EulerP}
  6350. %%\index{Binomial coefficients} \ttindex{Binomial}
  6351. %%\index{Stirling numbers}\ttindex{Stirling1}\ttindex{Stirling2}
  6352. %%
  6353. %%This special function package is separated into two portions to make it
  6354. %%easier to handle. The packages are called SPECFN and SPECFN2. The first
  6355. %%one is more general in nature, whereas the second is devoted to special
  6356. %%special functions. Documentation for the first package can be found in
  6357. %%the file specfn.tex in the ``doc'' directory, and examples in specfn.tst
  6358. %%and specfmor.tst in the examples directory.
  6359. %%
  6360. %%The package SPECFN is designed to provide algebraic and numerical
  6361. %%manipulations of several common special functions, namely:
  6362. %%
  6363. %%\begin{itemize}
  6364. %%\item Bernoulli Numbers and Euler Numbers;
  6365. %%\item Stirling Numbers;
  6366. %%\item Binomial Coefficients;
  6367. %%\item Pochhammer notation;
  6368. %%\item The Gamma function;
  6369. %%\item The Psi function and its derivatives;
  6370. %%\item The Riemann Zeta function;
  6371. %%\item The Bessel functions J and Y of the first and second kind;
  6372. %%\item The modified Bessel functions I and K;
  6373. %%\item The Hankel functions H1 and H2;
  6374. %%\item The Kummer hypergeometric functions M and U;
  6375. %%\item The Beta function, and Struve, Lommel and Whittaker functions;
  6376. %%\item The Exponential Integral, the Sine and Cosine Integrals;
  6377. %%\item The Hyperbolic Sine and Cosine Integrals;
  6378. %%\item The Fresnel Integrals and the Error function;
  6379. %%\item The Dilog function;
  6380. %%\item Hermite Polynomials;
  6381. %%\item Jacobi Polynomials;
  6382. %%\item Legendre Polynomials;
  6383. %%\item Laguerre Polynomials;
  6384. %%\item Chebyshev Polynomials;
  6385. %%\item Gegenbauer Polynomials;
  6386. %%\item Euler Polynomials;
  6387. %%\item Bernoulli Polynomials.
  6388. %%\end{itemize}
  6389. %%
  6390. %%Author: Chris Cannam, with contributions from Winfried Neun, Herbert
  6391. %%Melenk, Victor Adamchik, Francis Wright and several others.
  6392. %%
  6393. \item
  6394. {SPECFN2: Package for special special functions}
  6395. (chapter~\ref{SPECFN2});\ttindex{SPECFN2}
  6396. %%
  6397. %%\index{Generalized Hypergeometric functions}
  6398. %%\index{Meijer's G function}
  6399. %%
  6400. %%This package provides algebraic manipulations of generalized
  6401. %%hypergeometric functions and Meijer's G function. Generalized
  6402. %%hypergeometric functions are simplified towards special functions and
  6403. %%Meijer's G function is simplified towards special functions or generalized
  6404. %%hypergeometric functions.
  6405. %%
  6406. %%Author: Victor Adamchik, with major updates by Winfried Neun.
  6407. %%
  6408. \item
  6409. {SUM: A package for series summation} (chapter~\ref{SUM});\ttindex{SUM}
  6410. %%
  6411. %%This package implements the Gosper algorithm for the summation of series.
  6412. %%It defines operators {\tt SUM} and {\tt PROD}. The operator {\tt SUM}
  6413. %%returns the indefinite or definite summation of a given expression, and
  6414. %%{\tt PROD} returns the product of the given expression.
  6415. %%
  6416. %%This package loads automatically.
  6417. %%
  6418. %%Author: Fujio Kako.
  6419. %%
  6420. \item
  6421. {SYMMETRY: Operations on symmetric matrices} (chapter~\ref{SYMMETRY});
  6422. \ttindex{SYMMETRY}
  6423. %%
  6424. %%This package computes symmetry-adapted bases and block diagonal forms of
  6425. %%matrices which have the symmetry of a group. The package is the
  6426. %%implementation of the theory of linear representations for small finite
  6427. %%groups such as the dihedral groups.
  6428. %%
  6429. %%Author: Karin Gatermann.
  6430. %%
  6431. \item
  6432. {TAYLOR: Manipulation of Taylor series} (chapter~\ref{TAYLOR});\ttindex{TAYLOR}
  6433. %%
  6434. %%This package carries out the Taylor expansion of an expression in one or
  6435. %%more variables and efficient manipulation of the resulting Taylor series.
  6436. %%Capabilities include basic operations (addition, subtraction,
  6437. %%multiplication and division) and also application of certain algebraic and
  6438. %%transcendental functions.
  6439. %%
  6440. %%Author: Rainer Sch\"opf.
  6441. %%
  6442. \item
  6443. {TPS: A truncated power series package} (chapter~\ref{TPS});
  6444. \ttindex{TPS}\ttindex{PS}
  6445. %%
  6446. %%This package implements formal Laurent series expansions in one variable
  6447. %%using the domain mechanism of REDUCE. This means that power series
  6448. %%objects can be added, multiplied, differentiated etc., like other first
  6449. %%class objects in the system. A lazy evaluation scheme is used and thus
  6450. %%terms of the series are not evaluated until they are required for printing
  6451. %%or for use in calculating terms in other power series. The series are
  6452. %%extendible giving the user the impression that the full infinite series is
  6453. %%being manipulated. The errors that can sometimes occur using series that
  6454. %%are truncated at some fixed depth (for example when a term in the required
  6455. %%series depends on terms of an intermediate series beyond the truncation
  6456. %%depth) are thus avoided.
  6457. %%
  6458. %%Authors: Alan Barnes and Julian Padget.
  6459. %%
  6460. \item
  6461. {TRI: TeX REDUCE interface} (chapter~\ref{TRI});\ttindex{TRI}
  6462. %%
  6463. %%This package provides facilities written in REDUCE-Lisp for typesetting
  6464. %%REDUCE formulas using \TeX. The \TeX-REDUCE-Interface incorporates three
  6465. %%levels of \TeX output: without line breaking, with line breaking, and
  6466. %%with line breaking plus indentation.
  6467. %%
  6468. %%Author: Werner Antweiler.
  6469. %%
  6470. \item
  6471. {TRIGSIMP: Simplification and factorization of trigonometric and
  6472. hyperbolic functions} (chapter~\ref{TRIGSIMP});\ttindex{TRIGSIMP}
  6473. %%and hyperbolic functions}\ttindex{TRIGSIMP}
  6474. %%
  6475. %%TRIGSIMP is a useful tool for all kinds of trigonometric and hyperbolic
  6476. %%simplification and factorization. There are three procedures included in
  6477. %%TRIGSIMP: trigsimp, trigfactorize and triggcd. The first is for finding
  6478. %%simplifications of trigonometric or hyperbolic expressions with many
  6479. %%options, the second for factorizing them and the third for finding the
  6480. %%greatest common divisor of two trigonometric or hyperbolic polynomials.
  6481. %%
  6482. %%Author: Wolfram Koepf.
  6483. %%
  6484. \item
  6485. {XCOLOR: Calculation of the color factor in non-abelian gauge field
  6486. theories} (chapter~\ref{XCOLOR});\ttindex{XCOLOR}
  6487. %%
  6488. %%This package calculates the color factor in non-abelian gauge field
  6489. %%theories using an algorithm due to Cvitanovich.
  6490. %%
  6491. %%Documentation for this package is in plain text.
  6492. %%
  6493. %%Author: A. Kryukov.
  6494. %%
  6495. \item
  6496. {XIDEAL: Gr\"obner Bases for exterior algebra} (chapter~\ref{XIDEAL});
  6497. \ttindex{XIDEAL}
  6498. %%
  6499. %%XIDEAL constructs Gr\"obner bases for solving the left ideal membership
  6500. %%problem: Gr\"obner left ideal bases or GLIBs. For graded ideals, where each
  6501. %%form is homogeneous in degree, the distinction between left and right
  6502. %%ideals vanishes. Furthermore, if the generating forms are all homogeneous,
  6503. %%then the Gr\"obner bases for the non-graded and graded ideals are
  6504. %%identical. In this case, XIDEAL is able to save time by truncating the
  6505. %%Gr\"obner basis at some maximum degree if desired.
  6506. %%
  6507. %%Author: David Hartley.
  6508. %%
  6509. \item
  6510. {WU: Wu algorithm for polynomial systems} (chapter~\ref{WU});\ttindex{WU}
  6511. %%
  6512. %%This is a simple implementation of the Wu algorithm implemented in REDUCE
  6513. %%working directly from ``A Zero Structure Theorem for
  6514. %%Polynomial-Equations-Solving,'' Wu Wen-tsun, Institute of Systems Science,
  6515. %%Academia Sinica, Beijing.
  6516. %%
  6517. %%Author: Russell Bradford.
  6518. %%
  6519. \item
  6520. {ZEILBERG: A package for indefinite and definite summation}
  6521. (chapter~\ref{ZEILBERG});\ttindex{ZEILBERG}
  6522. %%
  6523. %%This package is a careful implementation of the Gosper and Zeilberger
  6524. %%algorithms for indefinite and definite summation of hypergeometric terms,
  6525. %%respectively. Extensions of these algorithms are also included that are
  6526. %%valid for ratios of products of powers, factorials, $\Gamma$ function
  6527. %%terms, binomial coefficients, and shifted factorials that are
  6528. %%rational-linear in their arguments.
  6529. %%
  6530. %%Authors: Gregor St\"olting and Wolfram Koepf.
  6531. %%
  6532. \item
  6533. {ZTRANS: $Z$-transform package} (chapter~\ref{ZTRANS});\ttindex{ZTRANS}
  6534. %%
  6535. %%This package is an implementation of the $Z$-transform of a sequence.
  6536. %%This is the discrete analogue of the Laplace Transform.
  6537. %%
  6538. %%Authors: Wolfram Koepf and Lisa Temme.
  6539. \end{itemize}
  6540. \chapter{Symbolic Mode}\index{Symbolic mode}
  6541. At the system level, {\REDUCE} is based on a version of the programming
  6542. language Lisp\index{Lisp} known as {\em Standard Lisp\/} which is described
  6543. in J. Marti, Hearn, A. C., Griss, M. L. and Griss, C., ``Standard LISP
  6544. Report" SIGPLAN Notices, ACM, New York, 14, No 10 (1979) 48-68. We shall
  6545. assume in this section that the reader is familiar with the material in
  6546. that paper. This also assumes implicitly that the reader has a reasonable
  6547. knowledge about Lisp in general, say at the level of the LISP 1.5
  6548. Programmer's Manual (McCarthy, J., Abrahams, P. W., Edwards, D. J., Hart,
  6549. T. P. and Levin, M. I., ``LISP 1.5 Programmer's Manual'', M.I.T. Press,
  6550. 1965) or any of the books mentioned at the end of this section. Persons
  6551. unfamiliar with this material will have some difficulty understanding this
  6552. section.
  6553. Although {\REDUCE} is designed primarily for algebraic calculations, its
  6554. source language is general enough to allow for a full range of Lisp-like
  6555. symbolic calculations. To achieve this generality, however, it is
  6556. necessary to provide the user with two modes of evaluation, namely an
  6557. algebraic mode\index{Algebraic mode} and a symbolic mode.\index{Symbolic
  6558. mode} To enter symbolic mode, the user types {\tt symbolic;}
  6559. \ttindex{SYMBOLIC} (or {\tt lisp;})\ttindex{LISP} and to return to
  6560. algebraic mode one types {\tt algebraic;}.\ttindex{ALGEBRAIC}
  6561. Evaluations proceed differently in each mode so the user is advised to
  6562. check what mode he is in if a puzzling error arises. He can find his mode
  6563. by typing\ttindex{EVAL\_MODE}
  6564. {\small\begin{verbatim}
  6565. eval_mode;
  6566. \end{verbatim}}
  6567. The current mode will then be printed as {\tt ALGEBRAIC} or {\tt SYMBOLIC}.
  6568. Expression evaluation may proceed in either mode at any level of a
  6569. calculation, provided the results are passed from mode to mode in a
  6570. compatible manner. One simply prefixes the relevant expression by the
  6571. appropriate mode. If the mode name prefixes an expression at the top
  6572. level, it will then be handled as if the global system mode had been
  6573. changed for the scope of that particular calculation.
  6574. For example, if the current mode is {\tt ALGEBRAIC}, then the commands
  6575. \extendedmanual{\newpage}
  6576. {\small\begin{verbatim}
  6577. symbolic car '(a);
  6578. x+y;
  6579. \end{verbatim}}
  6580. will cause the first expression to be evaluated and printed in symbolic
  6581. mode and the second in algebraic mode. Only the second evaluation will
  6582. thus affect the expression workspace. On the other hand, the statement
  6583. {\small\begin{verbatim}
  6584. x + symbolic car '(12);
  6585. \end{verbatim}}
  6586. will result in the algebraic value {\tt X+12}.
  6587. The use of {\tt SYMBOLIC} (and equivalently {\tt ALGEBRAIC}) in this
  6588. manner is the same as any operator. That means that parentheses could be
  6589. omitted in the above examples since the meaning is obvious. In other
  6590. cases, parentheses must be used, as in
  6591. {\small\begin{verbatim}
  6592. symbolic(x := 'a);
  6593. \end{verbatim}}
  6594. Omitting the parentheses, as in
  6595. {\small\begin{verbatim}
  6596. symbolic x := a;
  6597. \end{verbatim}}
  6598. would be wrong, since it would parse as
  6599. {\small\begin{verbatim}
  6600. symbolic(x) := a;
  6601. \end{verbatim}}
  6602. For convenience, it is assumed that any operator whose {\em first\/} argument is
  6603. quoted is being evaluated in symbolic mode, regardless of the mode in
  6604. effect at that time. Thus, the first example above could be equally well
  6605. written:
  6606. {\small\begin{verbatim}
  6607. car '(a);
  6608. \end{verbatim}}
  6609. Except where explicit limitations have been made, most {\REDUCE} algebraic
  6610. constructions carry over into symbolic mode.\index{Symbolic mode}
  6611. However, there are some differences. First, expression evaluation now
  6612. becomes Lisp evaluation. Secondly, assignment statements are handled
  6613. differently, as we shall discuss shortly. Thirdly, local variables and array
  6614. elements are initialized to {\tt NIL} rather than {\tt 0}. (In fact, any
  6615. variables not explicitly declared {\tt INTEGER} are also initialized to
  6616. {\tt NIL} in algebraic mode, but the algebraic evaluator recognizes {\tt
  6617. NIL} as {\tt 0}.) Finally, function definitions follow the conventions of
  6618. Standard Lisp.
  6619. To begin with, we mention a few extensions to our basic syntax which are
  6620. designed primarily if not exclusively for symbolic mode.
  6621. \section{Symbolic Infix Operators}
  6622. There are three binary infix operators in {\REDUCE} intended for use in
  6623. symbolic mode, namely . {\tt (CONS), EQ and MEMQ}. The precedence of
  6624. these operators was given in another section.
  6625. \section{Symbolic Expressions}
  6626. These consist of scalar variables and operators and follow the normal
  6627. rules of the Lisp meta language.
  6628. {\it Examples:}
  6629. {\small\begin{verbatim}
  6630. x
  6631. car u . reverse v
  6632. simp (u+v^2)
  6633. \end{verbatim}}
  6634. \section{Quoted Expressions}\ttindex{QUOTE}
  6635. Because symbolic evaluation requires that each variable or expression has a
  6636. value, it is necessary to add to {\REDUCE} the concept of a quoted expression
  6637. by analogy with the Lisp {\tt QUOTE} function. This is provided by the single
  6638. quote mark {\tt '}. For example,
  6639. \begin{quote}
  6640. \begin{tabbing}
  6641. {\tt '(a b c)} \= represents the Lisp S-expression \= {\tt (quote (a b
  6642. c))}\kill
  6643. {\tt 'a} \> represents the Lisp S-expression \>
  6644. {\tt (quote a)} \\
  6645. {\tt '(a b c)} \> represents the Lisp S-expression \> {\tt (quote (a b c))}
  6646. \end{tabbing}
  6647. \end{quote}
  6648. Note, however, that strings are constants and therefore evaluate to
  6649. themselves in symbolic mode. Thus, to print the string {\tt "A String"}, one
  6650. would write
  6651. {\small\begin{verbatim}
  6652. prin2 "A String";
  6653. \end{verbatim}}
  6654. Within a quoted expression, identifier syntax rules are those of {\REDUCE}.
  6655. Thus {\tt (A~!.~~B)} is the list consisting of the three elements {\tt A},
  6656. {\tt .}, and {\tt B}, whereas {\tt (A . B)} is the dotted pair of {\tt A}
  6657. and {\tt B}.
  6658. \section{Lambda Expressions}\ttindex{LAMBDA}
  6659. \label{sec-lambda}
  6660. {\tt LAMBDA} expressions provide the means for constructing Lisp {\tt LAMBDA}
  6661. expressions in symbolic mode. They may not be used in algebraic mode.
  6662. Syntax:
  6663. {\small\begin{verbatim}
  6664. <LAMBDA expression> ::=
  6665. LAMBDA <varlist><terminator><statement>
  6666. \end{verbatim}}
  6667. where
  6668. {\small\begin{verbatim}
  6669. <varlist> ::= (<variable>,...,<variable>)
  6670. \end{verbatim}}
  6671. e.g.,
  6672. {\small\begin{verbatim}
  6673. lambda (x,y); car x . cdr y;
  6674. \end{verbatim}}
  6675. is equivalent to the Lisp {\tt LAMBDA} expression
  6676. {\small\begin{verbatim}
  6677. (lambda (x y) (cons (car x) (cdr y)))
  6678. \end{verbatim}}
  6679. The parentheses may be omitted in specifying the variable list if desired.
  6680. {\tt LAMBDA} expressions may be used in symbolic mode in place of prefix
  6681. operators, or as an argument of the reserved word {\tt FUNCTION}.
  6682. In those cases where a {\tt LAMBDA} expression is used to introduce local
  6683. variables to avoid recomputation, a {\tt WHERE} statement can also be
  6684. used. For example, the expression
  6685. {\small\begin{verbatim}
  6686. (lambda (x,y); list(car x,cdr x,car y,cdr y))
  6687. (reverse u,reverse v)
  6688. \end{verbatim}}
  6689. can also be written
  6690. {\small\begin{verbatim}
  6691. {car x,cdr x,car y,cdr y} where x=reverse u,y=reverse v
  6692. \end{verbatim}}
  6693. Where possible, {\tt WHERE} syntax is preferred to {\tt LAMBDA} syntax,
  6694. since it is more natural.
  6695. \section{Symbolic Assignment Statements}\index{Assignment}
  6696. In symbolic mode, if the left side of an assignment statement is a
  6697. variable, a {\tt SETQ} of the right-hand side to that variable occurs. If
  6698. the left-hand side is an expression, it must be of the form of an array
  6699. element, otherwise an error will result. For example, {\tt x:=y}
  6700. translates into {\tt (SETQ X Y)} whereas {\tt a(3) := 3} will be valid if
  6701. {\tt A} has been previously declared a single dimensioned array of at
  6702. least four elements.
  6703. \section{FOR EACH Statement}\ttindex{FOR EACH}
  6704. The {\tt FOR EACH} form of the {\tt FOR} statement, designed for iteration
  6705. down a list, is more general in symbolic mode. Its syntax is:
  6706. {\small\begin{verbatim}
  6707. FOR EACH ID:identifier {IN|ON} LST:list
  6708. {DO|COLLECT|JOIN|PRODUCT|SUM} EXPRN:S-expr
  6709. \end{verbatim}}
  6710. As in algebraic mode, if the keyword {\tt IN} is used, iteration is on
  6711. each element of the list. With {\tt ON}, iteration is on the whole list
  6712. remaining at each point in the iteration. As a result, we have the
  6713. following equivalence between each form of {\tt FOR EACH} and the various
  6714. mapping functions in Lisp:
  6715. \begin{center}
  6716. {\tt
  6717. \begin{tabular}{|l|lr r|} \hline
  6718. & DO & COLLECT & JOIN \\ \hline
  6719. IN & MAPC & MAPCAR & MAPCAN \\
  6720. ON & MAP & MAPLIST & MAPCON \\ \hline
  6721. \end{tabular}}
  6722. \end{center}
  6723. {\it Example:} To list each element of the list {\tt (a b c)}:
  6724. {\small\begin{verbatim}
  6725. for each x in '(a b c) collect list x;
  6726. \end{verbatim}}
  6727. \section{Symbolic Procedures}\index{Symbolic procedure}
  6728. All the functions described in the Standard Lisp Report are available to
  6729. users in symbolic mode. Additional functions may also be defined as
  6730. symbolic procedures. For example, to define the Lisp function {\tt ASSOC},
  6731. the following could be used:
  6732. {\small\begin{verbatim}
  6733. symbolic procedure assoc(u,v);
  6734. if null v then nil
  6735. else if u = caar v then car v
  6736. else assoc(u, cdr v);
  6737. \end{verbatim}}
  6738. If the default mode were symbolic, then {\tt SYMBOLIC} could be omitted in
  6739. the above definition. {\tt MACRO}s\ttindex{MACRO} may be defined by
  6740. prefixing the keyword {\tt PROCEDURE} by the word {\tt MACRO}.
  6741. (In fact, ordinary functions may be defined with the keyword {\tt EXPR}
  6742. \ttindex{EXPR} prefixing {\tt PROCEDURE} as was used in the Standard Lisp
  6743. Report.) For example, we could define a {\tt MACRO CONSCONS} by
  6744. {\small\begin{verbatim}
  6745. symbolic macro procedure conscons l;
  6746. expand(cdr l,'cons);
  6747. \end{verbatim}}
  6748. Another form of macro, the {\tt SMACRO}\ttindex{SMACRO} is also available.
  6749. These are described in the Standard Lisp Report. The Report also defines
  6750. a function type {\tt FEXPR}.\ttindex{FEXPR}
  6751. However, its use is discouraged since it is hard to implement efficiently,
  6752. and most uses can be replaced by macros. At the present time, there are
  6753. no {\tt FEXPR}s in the core REDUCE system.
  6754. \section{Standard Lisp Equivalent of Reduce Input}
  6755. A user can obtain the Standard Lisp equivalent of his {\REDUCE} input by
  6756. turning on the switch {\tt DEFN}\ttindex{DEFN} (for definition). The
  6757. system then prints the Lisp translation of his input but does not evaluate
  6758. it. Normal operation is resumed when {\tt DEFN} is turned off.
  6759. \section{Communicating with Algebraic Mode}\index{Mode communication}
  6760. One of the principal motivations for a user of the algebraic facilities of
  6761. {\REDUCE} to learn about symbolic mode\index{Symbolic mode} is that it
  6762. gives one access to a wider range of techniques than is possible in
  6763. algebraic mode\index{Algebraic mode} alone. For example, if a user
  6764. wishes to use parts of the system defined in the basic system source code,
  6765. or refine their algebraic code definitions to make them more efficient,
  6766. then it is necessary to understand the source language in fairly complete
  6767. detail. Moreover, it is also necessary to know a little more about the
  6768. way {\REDUCE} operates internally. Basically, {\REDUCE} considers
  6769. expressions in two forms: prefix form, which follow the normal Lisp rules
  6770. of function composition, and so-called canonical form, which uses a
  6771. completely different syntax.
  6772. Once these details are understood, the most critical problem faced by a
  6773. user is how to make expressions and procedures communicate between symbolic
  6774. and algebraic mode. The purpose of this section is to teach a user the
  6775. basic principles for this.
  6776. If one wants to evaluate an expression in algebraic mode, and then use
  6777. that expression in symbolic mode calculations, or vice versa, the easiest
  6778. way to do this is to assign a variable to that expression whose value is
  6779. easily obtainable in both modes. To facilitate this, a declaration {\tt
  6780. SHARE}\ttindex{SHARE} is available. {\tt SHARE} takes a list of
  6781. identifiers as argument, and marks these variables as having recognizable
  6782. values in both modes. The declaration may be used in either mode.
  6783. E.g.,
  6784. {\small\begin{verbatim}
  6785. share x,y;
  6786. \end{verbatim}}
  6787. says that {\tt X} and {\tt Y} will receive values to be used in both modes.
  6788. If a {\tt SHARE} declaration is made for a variable with a previously
  6789. assigned algebraic value, that value is also made available in symbolic
  6790. mode.
  6791. \subsection{Passing Algebraic Mode Values to Symbolic Mode}
  6792. If one wishes to work with parts of an algebraic mode
  6793. \index{Algebraic mode} expression in symbolic mode,\index{Symbolic mode}
  6794. one simply makes an assignment\index{Assignment} of a shared variable to
  6795. the relevant expression in algebraic mode. For example, if one wishes to
  6796. work with {\tt (a+b)\verb|^|2}, one would say, in algebraic mode:
  6797. {\small\begin{verbatim}
  6798. x := (a+b)^2;
  6799. \end{verbatim}}
  6800. assuming that {\tt X} was declared shared as above. If we now change to
  6801. symbolic mode and say
  6802. {\small\begin{verbatim}
  6803. x;
  6804. \end{verbatim}}
  6805. its value will be printed as a prefix form with the syntax:
  6806. {\small\begin{verbatim}
  6807. (*SQ <standard quotient> T)
  6808. \end{verbatim}}
  6809. This particular format reflects the fact that the algebraic mode processor
  6810. currently likes to transfer prefix forms from command to command, but
  6811. doesn't like to reconvert standard forms\index{Standard form} (which
  6812. represent polynomials) and standard quotients back to a true Lisp prefix
  6813. form for the expression (which would result in excessive computation). So
  6814. {\tt *SQ} is used to tell the algebraic processor that it is dealing with
  6815. a prefix form which is really a standard quotient\index{Standard
  6816. quotient} and the second argument ({\tt T} or {\tt NIL}) tells it whether
  6817. it needs further processing (essentially, an {\em already simplified\/}
  6818. flag).
  6819. So to get the true standard quotient form in symbolic mode, one needs
  6820. {\tt CADR} of the variable. E.g.,
  6821. {\small\begin{verbatim}
  6822. z := cadr x;
  6823. \end{verbatim}}
  6824. would store in {\tt Z} the standard quotient form for {\tt (a+b)\verb|^|2}.
  6825. Once you have this expression, you can now manipulate it as you wish. To
  6826. facilitate this, a standard set of selectors\index{Selector} and
  6827. constructors\index{Constructor} are available for getting at parts of the
  6828. form. Those presently defined are as follows:
  6829. \extendedmanual{\newpage}
  6830. \begin{center}
  6831. \vspace{10pt}
  6832. {\large REDUCE Selectors\par}
  6833. %\end{center}
  6834. %\begin{center}
  6835. \renewcommand{\arraystretch}{1.5}
  6836. \begin{tabular}{lp{\rboxwidth}}
  6837. {\tt DENR} & denominator of standard quotient \\
  6838. %
  6839. {\tt LC} & leading coefficient of polynomial \\
  6840. %
  6841. {\tt LDEG} & leading degree of polynomial \\
  6842. %
  6843. {\tt LPOW} & leading power of polynomial \\
  6844. %
  6845. {\tt LT} & leading term of polynomial \\
  6846. %
  6847. {\tt MVAR} & main variable of polynomial \\
  6848. %
  6849. {\tt NUMR} & numerator (of standard quotient) \\
  6850. %
  6851. {\tt PDEG} & degree of a power \\
  6852. %
  6853. {\tt RED} & reductum of polynomial \\
  6854. %
  6855. {\tt TC} & coefficient of a term \\
  6856. %
  6857. {\tt TDEG} & degree of a term \\
  6858. %
  6859. {\tt TPOW} & power of a term
  6860. \end{tabular}
  6861. \end{center}
  6862. \begin{center}
  6863. \vspace{10pt}
  6864. {\large REDUCE Constructors \par}
  6865. %\end{center}
  6866. %\begin{center}
  6867. \renewcommand{\arraystretch}{1.5}
  6868. \begin{tabular}{lp{\redboxwidth}}
  6869. \verb|.+| & add a term to a polynomial \\
  6870. %
  6871. \verb|./| & divide (two polynomials to get quotient) \\
  6872. \verb|.*| & multiply power by coefficient to produce term \\
  6873. %
  6874. \verb|.^| & raise a variable to a power
  6875. \end{tabular}
  6876. \end{center}
  6877. For example, to find the numerator of the standard quotient above, one
  6878. could say:
  6879. {\small\begin{verbatim}
  6880. numr z;
  6881. \end{verbatim}}
  6882. or to find the leading term of the numerator:
  6883. {\small\begin{verbatim}
  6884. lt numr z;
  6885. \end{verbatim}}
  6886. Conversion between various data structures is facilitated by the use of a
  6887. set of functions defined for this purpose. Those currently implemented
  6888. include:
  6889. {\renewcommand{\arraystretch}{1.5}
  6890. \begin{tabular}{lp{\reduceboxwidth}}
  6891. {\tt !*A2F} & convert an algebraic expression to
  6892. a standard form. If result is rational, an error results; \\
  6893. %
  6894. {\tt !*A2K} & converts an algebraic expression to
  6895. a kernel. If this is not possible, an error results; \\
  6896. %
  6897. {\tt !*F2A} & converts a standard form to an
  6898. algebraic expression; \\
  6899. %
  6900. {\tt !*F2Q} & convert a standard form to a
  6901. standard quotient; \\
  6902. %
  6903. {\tt !*K2F} & convert a kernel to a standard form; \\
  6904. {\tt !*K2Q} & convert a kernel to a standard quotient; \\
  6905. %
  6906. {\tt !*P2F} & convert a standard power to a
  6907. standard form; \\
  6908. %
  6909. {\tt !*P2Q} & convert a standard power to a standard quotient; \\
  6910. %
  6911. {\tt !*Q2F} & convert a standard quotient to a
  6912. standard form. If the quotient denominator is not 1, an error results; \\
  6913. %
  6914. {\tt !*Q2K} & convert a standard quotient to a
  6915. kernel. If this is not possible, an error results; \\
  6916. %
  6917. {\tt !*T2F} & convert a standard term to a standard form \\
  6918. %
  6919. {\tt !*T2Q} & convert a standard term to a standard quotient.
  6920. \end{tabular}}
  6921. \subsection{Passing Symbolic Mode Values to Algebraic Mode}
  6922. In order to pass the value of a shared variable from symbolic mode to
  6923. algebraic mode, the only thing to do is make sure that the value in
  6924. symbolic mode is a prefix expression. E.g., one uses
  6925. {\tt (expt (plus a b) 2)} for {\tt (a+b)\verb|^|2}, or the format ({\tt *sq
  6926. <standard quotient> t}) as described above. However, if you have
  6927. been working with parts of a standard form they will probably not be in
  6928. this form. In that case, you can do the following:
  6929. \begin{enumerate}
  6930. \item If it is a standard quotient, call {\tt PREPSQ} on it. This takes a
  6931. standard quotient as argument, and returns a prefix expression.
  6932. Alternatively, you can call {\tt MK!*SQ} on it, which returns a prefix
  6933. form like ({\tt *SQ <standard quotient> T)} and avoids translation of
  6934. the expression into a true prefix form.
  6935. \item If it is a standard form, call {\tt PREPF} on it. This takes a
  6936. standard form as argument, and returns the equivalent prefix expression.
  6937. Alternatively, you can convert it to a standard quotient and then call
  6938. {\tt MK!*SQ}.
  6939. \item If it is a part of a standard form, you must usually first build up a
  6940. standard form out of it, and then go to step 2. The conversion functions
  6941. described earlier may be used for this purpose. For example,
  6942. \begin{enumerate}
  6943. \item If {\tt Z} is an expression which is a term, {\tt !*T2F Z} is a
  6944. standard form.
  6945. \item If {\tt Z} is a standard power, {\tt !*P2F Z} is a standard form.
  6946. \item If {\tt Z} is a variable, you can pass it direct to algebraic mode.
  6947. \end{enumerate}
  6948. \end{enumerate}
  6949. For example, to pass the leading term of {\tt (a+b)\verb|^|2} back to
  6950. algebraic mode, one could say:
  6951. {\small\begin{verbatim}
  6952. y:= mk!*sq !*t2q lt numr z;
  6953. \end{verbatim}}
  6954. where {\tt Y} has been declared shared as above. If you now go back to
  6955. algebraic mode, you can work with {\tt Y} in the usual way.
  6956. \subsection{Complete Example}
  6957. The following is the complete code for doing the above steps. The end
  6958. result will be that the square of the leading term of $(a+b)^{2}$ is
  6959. calculated.
  6960. %%\begin{tabular}{lp{\rboxwidth}}
  6961. %%{\tt share x,y;} & {\tt \% declare {\tt X} and
  6962. %%{\tt Y} as shared} \\
  6963. %%{\tt x := (a+b)\verb|^|2;} & {\tt \% store (a+b)\verb|^|2 in X} \\
  6964. %%{\tt symbolic;} & {\tt \% transfer to symbolic mode} \\
  6965. %%{\tt z := cadr x;} & {\tt \% store a true standard quotient \newline
  6966. %% \% in Z} \\[1.7pt]
  6967. %%{\tt lt numr z;} & {\tt \% print the leading term of the \newline
  6968. %% \% numerator of Z} \\
  6969. %%{\tt y := mk!*sq !*t2q numr z;} & {\tt \% store the
  6970. %% prefix form of this \newline
  6971. %% \% leading term in Y} \\
  6972. %%{\tt algebraic;} & {\tt \% return to algebraic mode} \\
  6973. %%{\tt y\verb|^|2;} & {\tt \% evaluate square of the leading \newline
  6974. %%\% term of (a+b)\verb|^|2}
  6975. %%\end{tabular}
  6976. {\small\begin{verbatim}
  6977. share x,y; % declare X and Y as shared
  6978. x := (a+b)^2; % store (a+b)^2 in X
  6979. symbolic; % transfer to symbolic mode
  6980. z := cadr x; % store a true standard quotient in Z
  6981. lt numr z; % print the leading term of the
  6982. % numerator of Z
  6983. y := mk!*sq !*t2q numr z; % store the prefix form of this
  6984. % leading term in Y
  6985. algebraic; % return to algebraic mode
  6986. y^2; % evaluate square of the leading term
  6987. % of (a+b)^2
  6988. \end{verbatim}}
  6989. \subsection{Defining Procedures for Intermode Communication}
  6990. If one wishes to define a procedure in symbolic mode for use as an
  6991. operator in algebraic mode, it is necessary to declare this fact to the
  6992. system by using the declaration {\tt OPERATOR}\ttindex{OPERATOR} in
  6993. symbolic mode. Thus
  6994. {\small\begin{verbatim}
  6995. symbolic operator leadterm;
  6996. \end{verbatim}}
  6997. would declare the procedure {\tt LEADTERM} as an algebraic operator. This
  6998. declaration {\em must\/} be made in symbolic mode as the effect in algebraic
  6999. mode is different. The value of such a procedure must be a prefix form.
  7000. The algebraic processor will pass arguments to such procedures in prefix
  7001. form. Therefore if you want to work with the arguments as standard
  7002. quotients you must first convert them to that form by using the function
  7003. {\tt SIMP!*}. This function takes a prefix form as argument and returns the
  7004. evaluated standard quotient.
  7005. For example, if you want to define a procedure {\tt LEADTERM} which gives the
  7006. leading term of an algebraic expression, one could do this as follows:
  7007. \begin{samepage}
  7008. {\small\begin{verbatim}
  7009. symbolic operator leadterm; % Declare LEADTERM as a symbolic
  7010. % mode procedure to be used in
  7011. % algebraic mode.
  7012. symbolic procedure leadterm u; % Define LEADTERM.
  7013. mk!*sq !*t2q lt numr simp!* u;
  7014. \end{verbatim}}
  7015. \end{samepage}
  7016. Note that this operator has a different effect than the operator {\tt LTERM}
  7017. \ttindex{LTERM}. In the latter case, the calculation is done
  7018. with respect to the second argument of the operator. In the example here,
  7019. we simply extract the leading term with respect to the system's choice of
  7020. main variable.
  7021. Finally, if you wish to use the algebraic evaluator on an argument in a
  7022. symbolic mode definition, the function {\tt REVAL} can be used. The one
  7023. argument of {\tt REVAL} must be the prefix form of an expression. {\tt
  7024. REVAL} returns the evaluated expression as a true Lisp prefix form.
  7025. \section{Rlisp '88}
  7026. Rlisp '88 is a superset of the Rlisp that has been traditionally used for
  7027. the support of REDUCE. It is fully documented in the book
  7028. Marti, J.B., ``{RLISP} '88: An Evolutionary Approach to Program Design
  7029. and Reuse'', World Scientific, Singapore (1993).
  7030. Rlisp '88 adds to the traditional Rlisp the following facilities:
  7031. \begin{enumerate}
  7032. \item more general versions of the looping constructs {\tt for},
  7033. {\tt repeat} and {\tt while};
  7034. \item support for a backquote construct;
  7035. \item support for active comments;
  7036. \item support for vectors of the form name[index];
  7037. \item support for simple structures;
  7038. \item support for records.
  7039. \end{enumerate}
  7040. In addition, ``--'' is a letter in Rlisp '88. In other words, {\tt A-B} is an
  7041. identifier, not the difference of the identifiers {\tt A} and {\tt B}. If
  7042. the latter construct is required, it is necessary to put spaces around the
  7043. - character. For compatibility between the two versions of Rlisp, we
  7044. recommend this convention be used in all symbolic mode programs.
  7045. To use Rlisp '88, type {\tt on rlisp88;}\ttindex{RLISP88}. This switches to
  7046. symbolic mode with the Rlisp '88 syntax and extensions. While in this
  7047. environment, it is impossible to switch to algebraic mode, or prefix
  7048. expressions by ``algebraic''. However, symbolic mode programs written in
  7049. Rlisp '88 may be run in algebraic mode provided the rlisp88 package has been
  7050. loaded. We also expect that many of the extensions defined in Rlisp '88
  7051. will migrate to the basic Rlisp over time. To return to traditional Rlisp
  7052. or to switch to algebraic mode, say ``off rlisp88''.
  7053. \section{References}
  7054. There are a number of useful books which can give you further information
  7055. about LISP. Here is a selection:
  7056. Allen, J.R., ``The Anatomy of LISP'', McGraw Hill, New York, 1978.
  7057. McCarthy J., P.W. Abrahams, J. Edwards, T.P. Hart and
  7058. M.I. Levin, ``LISP 1.5 Programmer's Manual'', M.I.T. Press, 1965.
  7059. Touretzky, D.S, ``{LISP}: A Gentle Introduction to Symbolic Computation'',
  7060. Harper \& Row, New York, 1984.
  7061. Winston, P.H. and Horn, B.K.P., ``LISP'', Addison-Wesley, 1981.
  7062. \chapter{Calculations in High Energy Physics}
  7063. A set of {\REDUCE} commands is provided for users interested in symbolic
  7064. calculations in high energy physics. Several extensions to our basic
  7065. syntax are necessary, however, to allow for the different data structures
  7066. encountered.
  7067. \section{High Energy Physics Operators}
  7068. \label{HEPHYS}
  7069. We begin by introducing three new operators required in these calculations.
  7070. \subsection{. (Cons) Operator}\index{Dot product}
  7071. Syntax:
  7072. {\small\begin{verbatim}
  7073. (EXPRN1:vector_expression)
  7074. . (EXPRN2:vector_expression):algebraic.
  7075. \end{verbatim}}
  7076. The binary {\tt .} operator, which is normally used to denote the addition
  7077. of an element to the front of a list, can also be used in algebraic mode
  7078. to denote the scalar product of two Lorentz four-vectors. For this to
  7079. happen, the second argument must be recognizable as a vector expression
  7080. \index{High energy vector expression} at the time of
  7081. evaluation. With this meaning, this operator is often referred to as the
  7082. {\em dot\/} operator. In the present system, the index handling routines all
  7083. assume that Lorentz four-vectors are used, but these routines could be
  7084. rewritten to handle other cases.
  7085. Components of vectors can be represented by including representations of
  7086. unit vectors in the system. Thus if {\tt EO} represents the unit vector
  7087. {\tt (1,0,0,0)}, {\tt (p.eo)} represents the zeroth component of the
  7088. four-vector P. Our metric and notation follows Bjorken and Drell
  7089. ``Relativistic Quantum Mechanics'' (McGraw-Hill, New York, 1965).
  7090. Similarly, an arbitrary component {\tt P} may be represented by
  7091. {\tt (p.u)}. If contraction over components of vectors is required, then
  7092. the declaration {\tt INDEX}\ttindex{INDEX} must be used. Thus
  7093. {\small\begin{verbatim}
  7094. index u;
  7095. \end{verbatim}}
  7096. declares {\tt U} as an index, and the simplification of
  7097. {\small\begin{verbatim}
  7098. p.u * q.u
  7099. \end{verbatim}}
  7100. would result in
  7101. {\small\begin{verbatim}
  7102. P.Q
  7103. \end{verbatim}}
  7104. The metric tensor $g^{\mu \nu}$ may be represented by {\tt (u.v)}. If
  7105. contraction over {\tt U} and {\tt V} is required, then they should be
  7106. declared as indices.
  7107. Errors occur if indices are not properly matched in expressions.
  7108. If a user later wishes to remove the index property from specific vectors,
  7109. he can do it with the declaration {\tt REMIND}.\ttindex{REMIND} Thus
  7110. {\tt remind v1...vn;} removes the index flags from the variables {\tt V1}
  7111. through {\tt Vn}. However, these variables remain vectors in the system.
  7112. \subsection{G Operator for Gamma Matrices}\index{Dirac $\gamma$ matrix}
  7113. \ttindex{G}
  7114. Syntax:
  7115. {\small\begin{verbatim}
  7116. G(ID:identifier[,EXPRN:vector_expression])
  7117. :gamma_matrix_expression.
  7118. \end{verbatim}}
  7119. {\tt G} is an n-ary operator used to denote a product of $\gamma$ matrices
  7120. contracted with Lorentz four-vectors. Gamma matrices are associated with
  7121. fermion lines in a Feynman diagram. If more than one such line occurs,
  7122. then a different set of $\gamma$ matrices (operating in independent spin
  7123. spaces) is required to represent each line. To facilitate this, the first
  7124. argument of {\tt G} is a line identification identifier (not a number)
  7125. used to distinguish different lines.
  7126. Thus
  7127. {\small\begin{verbatim}
  7128. g(l1,p) * g(l2,q)
  7129. \end{verbatim}}
  7130. denotes the product of {\tt $\gamma$.p} associated with a fermion line
  7131. identified as {\tt L1}, and {\tt $\gamma$.q} associated with another line
  7132. identified as {\tt L2} and where {\tt p} and {\tt q} are Lorentz
  7133. four-vectors. A product of $\gamma$ matrices associated with the same
  7134. line may be written in a contracted form.
  7135. Thus
  7136. {\small\begin{verbatim}
  7137. g(l1,p1,p2,...,p3) = g(l1,p1)*g(l1,p2)*...*g(l1,p3) .
  7138. \end{verbatim}}
  7139. The vector {\tt A} is reserved in arguments of G to denote the special
  7140. $\gamma$ matrix $\gamma^{5}$. Thus
  7141. \begin{quote}
  7142. \begin{tabbing}
  7143. \ \ \ \ \ {\tt g(l,a)}\hspace{0.2in} \= =\ \ \ $\gamma^{5}$ \hspace{0.5in}
  7144. \= associated with the line {\tt L} \\[0.1in]
  7145. \ \ \ \ \ {\tt g(l,p,a)} \> =\ \ \ $\gamma$.p $\times \gamma^{5}$ \>
  7146. associated with the line {\tt L}.
  7147. \end{tabbing}
  7148. \end{quote}
  7149. $\gamma^{\mu}$ (associated with the line {\tt L}) may be written as
  7150. {\tt g(l,u)}, with {\tt U} flagged as an index if contraction over {\tt U}
  7151. is required.
  7152. The notation of Bjorken and Drell is assumed in all operations involving
  7153. $\gamma$ matrices.
  7154. \subsection{EPS Operator}\ttindex{EPS}
  7155. Syntax:
  7156. {\small\begin{verbatim}
  7157. EPS(EXPRN1:vector_expression,...,EXPRN4:vector_exp)
  7158. :vector_exp.
  7159. \end{verbatim}}
  7160. The operator {\tt EPS} has four arguments, and is used only to denote the
  7161. completely antisymmetric tensor of order 4 and its contraction with Lorentz
  7162. four-vectors. Thus
  7163. \[ \epsilon_{i j k l} = \left\{ \begin{array}{cl}
  7164. +1 & \mbox{if $i,j,k,l$ is an even permutation
  7165. of 0,1,2,3} \\
  7166. -1 & \mbox{if an odd permutation} \\
  7167. 0 & \mbox{otherwise}
  7168. \end{array}
  7169. \right. \]
  7170. A contraction of the form $\epsilon_{i j \mu \nu}p_{\mu}q_{\nu}$ may be
  7171. written as {\tt eps(i,j,p,q)}, with {\tt I} and {\tt J} flagged as indices,
  7172. and so on.
  7173. \section{Vector Variables}
  7174. Apart from the line identification identifier in the {\tt G} operator, all
  7175. other arguments of the operators in this section are vectors. Variables
  7176. used as such must be declared so by the type declaration {\tt VECTOR},
  7177. \ttindex{VECTOR} for example:
  7178. {\small\begin{verbatim}
  7179. vector p1,p2;
  7180. \end{verbatim}}
  7181. declares {\tt P1} and {\tt P2} to be vectors. Variables declared as
  7182. indices or given a mass\ttindex{MASS} are automatically declared
  7183. vector by these declarations.
  7184. \section{Additional Expression Types}
  7185. Two additional expression types are necessary for high energy
  7186. calculations, namely
  7187. \subsection{Vector Expressions}\index{High energy vector expression}
  7188. These follow the normal rules of vector combination. Thus the product of a
  7189. scalar or numerical expression and a vector expression is a vector, as are
  7190. the sum and difference of vector expressions. If these rules are not
  7191. followed, error messages are printed. Furthermore, if the system finds an
  7192. undeclared variable where it expects a vector variable, it will ask the
  7193. user in interactive mode whether to make that variable a vector or not. In
  7194. batch mode, the declaration will be made automatically and the user
  7195. informed of this by a message.
  7196. {\tt Examples:}
  7197. Assuming {\tt P} and {\tt Q} have been declared vectors, the following are
  7198. vector expressions
  7199. {\small\begin{verbatim}
  7200. p
  7201. 2*q/3
  7202. 2*x*y*p - p.q*q/(3*q.q)
  7203. \end{verbatim}}
  7204. whereas {\tt p*q} and {\tt p/q} are not.
  7205. \subsection{Dirac Expressions}
  7206. These denote those expressions which involve $\gamma$ matrices. A $\gamma$
  7207. matrix is implicitly a 4 $\times$ 4 matrix, and so the product, sum and
  7208. difference of such expressions, or the product of a scalar and Dirac
  7209. expression is again a Dirac expression. There are no Dirac variables in
  7210. the system, so whenever a scalar variable appears in a Dirac expression
  7211. without an associated $\gamma$ matrix expression, an implicit unit 4
  7212. by 4 matrix is assumed. For example, {\tt g(l,p) + m} denotes {\tt
  7213. g(l,p) + m*<unit 4 by 4 matrix>}. Multiplication of Dirac
  7214. expressions, as for matrix expressions, is of course non-commutative.
  7215. \section{Trace Calculations}\index{High energy trace}
  7216. When a Dirac expression is evaluated, the system computes one quarter of
  7217. the trace of each $\gamma$ matrix product in the expansion of the expression.
  7218. One quarter of each trace is taken in order to avoid confusion between the
  7219. trace of the scalar {\tt M}, say, and {\tt M} representing {\tt M * <unit
  7220. 4 by 4 matrix>}. Contraction over indices occurring in such expressions is
  7221. also performed. If an unmatched index is found in such an expression, an
  7222. error occurs.
  7223. The algorithms used for trace calculations are the best available at the
  7224. time this system was produced. For example, in addition to the algorithm
  7225. developed by Chisholm for contracting indices in products of traces,
  7226. {\REDUCE} uses the elegant algorithm of Kahane for contracting indices in
  7227. $\gamma$ matrix products. These algorithms are described in Chisholm, J. S.
  7228. R., Il Nuovo Cimento X, 30, 426 (1963) and Kahane, J., Journal Math.
  7229. Phys. 9, 1732 (1968).
  7230. It is possible to prevent the trace calculation over any line identifier
  7231. by the declaration {\tt NOSPUR}.\ttindex{NOSPUR} For example,
  7232. {\small\begin{verbatim}
  7233. nospur l1,l2;
  7234. \end{verbatim}}
  7235. will mean that no traces are taken of $\gamma$ matrix terms involving the line
  7236. numbers {\tt L1} and {\tt L2}. However, in some calculations involving
  7237. more than one line, a catastrophic error
  7238. {\small\begin{verbatim}
  7239. This NOSPUR option not implemented
  7240. \end{verbatim}}
  7241. can occur (for the reason stated!) If you encounter this error, please let
  7242. us know!
  7243. A trace of a $\gamma$ matrix expression involving a line identifier which has
  7244. been declared {\tt NOSPUR} may be later taken by making the declaration
  7245. {\tt SPUR}.\ttindex{SPUR}
  7246. See also the CVIT package for an alternative
  7247. mechanism\extendedmanual{ (chapter~\ref{CVIT})}.
  7248. \section{Mass Declarations}\ttindex{MASS}
  7249. It is often necessary to put a particle ``on the mass shell'' in a
  7250. calculation. This can, of course, be accomplished with a {\tt LET}
  7251. command such as
  7252. {\small\begin{verbatim}
  7253. let p.p= m^2;
  7254. \end{verbatim}}
  7255. but an alternative method is provided by two commands {\tt MASS} and
  7256. {\tt MSHELL}.\ttindex{MSHELL}
  7257. {\tt MASS} takes a list of equations of the form:
  7258. {\small\begin{verbatim}
  7259. <vector variable> = <scalar variable>
  7260. \end{verbatim}}
  7261. for example,
  7262. {\small\begin{verbatim}
  7263. mass p1=m, q1=mu;
  7264. \end{verbatim}}
  7265. The only effect of this command is to associate the relevant scalar
  7266. variable as a mass with the corresponding vector. If we now say
  7267. {\small\begin{verbatim}
  7268. mshell <vector variable>,...,<vector variable>;
  7269. \end{verbatim}}
  7270. and a mass has been associated with these arguments, a substitution of the
  7271. form
  7272. {\small\begin{verbatim}
  7273. <vector variable>.<vector variable> = <mass>^2
  7274. \end{verbatim}}
  7275. is set up. An error results if the variable has no preassigned mass.
  7276. \section{Example}
  7277. We give here as an example of a simple calculation in high energy physics
  7278. the computation of the Compton scattering cross-section as given in
  7279. Bjorken and Drell Eqs. (7.72) through (7.74). We wish to compute the trace of
  7280. $$\left. \alpha^2\over2 \right. \left({k^\prime\over k}\right)^2
  7281. \left({\gamma.p_f+m\over2m}\right)\left({\gamma.e^\prime \gamma.e
  7282. \gamma.k_i\over2k.p_i} + {\gamma.e\gamma.e^\prime
  7283. \gamma.k_f\over2k^\prime.p_i}\right)
  7284. \left({\gamma.p_i+m\over2m}\right)$$
  7285. $$
  7286. \left({\gamma.k_i\gamma.e\gamma.e^\prime\over2k.p_i} +
  7287. {\gamma.k_f\gamma.e^\prime\gamma.e\over2k^\prime.p_i}
  7288. \right)
  7289. $$
  7290. where $k_i$ and $k_f$ are the four-momenta of incoming and outgoing photons
  7291. (with polarization vectors $e$ and $e^\prime$ and laboratory energies
  7292. $k$ and $k^\prime$
  7293. respectively) and $p_i$, $p_f$ are incident and final electron four-momenta.
  7294. Omitting therefore an overall factor
  7295. ${\alpha^2\over2m^2}\left({k^\prime\over k}\right)^2$ we need to find
  7296. one quarter of the trace of
  7297. $${
  7298. \left( \gamma.p_f + m\right)
  7299. \left({\gamma.e^\prime \gamma.e\gamma.k_i\over2k.p_i} +
  7300. {\gamma.e\gamma.e^\prime \gamma.k_f\over 2k^\prime.p_i}\right) \left(
  7301. \gamma.p_i + m\right)}$$
  7302. $${
  7303. \left({\gamma.k_i\gamma.e\gamma.e^\prime\over 2k.p_i} +
  7304. {\gamma.k_f\gamma.e^\prime \gamma.e\over2k^\prime.p_i}\right) }$$
  7305. A straightforward REDUCE program for this, with appropriate substitutions
  7306. (using {\tt P1} for $p_i$, {\tt PF} for $p_f$, {\tt KI}
  7307. for $k_i$ and {\tt KF} for $k_f$) is
  7308. {\small\begin{verbatim}
  7309. on div; % this gives output in same form as Bjorken and Drell.
  7310. mass ki= 0, kf= 0, p1= m, pf= m; vector e,ep;
  7311. % if e is used as a vector, it loses its scalar identity as
  7312. % the base of natural logarithms.
  7313. mshell ki,kf,p1,pf;
  7314. let p1.e= 0, p1.ep= 0, p1.pf= m^2+ki.kf, p1.ki= m*k,p1.kf=
  7315. m*kp, pf.e= -kf.e, pf.ep= ki.ep, pf.ki= m*kp, pf.kf=
  7316. m*k, ki.e= 0, ki.kf= m*(k-kp), kf.ep= 0, e.e= -1,
  7317. ep.ep=-1;
  7318. for all p let gp(p)= g(l,p)+m;
  7319. comment this is just to save us a lot of writing;
  7320. gp(pf)*(g(l,ep,e,ki)/(2*ki.p1) + g(l,e,ep,kf)/(2*kf.p1))
  7321. * gp(p1)*(g(l,ki,e,ep)/(2*ki.p1) + g(l,kf,ep,e)/
  7322. (2*kf.p1))$
  7323. write "The Compton cxn is",ws;
  7324. \end{verbatim}}
  7325. (We use {\tt P1} instead of {\tt PI} in the above to avoid confusion with
  7326. the reserved variable {\tt PI}).
  7327. This program will print the following result
  7328. {\small\begin{verbatim}
  7329. (-1) (-1) 2
  7330. The Compton cxn is 1/2*K*KP + 1/2*K *KP + 2*E.EP - 1
  7331. \end{verbatim}}
  7332. \section{Extensions to More Than Four Dimensions}
  7333. In our discussion so far, we have assumed that we are working in the
  7334. normal four dimensions of QED calculations. However, in most cases, the
  7335. programs will also work in an arbitrary number of dimensions. The command
  7336. \ttindex{VECDIM}
  7337. {\small\begin{verbatim}
  7338. vecdim <expression>;
  7339. \end{verbatim}}
  7340. sets the appropriate dimension. The dimension can be symbolic as well as
  7341. numerical. Users should note however, that the {\tt EPS} operator and the
  7342. $\gamma_{5}$ symbol ({\tt A}) are not properly defined in other than four
  7343. dimensions and will lead to an error if used.
  7344. \chapter{{\REDUCE} and Rlisp Utilities}
  7345. {\REDUCE} and its associated support language system Rlisp\index{Rlisp}
  7346. include a number of utilities which have proved useful for program
  7347. development over the years. The following are supported in most of the
  7348. implementations of {\REDUCE} currently available.
  7349. \section{The Standard Lisp Compiler}\index{Compiler}
  7350. Many versions of {\REDUCE} include a Standard Lisp compiler that is
  7351. automatically loaded on demand. You should check your system specific
  7352. user guide to make sure you have such a compiler. To make the compiler
  7353. active, the switch {\tt COMP}\ttindex{COMP} should be turned on. Any
  7354. further definitions input after this will be compiled automatically. If
  7355. the compiler used is a derivative version of the original Griss-Hearn
  7356. compiler,
  7357. (M. L. Griss and A.
  7358. C. Hearn, ``A Portable LISP Compiler", SOFTWARE --- Practice and Experience
  7359. 11 (1981) 541-605),
  7360. there are other switches that might also be
  7361. used in this regard. However, these additional switches are not supported
  7362. in all compilers. They are as follows:
  7363. %\ttindex{PLAP}\ttindex{PGWD}\ttindex{PWRDS}
  7364. {\renewcommand{\arraystretch}{2}
  7365. \begin{tabular}{lp{\reduceboxwidth}}
  7366. {\tt PLAP} & If ON, causes the printing of the
  7367. portable macros produced by the compiler; \\
  7368. %
  7369. {\tt PGWD} & If ON, causes the printing of the
  7370. actual assembly language instructions generated from the macros; \\
  7371. %
  7372. {\tt PWRDS} & If ON, causes a statistic
  7373. message of the form \newline
  7374. {\tt <function> COMPILED, <words> WORDS, <words> LEFT} \newline
  7375. to be printed. The first number is the number of words of binary
  7376. program space the compiled function took, and the second number
  7377. the number of words left unused in binary program space. \\
  7378. \end{tabular}}
  7379. \section{Fast Loading Code Generation Program}\index{Fast loading of code}
  7380. \label{sec-load}
  7381. In most versions of {\REDUCE}, it is possible to take any set of Lisp, Rlisp
  7382. or {\REDUCE} commands and build a fast loading version of them. In Rlisp or
  7383. {\REDUCE}, one does the following:
  7384. {\small\begin{verbatim}
  7385. faslout <filename>;
  7386. <commands or IN statements>
  7387. faslend;
  7388. \end{verbatim}}
  7389. To load such a file, one uses the command {\tt LOAD},\ttindex{LOAD}
  7390. e.g. {\tt load foo;}
  7391. or {\tt load foo,bah;}
  7392. This process produces a fast-loading version of the original file. In some
  7393. implementations, this means another file is created with the same name but
  7394. a different extension. For example, in PSL-based systems, the extension is
  7395. {\tt b} (for binary). In CSL-based systems, however, this process adds the
  7396. fast-loading code to a single file in which all such code is stored.
  7397. Particular functions are provided by CSL for managing this file, and
  7398. described in the CSL user documentation.
  7399. In doing this build, as with the production of a Standard Lisp form of
  7400. such statements, it is important to remember that some of the commands
  7401. must be instantiated during the building process. For example, macros
  7402. must be expanded, and some property list operations must happen.
  7403. The {\REDUCE} sources should be consulted for further details on this.
  7404. % To facilitate this, the {\tt EVAL} and {\tt IGNORE} flags may be
  7405. % used. Note also that there can be no {\tt LOAD} command within the input
  7406. % statements.
  7407. To avoid excessive printout, input statements should be followed by a \$
  7408. instead of the semicolon. With {\tt LOAD} however, the input doesn't
  7409. print out regardless of which terminator is used with the command.
  7410. If you subsequently change the source files used in producing a fast
  7411. loading file, don't forget to repeat the above process in order to update
  7412. the fast loading file correspondingly. Remember also that the text which
  7413. is read in during the creation of the fast load file, in the compiling
  7414. process described above, is {\em not\/} stored in your {\REDUCE}
  7415. environment, but only translated and output. If you want to use the file
  7416. just created, you must then use {\tt LOAD} to load the output of the
  7417. fast-loading file generation program.
  7418. When the file to be loaded contains a complete package for a given
  7419. application, {\tt LOAD\_PACKAGE}\ttindex{LOAD\_PACKAGE} rather than
  7420. {\tt LOAD} should be used. The syntax is the same. However,
  7421. {\tt LOAD\_PACKAGE} does some additional bookkeeping such as recording that
  7422. this package has now been loaded, that is required for the correct
  7423. operation of the system.
  7424. \section{The Standard Lisp Cross Reference Program}\index{Cross reference}
  7425. {\tt CREF}\ttindex{CREF} is a Standard Lisp program for processing a
  7426. set of Standard LISP function definitions to produce:
  7427. \begin{enumerate}
  7428. \item A ``summary'' showing:
  7429. \begin{enumerate}
  7430. \item A list of files processed;
  7431. \item A list of ``entry points'' (functions which are not called or
  7432. are only called by themselves);
  7433. \item A list of undefined functions (functions called but not
  7434. defined in this set of functions);
  7435. \item A list of variables that were used non-locally but not
  7436. declared {\tt GLOBAL} or {\tt FLUID} before their use;
  7437. \item A list of variables that were declared {\tt GLOBAL} but not used
  7438. as {\tt FLUID}s, i.e., bound in a function;
  7439. \item A list of {\tt FLUID} variables that were not bound in a function
  7440. so that one might consider declaring them {\tt GLOBAL}s;
  7441. \item A list of all {\tt GLOBAL} variables present;
  7442. \item A list of all {\tt FLUID} variables present;
  7443. \item A list of all functions present.
  7444. \end{enumerate}
  7445. \item A ``global variable usage'' table, showing for each non-local
  7446. variable:
  7447. \begin{enumerate}
  7448. \item Functions in which it is used as a declared {\tt FLUID} or {\tt GLOBAL};
  7449. \item Functions in which it is used but not declared;
  7450. \item Functions in which it is bound;
  7451. \item Functions in which it is changed by {\tt SETQ}.
  7452. \end{enumerate}
  7453. \item A ``function usage'' table showing for each function:
  7454. \begin{enumerate}
  7455. \item Where it is defined;
  7456. \item Functions which call this function;
  7457. \item Functions called by it;
  7458. \item Non-local variables used.
  7459. \end{enumerate}
  7460. \end{enumerate}
  7461. The program will also check that functions are called with the correct
  7462. number of arguments, and print a diagnostic message otherwise.
  7463. The output is alphabetized on the first seven characters of each function
  7464. name.
  7465. \subsection{Restrictions}
  7466. Algebraic procedures in {\REDUCE} are treated as if they were symbolic, so
  7467. that algebraic constructs will actually appear as calls to symbolic
  7468. functions, such as {\tt AEVAL}.
  7469. \subsection{Usage}
  7470. To invoke the cross reference program, the switch {\tt CREF}
  7471. \ttindex{CREF} is used. {\tt on cref} causes the cref program to load
  7472. and the cross-referencing process to begin. After all the required
  7473. definitions are loaded, {\tt off cref} will cause the cross-reference
  7474. listing to be produced. For example, if you wish to cross-reference all
  7475. functions in the file {\tt tst.red}, and produce the cross-reference
  7476. listing in the file {\tt tst.crf}, the following sequence can be used:
  7477. {\small\begin{verbatim}
  7478. out "tst.crf";
  7479. on cref;
  7480. in "tst.red"$
  7481. off cref;
  7482. shut "tst.crf";
  7483. \end{verbatim}}
  7484. To process more than one file, more {\tt IN} statements may be added
  7485. before the call of {\tt off cref}, or the {\tt IN} statement changed to
  7486. include a list of files.
  7487. \subsection{Options}
  7488. Functions with the flag {\tt NOLIST} will not be examined or output.
  7489. Initially, all Standard Lisp functions are so flagged. (In fact, they are
  7490. kept on a list {\tt NOLIST!*}, so if you wish to see references to {\em
  7491. all} functions, then {\tt CREF} should be first loaded with the command {\tt
  7492. load cref}, and this variable then set to {\tt NIL}).
  7493. It should also be remembered that any macros with the property list flag
  7494. {\tt EXPAND}, or, if the switch {\tt FORCE} is on, without the property
  7495. list flag {\tt NOEXPAND}, will be expanded before the definition is seen
  7496. by the cross-reference program, so this flag can also be used to select
  7497. those macros you require expanded and those you do not.
  7498. \section{Prettyprinting Reduce Expressions}\index{Prettyprinting}
  7499. {\REDUCE} includes a module for printing {\REDUCE} syntax in a standard
  7500. format. This module is activated by the switch {\tt PRET},
  7501. \ttindex{PRET} which is normally off.
  7502. Since the system converts algebraic input into an equivalent symbolic form,
  7503. the printing program tries to interpret this as an algebraic expression
  7504. before printing it. In most cases, this can be done successfully. However,
  7505. there will be occasional instances where results are printed in symbolic
  7506. mode form that bears little resemblance to the original input, even though
  7507. it is formally equivalent.
  7508. If you want to prettyprint a whole file, say {\tt off output,msg;}
  7509. \ttindex{MSG} and (hopefully) only clean output will result. Unlike {\tt
  7510. DEFN},\ttindex{DEFN} input is also evaluated with {\tt PRET}
  7511. \ttindex{PRET} on.
  7512. \section{Prettyprinting Standard Lisp S-Expressions}\index{Prettyprinting}
  7513. REDUCE includes a module for printing
  7514. S-expressions in a standard format. The Standard Lisp function for this
  7515. purpose is {\tt PRETTYPRINT}\ttindex{PRETTYPRINT} which takes a Lisp
  7516. expression and prints the formatted equivalent.
  7517. Users can also have their {\REDUCE} input printed in this form by use of
  7518. the switch {\tt DEFN}.\ttindex{DEFN} This is in fact a convenient way to
  7519. convert {\REDUCE} (or Rlisp) syntax into Lisp. {\tt off msg;} will prevent
  7520. warning messages from being printed.
  7521. NOTE: When {\tt DEFN} is on, input is not evaluated.
  7522. \chapter {Maintaining {\REDUCE}}
  7523. {\REDUCE} continues to evolve both in terms of the number of facilities
  7524. available, and the power of the individual facilities. Corrections are
  7525. made as bugs are discovered, and awkward features simplified. In order to
  7526. provide users with easy access to such enhancements, a {\em {\REDUCE}
  7527. network library\/} has been established from which material can be extracted
  7528. by anyone with electronic mail access to the Internet computer network.
  7529. In addition to miscellaneous documents, source and utility files, the
  7530. library includes a bibliography of papers referencing {\REDUCE} which
  7531. contains over 800 entries. Instructions on using this library are sent to
  7532. all registered {\REDUCE} users who provide a network address. If you
  7533. would like a more complete list of the contents of the library, send to
  7534. {\em reduce-netlib@rand.org\/} the single line message {\em send index\/} or
  7535. {\em help}. The current {\REDUCE} information
  7536. package can be obtained from the network library by including on a
  7537. separate line {\em send info-package\/} and a demonstration file by
  7538. including the line {\em send demonstration}. If you prefer, hard copies
  7539. of the information package and the bibliography are available from the
  7540. {\REDUCE} secretary at RAND, 1700 Main Street, P.O. Box 2138, Santa
  7541. Monica, CA 90407-2138 ({\em reduce@rand.org}). Copies of the network
  7542. library are also maintained at other addresses. At the time of writing,
  7543. {\em reduce-netlib@can.nl\/} and {\em reduce-netlib@pi.cc.u-tokyo.ac.jp\/}
  7544. may also be used instead of {\em reduce-netlib@rand.org}.
  7545. A World Wide Web {\REDUCE} server with URL
  7546. {\small\begin{verbatim}
  7547. http://www.rrz.uni-koeln.de/REDUCE/
  7548. \end{verbatim}}
  7549. is also supported. In addition to general information about {\REDUCE}, this
  7550. server has pointers to the network library, the demonstration versions,
  7551. examples of {\REDUCE} programming, a set of manuals, and the {\REDUCE} online
  7552. help system.
  7553. Finally, there is a {\REDUCE} electronic forum accessible from the same
  7554. networks. This enables {\REDUCE} users to raise questions and discuss
  7555. ideas concerning the use and development of {\REDUCE} with other users.
  7556. Additions and changes to the network library and new releases of {\REDUCE}
  7557. are also announced in this forum. Any user with appropriate electronic
  7558. mail access is encouraged to register for membership in this forum. To do
  7559. so, send a message requesting inclusion to \\
  7560. {\em reduce-forum-request@rand.org}.
  7561. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BeginCodemist
  7562. %%% Taken from Reduce.sty
  7563. % \s{...} is a sentential form in descriptions. Enclosed \em text in <...>
  7564. \newcommand{\s}[1] {$<${\em #1}$>$}
  7565. % \meta{...} is an alternative sentential form in descriptions using \it.
  7566. %\newcommand{\meta}[1]{\mbox{$\langle$\it#1\/$\rangle$}}
  7567. % \k{...} is a keyword. Just do in bold for the moment.
  7568. \renewcommand{\k}[1] {{\bf #1}}
  7569. % \f is a function name. Just do this as tt.
  7570. \newcommand{\f}[1] {{\tt #1}}
  7571. % An example macro for numbering and indenting examples.
  7572. \newcounter{examplectr}
  7573. \newcommand{\example}{\refstepcounter{examplectr}
  7574. \noindent{\bf Example \theexamplectr}}
  7575. \part{Additional {\REDUCE} Documentation}
  7576. \setcounter{examplectr}{0}
  7577. The documentation in this section was written using to a large part
  7578. the \LaTeX\ files provided by the authors, and distributed with
  7579. \REDUCE. There has been extensive editing and much rewriting, so
  7580. the responsibility for this part of the manual rests with the editor,
  7581. John Fitch. It is hoped that this version of the documentation
  7582. contains sufficient information about the facilities available that a
  7583. user may be able to progress. It deliberately avoids discussions of
  7584. algorithms or advanced use; for these the package author's own
  7585. documentation should be consulted. In general the package
  7586. documentation will contain more examples and in some cases additional
  7587. facilities such as tracing.
  7588. \chapter{ALGINT: Integration of square roots}
  7589. \label{ALGINT}
  7590. \typeout{{ALGINT: Integration of square roots}}
  7591. {\footnotesize
  7592. \begin{center}
  7593. James Davenport \\
  7594. School of Mathematical Sciences \\
  7595. University of Bath \\
  7596. Bath BA2 7AY \\
  7597. England \\[0.05in]
  7598. e--mail: jhd@maths.bath.ac.uk
  7599. \end{center}
  7600. }
  7601. The package supplies no new functions, but extends the {\tt
  7602. INT}\ttindex{INT} operator for indefinite integration so it can handle
  7603. a wider range of expressions involving square roots. When it is
  7604. loaded the controlling switch {\tt ALGINT}\ttindex{ALGINT} is turned
  7605. on. If it is desired to revert to the standard integrator, then it
  7606. may be turned off. The normal integrator can deal with some square
  7607. roots but in an unsystematic fashion.
  7608. {\small\begin{verbatim}
  7609. 1: load_package algint;
  7610. 2: int(sqrt(sqrt(a^2+x^2)+x)/x,x);
  7611. 2 2
  7612. sqrt(a)*atan((sqrt(a)*sqrt(sqrt(a + x ) + x)
  7613. 2 2
  7614. *sqrt(a + x )
  7615. 2 2
  7616. - sqrt(a)*sqrt(sqrt(a + x ) + x)*a
  7617. 2 2
  7618. - sqrt(a)*sqrt(sqrt(a + x ) + x)*x)/(2
  7619. \end{verbatim}}
  7620. \newpage
  7621. {\small\begin{verbatim}
  7622. 2 2 2
  7623. *a )) + 2*sqrt(sqrt(a + x ) + x)
  7624. 2 2
  7625. + sqrt(a)*log(sqrt(sqrt(a + x ) + x) - sqrt(a))
  7626. 2 2
  7627. - sqrt(a)*log(sqrt(sqrt(a + x ) + x) + sqrt(a))
  7628. 3: off algint;
  7629. 4: int(sqrt(sqrt(a^2+x^2)+x)/x,x);
  7630. 2 2
  7631. sqrt(sqrt(a + x ) + x)
  7632. int(-------------------------,x)
  7633. x
  7634. \end{verbatim}}
  7635. There is also a switch {\tt TRA},\ttindex{TRA} which may be set on to
  7636. provide detailed tracing of the algorithm used. This is not
  7637. recommended for casual use.
  7638. \chapter[APPLYSYM: Infinitesimal symmetries]{APPLYSYM: Infinitesimal symmetries of differential equations}
  7639. \label{APPLYSYM}
  7640. \typeout{[APPLYSYM: Infinitesimal symmetries]}
  7641. {\footnotesize
  7642. \begin{center}
  7643. Thomas Wolf \\
  7644. School of Mathematical Sciences, Queen Mary and Westfield College \\
  7645. University of London \\
  7646. London E1 4NS, England \\[0.05in]
  7647. e--mail: T.Wolf@maths.qmw.ac.uk
  7648. \end{center}
  7649. }
  7650. The investigation of infinitesimal symmetries of differential equations
  7651. (DEs) with computer algebra programs attracted considerable attention
  7652. over the last years. The package {\tt APPLYSYM} concentrates on the
  7653. implementation of applying symmetries for calculating similarity
  7654. variables to perform a point transformation which lowers the order of
  7655. an ODE or effectively reduces the number of explicitly occuring
  7656. independent variables of a PDE(-system) and for generalising given
  7657. special solutions of ODEs/PDEs with new constant parameters.
  7658. A prerequisite for applying symmetries is the solution of first order
  7659. quasilinear PDEs. The corresponding program
  7660. {\tt QUASILINPDE}\ttindex{QUASILINPDE} can as well be used without
  7661. {\tt APPLYSYM}\ttindex{APPLYSYM} for solving first order PDEs which are
  7662. linear in their first order derivative and otherwise at most rationally
  7663. non-linear. The following two PDEs are equations (2.40) and (3.12)
  7664. taken from E. Kamke, "Loesungsmethoden und Loesungen von Differential-
  7665. gleichungen, Partielle Differentialgleichungen erster Ordnung",
  7666. B.G. Teubner, Stuttgart (1979).
  7667. \newpage
  7668. {\small
  7669. {\small\begin{verbatim}
  7670. ------------------------ Equation 2.40 ------------------------
  7671. 2 3 4
  7672. The quasilinear PDE: 0 = df(z,x)*x*y + 2*df(z,y)*y - 2*x
  7673. 2 2 2
  7674. + 4*x *y*z - 2*y *z .
  7675. The equivalent characteristic system:
  7676. 3 4 2 2 2
  7677. 0=2*(df(z,y)*y - x + 2*x *y*z - y *z )
  7678. 2
  7679. 0=y *(2*df(x,y)*y - x)
  7680. for the functions: x(y) z(y) .
  7681. The general solution of the PDE is given through
  7682. 4 2 2
  7683. log(y)*x - log(y)*x *y*z - y *z sqrt(y)*x
  7684. 0 = ff(----------------------------------,-----------)
  7685. 4 2 y
  7686. x - x *y*z
  7687. with arbitrary function ff(..).
  7688. ------------------------ Equation 3.12 ------------------------
  7689. The quasilinear PDE: 0 = df(w,x)*x + df(w,y)*a*x + df(w,y)*b*y
  7690. + df(w,z)*c*x + df(w,z)*d*y + df(w,z)*f*z.
  7691. The equivalent characteristic system:
  7692. 0=df(w,x)*x
  7693. 0=df(z,x)*x - c*x - d*y - f*z
  7694. 0=df(y,x)*x - a*x - b*y
  7695. for the functions: z(x) y(x) w(x) .
  7696. The general solution of the PDE is given through
  7697. a*x + b*y - y
  7698. 0 = ff(---------------,( - a*d*x + b*c*x + b*f*z - b*z - c*f*x
  7699. b b
  7700. x *b - x
  7701. 2 f f f 2 f
  7702. - d*f*y + d*y - f *z + f*z)/(x *b*f - x *b - x *f + x *f)
  7703. ,w)
  7704. with arbitrary function ff(..).
  7705. \end{verbatim}}
  7706. }
  7707. The program {\tt DETRAFO}\ttindex{DETRAFO} can be used to perform
  7708. point transformations of ODEs/PDEs (and -systems).
  7709. For detailed explanations the user is
  7710. referred to the paper {\em Programs for Applying Symmetries of PDEs}
  7711. by Thomas Wolf, supplied as part of the Reduce documentation as {\tt
  7712. applysym.tex} and published in the Proceedings of ISSAC'95 - 7/95
  7713. Montreal, Canada, ACM Press (1995).
  7714. \chapter{ARNUM: An algebraic number package}
  7715. \label{ARNUM}
  7716. \typeout{{ARNUM: An algebraic number package}}
  7717. {\footnotesize
  7718. \begin{center}
  7719. Eberhard Schr\"{u}fer \\
  7720. Institute SCAI.Alg \\
  7721. German National Research Center for Information Technology (GMD) \\
  7722. Schloss Birlinghoven \\
  7723. D-53754 Sankt Augustin, Germany \\[0.05in]
  7724. e--mail: schruefer@gmd.de
  7725. \end{center}
  7726. }
  7727. Algebraic numbers are the solutions of an irreducible polynomial over
  7728. some ground domain. \index{i} The algebraic number $i$ (imaginary
  7729. unit),\index{imaginary unit} for example, would be defined by the
  7730. polynomial $i^2 + 1$. The arithmetic of algebraic number $s$ can be
  7731. viewed as a polynomial arithmetic modulo the defining polynomial.
  7732. The {\tt ARNUM}\ttindex{ARNUM} package provides a mechanism to
  7733. define other algebraic numbers, and compute with them.
  7734. \section{DEFPOLY}\ttindex{DEFPOLY}
  7735. {\tt DEFPOLY} takes as its argument the defining polynomial for an
  7736. algebraic number, or a number of defining polynomials for different
  7737. algebraic numbers, and arranges that arithmetic with the new symbol(s) is
  7738. performed relative to these polynomials.
  7739. {\small\begin{verbatim}
  7740. load_package arnum;
  7741. defpoly sqrt2**2-2;
  7742. 1/(sqrt2+1);
  7743. SQRT2 - 1
  7744. (x**2+2*sqrt2*x+2)/(x+sqrt2);
  7745. X + SQRT2
  7746. on gcd;
  7747. (x**3+(sqrt2-2)*x**2-(2*sqrt2+3)*x-3*sqrt2)/(x**2-2);
  7748. 2
  7749. X - 2*X - 3
  7750. --------------
  7751. X - SQRT2
  7752. off gcd;
  7753. sqrt(x**2-2*sqrt2*x*y+2*y**2);
  7754. ABS(X - SQRT2*Y)
  7755. \end{verbatim}}
  7756. The following example introduces both $\sqrt 2$ and $5^{1 \over 3}$:
  7757. {\small\begin{verbatim}
  7758. defpoly sqrt2**2-2,cbrt5**3-5;
  7759. *** defining polynomial for primitive element:
  7760. 6 4 3 2
  7761. A1 - 6*A1 - 10*A1 + 12*A1 - 60*A1 + 17
  7762. sqrt2;
  7763. 5 4 3 2
  7764. 48/1187*A1 + 45/1187*A1 - 320/1187*A1 - 780/1187*A1 +
  7765. 735/1187*A1 - 1820/1187
  7766. sqrt2**2;
  7767. 2
  7768. \end{verbatim}}
  7769. \section{SPLIT\_FIELD}\ttindex{SPLIT\_FIELD}
  7770. The function {\tt SPLIT\_FIELD} calculates a primitive element of
  7771. minimal degree for which a given polynomial splits into linear
  7772. factors.
  7773. {\small\begin{verbatim}
  7774. split_field(x**3-3*x+7);
  7775. *** Splitting field is generated by:
  7776. 6 4 2
  7777. A5 - 18*A5 + 81*A5 + 1215
  7778. 4 2
  7779. {1/126*A5 - 5/42*A5 - 1/2*A5 + 2/7,
  7780. 4 2
  7781. - (1/63*A5 - 5/21*A5 + 4/7),
  7782. 4 2
  7783. 1/126*A5 - 5/42*A5 + 1/2*A5 + 2/7}
  7784. for each j in ws product (x-j);
  7785. 3
  7786. X - 3*X + 7
  7787. \end{verbatim}}
  7788. \chapter{ASSIST: Various Useful Utilities}
  7789. \label{ASSIST}
  7790. \typeout{{ASSIST: Various Useful Utilities}}
  7791. {\footnotesize
  7792. \begin{center}
  7793. Hubert Caprasse \\
  7794. D\'epartement d'Astronomie et d'Astrophysique \\
  7795. Institut de Physique, B--5, Sart Tilman \\
  7796. B--4000 LIEGE 1, Belgium\\[0.05in]
  7797. e--mail: caprasse@vm1.ulg.ac.be
  7798. \end{center}
  7799. }
  7800. The {\tt ASSIST}\ttindex{ASSIST} package provides a number of general
  7801. purpose functions which adapt \REDUCE\ to various
  7802. calculational strategies. All the examples in this section require
  7803. the {\tt ASSIST} package to be loaded.
  7804. \section{Control of Switches}
  7805. The two functions \f{SWITCHES, SWITCHORG}
  7806. \ttindex{SWITCHES}\ttindex{SWITCHORG} have no argument and are called
  7807. as if they were mere identifiers.
  7808. \f{SWITCHES} displays the current status of the most often used switches
  7809. when manipulating rational functions;
  7810. {\tt EXP}, {\tt DIV}, {\tt MCD}, {\tt GCD}, {\tt ALLFAC}, {\tt
  7811. INTSTR}, {\tt RAT}, {\tt RATIONAL}, {\tt FACTOR}.
  7812. The switch {\tt DISTRIBUTE} which controls the handling
  7813. of distributed polynomials is included as well (see section~\ref{DISTRIBUTE}).
  7814. \f{SWITCHORG} resets (almost) {\em all} switches in the status they
  7815. have when {\bf entering} into \REDUCE. (See also {\tt RESET},
  7816. chapter~\ref{RESET}\ttindex{RESET}). The new switch {\tt DISTRIBUTE}
  7817. facilitates changing polynomials to a distributed form.
  7818. \section{Manipulation of the List Structure}
  7819. Functions for list manipulation are provided and are generalised
  7820. to deal with the new structure {\tt BAG}.
  7821. \begin{itemize}
  7822. \item[i.]
  7823. Generation of a list of length $n$ with its elements initialised to 0
  7824. and also to append to a list $l$ sufficient zeros to
  7825. make it of length $n$:\ttindex{MKLIST}
  7826. {\small\begin{verbatim}
  7827. MKLIST n; %% n is an INTEGER
  7828. MKLIST(l,n); %% l is List-like, n is an INTEGER
  7829. \end{verbatim}}
  7830. \item[ii.]
  7831. Generation of a list of sublists of length $n$ containing $p$ elements
  7832. equal to $0$ and $n-p$ elements equal to $1$.
  7833. {\small\begin{verbatim}
  7834. SEQUENCES 2; ==> {{0,0},{0,1},{1,0},{1,1}}
  7835. \end{verbatim}}
  7836. The function \f{KERNLIST}\ttindex{KERNLIST} transforms any prefix of
  7837. a kernel into the {\bf \verb+list+} prefix. The output list is a copy:
  7838. {\small\begin{verbatim}
  7839. KERNLIST (<kernel>); ==> {<kernel arguments>}
  7840. \end{verbatim}}
  7841. There are four functions to delete elements from lists. The
  7842. \f{DELETE} function deletes the first occurrence of its first argument
  7843. from the second, while \f{REMOVE} removes a numbered element.
  7844. \f{DELETE\_ALL} eliminates from a list {\em all} elements equal to its
  7845. first argument. \f{DELPAIR} acts on list of pairs and eliminates from
  7846. it the {\em first} pair whose first element is equal to its first
  7847. argument:\ttindex{DELETE}\ttindex{REMOVE}\ttindex{DELETE\_ALL}\ttindex{DELPAIR}
  7848. {\small\begin{verbatim}
  7849. DELETE(x,{a,b,x,f,x}); ==> {a,b,f,x}
  7850. REMOVE({a,b,x,f,x},3); ==> {a,b,f,x}
  7851. DELETE_ALL(x,{a,b,x,f,x}); ==> {a,b,f}
  7852. DELPAIR(a,{{a,1},{b,2},{c,3}}; ==> {{b,2},{c,3}}
  7853. \end{verbatim}}
  7854. \item[iv.]
  7855. The function \f{ELMULT}\ttindex{ELMULT} returns an {\em integer} which is the
  7856. {\em multiplicity} of its first argument in the list which is its
  7857. second argument.
  7858. The function \f{FREQUENCY}\ttindex{FREQUENCY} gives a list of pairs
  7859. whose second element indicates the number of times the first element
  7860. appears inside the original list:
  7861. {\small\begin{verbatim}
  7862. ELMULT(x,{a,b,x,f,x}) ==> 2
  7863. FREQUENCY({a,b,c,a}); ==> {{a,2},{b,1},{c,1}}
  7864. \end{verbatim}}
  7865. \item[v.] The function \f{INSERT}\ttindex{INSERT} inserts a
  7866. given object into a list at the wanted position. The functions
  7867. \f{INSERT\_KEEP\_ORDER}\ttindex{INSERT\_KEEP\_ORDER} and
  7868. \f{MERGE\_LIST}\ttindex{MERGE\_LIST} keep a given ordering when
  7869. inserting one element inside a list or when merging two lists. Both
  7870. have 3 arguments. The last one is the name of a binary boolean
  7871. ordering function:
  7872. {\small\begin{verbatim}
  7873. ll:={1,2,3}$
  7874. INSERT(x,ll,3); ==> {1,2,x,3}
  7875. INSERT_KEEP_ORDER(5,ll,lessp); ==> {1,2,3,5}
  7876. MERGE_LIST(ll,ll,lessp); ==> {1,1,2,2,3,3}
  7877. \end{verbatim}}
  7878. \item[vi.]
  7879. Algebraic lists can be read from right to left or left to right.
  7880. They {\em look} symmetrical. It is sometimes convenient to have
  7881. functions which reflect this. So, as well as \f{FIRST} and \f{REST}
  7882. this package provides the functions \f{LAST}\ttindex{LAST} and
  7883. \f{BELAST}\ttindex{BELAST}. \f{LAST} gives the last element of the
  7884. list while \f{BELAST} gives the list {\em without} its last element. \\
  7885. Various additional functions are provided. They are:
  7886. \f{CONS}, \f{(.)}, \f{POSITION}, \f{DEPTH}, \f{PAIR}, \f{APPENDN},
  7887. \f{REPFIRST}, \f{REPLAST}
  7888. \ttindex{CONS}\ttindex{.}\ttindex{POSITION}\ttindex{DEPTH}
  7889. \ttindex{PAIR}\ttindex{APPENDN}\ttindex{REPLAST}\ttindex{REPLAST}
  7890. The token ``dot'' needs a special comment. It corresponds to
  7891. several different operations.
  7892. \begin{enumerate}
  7893. \item If one applies it on the left of a list, it acts as the \f{CONS}
  7894. function. Note however that blank spaces are required around the dot:
  7895. {\small\begin{verbatim}
  7896. 4 . {a,b}; ==> {4,a,b}
  7897. \end{verbatim}}
  7898. \item If one applies it on the right of a list, it has the same
  7899. effect as the \f{PART} operator:
  7900. {\small\begin{verbatim}
  7901. {a,b,c}.2; ==> b
  7902. \end{verbatim}}
  7903. \item If one applies it on 4--dimensional vectors, it acts as in the
  7904. HEPHYS package (chapter~\ref{HEPHYS}
  7905. \end{enumerate}
  7906. \f{POSITION} returns the position of the first occurrence of x in
  7907. a list or a message if x is not present in it.
  7908. \f{DEPTH} returns an {\em integer} equal to the number of levels where
  7909. a list is found if and only if this number is the {\em same} for each
  7910. element of the list otherwise it returns a message telling the user
  7911. that list is of {\em unequal depth}.
  7912. \f{PAIR} has two arguments which must be lists. It returns a list
  7913. whose elements are {\em lists of two elements.} The $n^{th}$ sublist
  7914. contains the $n^{th}$ element of the first list and the $n^{th}$
  7915. element of the second list. These types of lists are called {\em
  7916. association lists} or ALISTS in the following.
  7917. \f{APPENDN} has {\em any} number of lists as arguments, and appends
  7918. them all.
  7919. \f{REPFIRST} has two arguments. The first one is any object, the
  7920. second one is a list. It replaces the first element of the list by the
  7921. object.
  7922. \f{REPREST} has also two arguments. It replaces the rest of the list
  7923. by its first argument and returns the new list without destroying the
  7924. original list.
  7925. {\small\begin{verbatim}
  7926. ll:={{a,b}}$
  7927. ll1:=ll.1; ==> {a,b}
  7928. ll.0; ==> list
  7929. 0 . ll; ==> {0,{a,b}}
  7930. DEPTH ll; ==> 2
  7931. PAIR(ll1,ll1); ==> {{a,a},{b,b}}
  7932. REPFIRST{new,ll); ==> {new}
  7933. ll3:=APPENDN(ll1,ll1,ll1); ==> {a,b,a,b,a,b}
  7934. POSITION(b,ll3); ==> 2
  7935. REPREST(new,ll3); ==> {a,new}
  7936. \end{verbatim}}
  7937. \item[vii.]
  7938. The functions \f{ASFIRST}\ttindex{ASFIRST},
  7939. \f{ASLAST}\ttindex{ASLAST}, \f{ASREST}\ttindex{ASREST},
  7940. \f{ASFLIST}\ttindex{ASFLIST}, \f{ASSLIST}\ttindex{ASSLIST},
  7941. and \f{RESTASLIST}\ttindex{RESTASLIST}
  7942. act on ALISTS or on list of lists of well defined depths
  7943. and have two arguments. The first is the key object
  7944. which one seeks to associate in some way to an element of the association
  7945. list which is the second argument. \f{ASFIRST} returns the pair whose
  7946. first element is equal to the first argument. \f{ASLAST} returns the
  7947. pair whose last element is equal to the first argument. \f{ASREST}
  7948. needs a {\em list} as its first argument. The function seeks the first
  7949. sublist of a list of lists (which is its second argument)
  7950. equal to its first argument and returns it.
  7951. \f{RESTASLIST} has a {\em list of keys} as its first arguments. It
  7952. returns the collection of pairs which meet the criterion of \f{ASREST}.
  7953. \f{ASFLIST} returns a list containing {\em all pairs} which
  7954. satisfy to the criteria of the function \f{ASFIRST}. So the output
  7955. is also an ALIST or a list of lists.
  7956. \f{ASSLIST} returns a list which contains {\em all pairs} which have
  7957. their second element equal to the first argument.
  7958. {\small\begin{verbatim}
  7959. lp:={{a,1},{b,2},{c,3}}$
  7960. ASFIRST(a,lp); ==> {a,1}
  7961. ASLAST(1,lp); ==> {a,1}
  7962. ASREST({1},lp); ==> {a,1}
  7963. RESTASLIST({a,b},lp); ==> {{1},{2}}
  7964. lpp:=APPEND(lp,lp)$
  7965. ASFLIST(a,lpp); ==> {{a,1},{a,1}}
  7966. ASSLIST(1,lpp); ==> {{a,1},{a,1}}
  7967. \end{verbatim}}
  7968. \end{itemize}
  7969. \section{The Bag Structure and its Associated Functions}
  7970. The LIST structure of \REDUCE\ is very convenient for manipulating
  7971. groups of objects which are, {\em a priori}, unknown. This structure is
  7972. endowed with other properties such as ``mapping'' {\em i.e.\ }the fact
  7973. that if \verb+OP+ is an operator one gets, by default,
  7974. {\small\begin{verbatim}
  7975. OP({x,y}); ==> {OP(x),OP(y)}
  7976. \end{verbatim}}
  7977. It is not permitted to submit lists to the operations valid on rings
  7978. so that lists cannot be indeterminates of polynomials. Frequently
  7979. procedure arguments cannot be lists.
  7980. At the other extreme, so to say, one has the \verb+KERNEL+
  7981. structure associated
  7982. to the algebraic declaration \verb+operator+. This structure behaves as
  7983. an ``unbreakable'' one and, for that reason, behaves
  7984. like an ordinary identifier.
  7985. It may generally be bound to all non-numeric procedure parameters
  7986. and it may appear
  7987. as an ordinary indeterminate inside polynomials. \\
  7988. The \verb+BAG+ structure is intermediate between a list and an operator.
  7989. From the operator it borrows the property to be a \verb+KERNEL+ and,
  7990. therefore, may be an indeterminate of a polynomial. From the list structure
  7991. it borrows the property to be a {\em composite} object.\\[5pt]
  7992. \mbox{\underline{{\bf Definition}:\hfill}}\\[4pt]
  7993. A bag is an object endowed with the following properties:
  7994. \begin{enumerate}
  7995. \item It is a \verb+KERNEL+ composed of an atomic prefix (its
  7996. envelope) and
  7997. its content (miscellaneous objects).
  7998. \item Its content may be changed in an analogous way as the content of a
  7999. list. During these manipulations the name of the bag is {\em conserved}.
  8000. \item Properties may be given to the envelope. For instance, one may
  8001. declare it \verb+NONCOM+ or \verb+SYMMETRIC+ etc.\ $\ldots$
  8002. \end{enumerate}
  8003. \vspace{5pt}
  8004. \mbox{\underline{{\bf Available Functions}:\hfill}}
  8005. \begin{itemize}
  8006. \item[i.] A default bag envelope \verb+BAG+\index{BAG} is defined.
  8007. It is a reserved identifier.
  8008. An identifier other than \verb+LIST+ or one which is already associated
  8009. with a boolean function may be defined as a bag envelope through the
  8010. command \f{PUTBAG}\ttindex{PUTBAG}. In particular, any operator may
  8011. also be declared to be a bag. {\bf When and only when} the identifier
  8012. is not an already defined function does \f{PUTBAG} puts on it the
  8013. property of an OPERATOR PREFIX.
  8014. The command:
  8015. {\small\begin{verbatim}
  8016. PUTBAG id1,id2,....idn;
  8017. \end{verbatim}}
  8018. declares \verb+id1,.....,idn+ as bag envelopes.
  8019. Analogously, the command\ttindex{CLEARBAG}
  8020. {\small\begin{verbatim}
  8021. CLEARBAG id1,...idn;
  8022. \end{verbatim}}
  8023. eliminates the bag property on \verb+id1,...,idn+.
  8024. \item[ii.] The boolean function \f{BAGP}\ttindex{BAGP} detects the bag
  8025. property.
  8026. {\small\begin{verbatim}
  8027. aa:=bag(x,y,z)$
  8028. if BAGP aa then "ok"; ==> ok
  8029. \end{verbatim}}
  8030. \item[iii.] Most functions defined above for lists do also work for
  8031. bags.
  8032. Moreover functions subsequently defined for SETS (see
  8033. section~\ref{A-SETS}) also work.
  8034. However, because of the conservation of the envelope, they act
  8035. somewhat differently.
  8036. {\small\begin{verbatim}
  8037. PUTBAG op; ==> T
  8038. aa:=op(x,y,z)$
  8039. FIRST op(x,y,z); ==> op(x)
  8040. REST op(x,y,z); ==> op(y,z)
  8041. BELAST op(x,y,z); ==> op(x,y)
  8042. APPEND(aa,aa); ==> op(x,y,z,x,y,z)
  8043. LENGTH aa; ==> 3
  8044. DEPTH aa; ==> 1
  8045. \end{verbatim}}
  8046. When ``appending'' two bags with {\em different} envelopes, the
  8047. resulting bag gets the name of the one bound to the first parameter of
  8048. \f{APPEND}.
  8049. The function \f{LENGTH} gives the actual number of variables on which
  8050. the operator (or the function) depends.
  8051. The NAME of the ENVELOPE is kept by the functions \f{FIRST},
  8052. \f{SECOND}, \f{LAST} and \f{BELAST}.
  8053. \item[iv.]
  8054. The connection between the list and the bag structures is made easy
  8055. thanks to \f{KERNLIST} which transforms a bag into a list and thanks to
  8056. the coercion function \f{LISTBAG}\ttindex{LISTBAG}. This function has
  8057. 2 arguments and is used as follows:
  8058. {\small\begin{verbatim}
  8059. LISTBAG(<list>,<id>); ==> <id>(<arg_list>)
  8060. \end{verbatim}}
  8061. The identifier \verb+<id>+ if allowed is automatically declared as a bag
  8062. envelope or an error message is generated.
  8063. Finally, two boolean functions which work both for bags and lists are
  8064. provided. They are \f{BAGLISTP}\ttindex{BAGLISTP} and
  8065. \f{ABAGLISTP}\ttindex{ABAGLISTP}.
  8066. They return T or NIL (in a conditional statement) if their argument
  8067. is a bag or a list for the first one, if their argument is a list of
  8068. sublists or a bag containing bags for the second one.
  8069. \end{itemize}
  8070. \section{Sets and their Manipulation Functions}
  8071. \label{A-SETS}
  8072. The ASSIST package makes the Standard LISP set functions available in
  8073. algebraic mode and also {\em generalises} them so that they can be
  8074. applied on bag--like objects as well.
  8075. \begin{itemize}
  8076. \item[i.]
  8077. The constructor \f{MKSET}\ttindex{MKSET} transforms a list or bag into
  8078. a set by eliminating duplicates.
  8079. {\small\begin{verbatim}
  8080. MKSET({1,a,a1}); ==> {1,a}
  8081. MKSET bag(1,a,a1); ==> bag(1,a)
  8082. \end{verbatim}}
  8083. \f{SETP}\ttindex{SETP} is a boolean function which recognises
  8084. set--like objects.
  8085. \item[ii.]
  8086. The standard functions are \f{UNION}\ttindex{UNION},
  8087. \f{INTERSECT}\ttindex{INTERSECT}, \f{DIFFSET}\ttindex{DIFFSET}
  8088. and \f{SYMDIFF}\ttindex{SYMDIFF}.
  8089. They have two arguments which must be sets; otherwise an error message
  8090. is issued.
  8091. \end{itemize}
  8092. \section{General Purpose Utility Functions}
  8093. \begin{itemize}
  8094. \item[i.]
  8095. The functions \f{MKIDNEW}\ttindex{MKIDNEW},
  8096. \f{DELLASTDIGIT}\ttindex{DELLASTDIGIT},
  8097. \f{DETIDNUM}\ttindex{DETIDNUM},
  8098. \f{LIST\_TO\_IDS}\ttindex{LIST\_TO\_IDS}
  8099. handle identifiers. \f{MKIDNEW}\ttindex{MKIDNEW} is a variant of \f{MKID}.
  8100. \f{MKIDNEW} has either 0 or 1 argument. It generates an identifier which
  8101. has not yet been used before.
  8102. {\small\begin{verbatim}
  8103. MKIDNEW(); ==> g0001
  8104. MKIDNEW(a); ==> ag0002
  8105. \end{verbatim}}
  8106. \f{DELLASTDIGIT} takes an integer as argument, it strips it from its last
  8107. digit.
  8108. {\small\begin{verbatim}
  8109. DELLASTDIGIT 45; ==> 4
  8110. \end{verbatim}}
  8111. \f{DETIDNUM}, determines the trailing integer from an identifier. It is
  8112. convenient when one wants to make a do loop starting from a set of
  8113. indices $ a_1, \ldots , a_{n} $.
  8114. {\small\begin{verbatim}
  8115. DETIDNUM a23; ==> 23
  8116. \end{verbatim}}
  8117. \f{LIST\_to\_IDS} generalises the function \f{MKID} to a list of
  8118. atoms. It creates and interns an identifier from the concatenation of
  8119. the atoms. The first atom cannot be an integer.
  8120. {\small\begin{verbatim}
  8121. LIST_TO_IDS {a,1,id,10}; ==> a1id10
  8122. \end{verbatim}}
  8123. The function \f{ODDP}\ttindex{ODDP} detects odd integers.
  8124. The function \f{FOLLOWLINE}\ttindex{FOLLOWLINE} is convenient when
  8125. using the function \f{PRIN2} for controlling layout.
  8126. {\small\begin{verbatim}
  8127. <<prin2 2; prin2 5>>$
  8128. 25
  8129. <<prin2 2; followline(3); prin2 5>>$
  8130. 2
  8131. 5
  8132. \end{verbatim}}
  8133. The function \f{RANDOMLIST}\ttindex{RANDOMLIST} generates a list of
  8134. positive random numbers. It takes
  8135. two arguments which are both integers. The first one indicates the range
  8136. inside which the random numbers are chosen. The second one indicates how
  8137. many numbers are to be generated.
  8138. {\small\begin{verbatim}
  8139. RANDOMLIST(10,5); ==> {2,1,3,9,6}
  8140. \end{verbatim}}
  8141. \f{MKRANDTABL}\ttindex{MKRANDTABL} generates a table of random
  8142. numbers. This table is either
  8143. a one or two dimensional array. The base of random numbers may be either
  8144. an integer or a floating point number. In this latter case
  8145. the switch \f{rounded} must be ON. The function has three
  8146. arguments. The first is either a one integer or a two integer
  8147. list. The second is the base chosen to generate the random
  8148. numbers. The third is the chosen name for the generated array. In the
  8149. example below a two-dimensional table of integer random numbers is
  8150. generated as array elements of the identifier {\f ar}.
  8151. {\small\begin{verbatim}
  8152. MKRANDTABL({3,4},10,ar); ==>
  8153. *** array ar redefined
  8154. {3,4}
  8155. \end{verbatim}}
  8156. The output is the array dimension.
  8157. \f{COMBNUM(n,p)}\ttindex{COMBNUM} gives the number of combinations of
  8158. $n$ objects taken $p$ at a time. It has the two integer arguments $n$
  8159. and $p$.
  8160. \f{PERMUTATIONS(n)}\ttindex{PERMUTATIONS} gives the list of permutations
  8161. on $n$ objects, each permutation being represented as a list.
  8162. \f{CYCLICPERMLIST}\ttindex{CYCLICPERMLIST} gives the list of
  8163. {\em cyclic} permutations. For both functions, the argument may
  8164. also be a {\tt bag}.
  8165. {\small\begin{verbatim}
  8166. PERMUTATIONS {1,2} ==> {{1,2},{2,1}}
  8167. CYCLICPERMLIST {1,2,3} ==>
  8168. {{1,2,3},{2,3,1},{3,1,2}}
  8169. \end{verbatim}}
  8170. \f{COMBINATIONS}\ttindex{COMBINATIONS} gives a list of combinations on
  8171. $n$ objects taken $p$ at a time. The first argument is a
  8172. list (or a bag) and the second is the integer $p$.
  8173. {\small\begin{verbatim}
  8174. COMBINATIONS({1,2,3},2) ==> {{2,3},{1,3},{1,2}}
  8175. \end{verbatim}}
  8176. \f{REMSYM}\ttindex{REMSYM} is a command that erases the \REDUCE\ commands
  8177. {\tt symmetric} or {\tt antisymmetric}.
  8178. \f{SYMMETRIZE}\ttindex{SYMMETRIZE} is a powerful function which
  8179. generate a symmetric expression.
  8180. It has 3 arguments. The first is a list (or a list of lists) containing
  8181. the expressions which will appear as variables for a kernel. The second
  8182. argument is the kernel-name and the third is a permutation function
  8183. which either exist in the algebraic or in the symbolic mode. This
  8184. function may have been constructed by the user. Within this package
  8185. the two functions \f{PERMUTATIONS} and \f{CYCLICPERMLIST} may be used.
  8186. {\small\begin{verbatim}
  8187. ll:={a,b,c}$
  8188. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  8189. OP(A,B,C) + OP(B,C,A) + OP(C,A,B)
  8190. SYMMETRIZE(list ll,op,cyclicpermlist); ==>
  8191. OP({A,B,C}) + OP({B,C,A}) + OP({C,A,B})
  8192. \end{verbatim}}
  8193. Notice that taking for the first argument a list of lists gives rise to
  8194. an expression where each kernel has a {\em list as argument}. Another
  8195. peculiarity of this function is that, unless a pattern matching is
  8196. made on the operator \verb+OP+, it needs to be reevaluated. Here is
  8197. an illustration:
  8198. {\small\begin{verbatim}
  8199. op(a,b,c):=a*b*c$
  8200. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  8201. OP(A,B,C) + OP(B,C,A) + OP(C,A,B)
  8202. for all x let op(x,a,b)=sin(x*a*b);
  8203. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  8204. OP(B,C,A) + SIN(A*B*C) + OP(A,B,C)
  8205. \end{verbatim}}
  8206. The functions \f{SORTNUMLIST}\ttindex{SORTNUMLIST} and
  8207. \f{SORTLIST}\ttindex{SORTLIST} are functions which sort
  8208. lists. They use {\em bubblesort} and {\em quicksort} algorithms.
  8209. \f{SORTNUMLIST} takes as argument a list of numbers. It sorts it in
  8210. increasing order.
  8211. \f{SORTLIST} is a generalisation of the above function.
  8212. It sorts the list according
  8213. to any well defined ordering. Its first argument is the list and its
  8214. second argument is the ordering function. The content of the list
  8215. is not necessary numbers but must be such that the ordering function has
  8216. a meaning.
  8217. {\small\begin{verbatim}
  8218. l:={1,3,4,0}$ SORTNUMLIST l; ==> {0,1,3,4}
  8219. ll:={1,a,tt,z}$ SORTLIST(ll,ordp); ==> {a,z,tt,1}
  8220. \end{verbatim}}
  8221. Note: using these functions for kernels or bags may be
  8222. dangerous since they are destructive. If it is needed, it is recommended
  8223. first to apply \f{KERNLIST} on them.
  8224. The function \f{EXTREMUM}\ttindex{EXTREMUM} is a generalisation of the
  8225. functions \f{MIN} and \f{MAX} to include general orderings. It is a 2
  8226. arguments function.
  8227. The first is the list and the second is the ordering function.
  8228. With the list \verb+ll+ defined in the last example, one gets
  8229. {\small\begin{verbatim}
  8230. EXTREMUM(ll,ordp); ==> 1
  8231. \end{verbatim}}
  8232. \item[iii.] There are four functions to identify dependencies.
  8233. \f{FUNCVAR}\ttindex{FUNCVAR} takes any expression as argument and
  8234. returns the set of variables on which it depends. Constants are eliminated.
  8235. {\small\begin{verbatim}
  8236. FUNCVAR(e+pi+sin(log(y)); ==> {y}
  8237. \end{verbatim}}
  8238. \f{DEPATOM}\ttindex{DEPATOM} has an {\bf atom} as argument. It returns
  8239. its argument if it is
  8240. a number or if no dependency has previously been declared. Otherwise,
  8241. it returns the list of variables on which in depends as declared in
  8242. various {\tt DEPEND} declarations.
  8243. {\small\begin{verbatim}
  8244. DEPEND a,x,y;
  8245. DEPATOM a; ==> {x,y}
  8246. \end{verbatim}}
  8247. The functions \f{EXPLICIT}\ttindex{EXPLICIT} and
  8248. \f{IMPLICIT}\ttindex{IMPLICIT} make explicit or
  8249. implicit the dependencies.
  8250. {\small\begin{verbatim}
  8251. depend a,x; depend x,y,z;
  8252. EXPLICIT a; ==> a(x(y,z))
  8253. IMPLICIT ws; ==> a
  8254. \end{verbatim}}
  8255. These are useful when one does not know the names of the variables
  8256. and (or) the nature of the dependencies.
  8257. \f{KORDERLIST}\ttindex{KORDERLIST} is a zero argument function which
  8258. display the actual ordering.
  8259. {\small\begin{verbatim}
  8260. KORDER x,y,z;
  8261. KORDERLIST; ==> (x,y,z)
  8262. \end{verbatim}}
  8263. \item[iv.] A function \f{SIMPLIFY}\ttindex{SIMPLIFY} which takes an
  8264. arbitrary expression
  8265. is available which {\em forces} down-to-the-bottom simplification of
  8266. an expression. It is useful with \f{SYMMETRIZE}. It has also proved
  8267. useful to simplify some output expressions of the package EXCALC
  8268. (chapter~\ref{EXCALC}).
  8269. {\small\begin{verbatim}
  8270. l:=op(x,y,z)$
  8271. op(x,y,z):=x*y*z$
  8272. SYMMETRIZE(l,op,cyclicpermlist); ==>
  8273. op(x,y,z)+op(y,z,x)+op(z,x,y)
  8274. SIMPLIFY ws; ==> op(y,z,x)+op(z,x,y)+x*y*z
  8275. \end{verbatim}}
  8276. \item[v.] Filtering functions for lists.
  8277. \f{CHECKPROLIST}\ttindex{CHECKPROLIST} is a boolean function which
  8278. checks if the elements of a list have a definite property. Its first
  8279. argument is the list, and its second argument is a boolean function
  8280. (\f{FIXP NUMBERP $\ldots$}) or an ordering function (as \f{ORDP}).
  8281. \f{EXTRACTLIST}\ttindex{EXTRACTLIST} extracts from the list given as
  8282. its first argument the elements which satisfy the boolean function
  8283. given as its second argument.
  8284. {\small\begin{verbatim}
  8285. l:={1,a,b,"st")$
  8286. EXTRACTLIST(l,fixp); ==> {1}
  8287. EXTRACTLIST(l,stringp); ==> {st}
  8288. \end{verbatim}}
  8289. \end{itemize}
  8290. \section{Properties and Flags}
  8291. It may be useful to provide analogous functions in algebraic mode to
  8292. the properties and flags of LISP. Just using the symbolic mode
  8293. functions to alter property lists of objects may easily destroy the
  8294. integrity of the system. The functions which are here described {\bf
  8295. do ignore} the property list and flags already defined by the system
  8296. itself. They generate and track the {\em additional properties and
  8297. flags} that the user issues using them. They offer the possibility of
  8298. working on property lists in an algebraic context.
  8299. \begin{description}
  8300. \item[i. Flags]
  8301. To a given identifier, one may
  8302. associates another one linked to it ``in the background''. The three
  8303. functions \f{PUTFLAG}\ttindex{PUTFLAG},
  8304. \f{DISPLAYFLAG}\ttindex{DISPLAYFLAG} and
  8305. \f{CLEARFLAG}\ttindex{CLEARFLAG} handle them.
  8306. \f{PUTFLAG} has 3 arguments. The first is the identifier or a list
  8307. of identifiers, the second is the name of the flag,
  8308. the third is T (true) or 0 (zero).
  8309. When the third argument is T, it creates the flag, when it is 0 it
  8310. destroys it.
  8311. {\small\begin{verbatim}
  8312. PUTFLAG(z1,flag_name,t); ==> flag_name
  8313. PUTFLAG({z1,z2},flag1_name,t); ==> t
  8314. PUTFLAG(z2,flag1_name,0); ==>
  8315. \end{verbatim}}
  8316. \f{DISPLAYFLAG} allows to extract flags. Continuing the example:
  8317. {\small\begin{verbatim}
  8318. DISPLAYFLAG z1; ==> {flag_name,flag1_name}
  8319. DISPLAYFLAG z2; ==> {}
  8320. \end{verbatim}}
  8321. \f{CLEARFLAG} is a command which clears {\em all} flags associated to
  8322. the identifiers $id_1, \ldots , id_n$.
  8323. \item[ii. Properties]
  8324. \f{PUTPROP}\ttindex{PUTPROP} has four arguments. The second argument
  8325. is the {\em indicator} of the property. The third argument may
  8326. be {\em any valid expression}. The fourth one is also T or 0.
  8327. {\small\begin{verbatim}
  8328. PUTPROP(z1,property,x^2,t); ==> z1
  8329. \end{verbatim}}
  8330. In general, one enter
  8331. {\small\begin{verbatim}
  8332. PUTPROP(LIST(idp1,idp2,..),<propname>,<value>,T);
  8333. \end{verbatim}}
  8334. If the last argument is 0 then the property is removed.
  8335. To display a specific property, one uses
  8336. \f{DISPLAYPROP} which takes two arguments. The first is the name of the
  8337. identifier, the second is the indicator of the property.
  8338. {\small\begin{verbatim}
  8339. 2
  8340. DISPLAYPROP(z1,property); ==> {property,x }
  8341. \end{verbatim}}
  8342. Finally, \f{CLEARPROP} is a nary commmand which clears {\em all}
  8343. properties of the identifiers which appear as arguments.
  8344. \end{description}
  8345. \section{Control Functions}
  8346. The ASSIST package also provides additional functions which
  8347. improve the user control of the environment.
  8348. \begin{itemize}
  8349. \item[i.]
  8350. The first set of functions is composed of unary and binary boolean functions.
  8351. They are:
  8352. {\small\begin{verbatim}
  8353. ALATOMP x; x is anything.
  8354. ALKERNP x; x is anything.
  8355. DEPVARP(x,v); x is anything.
  8356. (v is an atom or a kernel)
  8357. \end{verbatim}}
  8358. \f{ALATOMP}\ttindex{ALATOMP} has the value T iff x is an integer or
  8359. an identifier {\em after} it has been evaluated down to the bottom.
  8360. \f{ALKERNP}\ttindex{ALKERNP} has the value T iff x is a kernel {\em
  8361. after} it has been evaluated down to the bottom.
  8362. \f{DEPVARP}\ttindex{DEPVARP} returns T iff the expression x depends on
  8363. v at {\bf any level}.
  8364. The above functions together with \f{PRECP}\ttindex{PRECP} have been
  8365. declared operator functions to ease the verification of their value.
  8366. \f{NORDP}\ttindex{NORDP} is essentially equivalent to \verb+not+\f{ORDP}
  8367. when inside a conditional statement. Otherwise, it can be used
  8368. while \verb+not+\f{ORDP} cannot.
  8369. \item[ii.]
  8370. The next functions allow one to {\em analyse} and to {\em clean} the
  8371. environment of \REDUCE\ which is created by the user while
  8372. working interactively. Two functions are provided:\\
  8373. \f{SHOW}\ttindex{SHOW} allows to get the various identifiers already
  8374. assigned and to see their type. \f{SUPPRESS}\ttindex{SUPPRESS}
  8375. selectively clears the used identifiers or clears them all. It is to
  8376. be stressed that identifiers assigned from the input of files are {\bf
  8377. ignored}. Both functions have one argument and the same options for
  8378. this argument:
  8379. {\small\begin{verbatim}
  8380. SHOW (SUPPRESS) all
  8381. SHOW (SUPPRESS) scalars
  8382. SHOW (SUPPRESS) lists
  8383. SHOW (SUPPRESS) saveids (for saved expressions)
  8384. SHOW (SUPPRESS) matrices
  8385. SHOW (SUPPRESS) arrays
  8386. SHOW (SUPPRESS) vectors
  8387. (contains vector, index and tvector)
  8388. SHOW (SUPPRESS) forms
  8389. \end{verbatim}}
  8390. The option \verb+all+ is the most convenient for \f{SHOW} but it may
  8391. takes time to get the answer after one has worked several hours.
  8392. When entering \REDUCE\ the option \verb+all+ for \f{SHOW} gives:
  8393. {\small\begin{verbatim}
  8394. SHOW all; ==> scalars are: NIL
  8395. arrays are: NIL
  8396. lists are: NIL
  8397. matrices are: NIL
  8398. vectors are: NIL
  8399. forms are: NIL
  8400. \end{verbatim}}
  8401. It is a convenient way to remember the various options.
  8402. Starting from a fresh environment
  8403. {\small\begin{verbatim}
  8404. a:=b:=1$
  8405. SHOW scalars; ==> scalars are: (A B)
  8406. SUPPRESS scalars; ==> t
  8407. SHOW scalars; ==> scalars are: NIL
  8408. \end{verbatim}}
  8409. \item[iii.]
  8410. The \f{CLEAR}\ttindex{CLEAR} function of the system does not do a
  8411. complete cleaning of \verb+OPERATORS+ and \verb+FUNCTIONS+. The
  8412. following two functions do a more complete cleaning and, also
  8413. automatically takes into account the {\em user} flag and properties that the
  8414. functions \f{PUTFLAG} and \f{PUTPROP} may have introduced.
  8415. Their names are \f{CLEAROP}\ttindex{CLEAROP} and
  8416. \f{CLEARFUNCTIONS}\ttindex{CLEARFUNCTIONS}.
  8417. \f{CLEAROP} takes one operator as its argument. \f{CLEARFUNCTIONS} is
  8418. a nary command. If one issues
  8419. {\small\begin{verbatim}
  8420. CLEARFUNCTIONS a1,a2, ... , an $
  8421. \end{verbatim}}
  8422. The functions with names \verb+ a1,a2, ... ,an+ are cleared.
  8423. One should be careful when using this facility since the
  8424. only functions which cannot be erased are those which are
  8425. protected with the \verb+lose+ flag.
  8426. \end{itemize}
  8427. \section{Handling of Polynomials}
  8428. The module contains some utility functions to handle
  8429. standard quotients and several new facilities to manipulate polynomials.
  8430. \begin{itemize}
  8431. \item[i.] Two functions \f{ALG\_TO\_SYMB}\ttindex{ALG\_TO\_SYMB} and
  8432. \f{SYMB\_TO\_ALG}\ttindex{SYMB\_TO\_ALG} allow the changing of an expression
  8433. which is in the algebraic standard quotient form into a prefix lisp
  8434. form and vice-versa. This is made
  8435. in such a way that the symbol \verb+list+ which appears in the
  8436. algebraic mode disappear in the symbolic form (there it becomes
  8437. a parenthesis ``()'' ) and it is reintroduced in the translation
  8438. from a symbolic prefix lisp expression to an algebraic one.
  8439. The following example shows how the well-known lisp function
  8440. \f{FLATTENS} can be trivially transportd into algebraic mode:
  8441. {\small\begin{verbatim}
  8442. algebraic procedure ecrase x;
  8443. lisp symb_to_alg flattens1 alg_to_symb algebraic x;
  8444. symbolic procedure flattens1 x;
  8445. % ll; ==> ((A B) ((C D) E))
  8446. % flattens1 ll; (A B C D E)
  8447. if atom x then list x else
  8448. if cdr x then
  8449. append(flattens1 car x, flattens1 cdr x)
  8450. else flattens1 car x;
  8451. \end{verbatim}}
  8452. gives, for instance,
  8453. {\small\begin{verbatim}
  8454. ll:={a,{b,{c},d,e},{{{z}}}}$
  8455. ECRASE ll; ==> {A, B, C, D, E, Z}
  8456. \end{verbatim}}
  8457. \item[ii.] \f{LEADTERM}\ttindex{LEADTERM} and
  8458. \f{REDEXPR}\ttindex{REDEXPR} are the algebraic equivalent of the
  8459. symbolic functions \f{LT} and \f{RED}. They give the
  8460. {\em leading term} and the {\em reductum} of a polynomial. They also
  8461. work for rational functions. Their interest lies in the fact that they
  8462. do not require to extract the main variable. They work according to
  8463. the current ordering of the system:
  8464. {\small\begin{verbatim}
  8465. pol:=x+y+z$
  8466. LEADTERM pol; ==> x
  8467. korder y,x,z;
  8468. LEADTERM pol; ==> y
  8469. REDEXPR pol; ==> x + z
  8470. \end{verbatim}}
  8471. By default, the representation of multivariate polynomials is recursive.
  8472. With such a representation, the function \f{LEADTERM} does not necessarily
  8473. extract a true monom. It extracts a monom in the leading indeterminate
  8474. multiplied by a polynomial in the other indeterminates. However, very often
  8475. one needs to handle true monoms separately. In that case, one needs a
  8476. polynomial in {\em distributive} form. Such a form is provided by the
  8477. package GROEBNER (chapter~\ref{GROEBNER}). The facility there may be
  8478. too involved and the need to load an additional package can be a
  8479. problem. So,
  8480. a new switch is created to handle {\em distributed} polynomials. It is
  8481. called {\tt DISTRIBUTE}\ttindex{DISTRIBUTE} and a new function
  8482. \label{DISTRIBUTE} \f{DISTRIBUTE} puts a polynomial in distributive
  8483. form. With the switch {\bf on}, \f{LEADTERM} gives {\bf true} monoms.
  8484. \f{MONOM}\ttindex{MONOM} transforms a polynomial into a list of
  8485. monoms. It works whatever the setting of the switch {\tt DISTRIBUTE}.
  8486. \f{SPLITTERMS}\ttindex{SPLITTERMS} is analoguous to \f{MONOM} except
  8487. that it gives a list of two lists. The first sublist contains the
  8488. positive terms while the second sublist contains the negative terms.
  8489. \f{SPLITPLUSMINUS}\ttindex{SPLITPLUSMINUS} gives a list whose first
  8490. element is an expression of the positive part of the polynomial and
  8491. its second element is its negative part.
  8492. \item[iii.]
  8493. Two complementary functions \f{LOWESTDEG}\ttindex{LOWESTDEG} and
  8494. \f{DIVPOL}\ttindex{DIVPOL} are provided.
  8495. The first takes a polynomial as its first argument and the name of an
  8496. indeterminate as its second argument. It returns the {\em lowest degree}
  8497. in that indeterminate. The second function takes two polynomials and
  8498. returns both the quotient and its remainder.
  8499. \end{itemize}
  8500. \section{Handling of Transcendental Functions}
  8501. The functions \f{TRIGREDUCE}\ttindex{TRIGREDUCE} and
  8502. \f{TRIGEXPAND}\ttindex{TRIGEXPAND} and the equivalent
  8503. ones for hyperbolic functions \f{HYPREDUCE}\ttindex{HYPREDUCE} and
  8504. \f{HYPEXPAND}\ttindex{HYPEXPAND}
  8505. make the transformations to multiple arguments and from
  8506. multiple arguments to elementary arguments.
  8507. {\small\begin{verbatim}
  8508. aa:=sin(x+y)$
  8509. TRIGEXPAND aa; ==> SIN(X)*COS(Y) + SIN(Y)*COS(X)
  8510. TRIGREDUCE ws; ==> SIN(Y + X)
  8511. \end{verbatim}}
  8512. When a trigonometric or hyperbolic expression is symmetric with
  8513. respect to the interchange of {\tt SIN (SINH)} and {\tt COS (COSH)},
  8514. the application of \f{TRIG(HYP)REDUCE} may often lead to great
  8515. simplifications. However, if it is highly asymmetric, the repeated
  8516. application of \f{TRIG(HYP)REDUCE} followed by the use of
  8517. \f{TRIG(HYP)EXPAND} will lead to {\em more} complicated
  8518. but more symmetric expressions:
  8519. {\small\begin{verbatim}
  8520. aa:=(sin(x)^2+cos(x)^2)^3$
  8521. TRIGREDUCE aa; ==> 1
  8522. bb:=1+sin(x)^3$
  8523. TRIGREDUCE bb; ==>
  8524. - SIN(3*X) + 3*SIN(X) + 4
  8525. ---------------------------
  8526. 4
  8527. TRIGEXPAND ws; ==>
  8528. 3 2
  8529. SIN(X) - 3*SIN(X)*COS(X) + 3*SIN(X) + 4
  8530. -------------------------------------------
  8531. 4
  8532. \end{verbatim}}
  8533. See also the TRIGSIMP package (chapter~\ref{TRIGSIMP}).
  8534. \section{Coercion from lists to arrays and converse}
  8535. Sometimes when a list is very long and especially if frequent access
  8536. to its elements are needed it is advantageous (temporarily) to
  8537. transform it into an array.
  8538. \f{LIST\_TO\_ARRAY}\ttindex{LIST\_TO\_ARRAY} has three arguments. The
  8539. first is the list. The second is an integer which indicates the array
  8540. dimension required. The third is the name of an identifier which will
  8541. play the role of the array name generated by it. If the chosen
  8542. dimension is not compatible with the list depth and structure an error
  8543. message is issued. \f{ARRAY\_TO\_LIST}\ttindex{ARRAY\_TO\_LIST} does
  8544. the opposite coercion. It takes the array name as its sole argument.
  8545. \section{Handling of n--dimensional Vectors}
  8546. Explicit vectors in {\tt EUCLIDEAN} space may be represented by
  8547. list-like or bag-like objects of depth 1. The components may be bags
  8548. but may {\bf not} be lists. Functions are provided to do the sum, the
  8549. difference and the scalar product. When space-dimension is three
  8550. there are also functions for the cross and mixed products.
  8551. \f{SUMVECT}\ttindex{SUMVECT}, \f{MINVECT}\ttindex{MINVECT},
  8552. \f{SCALVECT}\ttindex{SCALVECT}, \f{CROSSVECT}\ttindex{CROSSVECT} have
  8553. two arguments. \f{MPVECT}\ttindex{MPVECT} has three arguments.
  8554. {\small\begin{verbatim}
  8555. l:={1,2,3}$
  8556. ll:=list(a,b,c)$
  8557. SUMVECT(l,ll); ==> {A + 1,B + 2,C + 3}
  8558. MINVECT(l,ll); ==> { - A + 1, - B + 2, - C + 3}
  8559. SCALVECT(l,ll); ==> A + 2*B + 3*C
  8560. CROSSVECT(l,ll); ==> { - 3*B + 2*C,3*A - C, - 2*A + B}
  8561. MPVECT(l,ll,l); ==> 0
  8562. \end{verbatim}}
  8563. \section{Handling of Grassmann Operators}
  8564. \index{Grassmann Operators}
  8565. Grassman variables are often used in physics. For them the
  8566. multiplication operation is associative, distributive but
  8567. anticommutative. The basic \REDUCE\ does not provide this.
  8568. However implementing it in full generality would almost certainly
  8569. decrease the overall efficiency of the system. This small module
  8570. together with the declaration of antisymmetry for operators is enough
  8571. to deal with most calculations. The reason is, that a product of
  8572. similar anticommuting kernels can easily be transformed into an
  8573. antisymmetric operator with as many indices as the number of these
  8574. kernels. Moreover, one may also issue pattern matching rules to
  8575. implement the anticommutativity of the product. The functions in this
  8576. module represent the minimum functionality required to identify them
  8577. and to handle their specific features.
  8578. \f{PUTGRASS}\ttindex{PUTGRASS} is a (nary) command which give
  8579. identifiers the property to be the names of Grassmann kernels.
  8580. \f{REMGRASS}\ttindex{REMGRASS} removes this property.
  8581. \f{GRASSP}\ttindex{GRASSP} is a boolean function which detects
  8582. Grassmann kernels.
  8583. \f{GRASSPARITY}\ttindex{GRASSPARITY} takes a {\bf monom} as argument
  8584. and gives its parity. If the monom is a simple Grassmann kernel it
  8585. returns 1.
  8586. \f{GHOSTFACTOR}\ttindex{GHOSTFACTOR} has two arguments. Each one is a
  8587. monom. It is equal to
  8588. {\small\begin{verbatim}
  8589. (-1)**(GRASSPARITY u * GRASSPARITY v)
  8590. \end{verbatim}}
  8591. Here is an illustration to show how the above functions work:
  8592. {\small\begin{verbatim}
  8593. PUTGRASS eta;
  8594. if GRASSP eta(1) then "Grassmann kernel"; ==>
  8595. Grassmann kernel
  8596. aa:=eta(1)*eta(2)-eta(2)*eta(1); ==>
  8597. AA := - ETA(2)*ETA(1) + ETA(1)*ETA(2)
  8598. GRASSPARITY eta(1); ==> 1
  8599. GRASSPARITY (eta(1)*eta(2)); ==> 0
  8600. GHOSTFACTOR(eta(1),eta(2)); ==> -1
  8601. grasskernel:=
  8602. {eta(~x)*eta(~y) => -eta y * eta x when nordp(x,y),
  8603. (~x)*(~x) => 0 when grassp x}$
  8604. exp:=eta(1)^2$
  8605. exp where grasskernel; ==> 0
  8606. aa where grasskernel; ==> - 2*ETA(2)*ETA(1)
  8607. \end{verbatim}}
  8608. \section{Handling of Matrices}
  8609. There are additional facilities for matrices.
  8610. \begin{itemize}
  8611. \item[i.]
  8612. Often one needs to construct some {\tt UNIT} matrix of
  8613. a given dimension. This construction is performed by the function
  8614. \f{UNITMAT}\ttindex{UNITMAT}. It is a nary function. The command is
  8615. {\small\begin{verbatim}
  8616. UNITMAT M1(n1), M2(n2), .....Mi(ni) ;
  8617. \end{verbatim}}
  8618. where \verb+M1,...Mi+ are names of matrices and
  8619. \verb+ n1, n2, ..., ni+ are integers.
  8620. \f{MKIDM}\ttindex{MKIDM} is a generalisation of
  8621. \f{MKID}\ttindex{MKID}. It allows the indexing of matrix names. If
  8622. \verb+u+ and \verb+u1+ are two matrices, one can go from one to the
  8623. other:
  8624. {\small\begin{verbatim}
  8625. matrix u(2,2);$ unitmat u1(2)$
  8626. u1; ==>
  8627. [1 0]
  8628. [ ]
  8629. [0 1]
  8630. mkidm(u,1); ==>
  8631. [1 0]
  8632. [ ]
  8633. [0 1]
  8634. \end{verbatim}}
  8635. Note: MKIDM(V,1) will fail even if the matrix V1 exists, unless V is
  8636. also a matrix.
  8637. This function allows to make loops on matrices like the following.
  8638. If \verb+U, U1, U2,.., U5+ are matrices:
  8639. {\small\begin{verbatim}
  8640. FOR I:=1:5 DO U:=U-MKIDM(U,I);
  8641. \end{verbatim}}
  8642. \item[ii.]
  8643. The next functions map matrices onto bag-like or list-like objects
  8644. and conversely they generate matrices from bags or lists.
  8645. \f{COERCEMAT}\ttindex{COERCEMAT} transforms the matrix first argument
  8646. into a list of lists.
  8647. {\small\begin{verbatim}
  8648. COERCEMAT(U,id)
  8649. \end{verbatim}}
  8650. When \verb+id+ is \verb+list+ the matrix is transformed into a list of
  8651. lists. Otherwise it transforms it into a bag of bags whose envelope is
  8652. equal to \verb+id+.
  8653. \f{BAGLMAT}\ttindex{BAGLMAT} does the inverse. The {\bf first}
  8654. argument is the bag-like or list-like object while the second argument
  8655. is the matrix identifier.
  8656. {\small\begin{verbatim}
  8657. BAGLMAT(bgl,U)
  8658. \end{verbatim}}
  8659. \verb+bgl+ becomes the matrix \verb+U+. The transformation is
  8660. {\bf not} done if \verb+U+ is {\em already} the name of a
  8661. previously defined matrix, to avoid accidental redefinition
  8662. of that matrix.
  8663. \item[ii.]
  8664. The functions \f{SUBMAT}\ttindex{SUBMAT},
  8665. \f{MATEXTR}\ttindex{MATEXTR}, \f{MATEXTC}\ttindex{MATEXTC} take parts
  8666. of a given matrix.
  8667. \f{SUBMAT} has three arguments.
  8668. {\small\begin{verbatim}
  8669. SUBMAT(U,nr,nc)
  8670. \end{verbatim}}
  8671. The first is the matrix name, and the other two are the row and column
  8672. numbers. It gives the submatrix obtained from \verb+U+ deleting the
  8673. row \verb+nr+ and the column \verb+nc+. When one of them is equal to
  8674. zero only column \verb+nc+ or row \verb+nr+ is deleted.
  8675. \f{MATEXTR} and \f{MATEXTC} extract a row or a column and place it into
  8676. a list-like or bag-like object.
  8677. {\small\begin{verbatim}
  8678. MATEXTR(U,VN,nr)
  8679. MATEXTC(U,VN,nc)
  8680. \end{verbatim}}
  8681. where \verb+U+ is the matrix, \verb+VN+ is the ``vector name'',
  8682. \verb+nr+ and \verb+nc+ are integers. If \verb+VN+ is equal
  8683. to {\tt list} the vector is given as a list otherwise it is
  8684. given as a bag.
  8685. \item[iii.]
  8686. Functions which manipulate matrices: \f{MATSUBR}\ttindex{MATSUBR},
  8687. \f{MATSUBC}\ttindex{MATSUBC}, \f{HCONCMAT}\ttindex{HCONCMAT},
  8688. \f{VCONCMAT}\ttindex{VCONCMAT}, \f{TPMAT}\ttindex{TPMAT},
  8689. \f{HERMAT}\ttindex{HERMAT}.
  8690. \f{MATSUBR} and \f{MATSUBC} substitute rows and columns. They have
  8691. three arguments.
  8692. {\small\begin{verbatim}
  8693. MATSUBR(U,bgl,nr)
  8694. MATSUBC(U,bgl,nc)
  8695. \end{verbatim}}
  8696. The meaning of the variables \verb+U, nr, nc+ is the same as above
  8697. while \verb+bgl+ is a list-like or bag-like vector.
  8698. Its length should be compatible with the dimensions of the matrix.
  8699. \f{HCONCMAT} and \f{VCONCMAT} concatenate two matrices.
  8700. {\small\begin{verbatim}
  8701. HCONCMAT(U,V)
  8702. VCONCMAT(U,V)
  8703. \end{verbatim}}
  8704. The first function concatenates horizontally, the second one
  8705. concatenates vertically. The dimensions must match.
  8706. \f{TPMAT} makes the tensor product of two matrices. It is also an
  8707. {\em infix} function.
  8708. {\small\begin{verbatim}
  8709. TPMAT(U,V) or U TPMAT V
  8710. \end{verbatim}}
  8711. \f{HERMAT} takes the hermitian conjugate of a matrix
  8712. {\small\begin{verbatim}
  8713. HERMAT(U,HU)
  8714. \end{verbatim}}
  8715. where \verb+HU+ is the identifier for the hermitian matrix of
  8716. \verb+U+. It should {\bf unassigned} for this function to work
  8717. successfully. This is done on purpose to prevent accidental
  8718. redefinition of an already used identifier.
  8719. \item[iv.]
  8720. \f{SETELMAT} and \f{GETELMAT} are functions of two integers. The first
  8721. one reset the element \verb+(i,j)+ while the second one extract an
  8722. element identified by \verb+(i,j)+. They may be useful when
  8723. dealing with matrices {\em inside procedures}.
  8724. \end{itemize}
  8725. \chapter[ATENSOR: Tensor Simplification]%
  8726. {ATENSOR: Package for Tensor Simplification}
  8727. \label{ATENSOR}
  8728. \typeout{{ATENSOR: Package for Tensor Simplification}}
  8729. {\footnotesize
  8730. \begin{center}
  8731. V.~A.~Ilyin and A.~P.~Kryukov \\
  8732. \end{center}
  8733. }
  8734. \ttindex{ATENSOR}
  8735. %\markboth{CHAPTER \ref{ATENSOR}. ATENSOR: TENSOR SIMPLIFICATION}{}
  8736. %\thispagestyle{myheadings}
  8737. Tensors are classical examples for Objects often used in mathematics and physics.
  8738. Indexed objects can have very complicated and intricated properties.
  8739. For example the Riemann tensor has symmetry properties with respect to
  8740. permutation of indices. Moreover it satisfies the cyclic identity. There are a
  8741. number of linear identities with many terms in the case of Riemann-Cartan geometry
  8742. with torsion.
  8743. From the user's point of view, there are three groups of tensor properties:
  8744. \begin{itemize}
  8745. \item {\bf S} - symmetry with respect to index permutation;
  8746. \item {\bf I} - linear identities;
  8747. \item {\bf D} - invariance with respect to renamings of dummy indices;
  8748. \end{itemize}
  8749. The problem under investigation can be formulated as whether two tensor
  8750. expressions are equal or not by taking into account S-I-D properties.
  8751. \section{Basic tensors and tensor expressions}
  8752. Under basic tensors we understand the object with finite number of indices
  8753. which can have such properties as {\it symmetry} and {\it multiterm linear identities}
  8754. (including the {\it symmetry relations}). \\
  8755. Under tensor expression we understand any expression which can be obtained
  8756. from basic tensors by summation with integer coefficients and multiplication
  8757. (commutative) of basic tensors. \\
  8758. It is assumed that all terms in the tensor expression have the same number of
  8759. indices. Some pairs of them are marked as dummy ones. The set of nondummy
  8760. names have to be the same for each term in the tensor expression. The names
  8761. of dummies can be arbitrary.
  8762. \section{Operators for tensors}
  8763. Use \f{TENSOR}\ttindex{TENSOR} to declare tensors and \f{TCLEAR}\ttindex{TCLEAR}
  8764. to remove them. The command \f{TSYM}\ttindex{TSYM} defines symmetry relations of basic
  8765. tensors and \f{KBASIS}\ttindex{KBASIS} determines the
  8766. {\bf K}-Basis, which is the general name for a ``triangle'' set of linear independent
  8767. vectors for a basic tensor considered as a separate tensor expression.
  8768. It is possible to build the sum, the difference and the multiplication for tensors.
  8769. It is assumed that indices with identical names means the summation over their values. \par
  8770. {\bf Example}:
  8771. {\small\begin{verbatim}
  8772. 1: load atensor;
  8773. 2: tensor s2,a3;
  8774. 3: tsym s2(i,j) - s2(j,i), % Symmetric
  8775. 3: a3(i,j,k) + a3(j,i,k), % Antisymm.
  8776. 3: a3(i,j,k) - a3(j,k,i);
  8777. 4: kbasis s2,a3;
  8778. s2(j,i) + (-1)*s2(i,j)
  8779. 1
  8780. a3(k,i,j) + a3(j,i,k)
  8781. a3(k,j,i) + (-1)*a3(j,i,k)
  8782. a3(i,k,j) + (-1)*a3(j,i,k)
  8783. a3(i,j,k) + a3(j,i,k)
  8784. a3(j,k,i) + a3(j,i,k)
  8785. 5
  8786. \end{verbatim}}
  8787. \section{Switches}
  8788. There are two switches defined. The switch \f{DUMMYPRI}\ttindex{DUMMYPRI} prints dummy
  8789. indices with internal names and numbers. It's default value is {\tt OFF}.
  8790. The other switch called \f{SHORTEST}\ttindex{SHORTEST} prints tensor expressions in shortest
  8791. form that was produced during evaluation. The default value is {\tt OFF}. \par
  8792. \ \\
  8793. For further information refer to the documentation which comes with this package.
  8794. \chapter[AVECTOR: Vector Algebra]%
  8795. {AVECTOR: A vector algebra and calculus package}
  8796. \label{AVECTOR}
  8797. \typeout{{AVECTOR: Vector Algebra}}
  8798. {\footnotesize
  8799. \begin{center}
  8800. David Harper \\
  8801. Astronomy Unit, Queen Mary and Westfield College \\
  8802. University of London \\
  8803. Mile End Road \\
  8804. London E1 4NS, England \\[0.05in]
  8805. e--mail: adh@star.qmw.ac.uk
  8806. \end{center}
  8807. }
  8808. \ttindex{AVECTOR}
  8809. This package provides \REDUCE\ with the ability to perform vector
  8810. algebra using the same notation as scalar algebra. The basic
  8811. algebraic operations are supported, as are differentiation and
  8812. integration of vectors with respect to scalar variables, cross product
  8813. and dot product, component manipulation and application of scalar
  8814. functions ({\em e.g.} cosine) to a vector to yield a vector result.
  8815. \section{Vector declaration and initialisation}
  8816. To declare a list of names to be vectors use the VEC command:
  8817. \index{VEC command}
  8818. {\small\begin{verbatim}
  8819. VEC A,B,C;
  8820. \end{verbatim}}
  8821. declares the variables {\tt A}, {\tt B} and {\tt C} to be vectors.
  8822. If they have already been assigned (scalar) values, these will be lost.
  8823. When a vector is declared using the {\tt VEC} command, it does not
  8824. have an initial value.
  8825. If a vector value is assigned to a scalar variable, then that
  8826. variable will automatically be declared as a vector and the
  8827. user will be notified that this has happened.
  8828. \index{AVEC function}
  8829. A vector may be initialised using the {\tt AVEC} function which
  8830. takes three scalar arguments and returns a vector made up
  8831. from those scalars. For example
  8832. {\small\begin{verbatim}
  8833. A := AVEC(A1, A2, A3);
  8834. \end{verbatim}}
  8835. sets the components of the vector {\tt A} to {\tt A1}, {\tt A2} and
  8836. {\tt A3}.
  8837. \section{Vector algebra}
  8838. (In the examples which follow, {\tt V}, {\tt V1}, {\tt V2} {\em etc}
  8839. are assumed to be vectors while {\tt S}, {\tt S1}, {\tt S2} etc are
  8840. scalars.)
  8841. \index{+ ! vector}\index{- ! vector}\index{* ! vector}\index{/ ! vector}
  8842. The scalar algebra operators +,-,* and / may be used with
  8843. vector operands according to the rules of vector algebra.
  8844. Thus multiplication and division of a vector by a scalar
  8845. are both allowed, but it is an error to multiply or
  8846. divide one vector by another.
  8847. \begin{tabular}{l l}
  8848. {\tt V := V1 + V2 - V3;} & Addition and subtraction \\
  8849. {\tt V := S1*3*V1;} & Scalar multiplication \\
  8850. {\tt V := V1/S;} & Scalar division \\
  8851. {\tt V := -V1;} & Negation \\
  8852. \end{tabular}
  8853. \index{DOT ! vector}\index{Dot product}\index{CROSS ! vector}
  8854. \index{cross product}
  8855. \noindent Vector multiplication is carried out using the infix
  8856. operators {\tt DOT} and {\tt CROSS}. These are defined to have
  8857. higher precedence than scalar multiplication and
  8858. division.
  8859. \begin{tabular}{l l}
  8860. {\tt V := V1 CROSS V2;} & Cross product \\
  8861. {\tt S := V1 DOT V2;} & Dot product \\
  8862. {\tt V := V1 CROSS V2 + V3;} & \\
  8863. {\tt V := (V1 CROSS V2) + V3;} & \\
  8864. \end{tabular}
  8865. The last two expressions are equivalent due to the precedence of
  8866. the {\tt CROSS} operator.
  8867. \index{VMOD operator}
  8868. The modulus of a vector may be calculated using the {\tt VMOD} operator.
  8869. {\small\begin{verbatim}
  8870. S := VMOD V;
  8871. \end{verbatim}}
  8872. A unit vector may be generated from any vector using the {\tt VMOD}
  8873. operator.
  8874. {\small\begin{verbatim}
  8875. V1 := V/(VMOD V);
  8876. \end{verbatim}}
  8877. Components may be extracted from any vector using index notation
  8878. in the same way as an array.
  8879. \begin{tabular}{l l}
  8880. {\tt V := AVEC(AX, AY, AZ);} & \\
  8881. {\tt V(0);} & yields AX \\
  8882. {\tt V(1);} & yields AY \\
  8883. {\tt V(2);} & yields AZ \\
  8884. \end{tabular}
  8885. It is also possible to set values of individual components. Following
  8886. from above:
  8887. {\small\begin{verbatim}
  8888. V(1) := B;
  8889. \end{verbatim}}
  8890. The vector {\tt V} now has components {\tt AX}, {\tt B}, {\tt AZ}.
  8891. \index{vector ! differentiation}
  8892. \index{vector ! integration}
  8893. \index{differentiation ! vector}
  8894. \index{differentiation ! vector}
  8895. Vectors may be used as arguments in the differentiation and
  8896. integration routines in place of the dependent expression.
  8897. \begin{tabular}{l l}
  8898. {\tt V := AVEC(X**2, SIN(X), Y);} & \\
  8899. {\tt DF(V,X);} & yields (2*X, COS(X), 0) \\
  8900. {\tt INT(V,X);} & yields (X**3/3, -COS(X), Y*X) \\
  8901. \end{tabular}
  8902. Vectors may be given as arguments to monomial functions such as {\tt
  8903. SIN}, {\tt LOG} and {\tt TAN}. The result is a vector obtained by
  8904. applying the function component-wise to the argument vector.
  8905. \begin{tabular}{l l}
  8906. {\tt V := AVEC(A1, A2, A3);} & \\
  8907. {\tt SIN(V);} & yields (SIN(A1), SIN(A2), SIN(A3)) \\
  8908. \end{tabular}
  8909. \section{Vector calculus}
  8910. \index{DIV ! operator}\index{divergence ! vector field}
  8911. \index{GRAD ! operator}\index{gradient ! vector field}
  8912. \index{CURL ! operator}\index{curl ! vector field}
  8913. \index{DELSQ ! operator}\index{Laplacian ! vector field}
  8914. The vector calculus operators div, grad and curl are recognised.
  8915. The Laplacian operator is also available and may be applied to
  8916. scalar and vector arguments.
  8917. \begin{tabular}{l l}
  8918. {\tt V := GRAD S;} & Gradient of a scalar field \\
  8919. {\tt S := DIV V;} & Divergence of a vector field \\
  8920. {\tt V := CURL V1;} & Curl of a vector field \\
  8921. {\tt S := DELSQ S1;} & Laplacian of a scalar field \\
  8922. {\tt V := DELSQ V1;} & Laplacian of a vector field \\
  8923. \end{tabular}
  8924. These operators may be used in any orthogonal curvilinear coordinate
  8925. system. The user may alter the names of the coordinates and the values
  8926. of the scale factors. Initially the coordinates are {\tt X}, {\tt Y}
  8927. and {\tt Z} and the scale factors are all unity.
  8928. \index{COORDS vector}\index{HFACTORS scale factors}
  8929. There are two special vectors : {\tt COORDS} contains the names
  8930. of the coordinates in the current system and {\tt HFACTORS}
  8931. contains the values of the scale factors.
  8932. \index{COORDINATES operator}
  8933. The coordinate names may be changed using the {\tt COORDINATES}
  8934. operator.
  8935. {\small\begin{verbatim}
  8936. COORDINATES R,THETA,PHI;
  8937. \end{verbatim}}
  8938. This command changes the coordinate names to {\tt R}, {\tt THETA} and
  8939. {\tt PHI}.
  8940. \index{SCALEFACTORS operator}
  8941. The scale factors may be altered using the {\tt SCALEFACTORS} operator.
  8942. {\small\begin{verbatim}
  8943. SCALEFACTORS(1,R,R*SIN(THETA));
  8944. \end{verbatim}}
  8945. This command changes the scale factors to {\tt 1}, {\tt R} and {\tt R
  8946. SIN(THETA)}.
  8947. Note that the arguments of {\tt SCALEFACTORS} must be enclosed in
  8948. parentheses. This is not necessary with {\tt COORDINATES}.
  8949. When vector differential operators are applied to an expression,
  8950. the current set of coordinates are used as the independent
  8951. variables and the scale factors are employed in the calculation.
  8952. %%(See, for example, Batchelor G.K. 'An Introduction to Fluid
  8953. %%Mechanics', Appendix 2.)
  8954. \index{"!*CSYSTEMS global (AVECTOR)}
  8955. Several coordinate systems are pre-defined and may be invoked by
  8956. name. To see a list of valid names enter
  8957. {\small\begin{verbatim}
  8958. SYMBOLIC !*CSYSTEMS;
  8959. \end{verbatim}}
  8960. and \REDUCE\ will respond with something like
  8961. {\small\begin{verbatim}
  8962. (CARTESIAN SPHERICAL CYLINDRICAL)
  8963. \end{verbatim}}
  8964. \index{GETCSYSTEM command}
  8965. To choose a coordinate system by name, use the command {\tt GETCSYSTEM}.
  8966. To choose the Cartesian coordinate system :
  8967. {\small\begin{verbatim}
  8968. GETCSYSTEM 'CARTESIAN;
  8969. \end{verbatim}}
  8970. \index{PUTCSYSTEM command}
  8971. Note the quote which prefixes the name of the coordinate system. This
  8972. is required because {\tt GETCSYSTEM} (and its complement {\tt
  8973. PUTCSYSTEM}) is a {\tt SYMBOLIC} procedure which requires a literal
  8974. argument.
  8975. \REDUCE\ responds by typing a list of the coordinate names in that
  8976. coordinate system. The example above would produce the response
  8977. {\small\begin{verbatim}
  8978. (X Y Z)
  8979. \end{verbatim}}
  8980. whilst
  8981. {\small\begin{verbatim}
  8982. GETCSYSTEM 'SPHERICAL;
  8983. \end{verbatim}}
  8984. would produce
  8985. {\small\begin{verbatim}
  8986. (R THETA PHI)
  8987. \end{verbatim}}
  8988. Note that any attempt to invoke a coordinate system is subject to the
  8989. same restrictions as the implied calls to {\tt COORDINATES} and {\tt
  8990. SCALEFACTORS}. In particular, {\tt GETCSYSTEM} fails if any of the
  8991. coordinate names has been assigned a value and the previous coordinate
  8992. system remains in effect.
  8993. A user-defined coordinate system can be assigned a name using the
  8994. command {\tt PUTCSYSTEM}. It may then be re-invoked at a later stage using
  8995. {\tt GETCSYSTEM}.
  8996. \example\index{AVECTOR package ! example}
  8997. We define a general coordinate system with coordinate names {\tt
  8998. X},{\tt Y},{\tt Z} and scale factors {\tt H1},{\tt H2},{\tt H3} :
  8999. {\small\begin{verbatim}
  9000. COORDINATES X,Y,Z;
  9001. SCALEFACTORS(H1,H2,H3);
  9002. PUTCSYSTEM 'GENERAL;
  9003. \end{verbatim}}
  9004. This system may later be invoked by entering
  9005. {\small\begin{verbatim}
  9006. GETCSYSTEM 'GENERAL;
  9007. \end{verbatim}}
  9008. \section{Volume and Line Integration}
  9009. Several functions are provided to perform volume and line integrals.
  9010. These operate in any orthogonal curvilinear coordinate system and
  9011. make use of the scale factors described in the previous section.
  9012. Definite integrals of scalar and vector expressions may be calculated
  9013. using the {\tt DEFINT} function\footnote{Not to be confused with the
  9014. DEFINT package described in chapter~\ref{DEFINT}}.
  9015. \example\index{AVECTOR package ! example}
  9016. \index{DEFINT function}\index{integration ! definite (simple)}
  9017. \index{definite integration (simple)}
  9018. \noindent To calculate the definite integral of $\sin(x)^2$ between 0 and
  9019. 2$\pi$ we enter
  9020. {\small\begin{verbatim}
  9021. DEFINT(SIN(X)**2,X,0,2*PI);
  9022. \end{verbatim}}
  9023. This function is a simple extension of the {\tt INT} function taking
  9024. two extra arguments, the lower and upper bounds of integration
  9025. respectively.
  9026. \index{VOLINTEGRAL function}\index{integration ! volume}
  9027. Definite volume integrals may be calculated using the {\tt
  9028. VOLINTEGRAL} function whose syntax is as follows :
  9029. \noindent {\tt VOLINTEGRAL}({\tt integrand}, vector {\tt lower-bound},
  9030. vector {\tt upper-bound});
  9031. \example\index{AVECTOR package ! example}
  9032. \noindent In spherical polar coordinates we may calculate the volume of a
  9033. sphere by integrating unity over the range $r$=0 to {\tt RR}, $\theta$=0 to
  9034. {\tt PI}, $\phi$=0 to 2*$\pi$ as follows :
  9035. \begin{tabular}{l l}
  9036. {\tt VLB := AVEC(0,0,0);} & Lower bound \\
  9037. {\tt VUB := AVEC(RR,PI,2*PI);} & Upper bound in $r, \theta, \phi$
  9038. respectively \\
  9039. {\tt VOLINTORDER := (0,1,2);} & The order of integration \\
  9040. {\tt VOLINTEGRAL(1,VLB,VUB);} & \\
  9041. \end{tabular}
  9042. \index{VOLINTORDER vector}
  9043. Note the use of the special vector {\tt VOLINTORDER} which controls
  9044. the order in which the integrations are carried out. This vector
  9045. should be set to contain the number 0, 1 and 2 in the required order.
  9046. The first component of {\tt VOLINTORDER} contains the index of the
  9047. first integration variable, the second component is the index of the
  9048. second integration variable and the third component is the index of
  9049. the third integration variable.
  9050. \example\index{AVECTOR package ! example}
  9051. Suppose we wish to calculate the volume of a right circular cone. This
  9052. is equivalent to integrating unity over a conical region with the
  9053. bounds:
  9054. \begin{tabular}{l l}
  9055. z = 0 to H & (H = the height of the cone) \\
  9056. r = 0 to pZ & (p = ratio of base diameter to height) \\
  9057. phi = 0 to 2*PI & \\
  9058. \end{tabular}
  9059. We evaluate the volume by integrating a series of infinitesimally thin
  9060. circular disks of constant z-value. The integration is thus performed
  9061. in the order : d($\phi$) from 0 to $2\pi$, dr from 0 to p*Z, dz from 0 to H.
  9062. The order of the indices is thus 2, 0, 1.
  9063. {\small\begin{verbatim}
  9064. VOLINTORDER := AVEC(2,0,1);
  9065. VLB := AVEC(0,0,0);
  9066. VUB := AVEC(P*Z,H,2*PI);
  9067. VOLINTEGRAL(1,VLB,VUB);
  9068. \end{verbatim}}
  9069. \index{LINEINT function}\index{DEFLINEINT function}
  9070. \index{integration ! line}\index{line integrals}
  9071. Line integrals may be calculated using the {\tt LINEINT} and {\tt DEFLINEINT}
  9072. functions. Their general syntax is
  9073. \noindent {\tt LINEINT}({\tt vector-fnct}, {\tt vector-curve},
  9074. {\tt variable});
  9075. \noindent{\tt DEFLINENINT}({\tt vector-fnct}, {\tt vector-curve},
  9076. {\tt variable},\\
  9077. \noindent\verb+ +{\tt lower-bnd}, {\tt upper-bnd});
  9078. \noindent where
  9079. \begin{description}
  9080. \item[{\tt vector-fnct}] is any vector-valued expression;
  9081. \item[{\tt vector-curve}] is a vector expression which describes the path of
  9082. integration in terms of the independent variable;
  9083. \item[{\tt variable}] is the independent variable;
  9084. \item[{\tt lower-bnd}]
  9085. \item[{\tt upper-bnd}] are the bounds of integration in terms of the
  9086. independent variable.
  9087. \end{description}
  9088. \example\index{AVECTOR package ! example}
  9089. In spherical polar coordinates, we may integrate round a line of
  9090. constant theta (`latitude') to find the length of such a line. The
  9091. vector function is thus the tangent to the `line of latitude', (0,0,1)
  9092. and the path is {\tt (0,LAT,PHI)} where {\tt PHI} is the independent
  9093. variable. We show how to obtain the definite integral {\em i.e.} from
  9094. $\phi=0$ to $2 \pi$ :
  9095. {\small\begin{verbatim}
  9096. DEFLINEINT(AVEC(0,0,1),AVEC(0,LAT,PHI),PHI,0,2*PI);
  9097. \end{verbatim}}
  9098. \chapter{BOOLEAN: A package for boolean algebra}
  9099. \label{BOOLEAN}
  9100. \typeout{{BOOLEAN: A package for boolean algebra}}
  9101. {\footnotesize
  9102. \begin{center}
  9103. Herbert Melenk\\
  9104. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  9105. Takustra\"se 7 \\
  9106. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  9107. e--mail: melenk@zib.de
  9108. \end{center}
  9109. }
  9110. \ttindex{BOOLEAN}
  9111. The package {\bf Boolean} supports the computation with boolean
  9112. expressions in the propositional calculus. The data objects are
  9113. composed from algebraic expressions (``atomic parts'', ``leafs'')
  9114. connected by the infix boolean operators {\bf and}, {\bf or}, {\bf
  9115. implies}, {\bf equiv}, and the unary prefix operator {\bf not}. {\bf
  9116. Boolean} allows simplification of expressions built from these
  9117. operators, and to test properties like equivalence, subset property
  9118. etc. Also the reduction of a boolean expression by a partial
  9119. evaluation and combination of its atomic parts is supported.
  9120. \section{Entering boolean expressions}
  9121. In order to distinguish boolean data expressions from
  9122. boolean expressions in the \REDUCE\ programming
  9123. language ({\em e.g.} in an {\bf if} statement), each expression
  9124. must be tagged explicitly by an operator {\bf boolean}.
  9125. Otherwise the boolean operators are not accepted in the
  9126. \REDUCE\ algebraic mode input.
  9127. The first argument of {\bf boolean} can be any boolean expression,
  9128. which may contain references to other boolean values.
  9129. {\small\begin{verbatim}
  9130. load_package boolean;
  9131. boolean (a and b or c);
  9132. q := boolean(a and b implies c);
  9133. boolean(q or not c);
  9134. \end{verbatim}}
  9135. Brackets are used to override the operator precedence as usual.
  9136. The leafs or atoms of a boolean expression are those parts which
  9137. do not contain a leading boolean operator. These are
  9138. considered as constants during the boolean evaluation. There
  9139. are two pre-defined values:
  9140. \begin{itemize}
  9141. \item {\bf true}, {\bf t} or {\bf 1}
  9142. \item {\bf false}, {\bf nil} or {\bf 0}
  9143. \end{itemize}
  9144. These represent the boolean constants. In a result
  9145. form they are used only as {\bf 1} and {\bf 0}.
  9146. By default, a {\bf boolean} expression is converted to a
  9147. disjunctive normal form.
  9148. On output, the operators {\bf and} and {\bf or} are represented as
  9149. \verb+/\+ and \verb+\/+, respectively.
  9150. {\small\begin{verbatim}
  9151. boolean(true and false); -> 0
  9152. boolean(a or not(b and c)); -> boolean(not(b) \/ not(c) \/ a)
  9153. boolean(a equiv not c); -> boolean(not(a)/\c \/ a/\not(c))
  9154. \end{verbatim}}
  9155. \section{Normal forms}
  9156. The {\bf disjunctive} normal form is used by default.
  9157. Alternatively a {\bf conjunctive} normal form can be
  9158. selected as simplification target, which is a form with
  9159. leading operator {\bf and}. To produce that form add the keyword {\bf and}
  9160. as an additional argument to a call of {\bf boolean}.
  9161. {\small\begin{verbatim}
  9162. boolean (a or b implies c);
  9163. ->
  9164. boolean(not(a)/\not(b) \/ c)
  9165. boolean (a or b implies c, and);
  9166. ->
  9167. boolean((not(a) \/ c)/\(not(b) \/ c))
  9168. \end{verbatim}}
  9169. Usually the result is a fully reduced disjunctive or conjuntive normal
  9170. form, where all redundant elements have been eliminated following the
  9171. rules
  9172. $ a \wedge b \vee \neg a \wedge b \longleftrightarrow b$
  9173. $ a \vee b \wedge \neg a \vee b \longleftrightarrow b$
  9174. Internally the full normal forms are computed
  9175. as intermediate result; in these forms each term contains
  9176. all leaf expressions, each one exactly once. This unreduced form is
  9177. returned when the additional keyword {\bf full} is set:
  9178. \newpage
  9179. {\small\begin{verbatim}
  9180. boolean (a or b implies c, full);
  9181. ->
  9182. boolean(a/\b/\c \/ a/\not(b)/\c \/ not(a)/\b/\c \/ not(a)/\not(b)/\c
  9183. \/ not(a)/\not(b)/\not(c))
  9184. \end{verbatim}}
  9185. The keywords {\bf full} and {\bf and} may be combined.
  9186. \section{Evaluation of a boolean expression}
  9187. If the leafs of the boolean expression are algebraic expressions which
  9188. may evaluate to logical values because the environment has changed
  9189. ({\em e.g.\ }variables have been bound), one can re--investigate the
  9190. expression using the operator \f{TESTBOOL}\ttindex{TESTBOOL} with the
  9191. boolean expression as argument. This operator tries to evaluate all
  9192. leaf expressions in \REDUCE\ boolean style. As many terms as possible
  9193. are replaced by their boolean values; the others remain unchanged.
  9194. The resulting expression is contracted to a minimal form. The result
  9195. {\bf 1} (= true) or {\bf 0} (=false) signals that the complete
  9196. expression could be evaluated.
  9197. In the following example the leafs are built as numeric greater test.
  9198. For using ${\bf >}$ in the expressions the greater sign must
  9199. be declared operator first. The error messages are meaningless.
  9200. {\small\begin{verbatim}
  9201. operator >;
  9202. fm:=boolean(x>v or not (u>v));
  9203. ->
  9204. fm := boolean(not(u>v) \/ x>v)
  9205. v:=10$ testbool fm;
  9206. ***** u - 10 invalid as number
  9207. ***** x - 10 invalid as number
  9208. ->
  9209. boolean(not(u>10) \/ x>10)
  9210. x:=3$ testbool fm;
  9211. ***** u - 10 invalid as number
  9212. ->
  9213. boolean(not(u>10))
  9214. x:=17$ testbool fm;
  9215. ***** u - 10 invalid as number
  9216. ->
  9217. 1
  9218. \end{verbatim}}
  9219. \chapter[CALI: Commutative Algebra]{CALI: Computational Commutative Algebra}
  9220. \label{CALI}
  9221. \typeout{{CALI: Computational Commutative Algebra}}
  9222. {\footnotesize
  9223. \begin{center}
  9224. Hans-Gert Gr\"abe \\
  9225. Institut f\"ur Informatik, Universit\"at Leipzig\\
  9226. Augustusplatz 10 -- 11\\
  9227. 04109 Leipzig, Germany \\[0.05in]
  9228. e--mail: graebe@informatik.uni-leipzig.de
  9229. \end{center}
  9230. }
  9231. \ttindex{CALI}
  9232. This package contains algorithms for computations in commutative algebra
  9233. closely related to the Gr\"obner algorithm for ideals and modules. Its
  9234. heart is a new implementation of the Gr\"obner algorithm that also allows
  9235. for the computation of syzygies. This implementation is also applicable to
  9236. submodules of free modules with generators represented as rows of a matrix.
  9237. As main topics CALI contains facilities for
  9238. \begin{itemize}
  9239. \item defining rings, ideals and modules,
  9240. \item computing Gr\"obner bases and local standard bases,
  9241. \item computing syzygies, resolutions and (graded) Betti numbers,
  9242. \item computing (now also weighted) Hilbert series, multiplicities,
  9243. independent sets, and dimensions,
  9244. \item computing normal forms and representations,
  9245. \item computing sums, products, intersections, quotients, stable
  9246. quotients, elimination ideals etc.,
  9247. \item primality tests, computation of radicals, unmixed radicals,
  9248. equidimensional parts, primary decompositions etc. of ideals and
  9249. modules,
  9250. \item advanced applications of Gr\"obner bases (blowup, associated graded
  9251. ring, analytic spread, symmetric algebra, monomial curves etc.),
  9252. \item applications of linear algebra techniques to zero dimensional
  9253. ideals, as {\em e.g.\ }the FGLM change of term orders, border bases
  9254. and affine and projective ideals of sets of points,
  9255. \item splitting polynomial systems of equations mixing factorisation and
  9256. the Gr\"obner algorithm, triangular systems, and different versions of the
  9257. extended Gr\"obner factoriser.
  9258. \end{itemize}
  9259. There is more extended documentation on this package elsewhere, which
  9260. includes facilities for tracing and switches to control its behaviour.
  9261. \chapter[CAMAL: Celestial Mechanics]{CAMAL: Calculations in Celestial Mechanics}
  9262. \label{CAMAL}
  9263. \typeout{{CAMAL: Calculations in Celestial Mechanics}}
  9264. {\footnotesize
  9265. \begin{center}
  9266. J. P. Fitch \\
  9267. School of Mathematical Sciences, University of Bath\\
  9268. BATH BA2 7AY, England \\[0.05in]
  9269. e--mail: jpff@maths.bath.ac.uk
  9270. \end{center}
  9271. }
  9272. \ttindex{CAMAL}
  9273. The CAMAL package provides facilities for calculations in Fourier
  9274. series similar to those in the specialist Celestial Mechanics system
  9275. of the 1970s, and the Cambridge Algebra system in
  9276. particular.\index{Fourier Series}\index{CAMAL}\index{Celestial
  9277. Mechanics}
  9278. \section{Operators for Fourier Series}
  9279. \subsection*{\f{HARMONIC}}\ttindex{HARMONIC}
  9280. The celestial mechanics system distinguish between polynomial
  9281. variables and angular variables. All angles must be declared before
  9282. use with the \f{HARMONIC} function.
  9283. {\small\begin{verbatim}
  9284. harmonic theta, phi;
  9285. \end{verbatim}}
  9286. \subsection*{\f{FOURIER}}\ttindex{FOURIER}
  9287. The \f{FOURIER} function coerces its argument into the domain of a
  9288. Fourier Series. The expression may contain {\em sine} and {\em
  9289. cosine} terms of linear sums of harmonic variables.
  9290. {\small\begin{verbatim}
  9291. fourier sin(theta)
  9292. \end{verbatim}}
  9293. Fourier series expressions may be added, subtracted multiplies and
  9294. differentiated in the usual \REDUCE\ fashion. Multiplications involve
  9295. the automatic linearisation of products of angular functions.
  9296. There are three other functions which correspond to the usual
  9297. restrictive harmonic differentiation and integration, and harmonic
  9298. substitution.
  9299. \subsection*{\f{HDIFF} and \f{HINT}}\ttindex{HDIFF}\ttindex{HINT{}}
  9300. Differentiate or integrate a Fourier expression with respect to an angular
  9301. variable. Any secular terms in the integration are disregarded without
  9302. comment.
  9303. {\small\begin{verbatim}
  9304. load_package camal;
  9305. harmonic u;
  9306. bige := fourier (sin(u) + cos(2*u));
  9307. aa := fourier 1+hdiff(bige,u);
  9308. ff := hint(aa*aa*fourier cc,u);
  9309. \end{verbatim}}
  9310. \subsection*{\f{HSUB}}\ttindex{HSUB}
  9311. The operation of substituting an angle plus a Fourier expression for
  9312. an angles and expanding to some degree is called harmonic substitution.
  9313. The function takes 5 arguments; the basic expression, the angle being
  9314. replaced, the angular part of the replacement, the fourier part of the
  9315. replacement and a degree to which to expand.
  9316. {\small\begin{verbatim}
  9317. harmonic u,v,w,x,y,z;
  9318. xx:=hsub(fourier((1-d*d)*cos(u)),u,u-v+w-x-y+z,yy,n);
  9319. \end{verbatim}}
  9320. \section{A Short Example}
  9321. The following program solves Kepler's Equation as a Fourier series to
  9322. the degree $n$.
  9323. {\small\begin{verbatim}
  9324. bige := fourier 0;
  9325. for k:=1:n do <<
  9326. wtlevel k;
  9327. bige:=fourier e * hsub(fourier(sin u), u, u, bige, k);
  9328. >>;
  9329. write "Kepler Eqn solution:", bige$
  9330. \end{verbatim}}
  9331. \chapter{CGB: Comprehensive Gr\"obner Bases}
  9332. \label{CGB}
  9333. \typeout{{CGB: Comprehensive Gr\"obner Bases}}
  9334. {\footnotesize
  9335. \begin{center}
  9336. Andreas Dolzmann \& Thomas Sturm\\
  9337. Department of Mathematics and Computer Science\\ University of Passau\\
  9338. D-94030 Passau, Germany\\[1ex]
  9339. e-mail: dolzmann@uni-passau.de, sturm@uni-passau.de
  9340. \end{center}
  9341. }
  9342. \ttindex{REDLOG}
  9343. \section{Introduction}
  9344. Consider the ideal basis $F=\{ax,x+y\}$. Treating $a$ as a parameter,
  9345. the calling sequence
  9346. {\small\begin{verbatim}
  9347. torder({x,y},lex)$
  9348. groebner{a*x,x+y};
  9349. {x,y}
  9350. \end{verbatim}}
  9351. yields $\{x,y\}$ as reduced Gr\"obner basis. This is, however, not
  9352. correct under the specialization $a=0$. The reduced Gr\"obner basis
  9353. would then be $\{x+y\}$. Taking these results together, we obtain
  9354. $C=\{x+y,ax,ay\}$, which is correct wrt.~{\em all} specializations for
  9355. $a$ including zero specializations. We call this set $C$ a {\em
  9356. comprehensive Gr\"obner basis} ({\sc cgb}).
  9357. The notion of a {\sc cgb} and a corresponding algorithm has been
  9358. introduced bei Weispfenning \cite{Weispfenning:92}. This algorithm
  9359. works by performing case distinctions wrt.~parametric coefficient
  9360. polynomials in order to find out what the head monomials are under all
  9361. possible specializations. It does thus not only determine a {\sc cgb},
  9362. but even classifies the contained polynomials wrt.~the specializations
  9363. they are relevant for. If we keep the Gr\"obner bases for all cases
  9364. separate and associate information on the respective specializations
  9365. with them, we obtain a {\em Gr\"obner system}. For our example, the
  9366. Gr\"obner system is the following;
  9367. $$
  9368. \left[
  9369. \begin{array}{c|c}
  9370. a\neq0 & \{x+y,ax,ay\}\\
  9371. a=0 & \{x+y\}
  9372. \end{array}
  9373. \right].
  9374. $$
  9375. A {\sc cgb} is obtained as the union of the single Gr\"obner bases in
  9376. a Gr\"obner system. It has also been shown that, on the other hand, a
  9377. Gr\"obner system can easily be reconstructed from a given {\sc cgb}
  9378. \cite{Weispfenning:92}.
  9379. The CGB package provides functions for computing both {\sc cgb}'s and
  9380. Gr\"obner systems, and for turning Gr\"obner systems into {\sc cgb}'s.
  9381. %
  9382. \section{Using the REDLOG Package}
  9383. For managing the conditions occurring with the {\sc cgb} computations,
  9384. the CGB package uses the package REDLOG implementing first-order
  9385. formulas, \cite{DolzmannSturm:97a,DolzmannSturm:99}, which is also
  9386. part of the \textsc{reduce} distribution.
  9387. %
  9388. \section{Term Ordering Mode}
  9389. The CGB package uses the settings made with the function \f{TORDER}
  9390. of the GROEBNER package. This includes in particular the choice of the
  9391. main variables. All variables not mentioned in the variable list
  9392. argument of \f{TORDER} are parameters. The only term ordering modes
  9393. recognized by \textsc{cgb} are \f{LEX} and \f{REVGRADLEX}.
  9394. %
  9395. \section{CGB: Comprehensive Gr\"ob\-ner Basis}
  9396. The function \f{CGB}\ttindex{CGB} expects a list $F$ of expressions.
  9397. It returns a {\sc cgb} of $F$ wrt.~the current \f{TORDER} setting.
  9398. %
  9399. \subsection*{Example:}
  9400. {\small\begin{verbatim}
  9401. torder({x,y},lex)$
  9402. cgb{a*x+y,x+b*y};
  9403. {x + b*y,a*x + y,(a*b - 1)*y}
  9404. ws;
  9405. {b*y + x,
  9406. a*x + y,
  9407. y*(a*b - 1)}
  9408. \end{verbatim}}
  9409. Note that the basis returned by the \f{CGB} call has not undergone
  9410. the standard evaluation process: The returned polynomials are ordered
  9411. wrt.~the chosen term order. Reevaluation changes this as can be seen
  9412. with the output of \f{WS}.
  9413. %
  9414. \section{GSYS: Gr\"obner System}
  9415. The function \f{GSYS}\ttindex{GSYS} follows the same calling conventions as
  9416. \f{CGB}. It returns the complete Gr\"obner system represented as a nested
  9417. list
  9418. \begin{center}
  9419. \begin{tt}
  9420. $\bigl\{\bigl\{c_1,\{g_{11},\ldots,g_{1n_1}\}\bigr\},\dots,
  9421. \bigl\{c_m,\{g_{m1},\dots,g_{1n_m}\}\bigr\}\bigr\}$.
  9422. \end{tt}
  9423. \end{center}
  9424. The {\tt $c_i$} are conditions in the parameters represented as
  9425. quantifier-free REDLOG formulas. Each choice of parameters will obey
  9426. at least one of the {\tt $c_i$}. Whenever a choice of parameters obeys
  9427. some {\tt $c_i$}, the corresponding {\tt $\{g_{i1},\ldots,g_{in_i}\}$}
  9428. is a Gr\"obner basis for this choice.
  9429. %
  9430. \subsection*{Example:}
  9431. {\small\begin{verbatim}
  9432. torder({x,y},lex)$
  9433. gsys {a*x+y,x+b*y};
  9434. {{a*b - 1 <> 0 and a <> 0,
  9435. {a*x + y,x + b*y,(a*b - 1)*y}},
  9436. {a <> 0 and a*b - 1 = 0,
  9437. {a*x + y,x + b*y}},
  9438. {a = 0,{a*x + y,x + b*y}}}
  9439. \end{verbatim}}
  9440. As with the function \f{CGB}, the contained polynomials remain
  9441. unevaluated.
  9442. Computing a Gr\"obner system is not harder than computing a {\sc cgb}.
  9443. In fact, \f{CGB} also computes a Gr\"obner system and then turns it
  9444. into a {\sc cgb}.
  9445. \subsection{Switch CGBGEN: Only the Generic Case}
  9446. If the switch \f{CGBGEN}\ttindex{CGBGEN} is turned on, both \f{GSYS} and
  9447. \f{CGB} will assume all parametric coefficients to be non-zero ignoring
  9448. the other cases. For \f{CGB} this means that the result equals---up
  9449. to auto-reduction---that of \f{GROEBNER}. A call to \f{GSYS} will
  9450. return this result as a single case including the assumptions made
  9451. during the computation:
  9452. %
  9453. \subsection*{Example:}
  9454. {\small\begin{verbatim}
  9455. torder({x,y},lex)$
  9456. on cgbgen;
  9457. gsys{a*x+y,x+b*y};
  9458. {{a*b - 1 <> 0 and a <> 0,
  9459. {a*x + y,x + b*y,(a*b - 1)*y}}}
  9460. off cgbgen;
  9461. \end{verbatim}}
  9462. %
  9463. \section{GSYS2CGB: Gr\"obner System to CGB}
  9464. The call \f{GSYS2CGB}\ttindex{GSYS2CGB} turns a given Gr\"obner system into a
  9465. {\sc cgb} by constructing the union of the Gr\"obner bases of the single
  9466. cases.
  9467. %
  9468. \subsection*{Example:}
  9469. {\small\begin{verbatim}
  9470. torder({x,y},lex)$
  9471. gsys{a*x+y,x+b*y}$
  9472. gsys2cgb ws;
  9473. {x + b*y,a*x + y,(a*b - 1)*y}
  9474. \end{verbatim}}
  9475. %
  9476. \section{Switch CGBREAL: Computing over the Real Numbers}\label{cgbreal}
  9477. All computations considered so far have taken place over the complex
  9478. numbers, more precisely, over algebraically closed fields. Over the
  9479. real numbers, certain branches of the {\sc cgb} computation can become
  9480. inconsitent though they are not inconsistent over the complex numbers.
  9481. Consider, e.g., a condition $a^2+1=0$.
  9482. When turning on the switch \f{CGBREAL}\ttindex{CGBREAL}, all
  9483. simplifications of conditions are performed over the real numbers.
  9484. The methods used for this are described in \cite{DolzmannSturm:97c}.
  9485. %
  9486. \subsection*{Example:}
  9487. {\small\begin{verbatim}
  9488. torder({x,y},lex)$
  9489. off cgbreal;
  9490. gsys {a*x+y,x-a*y};
  9491. 2
  9492. {{a + 1 <> 0 and a <> 0,
  9493. 2
  9494. {a*x + y,x - a*y,(a + 1)*y}},
  9495. 2
  9496. {a <> 0 and a + 1 = 0,{a*x + y,x - a*y}},
  9497. {a = 0,{a*x + y,x - a*y}}}
  9498. on cgbreal;
  9499. gsys({a*x+y,x-a*y});
  9500. {{a <> 0,
  9501. 2
  9502. {a*x + y,x - a*y,(a + 1)*y}},
  9503. {a = 0,{a*x + y,x - a*y}}}
  9504. \end{verbatim}}
  9505. \section{Switches}
  9506. \begin{description}
  9507. \item[\f{CGBREAL}] Compute over the real numbers. See
  9508. Section~\ref{cgbreal} for details.
  9509. \item[\f{CGBGS}\ttindex{CGBGS}] Gr\"obner simplification of the condition. The switch
  9510. \f{CGBGS} can be turned on for applying advanced algebraic
  9511. simplification techniques to the conditions. This will, in general,
  9512. slow down the computation, but lead to a simpler Gr\"obner system.
  9513. \item[\f{CGBSTAT}\ttindex{CGBSTAT}] Statistics of the CGB run. The switch \f{CGBSTAT}
  9514. toggles the creation and output of statistical information on the CGB
  9515. run. The statistical information is printed at the end of the run.
  9516. \item[\f{CGBFULLRED}\ttindex{CGBFULLRED}] Full reduction. By default, the CGB functions
  9517. perform full reductions in contrast to pure top reductions. By turning
  9518. off the switch \f{CGBFULLRED}, reduction can be restricted to top
  9519. reductions.
  9520. \end{description}
  9521. \chapter[CHANGEVR: Change of Variables in DEs]%
  9522. {CHANGEVR: Change of Independent Variables in DEs}
  9523. \label{CHANGEVR}
  9524. \typeout{[CHANGEVR: Change of Variables in DEs]}
  9525. {\footnotesize
  9526. \begin{center}
  9527. G. \"{U}\c{c}oluk \\
  9528. Department of Physics, Middle East Technical University \\
  9529. Ankara, Turkey\\[0.05in]
  9530. e--mail: ucoluk@trmetu.bitnet
  9531. \end{center}
  9532. }
  9533. The function {\tt CHANGEVAR} has (at least) four different
  9534. arguments.\ttindex{CHANGEVAR}
  9535. \begin{itemize}
  9536. \item {\bf FIRST ARGUMENT} \\
  9537. is a list of the dependent variables of the differential equation.
  9538. If there is only one dependent variable it can be given directly,
  9539. not as a list.
  9540. \item {\bf SECOND ARGUMENT} \\
  9541. is a list of the {\bf new} independent variables, or in the case
  9542. of only one, the variable.
  9543. \item {\bf THIRD ARGUMENT, FOURTH {\em etc.}} \\
  9544. are equations is of the form
  9545. \begin{quote}{\tt{\em old variable} = {\em a function in new variables}}\end{quote}
  9546. The left hand side cannot be a non-kernel structure. These give
  9547. the old variables in terms of the new ones.
  9548. \item {\bf LAST ARGUMENT} \\
  9549. is a list of algebraic expressions which evaluates to differential
  9550. equations in the usual list notation.
  9551. Again it is possible to omit the list form if there is
  9552. only {\bf one} differential equation.
  9553. \end{itemize}
  9554. If the last argument is a list then the result of {\tt CHANGEVAR} is a
  9555. list too.
  9556. It is possible to display the entries of the inverse Jacobian. To do
  9557. so, turn {\tt ON} the flag {\tt DISPJACOBIAN}\ttindex{DISPJACOBIAN}.
  9558. \section{An example: the 2-D Laplace Equation}
  9559. The 2-dimensional Laplace equation in Cartesian coordinates is:
  9560. \[
  9561. \frac{\partial^{2} u}{\partial x^{2}} +
  9562. \frac{\partial^{2} u}{\partial y^{2}} = 0
  9563. \]
  9564. Now assume we want to obtain the polar coordinate form of Laplace equation.
  9565. The change of variables is:
  9566. \[
  9567. x = r \cos \theta, {\;\;\;\;\;\;\;\;\;\;} y = r \sin \theta
  9568. \]
  9569. The solution using {\tt CHANGEVAR} is
  9570. {\small\begin{verbatim}
  9571. CHANGEVAR({u},{r,theta},{x=r*cos theta,y=r*sin theta},
  9572. {df(u(x,y),x,2)+df(u(x,y),y,2)} );
  9573. \end{verbatim}}
  9574. Here we could omit the curly braces in the first and last arguments (because
  9575. those lists have only one member) and the curly braces in the third argument
  9576. (because they are optional), but not in the second. So one could
  9577. equivalently write
  9578. {\small\begin{verbatim}
  9579. CHANGEVAR(u,{r,theta},x=r*cos theta,y=r*sin theta,
  9580. df(u(x,y),x,2)+df(u(x,y),y,2) );
  9581. \end{verbatim}}
  9582. The {\tt u(x,y)} operator will be changed to {\tt u(r,theta)} in the
  9583. result as one would do with pencil and paper. {\tt u(r,theta)}
  9584. represents the the transformed dependent variable.
  9585. \chapter[COMPACT: Compacting expressions]{COMPACT: Package for compacting expressions}
  9586. \label{COMPACT}
  9587. \typeout{{COMPACT: Package for compacting expressions}}
  9588. {\footnotesize
  9589. \begin{center}
  9590. Anthony C. Hearn\\
  9591. RAND\\
  9592. Santa Monica \\
  9593. CA 90407-2138, U.S.A. \\[0.05in]
  9594. e--mail: hearn@rand.org
  9595. \end{center}
  9596. }
  9597. \ttindex{COMPACT}\index{COMPACT package}\index{side relations}
  9598. \index{relations ! side}
  9599. {COMPACT} is a package of functions for the reduction of a polynomial in
  9600. the presence of side relations. The package defines one operator {COMPACT}
  9601. \index{COMPACT operator}
  9602. whose syntax is:
  9603. \begin{quote}
  9604. \k{COMPACT}(\s{expression}, \s{list}):\s{expression}
  9605. \end{quote}
  9606. \s{expression} can be any well-formed algebraic expression, and
  9607. \s{list} an expression whose value is a list
  9608. of either expressions or equations. For example
  9609. {\small\begin{verbatim}
  9610. compact(x**2+y**3*x-5y,{x+y-z,x-y-z1});
  9611. compact(sin(x)**10*cos(x)**3+sin(x)**8*cos(x)**5,
  9612. {cos(x)**2+sin(x)**2=1});
  9613. let y = {cos(x)**2+sin(x)**2-1};
  9614. compact(sin(x)**10*cos(x)**3+sin(x)**8*cos(x)**5,y);
  9615. \end{verbatim}}
  9616. {COMPACT} applies the relations to the expression so that an equivalent
  9617. expression results with as few terms as possible. The method used is
  9618. briefly as follows:
  9619. \begin{enumerate}
  9620. \item Side relations are applied separately to numerator and denominator, so
  9621. that the problem is reduced to the reduction of a polynomial with respect to
  9622. a set of polynomial side relations.
  9623. \item Reduction is performed sequentially, so that the problem is reduced
  9624. further to the reduction of a polynomial with respect to a single
  9625. polynomial relation.
  9626. \item The polynomial being reduced is reordered so that the variables
  9627. (kernels) occurring in the side relation have least precedence.
  9628. \item Each coefficient of the remaining kernels (which now only contain
  9629. the kernels
  9630. in the side relation) is reduced with respect to that side relation.
  9631. \item A polynomial quotient/remainder calculation is performed on the
  9632. coefficient. The remainder is
  9633. used instead of the original if it has fewer terms.
  9634. \item The remaining expression is reduced with respect to the side relation
  9635. using a ``nearest neighbour'' approach.
  9636. \end{enumerate}
  9637. \chapter[CRACK: Overdetermined systems of DEs]%
  9638. {CRACK: Solving overdetermined systems of PDEs or ODEs}
  9639. \label{CRACK}
  9640. \typeout{[CRACK: Overdetermined systems of DEs]}
  9641. {\footnotesize
  9642. \begin{center}
  9643. Thomas Wolf \\
  9644. School of Mathematical Sciences, Queen Mary and Westfield College \\
  9645. University of London \\
  9646. London E1 4NS, England \\[0.05in]
  9647. e--mail: T.Wolf@maths.qmw.ac.uk \\ [0.10in]
  9648. %%WWW: http://www.zib-berlin.de/Symbolik/crack.html \\[0.10in]
  9649. Andreas Brand \\
  9650. Institut f\"{u}r Informatik \\
  9651. Friedrich Schiller Universit\"{a}t Jena \\
  9652. 07740 Jena, Germany \\[0.05in]
  9653. e--mail: maa@hpux.rz.uni-jena.de
  9654. \end{center}
  9655. }
  9656. \ttindex{CRACK}
  9657. The package CRACK aims at solving or at least partially
  9658. integrating single ordinary differential equations or partial
  9659. differential equations (ODEs/PDEs), and systems of them, exactly and in full
  9660. generality. Calculations done with input DEs include the
  9661. \begin{itemize}
  9662. \item integration of exact DEs and generalised exact DEs
  9663. \item determination of monomial integrating factors
  9664. \item direct and indirect separation of DEs
  9665. \item systematic application of integrability conditions
  9666. \item solution of single elementary ODEs by using the REDUCE
  9667. package ODESOLVE (chapter~\ref{ODESOLVE}).
  9668. \end{itemize}
  9669. %More details are given in the manual CRACK.TEX.
  9670. Input DEs may be polynomially non-linear in the unknown functions
  9671. and their derivatives and may depend arbitrarily on the independent
  9672. variables.
  9673. Suitable applications of CRACK are the solution of
  9674. \begin{itemize}
  9675. \item overdetermined ODE/PDE-systems (overdetermined here just means
  9676. that the number of unknown functions of all independent variables
  9677. is less than the number of given equations for these functions).
  9678. \item simple non-overdetermined DE-systems (such as characteristic
  9679. ODE-systems of first order quasilinear PDEs).
  9680. \end{itemize}
  9681. The strategy is to have {\bf one} universal program (CRACK) which
  9682. is as effective as possible for solving overdetermined PDE-systems
  9683. and many application programs (such as LIEPDE) which merely generate an
  9684. overdetermined PDE-system depending on what is to be investigated
  9685. (for example, symmetries or conservation laws).
  9686. Examples are:
  9687. \begin{itemize}
  9688. \item the investigation of infinitesimal symmetries of DEs (LIEPDE),
  9689. \item the determination of an equivalent Lagrangian for second order
  9690. ODEs (LAGRAN)
  9691. \item the investigation of first integrals of ODEs which are polynomial
  9692. in their highest derivative (FIRINT)
  9693. \item the splitting of an $n^{th}$ order ODE into a first order ODE and
  9694. an $(n-1)^{th}$ order problem (DECOMP)
  9695. %%\item the search for conservation laws of PDEs (-systems) (CONLAW, not
  9696. %% yet added to the library (Sep.\ 1995) but obtainable from T.W.)
  9697. \end{itemize}
  9698. Other applications where non-overdetermined problems are treated are
  9699. \begin{itemize}
  9700. \item the application of infinitesimal symmetries ({\em e.g.\
  9701. }calculated by LIEPDE) in the package APPLYSYM (chapter~\ref{APPLYSYM}),
  9702. \item the program QUASILINPDE (also in the package APPLYSYM)
  9703. for solving single first order quasilinear PDEs.
  9704. \end{itemize}
  9705. The kernel package for solving overdetermined or simple non-overdetermined
  9706. DE-systems is accessible through a call to the program CRACK
  9707. in the package CRACK. All the application programs (LIEPDE, LAGRAN,
  9708. FIRINT, DECOMP except APPLYSYM) are contained in the package CRACKAPP.
  9709. The programs APPLYSYM and QUASILINPDE are contained in the package
  9710. APPLYSYM (described in chapter~\ref{APPLYSYM}).
  9711. %%A short description of all the applications mentioned above including
  9712. %%examples are given in an paper to be published in a special issue of
  9713. %%"Mathematical and Computer Modelling", ed. B.\ Fuchssteiner, V.\ Gerdt
  9714. %%and W.\ Oevel which also is available through ftp from
  9715. %%euclid.maths.qmw.ac.uk as preprint file pub/crack/demo.ps. More details are
  9716. %%given in the files CRACK.TEX and APPLYSYM.TEX and input examples are available
  9717. %%in the test files CRACK.TST and APPLYSYM.TST.
  9718. %%The latest versions of the programs, manuals and test files
  9719. %%are available through ftp
  9720. %%from euclid.maths.qmw.ac.uk and the directory /pub/crack.
  9721. Details of the CRACK applications can be found in the example file.
  9722. {\tt CRACK} is called by
  9723. \begin{tabbing}
  9724. {\tt CRACK}(\=\{{\it equ}$_1$, {\it equ}$_2$, \ldots , {\it equ}$_m$\}, \\
  9725. \>\{{\it ineq}$_1$, {\it ineq}$_2$, \ldots , {\it ineq}$_n$\}, \\
  9726. \>\{{\it fun}$_1$, {\it fun}$_2$, \ldots , {\it fun}$_p$\}, \\
  9727. \>\{{\it var}$_1$, {\it var}$_2$, \ldots , {\it var}$_q$\});
  9728. \end{tabbing}
  9729. $m,n,p,q$ are arbitrary.
  9730. \begin{itemize}
  9731. \item
  9732. The {\it equ}$_i$ are identically vanishing partial differential expressions,
  9733. {\em i.e.\ }
  9734. they represent equations $0 = {\it equ}_i$, which are to be solved for the
  9735. functions ${\it fun}_j$ as far as possible, thereby drawing only necessary
  9736. conclusions and not restricting the general solution.
  9737. \item
  9738. The {\it ineq}$_i$ are expressions which must not vanish identically for
  9739. any solution to be determined, {\em i.e.\ }only such solutions are
  9740. computed for which none of the {\it ineq}$_i$ vanishes identically in
  9741. all independent variables.
  9742. \item
  9743. The dependence of the (scalar) functions ${\it fun}_j$ on possibly a
  9744. number of variables is assumed to have been defined with DEPEND rather
  9745. than declaring these functions as operators. Their arguments may
  9746. themselves only be independent variables and not expressions.
  9747. \item
  9748. The functions ${\it fun}_j$ and their derivatives may only occur
  9749. polynomially. Other unknown functions in ${\it equ}_i$ may be
  9750. represented as operators.
  9751. \item
  9752. The ${\it var}_k$ are further independent variables, which are not
  9753. already arguments of any of the ${\it fun}_j$. If there are none then
  9754. the third argument is the empty list \{\}.
  9755. \item
  9756. The dependence of the ${\it equ}_i$ on the independent variables and on
  9757. constants and functions other than ${\it fun}_j$ is arbitrary.
  9758. \end{itemize}
  9759. The result is a list of solutions
  9760. \[ \{{\it sol}_1, \ldots \} \]
  9761. where each solution is a list of 3 lists:
  9762. \begin{tabbing}
  9763. \{\=\{${\it con}_1, \; {\it con}_2, \ldots , \; {\it con}_q$\}, \\
  9764. \>\{${\it fun}_a={\it ex}_a, \;\;
  9765. {\it fun}_b={\it ex}_b, \ldots , \;\; {\it fun}_p={\it ex}_p$\},\= \\
  9766. \>\{${\it fun}_c, \;\; {\it fun}_d, \ldots , \;\; {\it fun}_r$\} \>\}
  9767. \end{tabbing}
  9768. with integer $a, b, c, d, p, q, r.$
  9769. If {\tt CRACK} finds a contradiction as $0=1$ then there exists no
  9770. solution and it returns the empty list \{\}.
  9771. The empty list is also returned if no solution exists
  9772. which does not violate the inequalities
  9773. {\it ineq}$_i \neq 0.$
  9774. For example, in the case of a linear system as input, there is
  9775. at most one solution ${\it sol}_1$.
  9776. The expressions ${\it con}_i$ (if there are any), are the
  9777. remaining necessary and sufficient conditions for the functions
  9778. ${\it fun}_c,\ldots,{\it fun}_r$ in the third list. Those
  9779. functions can be original functions from the equations to be
  9780. solved (of the second argument of the call of {\tt CRACK}) or new
  9781. functions or constants which arose from integrations.
  9782. The dependence of new functions on variables is declared with {\tt DEPEND}
  9783. and to visualise this dependence the algebraic mode function
  9784. ${\tt FARGS({\it fun}_i)}$ can be used.
  9785. If there are no ${\it con}_i$ then all equations are solved and the
  9786. functions in the third list are unconstrained.
  9787. The second list contains
  9788. equations ${\it fun}_i={\it ex}_i$ where each ${\it fun}_i$ is an
  9789. original function and ${\it ex}_i$ is the computed expression
  9790. for ${\it fun}_i$.
  9791. The exact behaviour of {\tt CRACK} can be modified by internal
  9792. variables, and there is a help system particularly associated with
  9793. {\tt CRACK}. Users are referred to the detailed documentation for
  9794. more information.
  9795. \chapter[CVIT:Dirac gamma matrix traces]%
  9796. {CVIT: Fast calculation of Dirac gamma matrix traces}
  9797. \label{CVIT}
  9798. \typeout{[CVIT:Dirac gamma matrix traces]}
  9799. {\footnotesize
  9800. \begin{center}
  9801. V. Ilyin, A. Kryukov, A. Rodionov and A. Taranov \\
  9802. Institute for Nuclear Physics \\
  9803. Moscow State University \\
  9804. Moscow, 119899 Russia
  9805. \end{center}
  9806. }
  9807. \ttindex{CVIT}
  9808. The package consists of 5 sections, and provides an alternative to the
  9809. \REDUCE\ high-energy physics system. Instead of being based on
  9810. $\Gamma$-matrices as a basis for a Clifford algebra, it is based on
  9811. treating $\Gamma$-matrices as 3-j symbols, as described by
  9812. Cvitanovic.
  9813. The functions it provides are the same as those of the standard
  9814. package. It does have four switches which control its behaviour.
  9815. \noindent{\tt CVIT}\ttindex{CVIT}
  9816. If it is on then use Kennedy-Cvitanovic algorithm else use standard
  9817. facilities.
  9818. \noindent{\tt CVITOP}\ttindex{CVITOP}
  9819. Switches on Fierz optimisation. Default is off;
  9820. \noindent{\tt CVITBTR}\ttindex{CVITBTR}
  9821. Switches on the bubbles and triangles factorisation. The default is
  9822. on.
  9823. \noindent{\tt CVITRACE}\ttindex{CVITRACE}
  9824. Controls internal tracing of the CVIT package. Default is off.
  9825. {\small\begin{verbatim}
  9826. index j1,j2,j3,;
  9827. vecdim n$
  9828. g(l,j1,j2,j2,j1);
  9829. 2
  9830. n
  9831. g(l,j1,j2)*g(l1,j3,j1,j2,j3);
  9832. 2
  9833. n
  9834. g(l,j1,j2)*g(l1,j3,j1,j3,j2);
  9835. n*( - n + 2)
  9836. \end{verbatim}}
  9837. \chapter{DEFINT: Definite Integration for REDUCE}
  9838. \label{DEFINT}
  9839. \typeout{{DEFINT: Definite Integration for REDUCE}}
  9840. {\footnotesize
  9841. \begin{center}
  9842. Kerry Gaskell and Winfried Neun \\
  9843. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  9844. Takustra\"se 7 \\
  9845. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  9846. e--mail: neun@zib.de \\[0.10in]
  9847. Stanley L. Kameny \\
  9848. Los Angeles, U.S.A.
  9849. \end{center}
  9850. }
  9851. \ttindex{DEFINT}
  9852. \REDUCE{}'s definite integration package is able to calculate the
  9853. definite integrals of many functions, including several special
  9854. functions. There are a number of parts of this package, including
  9855. contour integration. The innovative integration process is to
  9856. represent each function as a Meijer G-function, and then calculating
  9857. the integral by using the following Meijer G integration formula.
  9858. \begin{displaymath}
  9859. \int_{0}^{\infty} x^{\alpha-1} G^{s t}_{u v}
  9860. \left( \sigma x \ \Bigg\vert \ {( c_u) \atop (d_v)} \right)
  9861. G^{m n}_{p q} \left( \omega x^{l/k} \ \Bigg\vert \ {(a_p) \atop (b_q)}
  9862. \right) dx = k G^{i j}_{k l} \left( \xi \ \Bigg\vert \
  9863. {(g_k) \atop (h_l)} \right) \hspace{5mm} (1)
  9864. \end{displaymath}
  9865. The resulting Meijer G-function is then retransformed, either directly
  9866. or via a hypergeometric function simplification, to give
  9867. the answer.
  9868. The user interface is via a four argument version of the
  9869. \f{INT}\ttindex{INT} operator, with the lower and upper limits added.
  9870. {\small\begin{verbatim}
  9871. load_package defint;
  9872. int(sin x,x,0,pi/2);
  9873. 1
  9874. \end{verbatim}}
  9875. \newpage
  9876. {\small\begin{verbatim}
  9877. int(log(x),x,1,5);
  9878. 5*log(5) - 4
  9879. int(x*e^(-1/2x),x,0,infinity);
  9880. 4
  9881. int(x^2*cos(x)*e^(-2*x),x,0,infinity);
  9882. 4
  9883. -----
  9884. 125
  9885. int(x^(-1)*besselj(2,sqrt(x)),x,0,infinity);
  9886. 1
  9887. int(si(x),x,0,y);
  9888. cos(y) + si(y)*y - 1
  9889. int(besselj(2,x^(1/4)),x,0,y);
  9890. 1/4
  9891. 4*besselj(3,y )*y
  9892. ---------------------
  9893. 1/4
  9894. y
  9895. \end{verbatim}}
  9896. The DEFINT package also defines a number of additional transforms,
  9897. such as the Laplace transform\index{Laplace transform}\footnote{See
  9898. Chapter~\ref{LAPLACE} for an alternative Laplace transform with
  9899. inverse Laplace transform}, the Hankel
  9900. transform\index{Hankel transform}, the Y-transform\index{Y-transform},
  9901. the K-transform\index{K-transform}, the StruveH
  9902. transform\index{StruveH transform}, the Fourier sine
  9903. transform\index{Fourier sine transform}, and the Fourier cosine
  9904. transform\index{Fourier cosine transform}.
  9905. {\small\begin{verbatim}
  9906. laplace_transform(cosh(a*x),x);
  9907. - s
  9908. ---------
  9909. 2 2
  9910. a - s
  9911. laplace_transform(Heaviside(x-1),x);
  9912. 1
  9913. ------
  9914. s
  9915. e *s
  9916. hankel_transform(x,x);
  9917. n + 4
  9918. gamma(-------)
  9919. 2
  9920. -------------------
  9921. n - 2 2
  9922. gamma(-------)*s
  9923. 2
  9924. fourier_sin(e^(-x),x);
  9925. s
  9926. --------
  9927. 2
  9928. s + 1
  9929. fourier_cos(x,e^(-1/2*x^2),x);
  9930. 2
  9931. i*s s /2
  9932. sqrt( - pi)*erf(---------)*s + e *sqrt(2)
  9933. sqrt(2)
  9934. ----------------------------------------------
  9935. 2
  9936. s /2
  9937. e *sqrt(2)
  9938. \end{verbatim}}
  9939. It is possible to the user to extend the pattern-matching process by
  9940. which the relevant Meijer G representation for any function is found.
  9941. Details can be found in the complete documentation.
  9942. \noindent{\bf Acknowledgement:}
  9943. This package depends greatly on the pioneering work of Victor
  9944. Adamchik, to whom thanks are due.
  9945. \chapter[DESIR: Linear Homogeneous DEs]%
  9946. {DESIR: Differential linear homogeneous equation solutions in the
  9947. neighbourhood of irregular and regular singular points}
  9948. \label{DESIR}
  9949. \typeout{[DESIR: Linear Homogeneous DEs]}
  9950. {\footnotesize
  9951. \begin{center}
  9952. C. Dicrescenzo, F. Richard--Jung, E. Tournier \\
  9953. Groupe de Calcul Formel de Grenoble \\
  9954. laboratoire TIM3 \\
  9955. France \\[0.05in]
  9956. e--mail: dicresc@afp.imag.fr
  9957. \end{center}
  9958. }
  9959. \ttindex{DESIR}
  9960. This software enables the basis of formal solutions to be computed for an
  9961. ordinary homogeneous differential equation with polynomial coefficients
  9962. over Q of any order, in the neighbourhood of zero (regular or irregular
  9963. singular point, or ordinary point).
  9964. This software can be used in two ways, directly via the \f{DELIRE}
  9965. procedure, or interactively with the \f{DESIR} procedure. The basic
  9966. procedure is the f{DELIRE} procedure which enables the solutions of a
  9967. linear homogeneous differential equation to be computed in the
  9968. neighbourhood of zero.
  9969. The \f{DESIR} procedure is a procedure without argument whereby
  9970. \f{DELIRE} can be called without preliminary treatment to the data,
  9971. that is to say, in an interactive autonomous way. This procedure also
  9972. proposes some transformations on the initial equation. This allows one
  9973. to start comfortably with an equation which has a non zero singular
  9974. point, a polynomial right-hand side and parameters.
  9975. \noindent{\tt delire(x,k,grille,lcoeff,param)}
  9976. This procedure computes formal solutions of a linear homogeneous
  9977. differential equation with polynomial coefficients over Q and of any
  9978. order, in the neighbourhood of zero, regular or irregular singular
  9979. point. {\tt x} is the variable, {\tt k} is the number of desired
  9980. terms (that is for each formal series in $x_t$ appearing in polysol,
  9981. $a_0+a_1 x_t+a_2 x_t^2+\ldots + a_n x_t^n+ \ldots$ we compute the
  9982. $k+1$ first coefficients $a_0$, $a_1$ to $a_k$. The coefficients of
  9983. the differential operator as polynomial in $x^{grille}$. In general
  9984. grille is 1. The argument {\tt lcoeff} is a list of coefficients of
  9985. the differential operator (in increasing order of differentiation) and
  9986. {\tt param} is a list of parameters. The procedure returns the list
  9987. of general solutions.
  9988. {\small\begin{verbatim}
  9989. lcoeff:={1,x,x,x**6};
  9990. 6
  9991. lcoeff := {1,x,x,x }
  9992. param:={};
  9993. param := {}
  9994. sol:=delire(x,4,1,lcoeff,param);
  9995. 4 3 2
  9996. xt - 4*xt + 12*xt - 24*xt + 24
  9997. sol := {{{{0,1,-----------------------------------,1},{
  9998. 12
  9999. }}},
  10000. 4 3
  10001. {{{0,1,(6*log(xt)*xt - 18*log(xt)*xt
  10002. 2
  10003. + 36*log(xt)*xt - 36*log(xt)*xt
  10004. 4 3
  10005. - 5*xt + 9*xt - 36*xt + 36)/36,0},{}
  10006. }},
  10007. 1
  10008. {{{-------,1,
  10009. 4
  10010. 4*xt
  10011. 4 3 2
  10012. 361*xt + 4*xt + 12*xt + 24*xt + 24
  10013. ---------------------------------------,10},
  10014. 24
  10015. {}}}}
  10016. \end{verbatim}}
  10017. \chapter{DFPART: Derivatives of generic functions}
  10018. \label{DFPART}
  10019. \typeout{{DFPART: Derivatives of generic functions}}
  10020. {\footnotesize
  10021. \begin{center}
  10022. Herbert Melenk \\
  10023. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  10024. Takustra\"se 7 \\
  10025. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  10026. e--mail: melenk@zib.de
  10027. \end{center}
  10028. }
  10029. \ttindex{DFPART}
  10030. \index{derivatives}
  10031. \index{partial derivatives}
  10032. \index{generic function}
  10033. The package {\tt DFPART} supports computations with total and partial
  10034. derivatives of formal function objects. Such computations can be
  10035. useful in the context of differential equations or power series
  10036. expansions.
  10037. \section{Generic Functions}
  10038. A generic function is a symbol which represents a mathematical
  10039. function. The minimal information about a generic function
  10040. function is the number of its arguments. In order to facilitate
  10041. the programming and for a better readable output this package
  10042. assumes that the arguments of a generic function have default
  10043. names such as $f(x,y)$, $q(rho,phi)$.
  10044. A generic function is declared by prototype form in a
  10045. statement\ttindex{GENERIC\_FUNCTION}
  10046. \vspace{.1in}
  10047. {\tt GENERIC\_FUNCTION} $fname(arg_1,arg_2\cdots arg_n)$;
  10048. \vspace{.1in}
  10049. \noindent
  10050. where $fname$ is the (new) name of a function and $arg_i$ are
  10051. symbols for its formal arguments. In the following $fname$ is
  10052. referred to as ``generic function'', $arg_1,arg_2\cdots arg_n$ as
  10053. ``generic arguments'' and $fname(arg_1,arg_2\cdots arg_n)$ as
  10054. ``generic form''.
  10055. Examples:
  10056. {\small\begin{verbatim}
  10057. generic_function f(x,y);
  10058. generic_function g(z);
  10059. \end{verbatim}}
  10060. After this declaration {\REDUCE} knows that
  10061. \begin{itemize}
  10062. \item there are formal partial derivatives $\frac{\partial f}{\partial x}$,
  10063. $\frac{\partial f}{\partial y}$ $\frac{\partial g}{\partial z}$
  10064. and higher ones, while partial derivatives of $f$ and $g$
  10065. with respect to other variables are assumed as zero,
  10066. \item expressions of the type $f()$, $g()$ are abbreviations for
  10067. $f(x,y)$, $g(z)$,
  10068. \item expressions of the type $f(u,v)$ are abbreviations for\\
  10069. $sub(x=u,y=v,f(x,y))$
  10070. \item a total derivative $\frac{d f(u,v)}{d w}$ has to be computed
  10071. as $\frac{\partial f}{\partial x} \frac{d u}{d w} +
  10072. \frac{\partial f}{\partial y} \frac{d v}{d w}$
  10073. \end{itemize}
  10074. \section{Partial Derivatives}
  10075. The operator {\tt DFP}\ttindex{DFP} represents a partial derivative:
  10076. \vspace{.1in}
  10077. {\tt DFP}($expr,{dfarg_1,dfarg_2\cdots dfarg_n}$);
  10078. \vspace{.1in}
  10079. \noindent
  10080. where $expr$ is a function expression and $dfarg_i$ are
  10081. the differentiation variables. Examples:
  10082. {\small\begin{verbatim}
  10083. dfp(f(),{x,y});
  10084. \end{verbatim}}
  10085. means $\frac{\partial ^2 f}{\partial x \partial y}$ and
  10086. {\small\begin{verbatim}
  10087. dfp(f(u,v),{x,y});
  10088. \end{verbatim}}
  10089. stands for $\frac{\partial ^2 f}{\partial x \partial y} (u,v)$.
  10090. For compatibility with the $DF$ operator the differentiation
  10091. variables need not be entered in list form; instead the syntax
  10092. of {\tt DF} can be used, where the function expression is followed
  10093. by the differentiation variables, eventually with repetition
  10094. numbers. Such forms are internally converted to the above
  10095. form with a list as second parameter.
  10096. The expression $expr$ can be a generic function
  10097. with or without arguments, or an arithmetic expression built
  10098. from generic functions and other algebraic parts. In the
  10099. second case the standard differentiation rules are applied
  10100. in order to reduce each derivative expressions to a minimal
  10101. form.
  10102. When the switch {\tt NAT} is on partial derivatives of generic
  10103. functions are printed in standard index notation, that is
  10104. $f_{xy}$ for $\frac{\partial ^2 f}{\partial x \partial y}$
  10105. and $f_{xy}(u,v)$ for $\frac{\partial ^2 f}{\partial x \partial y}(u,v)$.
  10106. Therefore single characters should be used for the arguments
  10107. whenever possible. Examples:
  10108. {\small\begin{verbatim}
  10109. generic_function f(x,y);
  10110. generic_function g(y);
  10111. dfp(f(),x,2);
  10112. F
  10113. XX
  10114. dfp(f()*g(),x,2);
  10115. F *G()
  10116. XX
  10117. dfp(f()*g(),x,y);
  10118. F *G() + F *G
  10119. XY X Y
  10120. \end{verbatim}}
  10121. The difference between partial and total derivatives is
  10122. illustrated by the following example:
  10123. {\small\begin{verbatim}
  10124. generic_function h(x);
  10125. dfp(f(x,h(x))*g(h(x)),x);
  10126. F (X,H(X))*G(H(X))
  10127. X
  10128. df(f(x,h(x))*g(h(x)),x);
  10129. F (X,H(X))*G(H(X)) + F (X,H(X))*H (X)*G(H(X))
  10130. X Y X
  10131. + G (H(X))*H (X)*F(X,H(X))
  10132. Y X
  10133. \end{verbatim}}
  10134. Normally partial differentials are assumed as non-commutative
  10135. {\small\begin{verbatim}
  10136. dfp(f(),x,y)-dfp(f(),y,x);
  10137. F - F
  10138. XY YX
  10139. \end{verbatim}}
  10140. However, a generic function can be declared to have globally
  10141. interchangeable partial derivatives using the declaration
  10142. {\tt DFP\_COMMUTE}\ttindex{DFP\_COMMUTE}
  10143. which takes the name of a generic function or a generic function
  10144. form as argument. For such a function differentiation variables are
  10145. rearranged corresponding to the sequence of the generic variables.
  10146. {\small\begin{verbatim}
  10147. generic_function q(x,y);
  10148. dfp_commute q(x,y);
  10149. dfp(q(),{x,y,y}) + dfp(q(),{y,x,y}) + dfp(q(),{y,y,x});
  10150. 3*Q
  10151. XYY
  10152. \end{verbatim}}
  10153. If only a part of the derivatives commute, this has to be
  10154. declared using the standard {\REDUCE} rule mechanism. Please
  10155. note that then the derivative variables must be written as
  10156. list.
  10157. \section{Substitutions}
  10158. When a generic form or a {\tt DFP} expression takes part in a
  10159. substitution the following steps are performed:
  10160. \begin{enumerate}
  10161. \item The substitutions are performed for the arguments. If the
  10162. argument list is empty the substitution is applied to the
  10163. generic arguments of the function; if these change, the resulting
  10164. forms are used as new actual arguments.
  10165. If the generic function itself is not affected by the substitution,
  10166. the process stops here.
  10167. \item If the function name or the generic function
  10168. form occurs as a left hand side in the substitution list,
  10169. it is replaced by the corresponding right hand side.
  10170. \item The new form is partially differentiated according to the
  10171. list of partial derivative variables.
  10172. \item The (eventually modified) actual parameters are substituted
  10173. into the form for their corresponding generic variables.
  10174. This substitution is done by name.
  10175. \end{enumerate}
  10176. Examples:
  10177. {\small\begin{verbatim}
  10178. generic_function f(x,y);
  10179. sub(y=10,f());
  10180. F(X,10)
  10181. sub(y=10,dfp(f(),x,2));
  10182. F (X,10)
  10183. XX
  10184. sub(y=10,dfp(f(y,y),x,2));
  10185. F (10,10)
  10186. XX
  10187. sub(f=x**3*y**3,dfp(f(),x,2));
  10188. 3
  10189. 6*X*Y
  10190. generic_function ff(y,z);
  10191. sub(f=ff,f(a,b));
  10192. FF(B,Z)
  10193. \end{verbatim}}
  10194. \chapter[DUMMY: Expressions with dummy vars]%
  10195. {DUMMY: Canonical form of expressions with dummy variables}
  10196. \label{DUMMY}
  10197. \typeout{[DUMMY: Expressions with dummy variables]}
  10198. {\footnotesize
  10199. \begin{center}
  10200. Alain Dresse \\
  10201. Universit\'e Libre de Bruxelles \\
  10202. Boulevard du Triomphe, CP 210/01 \\
  10203. B--1050 BRUXELLES, Belgium \\[0.05in]
  10204. e--mail: adresse@ulb.ac.be
  10205. \end{center}
  10206. }
  10207. \ttindex{DUMMY}
  10208. An expression of the type
  10209. $$
  10210. \sum_{a=1}^{n} f(a)
  10211. $$
  10212. for any $n$ is simply written as
  10213. $$
  10214. f(a)
  10215. $$
  10216. and $a$ is a {\em dummy} index.
  10217. If the previous expression is written as
  10218. $$
  10219. \sum_{b=1}^{n} f(b)
  10220. $$
  10221. $b$ is also a dummy index and, obviously we should be able to get the
  10222. equality
  10223. $$
  10224. f(a)-f(b);\, \rightarrow 0
  10225. $$
  10226. To declare dummy variables, two declarations are
  10227. available:\ttindex{DUMMY\_BASE}
  10228. \begin{itemize}
  10229. \item[i.]
  10230. {\small\begin{verbatim}
  10231. dummy_base <idp>;
  10232. \end{verbatim}}
  10233. where {\tt idp} is the name of any unassigned identifier.
  10234. \item[ii.]\ttindex{dummy\_names}
  10235. {\small\begin{verbatim}
  10236. dummy_names <d>,<dp>,<dpp> ....;
  10237. \end{verbatim}}
  10238. \end{itemize}
  10239. The first declares {\tt idp1,$\cdots$, idpn} as dummy variables {\em
  10240. i.e.\ }all variables of the form ``{\tt idxxx}'' where {\tt xxx} is a
  10241. number will be dummy variables, such as {\tt id1, id2, ... , id23}.
  10242. The second gives special names for dummy variables.
  10243. All other arguments are assumed to be {\tt free}.\\
  10244. An example:
  10245. {\small\begin{verbatim}
  10246. dummy_base dv; ==> dv
  10247. % dummy indices are dv1, dv2, dv3, ...
  10248. dummy_names i,j,k; ==> t
  10249. % dummy names are i,j,k.
  10250. \end{verbatim}}
  10251. When this is done, an expression like
  10252. {\small\begin{verbatim}
  10253. op(dv1)*sin(dv2)*abs(x)*op(i)^3*op(dv2)$
  10254. \end{verbatim}}
  10255. is allowed. Notice that, dummy indices may not be repeated (it is not
  10256. limited to tensor calculus) or that they be repeated many times inside
  10257. the expression.
  10258. By default all operators with dummy arguments are assumed to be {\em
  10259. commutative} and without symmetry properties. This can be varied by
  10260. declarations {\tt NONCOM}, {\tt SYMMETRIC} and {\tt AN\-TI\-SYM\-ME\-TRIC}
  10261. may be used on the
  10262. operators.\ttindex{NONCOM}\ttindex{SYMMETRIC}\ttindex{ANTISYMMETRIC}
  10263. They can also be declared anticommutative.\ttindex{ANTICOM}
  10264. {\small\begin{verbatim}
  10265. anticom ao1, ao2;
  10266. \end{verbatim}}
  10267. More complex symmetries can be handled with {\tt
  10268. SYMTREE}.\ttindex{SYMTREE}
  10269. The corresponding declaration for the Riemann tensor is
  10270. {\small\begin{verbatim}
  10271. symtree (r, {!+, {!-, 1, 2}, {!-, 3, 4}});
  10272. \end{verbatim}}
  10273. The symbols !*, !+ and !- at the beginning of each list mean that the
  10274. operator has no symmetry, is symmetric and is antisymmetric with
  10275. respect to the indices inside the list. Notice that the indices are
  10276. not designated by their names but merely by their natural order of
  10277. appearance. 1 means the first written argument of {\tt r}, 2 its
  10278. second argument {\em etc.} In the example above r is symmetric with
  10279. respect to interchange of the pairs of indices 1,2 and 3,4
  10280. respectively.
  10281. \chapter{EDS: Exterior differential systems}
  10282. \label{EDS}
  10283. \typeout{{EDS: Exterior differential systems}}
  10284. {\footnotesize
  10285. \begin{center}
  10286. David Hartley \\
  10287. Physics and Mathematical Physics \\
  10288. University of Adelaide SA 5005, Australia \\
  10289. e-mail: DHartley@physics.adelaide.edu.au
  10290. \end{center}
  10291. }
  10292. \ttindex{EDS: Exterior differential dystems}
  10293. \ttindex{EDS}
  10294. \section{Introduction}
  10295. Exterior differential systems give a geometrical framework for partial
  10296. differential equations and more general differential geometric problems.
  10297. The geometrical formulation has several advantages stemming from its
  10298. coordinate-independence, including superior treatment of nonlinear and
  10299. global problems. {\tt EDS} provides a number of tools for setting up and
  10300. manipulating exterior differential systems and implements many features of
  10301. the theory. Its main strengths are the ability to use anholonomic or moving
  10302. frames and the care taken with nonlinear problems.
  10303. The package is loaded
  10304. %\footnote{The package {\tt EXCALC}
  10305. %(Chap. \ref{EXCALC} p. \pageref{EXCALC}) and the package {\tt XIDEAL}
  10306. %(Chap. \ref{XIDEAL} p. \pageref{XIDEAL}) are loaded automatically with
  10307. %this package.}
  10308. by typing \quad {\tt load eds;} \par
  10309. Reading the full documentation, which comes with this
  10310. package, is strongly recommended.
  10311. The test file eds.tst, which is also in the package, provides
  10312. three inspiring examples on the subject. \\
  10313. EDS uses E.~Schr{\"u}fer's EXCALC package for the underlying
  10314. exterior calculus operations.
  10315. \section{Data Structures and Concepts}
  10316. \subsection{EDS}
  10317. A simple \meta{EDS}, or exterior differential system, is a triple
  10318. {\tt (S,$\Omega$,M)}, where {\it M} is a {\it coframing}, {\it S} is a
  10319. system on {\it M}, and {\it $\Omega$} is an independence condition.
  10320. Exterior differential equations without independence condition are not
  10321. treated by {\tt EDS}. {\it $\Omega$} should be either a decomposable
  10322. \meta{p-form} or a \meta{system} of 1-forms on {\it M}. \\
  10323. More generally an \meta{EDS} is a list of simple \meta{EDS} objects
  10324. where the various coframings are all disjoint. \\
  10325. The solutions of {\it (S,$\Omega$,M)} are integral manifolds, or immersions
  10326. on which {\it S} vanishes and the rank of $\Omega$ is preserved. Solutions
  10327. at a single point are described by integral elements.
  10328. \subsection{Coframing}
  10329. Within the context of {\tt EDS}, a {\it coframing} means a real
  10330. finite-dimensional differentiable manifold with a given global cobasis.
  10331. The information about a coframing required by {\tt EDS} is kept in a
  10332. \meta{coframing} object. The cobasis is the identifying element of
  10333. an {\tt EDS}. In addition to the cobasis, there can be given {\it coordinates,
  10334. structure equations} and {\it restrictions}.
  10335. In addition to the cobasis, {\it coordinates, structure equations} and
  10336. {\it restrictions} can be given.
  10337. The coordinates may be an incomplete or
  10338. overcomplete set. The structure equations express the exterior derivative of the
  10339. coordinates and cobasis elements as needed. All coordinate differentials must
  10340. be expressed in terms of the given cobasis, but not all cobasis derivatives
  10341. need be known.
  10342. The restrictions are a set of inequalities describing point sets
  10343. not in the manifold. \\
  10344. Please note that the \meta{coframing} object is by no means a full description
  10345. of a differentiable manifold. However, the \meta{coframing} object carries
  10346. sufficient information about the underlying manifold to allow a range of exterior
  10347. systems calculations to be carried out.
  10348. \subsection{Systems and background coframing}
  10349. The label \meta{system} refers to a list $\{<${\it p-form expr}$>,\ldots\}$ of
  10350. differential forms. If an {\tt EDS} operator also accepts a \meta{system} as
  10351. argument, then any extra information which is required is taken from the
  10352. background coframing. \\
  10353. It is possible to activate the rules and orderings of a \f{COFRAMING} operator
  10354. globally, by making it the {\it background coframing}. All subsequent \f{EXCALC}
  10355. \ttindex{EXCALC} operations will be governed by those rules. Operations on
  10356. \meta{EDS} objects are unaffected, since their coframings are still activated
  10357. locally.
  10358. \subsection{Integral elements}
  10359. An \meta{integral element} of an exterior system $(S,\Omega,M)$ is a subspace
  10360. $P \subset T_pM$ of the tangent space at some point $p \in M$. This integral
  10361. element can be represented by its annihilator $P^\perp \subset T^*_pM$, comprising
  10362. those 1-forms at $p$ which annihilate every vector in $P$. This can also be understood
  10363. as a maximal set of 1-forms at $p$ such that $S \simeq 0 \pmod{P^\perp}$ and the
  10364. rank of $\Omega$ is preserved modulo $P^\perp$. \\
  10365. An \meta{integral element} in EDS is a distribution of 1-forms on $M$,
  10366. specified as a \meta{system} of 1-forms.
  10367. \subsection{Properties and normal form}
  10368. For large problems, it can require a great deal of computation to establish
  10369. whether, for example, a system is closed or not. In order to save
  10370. recomputing such properties, an \meta{EDS} object carries a list of
  10371. \meta{properties} of the form
  10372. \begin{list}{}
  10373. \item {\tt \{\meta{keyword} = \meta{value},$\cdots$\}}
  10374. \end{list}
  10375. where \meta{keyword} is one of \f{closed}, \f{quasilinear}, \f{pfaffian} or
  10376. \f{involutive}, and \meta{value} is either \f{0} (false) or \f{1}
  10377. (true). These properties are suppressed when an \meta{EDS} is printed,
  10378. unless the \f{nat} switch is \f{off}. They can be examined using the
  10379. \f{PROPERTIES} operator. \\
  10380. Parts of the theory of exterior differential systems apply only at points
  10381. on the underlying manifold where the system is in some sense
  10382. non-singular. To ensure the theory applies, EDS automatically works all
  10383. exterior systems $(S,\Omega,M)$ into a {\em normal form}. This means that
  10384. the Pfaffian component of $S$ and the independence condition $\Omega$ are
  10385. in {\it solved} forms, distinguished terms from the 1-forms in $S$ have
  10386. been eliminated from the rest of $S$ and from $\Omega$ and any 1-forms in
  10387. $S$ which vanish modulo the independence condition are removed from the
  10388. system and their coefficients are appended as 0-forms.
  10389. \section{The EDS Package}
  10390. In the descriptions of the various operators we define the following
  10391. abbreviations for function parameters:
  10392. \vspace{0.25cm}
  10393. \begin{tabular}{ll}
  10394. $E$, $E'$ & \meta{EDS}\\
  10395. $S$ & \meta{system}\\
  10396. $M$, $N$ & \meta{coframing}, or a \meta{system} specifying a \meta{coframing}\\
  10397. $r$ & \meta{integer}\\
  10398. $\Omega$ & \meta{p-form}\\
  10399. $f$ & \meta{map}\\
  10400. $rsx$ & \meta{list of inequalities}\\
  10401. $cob$ & \meta{list of 1-form variables}\\
  10402. $crd$, $dep$, $ind$
  10403. & \meta{list of 0-form variables}\\
  10404. $drv$ & \meta{list of rules for exterior derivatives}\\
  10405. $pde$ & \meta{list of expressions or equations}\\
  10406. $X$ & \meta{transform}\\
  10407. $T$ & \meta{tableau}\\
  10408. $P$ & \meta{integral element}\\
  10409. \end{tabular}
  10410. \subsection{Constructing EDS objects}
  10411. An EDS \meta{coframing} is constructed using the \f{COFRAMING} operator.
  10412. In one form it examines the argument for 0-form and 1-form variables. The more
  10413. basic syntax takes the \meta{cobasis} as a list of 1-forms, \meta{coordinates}
  10414. as a list of 0-forms, \meta{restrictions} as a list of inequalities and
  10415. \meta{structure equations} as a list giving the exterior derivatives of the
  10416. coordinates and cobasis elements. All arguments except the cobasis are optional. \\
  10417. A simple \meta{EDS} is constructed using the \f{EDS} operator where the
  10418. \meta{indep. condition} can be either a decomposable \meta{p-form} or a
  10419. \meta{system} of 1-forms. The \meta{coframing} and the \meta{properties}
  10420. arguments can be omitted. The {\it EDS} is put into normal form before being
  10421. returned. With \f{SET\_COFRAMING} the background coframing is set. \\
  10422. The operator \f{PDS2EDS} encodes a PDE system into an \meta{EDS} object. \\
  10423. \begin{tabular}{lll}
  10424. \f{COFRAMING}(cob,crd,rsx,drv)\ttindex{COFRAMING} &
  10425. \f{COFRAMING}(S)\ttindex{COFRAMING} &
  10426. \f{EDS}(S,$\Omega$,M)\ttindex{EDS} \\
  10427. \f{CONTACT}(r,M,N)\ttindex{CONTACT} &
  10428. \f{PDE2EDS}(pde,dep,ind)\ttindex{PDE2EDS} &
  10429. \f{SET\_COFRAMING}(M)\ttindex{SET\_COFRAMING} \\
  10430. \f{SET\_COFRAMING}(E)\ttindex{SET\_COFRAMING} &
  10431. \f{SET\_COFRAMING}()\ttindex{SET\_COFRAMING}
  10432. \end{tabular}
  10433. \vspace{0.5cm}
  10434. {\bf Example:}
  10435. {\small\begin{verbatim}
  10436. 1: load eds;
  10437. 2: pform {x,y,z,p,q}=0,{e(i),w(i,j)}=1;
  10438. 3: indexrange {i,j,k}={1,2},{a,b,c}={3};
  10439. 4: eds({d z - p*d x - q*d y, d p^d q},{d x,d y});
  10440. EDS({d z - p*d x - q*d y,d p^d q},d x^d y)
  10441. 5: OMrules:=index_expand {d e(i)=>-w(i,-j)^e(j),w(i,-j)+w(j,-i)=>0}$
  10442. 6: eds({e(a)},{e(i)}) where OMrules;
  10443. 3 1 2
  10444. EDS({e },{e ,e })
  10445. 7: coframing ws;
  10446. 3 2 1 2 1 2 2
  10447. coframing({e ,w ,e ,e },{},{d e => - e ^w ,
  10448. 1 1
  10449. 2 1 2
  10450. d e => e ^w },{})
  10451. 1
  10452. \end{verbatim}}
  10453. \subsection{Inspecting EDS objects}
  10454. Using these operators you can get parts of your \meta{EDS} object. The
  10455. \f{PROPERTIES}(E) operator for example returns a list of properties which are
  10456. normally not printed out, unless the \f{NAT}\ttindex{NAT} switch is off. \\
  10457. \begin{tabular}{lll}
  10458. \f{COFRAMING}(E)\ttindex{COFRAMING} &
  10459. \f{COFRAMING}()\ttindex{COFRAMING} &
  10460. \f{COBASIS}(M)\ttindex{COBASIS} \\
  10461. \f{COBASIS}(E)\ttindex{COBASIS} &
  10462. \f{COORDINATES}(M)\ttindex{COORDINATES} &
  10463. \f{COORDINATES}(E)\ttindex{COORDINATES} \\
  10464. \f{STRUCTURE\_EQUATIONS}(M)\ttindex{STRUCTURE\_EQUATIONS} &
  10465. \f{STRUCTURE\_EQUATIONS}(E)\ttindex{STRUCTURE\_EQUATIONS} &
  10466. \f{RESTRICTIONS}(M)\ttindex{RESTRICTIONS} \\
  10467. \f{RESTRICTIONS}(E)\ttindex{RESTRICTIONS} &
  10468. \f{SYSTEM}(E)\ttindex{SYSTEM} &
  10469. \f{INDEPENDENCE}(E)\ttindex{INDEPENDENCE} \\
  10470. \f{PROPERTIES}(E)\ttindex{PROPERTIES} &
  10471. \f{ONE\_FORMS}(E)\ttindex{ONE\_FORMS} &
  10472. \f{ONE\_FORMS}(S)\ttindex{ONE\_FORMS} \\
  10473. \f{ZERO\_FORMS}(E)\ttindex{ZERO\_FORMS} &
  10474. \f{ZERO\_FORMS}(S)\ttindex{ZERO\_FORMS} &
  10475. \end{tabular}
  10476. \vspace{0.5cm}
  10477. {\bf Example:}
  10478. {\small\begin{verbatim}
  10479. 8: depend u,x,y; depend v,x,y;
  10480. 9: pde2eds({df(u,y,y)=df(v,x),df(v,y)=y*df(v,x)});
  10481. EDS({d u - u *d x - u *d y, d u - u *d x - u *d y,
  10482. x y x x x y x
  10483. d u - u *d x - v *d y, d v - v *d x - v *y*d y},d x^d y)
  10484. y y x x x x
  10485. 10: dependencies;
  10486. {{u,y,x},{v,y,x}}
  10487. 11: coordinates contact(3,{x},{u});
  10488. {x,u,u ,u ,u }
  10489. x x x x x x
  10490. 12: fdomain u=u(x);
  10491. 13: coordinates {d u+d y};
  10492. {x,y}
  10493. \end{verbatim}}
  10494. \subsection{Manipulating EDS objects}
  10495. These operators allow you to manipulate your \meta{EDS} objects. The
  10496. \f{AUGMENT}(E,S) operator, see example below, appends the extra forms in the second
  10497. argument to the system part of the first. The original \meta{EDS} remains
  10498. unchanged. As another example by using the \f{TRANSFORM} operator
  10499. a change of the cobasis is made, where the argument \meta{transform} is a list of
  10500. substitutions. \\
  10501. \begin{tabular}{llll}
  10502. \f{AUGMENT}(E,S)\ttindex{AUGMENT} &
  10503. $M$ \f{CROSS} $N$\ttindex{CROSS} &
  10504. $E$ \f{CROSS} $N$\ttindex{CROSS} &
  10505. \f{PULLBACK(E,f)}\ttindex{PULLBACK} \\
  10506. \f{PULLBACK}(S,f)\ttindex{PULLBACK} &
  10507. \f{PULLBACK}($\Omega$,f)\ttindex{PULLBACK} &
  10508. \f{PULLBACK}(M,f)\ttindex{PULLBACK} &
  10509. \f{RESTRICT}(E,f)\ttindex{RESTRICT} \\
  10510. \f{RESTRICT}(S,f)\ttindex{RESTRICT} &
  10511. \f{RESTRICT}($\Omega$,f)\ttindex{RESTRICT} &
  10512. \f{RESTRICT}(M,f)\ttindex{RESTRICT} &
  10513. \f{TRANSFORM}(M,X)\ttindex{TRANSFORM} \\
  10514. \f{TRANSFORM}(E,X)\ttindex{TRANSFORM} &
  10515. \f{TRANSFORM}(S,X)\ttindex{TRANSFORM} &
  10516. \f{TRANSFORM}($\Omega$,X)\ttindex{TRANSFORM} &
  10517. \f{LIFT(E)}\ttindex{LIFT} \\
  10518. \end{tabular}
  10519. \vspace{0.5cm}
  10520. {\bf Example:}
  10521. {\small\begin{verbatim}
  10522. % Non-Pfaffian system for a Monge-Ampere equation
  10523. 14: PFORM {x,y,z}=0$
  10524. 15: S := CONTACT(1,{x,y},{z});
  10525. s := EDS({d z - z *d x - z *d y},d x^d y)
  10526. x y
  10527. 16: S:= AUGMENT(S,{d z(-x)^d z(-y)});
  10528. s := EDS({d z - z *d x - z *d y,
  10529. x y
  10530. d z ^d z },d x^d y)
  10531. x y
  10532. \end{verbatim}}
  10533. \subsection{Analysing and Testing exterior systems}
  10534. {\bf Analysing exterior systems} \par
  10535. This section introduces higher level operators for extracting information about
  10536. exterior systems. Many of them require a \meta{EDS} in normal form generated
  10537. in positive degree as input, but some can also analyse a \meta{system} or a
  10538. single \meta{p-form}. \\
  10539. \begin{tabular}{lll}
  10540. \f{CARTAN\_SYSTEM}(E)\ttindex{CARTAN\_SYSTEM} &
  10541. \f{CARTAN\_SYSTEM}(S)\ttindex{CARTAN\_SYSTEM} &
  10542. \f{CARTAN\_SYSTEM}($\Omega$)\ttindex{CARTAN\_SYSTEM} \\
  10543. \f{CAUCHY\_SYSTEM}(E)\ttindex{CAUCHY\_SYSTEM} &
  10544. \f{CAUCHY\_SYSTEM}(S)\ttindex{CAUCHY\_SYSTEM} &
  10545. \f{CAUCHY\_SYSTEM}($\Omega$)\ttindex{CAUCHY\_SYSTEM} \\
  10546. \f{CHARACTERS}(E)\ttindex{CHARACTERS} &
  10547. \f{CHARACTERS}(T)\ttindex{CHARACTERS} &
  10548. \f{CHARACTERS}(E,P)\ttindex{CHARACTERS} \\
  10549. \f{CLOSURE}(E)\ttindex{CLOSURE} &
  10550. \f{DERIVED\_SYSTEM}(E)\ttindex{DERIVED\_SYSTEMS} &
  10551. \f{DERIVED\_SYSTEM}(S)\ttindex{DERIVED\_SYSTEMS} \\
  10552. \f{DIM\_GRASSMANN\_VARIETY}(E)\ttindex{DIM\_GRASSMANN\_VARIETY} &
  10553. \f{DIM\_GRASSMANN\_VARIETY}(E,P)\ttindex{DIM\_GRASSMANN\_VARIETY} &
  10554. \f{DIM}(M)\ttindex{DIM} \\
  10555. \f{DIM}(E)\ttindex{DIM} &
  10556. \f{INVOLUTION}(E)\ttindex{INVOLUTION} &
  10557. \f{LINEARISE}(E,P)\ttindex{LINEARISE} \\
  10558. \f{INTEGRAL\_ELEMENT}(E)\ttindex{INTEGRAL\_ELEMENT} &
  10559. \f{PROLONG}(E)\ttindex{PROLONG} &
  10560. \f{TABLEAU}(E)\ttindex{TABLEAU} \\
  10561. \f{TORSION}(E)\ttindex{TORSION} &
  10562. \f{GRASSMANN\_VARIETY}(E)\ttindex{GRASSMANN\_VARIETY} &
  10563. \end{tabular}
  10564. \par
  10565. \ \\
  10566. {\bf Testing exterior systems} \par
  10567. The following operators allow various properties of an \meta{EDS} to be checked.
  10568. The result is either a {\bf 1} or a {\bf 0}, so these operators can be used in
  10569. boolean expressions. Since checking these properties is very time-consuming, the
  10570. result of the first test is stored on the \meta{properties} record of an
  10571. \meta{EDS} to avoid re-checking. This memory can be cleared using the
  10572. \f{CLEANUP}\ttindex{CLEANUP} opearator. \\
  10573. \begin{tabular}{llll}
  10574. \f{CLOSED}(E)\ttindex{CLOSED} &
  10575. \f{CLOSED}(S)\ttindex{CLOSED} &
  10576. \f{CLOSED}($\Omega$)\ttindex{CLOSED} &
  10577. \f{INVOLUTIVE}(E)\ttindex{INVOLUTIVE} \\
  10578. \f{PFAFFIAN}(E)\ttindex{PFAFFIAN} &
  10579. \f{QUASILINEAR}(E)\ttindex{QUASILINEAR} &
  10580. \f{SEMILINEAR}(E)\ttindex{SEMILINEAR} &
  10581. $E$ \f{EQUIV} $E'$\ttindex{EQUIV} \\
  10582. \end{tabular}
  10583. \vspace{0.5cm}
  10584. \subsection{Switches}
  10585. EDS provides several switches to govern the display of information and enhance
  10586. the speed or reliability of the calculations. For example the switch \f{EDSVERBOSE}
  10587. if {\tt ON} will display additional information as the calculation progresses,
  10588. which might generate too much output for larger problems. \\
  10589. All switches are {\tt OFF} by default.
  10590. \begin{tabular}{llllll}
  10591. \f{EDSVERBOSE}\ttindex{EDSVERBOSE} &
  10592. \f{EDSDEBUG}\ttindex{EDSDEBUG} &
  10593. \f{EDSSLOPPY}\ttindex{EDSSLOPPY} &
  10594. \f{EDSDISJOINT}\ttindex{EDSDISJOINT} &
  10595. \f{RANPOS}\ttindex{RANPOS} &
  10596. \f{GENPOS}\ttindex{GENPOS} \\
  10597. \end{tabular}
  10598. \subsection{Auxilliary functions}
  10599. The operators of this section are designed to ease working with exterior forms
  10600. and exterior systems in {\REDUCE}\ . \\
  10601. \begin{tabular}{lll}
  10602. \f{COORDINATES}(S)\ttindex{COORDINATES} &
  10603. \f{INVERT}(X)\ttindex{INVERT} &
  10604. \f{STRUCTURE\_EQUATIONS}(X)\ttindex{STRUCTURE\_EQUATIONS} \\
  10605. \f{STRUCTURE\_EQUATIONS}(X,$X^{-1}$)\ttindex{STRUCTURE\_EQUATIONS} &
  10606. \f{LINEAR\_DIVISORS}($\Omega$)\ttindex{LINEAR\_DIVISORS} &
  10607. \f{EXFACTORS}($\Omega$)\ttindex{EXFACTORS} \\
  10608. \f{INDEX\_EXPAND}(ANY)\ttindex{INDEX\_EXPAND} &
  10609. \f{PDE2JET}(pde,dep,ind)\ttindex{PDE2JET} &
  10610. \f{MKDEPEND}(list)\ttindex{MKDEPEND} \\
  10611. \f{DISJOIN}(f,g,...)\ttindex{DISJOIN} &
  10612. \f{CLEANUP}(E)\ttindex{CLEANUP} &
  10613. \f{CLEANUP}(M)\ttindex{CLEANUP} \\
  10614. \f{REORDER}(E)\ttindex{REORDER} &
  10615. \f{REORDER}(M)\ttindex{REORDER} &
  10616. \end{tabular}
  10617. \subsection{Experimental Functions}
  10618. The following operators are experimental facilities since, they are
  10619. either algorithmically not well-founded, or their implementation is
  10620. very unstable, or they have known bugs. \\
  10621. \begin{tabular}{lll}
  10622. \f{POINCARE}($\Omega$)\ttindex{POINCARE} &
  10623. \f{INVARIANTS}(E,crd)\ttindex{INVARIANTS} &
  10624. \f{INVARIANTS}(S,crd)\ttindex{INVARIANTS} \\
  10625. \f{SYMBOL\_RELATIONS}(E,$\pi$)\ttindex{SYMBOL\_RELATIONS} &
  10626. \f{SYMBOL\_MATRIX}(E,$\xi$)\ttindex{SYMBOL\_MATRIX} &
  10627. \f{CHARACTERISTIC\_VARIETY}(E,$\xi$)\ttindex{CHARACTERISTIC\_VARIETY} \\
  10628. \end{tabular}
  10629. \vspace{0.5cm}
  10630. {\bf Example:}
  10631. {\small\begin{verbatim}
  10632. 17: % Riemann invariants for Euler-Poisson-Darboux equation.
  10633. 17: % Set up the EDS for the equation, and examine tableau.
  10634. 17: depend u,x,y; EPD :=PDE2EDS{DF(u,x,y)=-(df(u,x)+df(u,y))/(x+y)}$
  10635. 19: tableau EPD;
  10636. [d u 0 ]
  10637. [ x x ]
  10638. [ ]
  10639. [ 0 d u ]
  10640. [ y y]
  10641. 20: % 1-form dx is characteristic: construct characteristic EDS.
  10642. 20: xvars {}; C := cartan_system select(~f^d x=0,system closure epd)$
  10643. 22: S := augment(eds(system EPD,d y),C)$
  10644. 23: % Compute derived flag
  10645. 23: while not equiv(S,S1 := derived_system S) do S := S1;
  10646. 24: % Stabilised. Find the Riemann invariants.
  10647. 24: invariants(S,reverse coordinates S);
  10648. {x,
  10649. u *x + u *y + u,
  10650. x x
  10651. - u *x - u *y - 2*u }
  10652. x x x x x
  10653. \end{verbatim}}
  10654. \chapter[EXCALC: Differential Geometry]%
  10655. {EXCALC: A differential geometry package}
  10656. \label{EXCALC}
  10657. \typeout{{EXCALC: A differential geometry package}}
  10658. {\footnotesize
  10659. \begin{center}
  10660. Eberhard Schr\"{u}fer \\
  10661. GMD, Institut I1 \\
  10662. Postfach 1316 \\
  10663. 53757 St. Augustin, GERMANY \\[0.05in]
  10664. e--mail: schruefer@gmd.de
  10665. \end{center}
  10666. }
  10667. \ttindex{EXCALC}
  10668. {\bf EXCALC} is designed for easy use by all who are familiar with the
  10669. calculus of Modern Differential Geometry. Its syntax is kept as close
  10670. as possible to standard textbook notations. Therefore, no great
  10671. experience in writing computer algebra programs is required. It is
  10672. almost possible to input to the computer the same as what would have
  10673. been written down for a hand-calculation. For example, the statement
  10674. {\small\begin{verbatim}
  10675. f*x^y + u _| (y^z^x)
  10676. \end{verbatim}}
  10677. \index{exterior calculus}
  10678. would be recognized by the program as a formula involving exterior
  10679. products and an inner product. The program is currently able to
  10680. handle scalar-valued exterior forms, vectors and operations between
  10681. them, as well as non-scalar valued forms (indexed forms). With this,
  10682. it should be an ideal tool for studying differential equations,
  10683. doing calculations in general relativity and field theories, or doing
  10684. such simple things as calculating the Laplacian of a tensor field for
  10685. an arbitrary given frame. With the increasing popularity of this
  10686. calculus, this program should have an application in almost any field
  10687. of physics and mathematics.
  10688. \section{Declarations}
  10689. Geometrical objects like exterior forms or vectors are introduced to the
  10690. system by declaration commands. The declarations can appear anywhere in
  10691. a program, but must, of course, be made prior to the use of the object.
  10692. Everything that has no declaration is treated as a constant; therefore
  10693. zero-forms must also be declared.
  10694. An exterior form is introduced by\label{PFORM}\index{PFORM statement}
  10695. \index{exterior form ! declaration}
  10696. \hspace*{2em} \k{PFORM} \s{declaration$_1$}, \s{declaration$_2$}, \ldots;
  10697. where
  10698. \begin{tabbing}
  10699. \s{declaration} ::= \s{name} $\mid$ \s{list of names}=\s{number} $\mid$ \s{identifier} $\mid$ \\
  10700. \s{expression} \\
  10701. \s{name} ::= \s{identifier} $\mid$ \s{identifier}(\s{arguments})
  10702. \end{tabbing}
  10703. For example
  10704. {\small\begin{verbatim}
  10705. pform u=k,v=4,f=0,w=dim-1;
  10706. \end{verbatim}}
  10707. declares {\tt U} to be an exterior form of degree {\tt K}, {\tt V} to be a
  10708. form of degree 4, {\tt F} to be a form of degree 0 (a function), and {\tt W}
  10709. to be a form of degree {\tt DIM}-1.
  10710. The declaration of vectors is similar. The command {\tt TVECTOR}\label{TVECTOR}
  10711. takes a list of names.\index{TVECTOR command}\index{exterior form ! vector}
  10712. \hspace*{2em} \k{TVECTOR} \s{name$_1$}, \s{name$_2$}, \ldots;
  10713. For example, to declare {\tt X} as a vector and {\tt COMM} as a vector with
  10714. two indices, one would say
  10715. {\small\begin{verbatim}
  10716. tvector x,comm(a,b);
  10717. \end{verbatim}}
  10718. The exterior degree of a symbol or a general expression can be obtained
  10719. with the function \label{EXDEGREE}\index{EXDEGREE command}
  10720. \hspace*{2em} \k{EXDEGREE} \s{expression};
  10721. Example:
  10722. {\small\begin{verbatim}
  10723. exdegree(u + 3*chris(k,-k));
  10724. 1
  10725. \end{verbatim}}
  10726. \section{Exterior Multiplication}
  10727. \index{"\^{} ! exterior multiplication}\index{exterior product}
  10728. Exterior multiplication between exterior forms is carried out with the
  10729. nary infix operator \^{ } (wedge)\label{wedge}. Factors are ordered
  10730. according to the usual ordering in {\REDUCE} using the commutation
  10731. rule for exterior products.
  10732. {\small\begin{verbatim}
  10733. pform u=1,v=1,w=k;
  10734. u^v;
  10735. U^V
  10736. v^u;
  10737. - U^V
  10738. u^u;
  10739. 0
  10740. w^u^v;
  10741. K
  10742. ( - 1) *U^V^W
  10743. (3*u-a*w)^(w+5*v)^u;
  10744. A*(5*U^V^W - U^W^W)
  10745. \end{verbatim}}
  10746. It is possible to declare the dimension of the underlying space
  10747. by\label{SPACEDIM}\index{SPACEDIM command}\index{dimension}
  10748. \hspace*{2em} \k{SPACEDIM} \s{number} $\mid$ \s{identifier};
  10749. If an exterior product has a degree higher than the dimension of the
  10750. space, it is replaced by 0:
  10751. \section{Partial Differentiation}
  10752. Partial differentiation is denoted by the operator {\tt @}\label{at}.
  10753. Its capability is the same as the {\REDUCE} {\tt DF} operator.
  10754. \index{"@ operator}\index{partial differentiation}
  10755. \index{differentiation ! partial}
  10756. \example\index{EXCALC package ! example}
  10757. {\small\begin{verbatim}
  10758. @(sin x,x);
  10759. COS(X)
  10760. @(f,x);
  10761. 0
  10762. \end{verbatim}}
  10763. An identifier can be declared to be a function of certain variables.
  10764. \index{FDOMAIN command}
  10765. This is done with the command {\tt FDOMAIN}\label{FDOMAIN}. The
  10766. following would tell the partial differentiation operator that {\tt F}
  10767. is a function of the variables {\tt X} and {\tt Y} and that {\tt H} is
  10768. a function of {\tt X}.
  10769. {\small\begin{verbatim}
  10770. fdomain f=f(x,y),h=h(x);
  10771. \end{verbatim}}
  10772. Applying {\tt @} to {\tt F} and {\tt H} would result in
  10773. {\small\begin{verbatim}
  10774. @(x*f,x);
  10775. F + X*@ F
  10776. X
  10777. @(h,y);
  10778. 0
  10779. \end{verbatim}}
  10780. \index{tangent vector}
  10781. The partial derivative symbol can also be an operator with a single
  10782. argument. It then represents a natural base element of a tangent
  10783. vector\label{at1}.
  10784. \section{Exterior Differentiation}
  10785. \index{exterior differentiation}
  10786. Exterior differentiation of exterior forms is carried out by the
  10787. operator {\tt d}\label{d}. Products are normally differentiated out,
  10788. {\small\begin{verbatim}
  10789. pform x=0,y=k,z=m;
  10790. d(x * y);
  10791. X*d Y + d X^Y
  10792. \end{verbatim}}
  10793. This expansion can be suppressed by the command {\tt NOXPND
  10794. D}\label{NOXPNDD}.\index{NOXPND ! D}
  10795. Expansion is performed again when the command {\tt XPND D}\label{XPNDD}
  10796. is executed.\index{XPND ! D}
  10797. If an argument of an implicitly defined function has further
  10798. dependencies the chain rule will be applied {\em e.g.}\index{chain rule}
  10799. {\small\begin{verbatim}
  10800. fdomain y=y(z);
  10801. d f;
  10802. @ F*d X + @ F*@ Y*d Z
  10803. X Y Z
  10804. \end{verbatim}}
  10805. Expansion into partial derivatives can be inhibited by
  10806. {\tt NOXPND @}\label{NOXPNDA}
  10807. and enabled again by {\tt XPND @}\label{XPNDA}.
  10808. \index{NOXPND ! "@}\index{XPND ! "@}
  10809. \section{Inner Product}
  10810. \index{inner product ! exterior form}
  10811. The inner product between a vector and an exterior form is represented
  10812. by the diphthong \_$|$ \label{innerp} (underscore or-bar), which is the
  10813. notation of many textbooks. If the exterior form is an exterior
  10814. product, the inner product is carried through any factor.
  10815. \index{\_$\mid$ operator}
  10816. \example\index{EXCALC package ! example}
  10817. {\small\begin{verbatim}
  10818. pform x=0,y=k,z=m;
  10819. tvector u,v;
  10820. u _| (x*y^z);
  10821. K
  10822. X*(( - 1) *Y^U _| Z + U _| Y^Z)
  10823. \end{verbatim}}
  10824. \section{Lie Derivative}
  10825. \index{Lie Derivative}
  10826. The Lie derivative can be taken between a vector and an exterior form
  10827. or between two vectors. It is represented by the infix operator $|$\_
  10828. \label{lie}. In the case of Lie differentiating, an exterior form by
  10829. a vector, the Lie derivative is expressed through inner products and
  10830. exterior differentiations, {\em i.e.}\index{$\mid$\_ operator}
  10831. {\small\begin{verbatim}
  10832. pform z=k;
  10833. tvector u;
  10834. u |_ z;
  10835. U _| d Z + d(U _| Z)
  10836. \end{verbatim}}
  10837. \section{Hodge-* Duality Operator}
  10838. \index{Hodge-* duality operator}\index{"\# ! Hodge-* operator}
  10839. The Hodge-*\label{hodge} duality operator maps an exterior form of degree
  10840. {\tt K} to an exterior form of degree {\tt N-K}, where {\tt N} is the
  10841. dimension of the space. The double application of the operator must
  10842. lead back to the original exterior form up to a factor. The following
  10843. example shows how the factor is chosen here
  10844. {\small\begin{verbatim}
  10845. spacedim n;
  10846. pform x=k;
  10847. # # x;
  10848. 2
  10849. (K + K*N)
  10850. ( - 1) *X*SGN
  10851. \end{verbatim}}
  10852. \index{SGN ! indeterminate sign}\index{coframe}
  10853. The indeterminate SGN in the above example denotes the sign of the
  10854. determinant of the metric. It can be assigned a value or will be
  10855. automatically set if more of the metric structure is specified (via
  10856. COFRAME), {\em i.e.} it is then set to $g/|g|$, where $g$ is the
  10857. determinant of the metric. If the Hodge-* operator appears in an
  10858. exterior product of maximal degree as the leftmost factor, the Hodge-*
  10859. is shifted to the right according to
  10860. {\small\begin{verbatim}
  10861. pform {x,y}=k;
  10862. # x ^ y;
  10863. 2
  10864. (K + K*N)
  10865. ( - 1) *X^# Y
  10866. \end{verbatim}}
  10867. \section{Variational Derivative}
  10868. \index{derivative ! variational}\index{variational derivative}
  10869. \ttindex{VARDF}
  10870. The function {\tt VARDF}\label{VARDF} returns as its value the
  10871. variation of a given Lagrangian n-form with respect to a specified
  10872. exterior form (a field of the Lagrangian). In the shared variable
  10873. \ttindex{BNDEQ"!*}
  10874. {\tt BNDEQ!*}, the expression is stored that has to yield zero if
  10875. integrated over the boundary.
  10876. Syntax:
  10877. \hspace*{2em} \k{VARDF}(\s{Lagrangian n-form},\s{exterior form})
  10878. \example\index{EXCALC package ! example}
  10879. {\small\begin{verbatim}
  10880. spacedim 4;
  10881. pform l=4,a=1,j=3;
  10882. l:=-1/2*d a ^ # d a - a^# j$ %Lagrangian of the e.m. field
  10883. vardf(l,a);
  10884. - (# J + d # d A) %Maxwell's equations
  10885. bndeq!*;
  10886. - 'A^# d A %Equation at the boundary
  10887. \end{verbatim}}
  10888. For the calculation of the conserved currents induced by symmetry
  10889. operators (vector fields), the function {\tt NOETHER}\label{NOETHER}
  10890. \index{NOETHER function}
  10891. is provided. It has the syntax:
  10892. \hspace*{2em}
  10893. \k{NOETHER}(\s{Lagrangian n-form},\s{field},\s{symmetry generator})
  10894. \example\index{EXCALC package ! example}
  10895. {\small\begin{verbatim}
  10896. pform l=4,a=1,f=2;
  10897. spacedim 4;
  10898. l:= -1/2*d a^#d a; %Free Maxwell field;
  10899. tvector x(k); %An unspecified generator;
  10900. noether(l,a,x(-k));
  10901. ( - 2*d(X _|A)^# d A - (X _|d A)^# d A + d A^(X _|# d A))/2
  10902. K K K
  10903. \end{verbatim}}
  10904. \section{Handling of Indices}
  10905. \index{exterior form ! with indices}
  10906. Exterior forms and vectors may have indices. On input, the indices
  10907. are given as arguments of the object. A positive argument denotes a
  10908. superscript and a negative argument a subscript. On output, the
  10909. indexed quantity is displayed two dimensionally if {\tt NAT} is on.
  10910. \index{NAT flag}
  10911. Indices may be identifiers or numbers.
  10912. \example\index{EXCALC package ! example}
  10913. {\small\begin{verbatim}
  10914. pform om(k,l)=m,e(k)=1;
  10915. e(k)^e(-l);
  10916. K
  10917. E ^E
  10918. L
  10919. om(4,-2);
  10920. 4
  10921. OM
  10922. 2
  10923. \end{verbatim}}
  10924. In certain cases, one would like to inhibit the summation over
  10925. specified index names, or at all. For this the command
  10926. \index{NOSUM command}
  10927. \hspace*{2em} \k{NOSUM} \s{indexname$_1$}, \ldots;\label{NOSUM}
  10928. and the switch {\tt NOSUM} are\index{NOSUM switch}
  10929. available. The command {\tt NOSUM} has the effect that summation is
  10930. not performed over those indices which had been listed. The command
  10931. {\tt RENOSUM}\label{RENOSUM} enables summation again. The switch {\tt
  10932. NOSUM}, if on, inhibits any summation.\index{RENOSUM command}
  10933. \label{INDEXSYMMETRIES}\index{INDEXSYMMETRIES command}
  10934. It is possible to declare symmetry properties for an indexed quantity by
  10935. the command {\tt INDEX\_SYMMETRIES}. A prototypical example is as
  10936. follows
  10937. {\small\begin{verbatim}
  10938. index_symmetries u(k,l,m,n): symmetric in {k,l},{m,n}
  10939. antisymmetric in {{k,l},{m,n}},
  10940. g(k,l),h(k,l): symmetric;
  10941. \end{verbatim}}
  10942. It declares the object {\tt u} symmetric in the first two and last
  10943. two indices and antisymmetric with respect to commutation of the given
  10944. index pairs. If an object is completely symmetric or antisymmetric,
  10945. the indices need not to be given after the corresponding keyword as
  10946. shown above for {\tt g} and {\tt h}.
  10947. \section{Metric Structures}
  10948. \index{metric structure}\index{coframe}
  10949. A metric structure is defined in {\bf EXCALC} by specifying a set of
  10950. basis one-forms (the coframe) together with the metric.
  10951. Syntax:\label{COFRAME}
  10952. \begin{tabbing}
  10953. \hspace*{2em} \k{COFRAME} \=
  10954. \s{identifier}\s{(index$_1$)}=\s{expression$_1$}, \\
  10955. \> \s{identifier}\s{(index$_2$)}=\s{expression$_2$}, \\
  10956. \> . \\
  10957. \> . \\
  10958. \> . \\
  10959. \> \s{identifier}\s{(index$_n$)}=\s{expression$_n$} \\
  10960. \> \hspace{1em} \k{WITH} \k{METRIC} \s{name}=\s{expression}; \\
  10961. \end{tabbing}
  10962. \index{Euclidean metric}\index{COFRAME ! WITH METRIC}
  10963. This statement automatically sets the dimension of the space and the
  10964. index range. The clause {\tt WITH METRIC} can be omitted if the metric
  10965. \index{COFRAME ! WITH SIGNATURE}
  10966. is Euclidean and the shorthand {\tt WITH SIGNATURE \s{diagonal elements}}
  10967. \label{SIGNATURE} can be used in the case of a pseudo-Euclidean
  10968. metric. The splitting of a metric structure in its metric tensor
  10969. coefficients and basis one-forms is completely arbitrary including the
  10970. extremes of an orthonormal frame and a coordinate frame.
  10971. \newpage
  10972. \example\index{EXCALC package ! example}
  10973. {\small\begin{verbatim}
  10974. coframe e r=d r, e(ph)=r*d ph
  10975. with metric g=e(r)*e(r)+e(ph)*e(ph); %Polar coframe
  10976. \end{verbatim}}
  10977. The frame dual to the frame defined by the {\tt COFRAME} command can
  10978. be introduced by \k{FRAME} command.\index{FRAME command}
  10979. \hspace*{2em} \k{FRAME} \s{identifier};\label{FRAME}
  10980. This command causes the
  10981. dual property to be recognised, and the tangent vectors of the
  10982. coordinate functions are replaced by the frame basis vectors.
  10983. \example\index{EXCALC package ! example}
  10984. {\small\begin{verbatim}
  10985. coframe b r=d r,b ph=r*d ph,e z=d z; %Cylindrical coframe;
  10986. frame x; on nero;
  10987. x(-k) _| b(l);
  10988. R
  10989. NS := 1
  10990. R
  10991. PH
  10992. NS := 1
  10993. PH
  10994. Z
  10995. NS := 1
  10996. Z
  10997. x(-k) |_ x(-l); %The commutator of the dual frame;
  10998. NS := X /R
  10999. PH R PH
  11000. NS := ( - X )/R %i.e. it is not a coordinate base;
  11001. R PH PH
  11002. \end{verbatim}}
  11003. \index{DISPLAYFRAME command}\index{tracing ! EXCALC}
  11004. As a convenience, the frames can be displayed at any point in a program
  11005. by the command {\tt DISPLAYFRAME;}\label{DISPLAYFRAME}.
  11006. \index{Hodge-* duality operator}
  11007. The Hodge-* duality operator returns the explicitly constructed dual
  11008. element if applied to coframe base elements. The metric is properly
  11009. taken into account.
  11010. \index{Levi-Cevita tensor}\ttindex{EPS}
  11011. The total antisymmetric Levi-Cevita tensor {\tt EPS}\label{EPS} is
  11012. also available. The value of {\tt EPS} with an even permutation of the
  11013. indices in a covariant position is taken to be +1.
  11014. \section{Riemannian Connections}
  11015. \index{Riemannian Connections}
  11016. The command {\tt RIEMANNCONX} is provided for calculating the
  11017. \index{RIEMANNCONX command} \label{RIEMANNCONX}
  11018. connection 1 forms. The values are stored on the name given to {\tt
  11019. RIEMANNCONX}. This command is far more efficient than calculating the
  11020. connection from the differential of the basis one-forms and using
  11021. inner products.
  11022. \section{Ordering and Structuring}
  11023. \index{ordering ! exterior form}\index{FORDER command}
  11024. The ordering of an exterior form or vector can be changed by the
  11025. command {\tt FORDER}.\label{FORDER} In an expression, the first
  11026. identifier or kernel in the arguments of {\tt FORDER} is ordered ahead
  11027. of the second, and so on, and ordered ahead of all not appearing as
  11028. arguments. This ordering is done on the internal level and not only
  11029. on output. The execution of this statement can therefore have
  11030. tremendous effects on computation time and memory requirements. {\tt
  11031. REMFORDER}\label{REMFORDER} brings back standard ordering for those
  11032. elements that are listed as arguments.\index{REMFORDER command}
  11033. An expression can be put in a more structured form by renaming a
  11034. subexpression. This is done with the command {\tt KEEP} which
  11035. has the syntax\index{KEEP command}\label{KEEP}
  11036. \hspace*{2em} \k{KEEP}
  11037. \s{name$_1$}=\s{expression$_1$},\s{name$_2$}=\s{expression$_2$}, \ldots
  11038. \index{exterior product}
  11039. The capabilities of {\tt KEEP} are currently very limited. Only exterior
  11040. products should occur as righthand sides in {\tt KEEP}.
  11041. \noindent{\bf Note:}
  11042. This is just an introduction to the full power of {\tt EXCALC}. The
  11043. reader if referred to the full documentation.
  11044. \chapter[FIDE: Finite differences for PDEs]%
  11045. {FIDE: Finite difference method for partial differential equations}
  11046. \label{FIDE}
  11047. \typeout{[FIDE: Finite differences for PDEs]}
  11048. {\footnotesize
  11049. \begin{center}
  11050. Richard Liska \\
  11051. Faculty of Nuclear Science and Physical Engineering \\
  11052. Technical University of Prague \\
  11053. Brehova 7, 115 19 Prague 1, Czech Republic \\[0.05in]
  11054. e--mail: tjerl@aci.cvut.cz
  11055. \end{center}
  11056. }
  11057. \ttindex{FIDE}
  11058. The FIDE package performs automation of the process of numerical
  11059. solving partial differential equations systems (PDES) by generating
  11060. finite difference methods. In the process one can find several stages
  11061. in which computer algebra can be used for performing routine
  11062. analytical calculations, namely: transforming differential equations
  11063. into different coordinate systems, discretisation of differential
  11064. equations, analysis of difference schemes and generation of numerical
  11065. programs. The FIDE package consists of the following modules:
  11066. \begin{description}
  11067. \item[EXPRES] for transforming PDES into any orthogonal coordinate system.
  11068. \item[IIMET] for discretisation of PDES by integro-interpolation method.
  11069. \item[APPROX] for determining the order of approximation of
  11070. difference scheme.
  11071. \item[CHARPOL] for calculation of amplification matrix and
  11072. characteristic polynomial of difference scheme, which are needed in
  11073. Fourier stability analysis.\
  11074. \item[HURWP] for polynomial roots locating necessary in verifying the
  11075. von Neumann stability condition.
  11076. \item[LINBAND] for generating the block of FORTRAN code, which solves
  11077. a system of linear algebraic equations with band matrix appearing
  11078. quite often in difference schemes.
  11079. \end{description}
  11080. For more details on this package are given in the FIDE documentation,
  11081. and in the examples. A flavour of its capabilities can be seen from
  11082. the following simple example.
  11083. {\small\begin{verbatim}
  11084. off exp;
  11085. factor diff;
  11086. on rat,eqfu;
  11087. % Declare which indexes will be given to coordinates
  11088. coordinates x,t into j,m;
  11089. % Declares uniform grid in x coordinate
  11090. grid uniform,x;
  11091. % Declares dependencies of functions on coordinates
  11092. dependence eta(t,x),v(t,x),eps(t,x),p(t,x);
  11093. % Declares p as known function
  11094. given p;
  11095. same eta,v,p;
  11096. iim a, eta,diff(eta,t)-eta*diff(v,x)=0,
  11097. v,diff(v,t)+eta/ro*diff(p,x)=0,
  11098. eps,diff(eps,t)+eta*p/ro*diff(v,x)=0;
  11099. *****************************
  11100. ***** Program ***** IIMET Ver 1.1.2
  11101. *****************************
  11102. Partial Differential Equations
  11103. ==============================
  11104. diff(eta,t) - diff(v,x)*eta = 0
  11105. diff(p,x)*eta
  11106. --------------- + diff(v,t) = 0
  11107. ro
  11108. diff(v,x)*eta*p
  11109. diff(eps,t) + ----------------- = 0
  11110. ro
  11111. Backtracking needed in grid optimalization
  11112. 0 interpolations are needed in x coordinate
  11113. Equation for eta variable is integrated in half grid point
  11114. Equation for v variable is integrated in half grid point
  11115. Equation for eps variable is integrated in half grid point
  11116. 0 interpolations are needed in t coordinate
  11117. Equation for eta variable is integrated in half grid point
  11118. Equation for v variable is integrated in half grid point
  11119. Equation for eps variable is integrated in half grid point
  11120. Equations after Discretization Using IIM :
  11121. ==========================================
  11122. (4*(eta(j,m + 1) - eta(j,m) - eta(j + 1,m)
  11123. + eta(j + 1,m + 1))*hx - (
  11124. (eta(j + 1,m + 1) + eta(j,m + 1))
  11125. *(v(j + 1,m + 1) - v(j,m + 1))
  11126. + (eta(j + 1,m) + eta(j,m))*(v(j + 1,m) - v(j,m)))
  11127. *(ht(m + 1) + ht(m)))/(4*(ht(m + 1) + ht(m))*hx) = 0
  11128. (4*(v(j,m + 1) - v(j,m) - v(j + 1,m) + v(j + 1,m + 1))*hx*ro
  11129. + ((eta(j + 1,m + 1) + eta(j,m + 1))
  11130. *(p(j + 1,m + 1) - p(j,m + 1))
  11131. + (eta(j + 1,m) + eta(j,m))*(p(j + 1,m) - p(j,m)))
  11132. *(ht(m + 1) + ht(m)))/(4*(ht(m + 1) + ht(m))*hx*ro) = 0
  11133. (4*(eps(j,m + 1) - eps(j,m) - eps(j + 1,m)
  11134. + eps(j + 1,m + 1))*hx*ro + ((
  11135. eta(j + 1,m + 1)*p(j + 1,m + 1)
  11136. + eta(j,m + 1)*p(j,m + 1))
  11137. *(v(j + 1,m + 1) - v(j,m + 1)) +
  11138. (eta(j + 1,m)*p(j + 1,m) + eta(j,m)*p(j,m))
  11139. *(v(j + 1,m) - v(j,m)))*(ht(m + 1) + ht(m)))/(4
  11140. *(ht(m + 1) + ht(m))*hx*ro) = 0
  11141. clear a;
  11142. clearsame;
  11143. cleargiven;
  11144. \end{verbatim}}
  11145. \chapter[FPS: Formal power series]%
  11146. {FPS: Automatic calculation of formal power series}
  11147. \label{FPS}
  11148. \typeout{[FPS: Formal power series]}
  11149. {\footnotesize
  11150. \begin{center}
  11151. Wolfram Koepf and Winfried Neun\\
  11152. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  11153. Takustra\"se 7 \\
  11154. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  11155. e--mail: Koepf@zib.de and Neun@zib.de
  11156. \end{center}
  11157. }
  11158. \ttindex{FPS}
  11159. This package can expand functions of certain type into
  11160. their corresponding Laurent-Puiseux series as a sum of terms of the form
  11161. \begin{displaymath}
  11162. \sum_{k=0}^{\infty} a_{k} (x-x_{0})^{k/n + s}
  11163. \end{displaymath}
  11164. where $s$ is the `shift number', $n$ is the `Puiseux number',
  11165. and $x_0$ is the `point of development'. The following types are
  11166. supported:
  11167. \begin{itemize}
  11168. \item
  11169. {\bf functions of `rational type'}, which are either rational or have a
  11170. rational derivative of some order;
  11171. \item
  11172. {\bf functions of `hypergeometric type'} where $a_{k+m}/a_k$ is a rational
  11173. function for some integer $m$, the `symmetry number';
  11174. \item
  11175. {\bf functions of `exp-like type'} which satisfy a linear homogeneous
  11176. differential equation with constant coefficients.
  11177. \end{itemize}
  11178. {\tt FPS(f,x,x0)}\ttindex{FPS} tries to find a formal power
  11179. series expansion for {\tt f} with respect to the variable {\tt x}
  11180. at the point of development {\tt x0}.
  11181. It also works for formal Laurent (negative exponents) and Puiseux series
  11182. (fractional exponents). If the third
  11183. argument is omitted, then {\tt x0:=0} is assumed.
  11184. Example: {\tt FPS(asin(x)\verb+^+2,x)} results in
  11185. {\small\begin{verbatim}
  11186. 2*k 2*k 2 2
  11187. x *2 *factorial(k) *x
  11188. infsum(----------------------------,k,0,infinity)
  11189. factorial(2*k + 1)*(k + 1)
  11190. \end{verbatim}}
  11191. If possible, the output is given using factorials. In some cases, the
  11192. use of the Pochhammer symbol {\tt pochhammer(a,k)}$:=a(a+1)\cdots(a+k-1)$
  11193. is necessary.
  11194. {\tt SimpleDE(f,x)} tries to find a homogeneous linear differential
  11195. equation with polynomial coefficients for $f$ with respect to $x$.
  11196. Make sure that $y$ is not a used variable.
  11197. The setting {\tt factor df;} is recommended to receive a nicer output form.
  11198. Examples: {\tt SimpleDE(asin(x)\verb+^+2,x)} then results in
  11199. {\small\begin{verbatim}
  11200. 2
  11201. df(y,x,3)*(x - 1) + 3*df(y,x,2)*x + df(y,x)
  11202. \end{verbatim}}
  11203. The depth for the search of a differential equation for {\tt f} is
  11204. controlled by the variable {\tt
  11205. fps\verb+_+search\verb+_+depth};\ttindex{fps\_search\_depth} higher
  11206. values for {\tt fps\verb+_+search\verb+_+depth} will increase the
  11207. chance to find the solution, but increases the complexity as well. The
  11208. default value for {\tt fps\verb+_+search\verb+_+depth} is 5. For {\tt
  11209. FPS(sin(x\verb+^+(1/3)),x)}, or {\tt SimpleDE(sin(x\verb+^+(1/3)),x)}
  11210. {\em e.g.}, a setting {\tt fps\verb+_+search\verb+_+depth:=6} is necessary.
  11211. The output of the FPS package can be influenced by the\ttindex{TRACEFPS}
  11212. switch {\tt tracefps}. Setting {\tt on tracefps} causes various
  11213. prints of intermediate results.
  11214. \chapter{GENTRAN: A code generation package}
  11215. \label{GENTRAN}
  11216. \typeout{{GENTRAN: A code generation package}}
  11217. {\footnotesize
  11218. \begin{center}
  11219. Barbara L. Gates \\
  11220. RAND \\
  11221. Santa Monica CA 90407-2138 \\
  11222. U.S.A. \\[0.1in]
  11223. Michael C. Dewar \\
  11224. School of Mathematical Sciences, The University of Bath \\
  11225. Bath BA2 7AY, England \\[0.05in]
  11226. e--mail: mcd@maths.bath.ac.uk
  11227. \end{center}
  11228. }
  11229. \ttindex{GENTRAN}
  11230. GENTRAN is an automatic code GENerator and TRANslator which runs under
  11231. \REDUCE. It constructs complete numerical programs based on sets of
  11232. algorithmic specifications and symbolic expressions. Formatted
  11233. FORTRAN, RATFOR, PASCAL or C code can be generated through a series of
  11234. interactive commands or under the control of a template processing
  11235. routine. Large expressions can be automatically segmented into
  11236. subexpressions of manageable size, and a special file-handling
  11237. mechanism maintains stacks of open I/O channels to allow output to be
  11238. sent to any number of files simultaneously and to facilitate recursive
  11239. invocation of the whole code generation process. GENTRAN provides the
  11240. flexibility necessary to handle most code generation applications. It
  11241. is designed to work with the SCOPE code optimiser.
  11242. GENTRAN is a large system with a great many options. This section
  11243. will only describe the FORTRAN generation facilities, and in broad
  11244. outline only. The full manual is available as part of the \REDUCE\
  11245. documentation.
  11246. \section{Simple Use}
  11247. A substantial subset of all expressions and statements in the \REDUCE{}
  11248. programming language can be translated directly into numerical code.
  11249. The {\bf GENTRAN} command takes a \REDUCE\ expression, statement, or
  11250. procedure definition, and translates it into code in the target
  11251. language.
  11252. \begin{describe}{Syntax:}
  11253. {\bf GENTRAN} {\it stmt} [ {\bf OUT} {\it f1,f2,\dots\ ,fn} ]{\it ;}
  11254. \end{describe}
  11255. {\it stmt} is any \REDUCE\ expression, statement (simple, compound, or
  11256. group), or procedure definition that can be translated by GENTRAN into the
  11257. target language.
  11258. {\it stmt} may contain any number of calls
  11259. to the special functions {\bf EVAL}, {\bf DECLARE}, and {\bf LITERAL}.
  11260. {\it f1,f2,\dots\ ,fn } is an optional argument list containing one or more
  11261. {\it f}'s, where each {\it f} is one of:
  11262. \par
  11263. \begin{tabular}{lll}
  11264. {\it an atom} &= &an output file\\
  11265. {\bf T} &= &the terminal\\
  11266. {\bf NIL} &= &the current output file(s)\\
  11267. \ttindex{ALL"!*} {\bf ALL!*} &= &all files currently open for output \\
  11268. & & by GENTRAN (see section~\ref{GENTRAN:output})\\
  11269. \end{tabular}
  11270. If the optional part of the command is not given, generated code is simply
  11271. written to the current output file. However, if it is
  11272. given, then the current output file is temporarily overridden. Generated
  11273. code is written to each file represented by
  11274. {\it f1,f2,\dots\ ,fn} for this command only. Files which were open prior
  11275. to the call to {\bf GENTRAN} will remain open after the call, and files
  11276. which did not exist prior to the call will be created, opened, written to,
  11277. and closed. The output stack will be exactly the same both before and
  11278. after the call.
  11279. {\bf GENTRAN} returns the name(s) of the file(s) to which code was
  11280. written.
  11281. \index{GENTRAN package ! example}
  11282. {\small\begin{verbatim}
  11283. 1: GENTRANLANG!* := 'FORTRAN$
  11284. 2: GENTRAN
  11285. 2: FOR I:=1:N DO
  11286. 2: V(I) := 0$
  11287. DO 25001 I=1,N
  11288. V(I)=0.0
  11289. 25001 CONTINUE
  11290. \end{verbatim}}
  11291. \section{Precision}
  11292. \label{precision}
  11293. \index{precision}\index{DOUBLE switch}
  11294. By default {\bf GENTRAN} generates constants and type declarations in
  11295. single precision form. If the user requires double precision output
  11296. then the switch {\bf DOUBLE} must be set {\bf ON}.
  11297. \index{PRECISION command}\index{PRINT"!-PRECISION command}
  11298. To ensure the correct number of floating point digits are
  11299. generated it may be necessary to use either the {\bf PRECISION} or
  11300. {\bf PRINT!-PRECISION} commands. The former alters the number of
  11301. digits \REDUCE\ calculates, the latter only the number of digits
  11302. \REDUCE\ prints. Each takes an integer argument. It is not possible to set
  11303. the printed precision higher than the actual precision. Calling {\bf
  11304. PRINT!-PRECISION} with a negative argument causes the printed
  11305. precision to revert to the actual precision.
  11306. \subsection{The EVAL Function}
  11307. \label{eval}
  11308. \begin{describe}{Syntax:}
  11309. {\bf EVAL} {\it exp}
  11310. \end{describe}\ttindex{EVAL}
  11311. \begin{describe}{Argument:}
  11312. {\it exp} is any \REDUCE\ expression or statement which, after evaluation
  11313. by \REDUCE, results in an expression that can be translated by
  11314. GENTRAN into the target language.
  11315. \end{describe}
  11316. When {\bf EVAL} is called on an expression which is to be translated, it
  11317. tells {\bf GENTRAN} to give the expression to \REDUCE\ for evaluation
  11318. first, and then to translate the result of that evaluation.
  11319. {\small\begin{verbatim}
  11320. f;
  11321. 2
  11322. 2*X - 5*X + 6
  11323. \end{verbatim}}
  11324. We wish to generate an assignment statement for the quotient
  11325. of F and its derivative.
  11326. {\small\begin{verbatim}
  11327. 1: GENTRAN
  11328. 1: Q := EVAL(F)/EVAL(DF(F,X))$
  11329. Q=(2.0*X**2-(5.0*X)+6.0)/(4.0*X-5.0)
  11330. \end{verbatim}}
  11331. \subsection{The :=: Operator}
  11332. \index{:=:}
  11333. \label{rsetq}\index{GENTRAN ! preevaluation}\index{rsetq operator}
  11334. In many applications, assignments must be generated in which the
  11335. left-hand side is some known variable name, but the
  11336. right-hand side is an expression that must be evaluated. For
  11337. this reason, a special operator is provided to indicate that the expression
  11338. on the right-hand side is to be evaluated prior to translation. This
  11339. special operator is {\bf :=:} ({\em i.e.} the usual \REDUCE\ assignment operator
  11340. with an extra ``:'' on the right).
  11341. \begin{describe}{\example}
  11342. {\small\begin{verbatim}
  11343. 1: GENTRAN
  11344. 1: DERIV :=: DF(X^4-X^3+2*x^2+1,X)$
  11345. DERIV=4.0*X**3-(3.0*X**2)+4.0*X
  11346. \end{verbatim}}
  11347. \end{describe}
  11348. \subsection{The ::= Operator}
  11349. \label{lsetq}
  11350. \index{matrices ! in GENTRAN}
  11351. When assignments to matrix or array elements must be generated, many
  11352. times the indices of the element must be evaluated first. The special
  11353. operator\index{::=}\index{lsetq operator}
  11354. {\bf ::=} can be used within a call to {\bf GENTRAN}
  11355. to indicate that the indices of the matrix or
  11356. array element on the left-hand side of the assignment are to
  11357. be evaluated prior to translation. (This is the usual \REDUCE{}
  11358. assignment operator with an extra ``:'' on the left.)
  11359. \begin{describe}{\example}
  11360. We wish to generate assignments which assign zeros to all elements
  11361. on the main diagonal of M, an n x n matrix.
  11362. {\small\begin{verbatim}
  11363. 10: FOR j := 1 : 8 DO
  11364. 10: GENTRAN
  11365. 10: M(j,j) ::= 0$
  11366. M(1,1)=0.0
  11367. M(2,2)=0.0
  11368. :
  11369. :
  11370. M(8,8)=0.0
  11371. \end{verbatim}}
  11372. \end{describe}
  11373. {\bf LSETQ} may be used interchangeably with {\bf ::=} on input.\ttindex{LSETQ}
  11374. \subsection{The ::=: Operator}
  11375. \label{lrsetq}
  11376. \index{::=:} \index{lrsetq operator}
  11377. In applications in which evaluated expressions are to be assigned to
  11378. array elements with evaluated subscripts, the {\bf ::=:} operator can be
  11379. used. It is a combination of the {\bf ::=} and {\bf :=:} operators described
  11380. in sections~\ref{rsetq} and ~\ref{lsetq}.
  11381. \index{matrices ! in GENTRAN}
  11382. \begin{describe}{\example}
  11383. The following matrix, M, has been derived symbolically:
  11384. \newpage
  11385. {\small\begin{verbatim}
  11386. ( A 0 -1 1)
  11387. ( )
  11388. ( 0 B 0 0)
  11389. ( )
  11390. ( -1 0 C -1)
  11391. ( )
  11392. ( 1 0 -1 D)
  11393. \end{verbatim}}
  11394. We wish to generate assignment statements for those elements
  11395. on the main diagonal of the matrix.
  11396. {\small\begin{verbatim}
  11397. 10: FOR j := 1 : 4 DO
  11398. 10: GENTRAN
  11399. 10: M(j,j) ::=: M(j,j)$
  11400. M(1,1)=A
  11401. M(2,2)=B
  11402. M(3,3)=C
  11403. M(4,4)=D
  11404. \end{verbatim}}
  11405. \end{describe}
  11406. The alternative alphanumeric identifier associated with {\bf ::=:} is
  11407. {\bf LRSETQ}.\ttindex{LRSETQ}
  11408. \section{Explicit Type Declarations}
  11409. \label{explicit:type}
  11410. Type declarations are automatically generated each time a subprogram
  11411. heading is generated. Type declarations are constructed
  11412. from information stored in the GENTRAN symbol table. The user
  11413. can place entries into the symbol table explicitly through calls
  11414. to the special GENTRAN function {\bf DECLARE}.\index{DECLARE function}
  11415. \begin{describe}{Syntax:}
  11416. {\bf \ \ DECLARE} {\it v1,v2,\dots\ ,vn} {\bf :} {\it type;}
  11417. or
  11418. \begin{tabular}{ll}
  11419. {\bf DECLARE}\\
  11420. {\bf $<$$<$}\\
  11421. &{\it v11,v12,\dots\ ,v1n} {\bf :} {\it type1;}\\
  11422. &{\it v21,v22,\dots\ ,v2n} {\bf :} {\it type2;}\\
  11423. & :\\
  11424. & :\\
  11425. &{\it vn1,vnn,\dots\ ,vnn} {\bf :} {\it typen;}\\
  11426. {\bf $>$$>$}{\it ;}
  11427. \end{tabular}
  11428. \end{describe}
  11429. \begin{describe}{Arguments:}
  11430. Each {\it v1,v2,\dots\ ,vn} is a list of one or more variables
  11431. (optionally subscripted to indicate array dimensions), or
  11432. variable ranges (two letters separated by a ``-''). {\it v}'s are
  11433. not evaluated unless given as arguments to {\bf EVAL}.
  11434. Each {\it type} is a variable type in the target language. Each
  11435. must be an atom, optionally preceded by the atom {\bf IMPLICIT}.
  11436. \index{IMPLICIT option}
  11437. {\it type}'s are not evaluated unless given as arguments to {\bf EVAL}.
  11438. \end{describe}
  11439. The {\bf DECLARE} statement can also be used to declare subprogram
  11440. types ({\em i.e.\ } {\bf SUBROUTINE} or {\bf FUNCTION}) for
  11441. \index{SUBROUTINE}\index{FUNCTION} FORTRAN and RATFOR code, and
  11442. function types for all four languages.
  11443. \section{Expression Segmentation}
  11444. \label{segmentation}\index{segmenting expressions}
  11445. Symbolic derivations can easily produce formulas that can be anywhere
  11446. from a few lines to several pages in length. Such formulas
  11447. can be translated into numerical assignment statements, but unless they
  11448. are broken into smaller pieces they may be too long for a compiler
  11449. to handle. (The maximum number of continuation lines for one statement
  11450. allowed by most FORTRAN compilers is only 19.) Therefore GENTRAN
  11451. \index{continuation lines}
  11452. contains a segmentation facility which automatically {\it segments},
  11453. or breaks down unreasonably large expressions.
  11454. The segmentation facility generates a sequence of assignment
  11455. statements, each of which assigns a subexpression to an automatically
  11456. generated temporary variable. This sequence is generated in such a
  11457. way that temporary variables are re-used as soon as possible, thereby
  11458. keeping the number of automatically generated variables to a minimum.
  11459. The facility can be turned on or off by setting the mode
  11460. \index{GENTRANSEG switch} switch {\bf GENTRANSEG} accordingly ({\em
  11461. i.e.\ }by calling the \REDUCE\ function {\bf ON} or {\bf OFF} on it). The user
  11462. can control the maximum allowable expression size by setting the
  11463. \ttindex{MAXEXPPRINTLEN"!*}
  11464. variable {\bf MAXEXPPRINTLEN!*} to the maximum number of characters
  11465. allowed in an expression printed in the target language (excluding
  11466. spaces automatically printed by the formatter). The {\bf GENTRANSEG}
  11467. switch is on initially, and {\bf MAXEXPPRINTLEN!*} is initialised to
  11468. 800.
  11469. \section{Template Processing}\label{GENTRAN:template}
  11470. \index{GENTRAN ! templates}\index{templates}\index{code templates}
  11471. In some code generation applications pieces of the target numerical
  11472. program are known in advance. A {\it template} file containing a
  11473. program outline is supplied by the user, and formulas are derived in
  11474. \REDUCE, converted to numerical code, and inserted in the corresponding
  11475. places in the program outline to form a complete numerical program. A
  11476. template processor is provided by GENTRAN for use in these
  11477. applications.
  11478. \label{templates}\index{GENTRANIN command}
  11479. \begin{describe}{Syntax:}
  11480. {\bf GENTRANIN} {\it f1,f2,\dots\ ,fm} [{\bf OUT} {\it f1,f2,\dots\
  11481. ,fn\/}]{\it ;}
  11482. \end{describe}
  11483. \begin{describe}{Arguments:}
  11484. {\it f1,f2,\dots\ ,fm\/} is an argument list containing one or more
  11485. {\it f\/}'s,
  11486. where each {\it f\/} is one of:
  11487. \begin{center}
  11488. \begin{tabular}{lll}
  11489. {\it an atom}& = &a template (input) file\\
  11490. {\bf T}& = &the terminal\\
  11491. \end{tabular}
  11492. \end{center}
  11493. {\it f1,f2,\dots\ ,fn\/} is an optional argument list containing one or more
  11494. {\it f\/}'s, where each {\it f\/} is one of:
  11495. \begin{center}
  11496. \begin{tabular}{lll}
  11497. {\it an atom}& = &an output file\\
  11498. {\bf T}& = &the terminal\\
  11499. {\bf NIL}& = &the current output file(s)\\
  11500. {\bf ALL!*}& = &all files currently open for output \\
  11501. & & by GENTRAN (see section~\ref{GENTRAN:output}) \\
  11502. \end{tabular}
  11503. \end{center}
  11504. \end{describe}
  11505. {\bf GENTRANIN} processes each template file {\it f1,f2,\dots\ ,fm}
  11506. sequentially.
  11507. A template file may contain any number of parts, each of which
  11508. is either an active or an inactive part. All active parts start with
  11509. the character sequence {\bf ;BEGIN;} and end with {\bf ;END;}. The end
  11510. of the template file is indicated by an extra {\bf ;END;} character
  11511. sequence.\index{;BEGIN; marker} \index{;END; marker}
  11512. Inactive parts of template files are assumed to contain code in the
  11513. target language. All inactive parts are
  11514. copied to the output.
  11515. Active parts may contain any number of \REDUCE\ expressions, statements,
  11516. and commands. They are not copied directly to the output. Instead,
  11517. they are given to \REDUCE\ for evaluation in algebraic mode. All output
  11518. generated by each evaluation is sent to the output file(s). Returned
  11519. values are only printed on the terminal.\index{GENTRAN ! preevaluation}
  11520. Active parts will most likely contain calls to {\bf GENTRAN} to
  11521. generate code. This means that the result of processing a
  11522. template file will be the original template file with all active
  11523. parts replaced by generated code.
  11524. If {\bf OUT} {\it f1,f2,\dots\ ,fn} is not given, generated code is simply
  11525. written to the current-output file.
  11526. However, if {\bf OUT} {\it f1,f2,\dots\ ,fn}
  11527. is given, then the current-output file
  11528. is temporarily overridden. Generated code is written to each file
  11529. represented by {\it f1,f2,\dots\ ,fn} for this command only. Files
  11530. which were open prior to the call to {\bf GENTRANIN} will remain open
  11531. after the call, and files which did not exist prior to the call will
  11532. be created, opened, written to, and closed. The output-stack will be
  11533. exactly the same both before and after the call.
  11534. {\bf GENTRANIN} returns the names of all files written to by this
  11535. command.
  11536. \newpage
  11537. \begin{describe}{\example}
  11538. Suppose we wish to generate a FORTRAN subprogram to compute the
  11539. determinant of a 3 x 3 matrix. We can construct a template
  11540. file with an outline of the FORTRAN subprogram and \REDUCE\ and
  11541. GENTRAN commands to fill it in:
  11542. \index{matrices ! in GENTRAN}
  11543. Contents of file {\tt det.tem}:
  11544. \end{describe}
  11545. {\small\begin{verbatim}
  11546. REAL FUNCTION DET(M)
  11547. REAL M(3,3)
  11548. ;BEGIN;
  11549. OPERATOR M$
  11550. MATRIX MM(3,3)$
  11551. MM := MAT( (M(1,1),M(1,2),M(1,3)),
  11552. (M(2,1),M(2,2),M(2,3)),
  11553. (M(3,1),M(3,2),M(3,3)) )$
  11554. GENTRAN DET :=: DET(MM)$
  11555. ;END;
  11556. RETURN
  11557. END
  11558. ;END;
  11559. \end{verbatim}}
  11560. \begin{describe}{}
  11561. Now we can generate a FORTRAN subprogram with the following
  11562. \REDUCE\ session:
  11563. {\small\begin{verbatim}
  11564. 1: GENTRANLANG!* := 'FORTRAN$
  11565. 2: GENTRANIN
  11566. 2: "det.tem"
  11567. 2: OUT "det.f"$
  11568. \end{verbatim}}
  11569. Contents of file det.f:
  11570. \end{describe}
  11571. {\small\begin{verbatim}
  11572. REAL FUNCTION DET(M)
  11573. REAL M(3,3)
  11574. DET=M(3,3)*M(2,2)*M(1,1)-(M(3,3)*M(2,1)*M(1,2))-(M(3,2)
  11575. . *M(2,3)*M(1,1))+M(3,2)*M(2,1)*M(1,3)+M(3,1)*M(2,3)*M(1
  11576. . ,2)-(M(3,1)*M(2,2)*M(1,3))
  11577. RETURN
  11578. END
  11579. \end{verbatim}}
  11580. \section{Output Redirection}\label{GENTRAN:output}
  11581. \index{GENTRAN ! file output}
  11582. \index{GENTRANOUT command}\index{GENTRANSHUT command}
  11583. The {\bf GENTRANOUT} and {\bf GENTRANSHUT} commands are identical to
  11584. the \REDUCE\ {\bf OUT} and {\bf SHUT} commands with the following
  11585. exceptions:
  11586. \begin{itemize}
  11587. \item {\bf GENTRANOUT} and {\bf GENTRANSHUT} redirect {\it only\/}
  11588. code which is printed as a side effect of GENTRAN commands.
  11589. \item {\bf GENTRANOUT} allows more than one file name to be given
  11590. to indicate that generated code is to be sent to two or more
  11591. files. (It is particularly convenient to be able to
  11592. have generated code sent to
  11593. the terminal screen and one or more file simultaneously.)
  11594. \item {\bf GENTRANOUT} does not automatically erase existing files; it
  11595. prints a warning message on the terminal and asks the user whether the
  11596. existing file should be erased or the whole command be aborted.
  11597. \end{itemize}
  11598. \chapter[GEOMETRY: Plane geometry]%
  11599. {GEOMETRY: Mechanized (Plane) Geometry Manipulations}
  11600. \label{GEOMETRY}
  11601. \typeout{{GEOMETRY: Mechanized (Plane) Geometry Manipulations}}
  11602. \newcommand{\xxyy}[2] {\noindent{\f{#1}} \\\hspace*{1cm}
  11603. \parbox[t]{9cm}{#2} \\[6pt]}
  11604. \newcommand{\geo}{{\sc Geometry}}
  11605. \newenvironment{code}{\tt \begin{tabbing}
  11606. \hspace*{1cm}\=\hspace*{1cm}\=\hspace*{1cm}\=
  11607. \hspace*{1cm}\=\hspace*{1cm}\=\kill}{\end{tabbing}}
  11608. {\footnotesize
  11609. \begin{center}
  11610. Hans-Gert Gr\"abe \\
  11611. Universit\"at Leipzig, Germany \\
  11612. e-mail: graebe@informatik.uni-leipzig.de \\
  11613. \end{center}
  11614. }
  11615. \ttindex{GEOMETRY}
  11616. %\markboth{CHAPTER \ref{GEOMETRY}. GEOMETRY: (PLANE) GEOMETRY MANIPULATIONS}{}
  11617. %\thispagestyle{myheadings}
  11618. \section{Introduction}
  11619. This package provides tools for formulation and mechanized proofs of
  11620. geometry statements in the spirit of the ``Chinese Prover'' of
  11621. W.-T. Wu \cite{Wu:94} and the fundamental book \cite{Chou:88} of
  11622. S.-C. Chou who proved 512 geometry theorems with this mechanized
  11623. method, see also \cite{Chou:84}, \cite{Chou:90}, \cite{Wu:84a},
  11624. \cite{Wu:84b}.
  11625. The general idea behind this approach is an algebraic reformulation of
  11626. geometric conditions using generic coordinates. A (mathematically
  11627. strong) proof of the geometry statement then may be obtained from
  11628. appropriate manipulations of these algebraic expressions. A CAS as,
  11629. e.g., Reduce is well suited to mechanize these manipulations.
  11630. For a more detailed introduction to the topic see the accompanying
  11631. file {\tt geometry.tex} in \$REDUCEPATH/packages/geometry/.
  11632. \section{Basic Data Types and Constructors}
  11633. The basic data types in this package are {\tt Scalar, Point, Line, Circle1
  11634. and Circle}. \\
  11635. The function \f{POINT($a,b$)} creates a {\tt Point} in the plane with
  11636. the $(x,y)$-coordinates $(a,b)$.
  11637. A {\tt Line} is created with the function \f{LINE($a,b,c$)} and
  11638. fulfills the equation $ ax + by + c = 0$.
  11639. For circles there are two constructors. You can use
  11640. \f{CIRCLE($c_1,c_2,c_3,c_4$)} to create a {\tt Circle} where
  11641. the scalar variables solve the equation $c_1(x^2+y^2) + c_2x + c_3y + c_4 = 0$.
  11642. Note that lines are a subset of the circles with $c_1=0$. The other way
  11643. to create a {\tt Circle} is the function \f{CIRCLE1($M,s$)}.
  11644. The variable $M$ here denotes a {\tt Point} and $s$ the squared
  11645. radius. Please note that this package mostly uses the squared distances and
  11646. radiuses.
  11647. There are various functions whose return type is {\tt Scalar}.
  11648. Booleans are represented as extended booleans, i.e.\ the
  11649. procedure returns a {\tt Scalar} that is zero iff the condition is fulfilled.
  11650. For example, the function call \f{POINT\_ON\_CIRCLE(P,c)} returns zero if
  11651. the {\tt Point} $P$ is on the circle, otherwise $P$ is not on the circle.
  11652. In some cases also a non zero result has a geometric meaning. For example,
  11653. \f{COLLINEAR(A,B,C)} returns the signed area of the corresponding
  11654. parallelogram.
  11655. \section{Procedures}
  11656. This section contains a short description of all procedures available
  11657. in \geo. Per convention distances and radiuses of circles are squared.
  11658. \bigskip
  11659. \xxyy{ANGLE\_SUM(a,b:Scalar):Scalar \ttindex{ANGLE\_SUM}}
  11660. {Returns $\tan(\alpha+\beta)$, if $a=\tan(\alpha), b=\tan(\beta)$.}
  11661. \xxyy{ALTITUDE(A,B,C:Point):Line \ttindex{ALTITUDE}}
  11662. {The altitude from $A$ onto $g(BC)$. }
  11663. \xxyy{C1\_CIRCLE(M:Point,sqr:Scalar):Circle \ttindex{C1\_CIRCLE}}
  11664. {The circle with given center and sqradius.}
  11665. \xxyy{CC\_TANGENT(c1,c2:Circle):Scalar \ttindex{CC\_TANGENT}}
  11666. {Zero iff $c_1$ and $c_2$ are tangent.}
  11667. \xxyy{CHOOSE\_PC(M:Point,r,u):Point \ttindex{CHOOSE\_PC}}
  11668. {Chooses a point on the circle around $M$ with radius $r$ using its rational
  11669. parametrization with parameter $u$.}
  11670. \xxyy{CHOOSE\_PL(a:Line,u):Point \ttindex{CHOOSE\_PL}}
  11671. {Chooses a point on $a$ using parameter $u$.}
  11672. \xxyy{CIRCLE(c1,c2,c3,c4:Scalar):Circle \ttindex{CIRCLE}}
  11673. {The {\tt Circle} constructor.}
  11674. \xxyy{CIRCLE1(M:Point,sqr:Scalar):Circle1 \ttindex{CIRCLE1}}
  11675. {The {\tt Circle1} constructor. }
  11676. \xxyy{CIRCLE\_CENTER(c:Circle):Point \ttindex{CIRCLE\_CENTER}}
  11677. {The center of $c$.}
  11678. \xxyy{CIRCLE\_SQRADIUS(c:Circle):Scalar \ttindex{CIRCLE\_SQRADIUS}}
  11679. {The sqradius of $c$.}
  11680. \xxyy{CL\_TANGENT(c:Circle,l:Line):Scalar \ttindex{CL\_TANGENT}}
  11681. {Zero iff $l$ is tangent to $c$.}
  11682. \xxyy{COLLINEAR(A,B,C:Point):Scalar \ttindex{COLLINEAR}}
  11683. {Zero iff $A,B,C$ are on a common line. In general the signed area of the
  11684. parallelogram spanned by $\vec{AB}$ and $\vec{AC}$. }
  11685. \xxyy{CONCURRENT(a,b,c:Line):Scalar \ttindex{CONCURRENT}}
  11686. {Zero iff $a,b,c$ have a common point.}
  11687. \xxyy{INTERSECTION\_POINT(a,b:Line):Point \ttindex{INTERSECTION\_POINT}}
  11688. {The intersection point of the lines $a,b$. }
  11689. \xxyy{L2\_ANGLE(a,b:Line):Scalar \ttindex{L2\_ANGLE}}
  11690. {Tangens of the angle between $a$ and $b$. }
  11691. \xxyy{LINE(a,b,c:Scalar):Line \ttindex{LINE}}
  11692. {The {\tt Line} constructor.}
  11693. \xxyy{LOT(P:Point,a:Line):Line \ttindex{LOT}}
  11694. {The perpendicular from $P$ onto $a$.}
  11695. \xxyy{MEDIAN(A,B,C:Point):Line \ttindex{MEDIAN}}
  11696. {The median line from $A$ to $BC$.}
  11697. \xxyy{MIDPOINT(A,B:Point):Point \ttindex{MIDPOINT}}
  11698. {The midpoint of $AB$. }
  11699. \xxyy{MP(B,C:Point):Line \ttindex{MP}}
  11700. {The midpoint perpendicular of $BC$.}
  11701. \xxyy{ORTHOGONAL(a,b:Line):Scalar \ttindex{ORTHOGONAL}}
  11702. {zero iff the lines $a,b$ are orthogonal. }
  11703. \xxyy{OTHER\_CC\_POINT(P:Point,c1,c2:Circle):Point \ttindex{OTHER\_CC\_POINT}}
  11704. { $c_1$ and $c_2$ intersect at $P$. The procedure returns the second
  11705. intersection point. }
  11706. \xxyy{OTHER\_CL\_POINT(P:Point,c:Circle,l:Line):Point \ttindex{OTHER\_CL\_POINT}}
  11707. {$c$ and $l$ intersect at $P$. The procedure returns the second intersection
  11708. point.}
  11709. \xxyy{P3\_ANGLE(A,B,C:Point):Scalar \ttindex{P3\_ANGLE}}
  11710. {Tangens of the angle between $\vec{BA}$ and $\vec{BC}$. }
  11711. \xxyy{P3\_CIRCLE(A,B,C:Point):Circle\ \ttindex{P3\_CIRCLE} {\rm or\ }\\
  11712. P3\_CIRCLE1(A,B,C:Point):Circle1\ttindex{P3\_CIRCLE1} }
  11713. {The circle through 3 given points. }
  11714. \xxyy{P4\_CIRCLE(A,B,C,D:Point):Scalar \ttindex{P4\_CIRCLE}}
  11715. {Zero iff four given points are on a common circle. }
  11716. \xxyy{PAR(P:Point,a:Line):Line \ttindex{PAR}}
  11717. {The line through $P$ parallel to $a$. }
  11718. \xxyy{PARALLEL(a,b:Line):Scalar \ttindex{PARALLEL}}
  11719. {Zero iff the lines $a,b$ are parallel. }
  11720. \xxyy{PEDALPOINT(P:Point,a:Line):Point \ttindex{PEDALPOINT}}
  11721. {The pedal point of the perpendicular from $P$ onto $a$.}
  11722. \xxyy{POINT(a,b:Scalar):Point \ttindex{POINT}}
  11723. {The {\tt Point} constructor.}
  11724. \xxyy{POINT\_ON\_BISECTOR(P,A,B,C:Point):Scalar \ttindex{POINT\_ON\_BISECTOR}}
  11725. {Zero iff $P$ is a point on the (inner or outer) bisector of the
  11726. angle $\angle\,ABC$.}
  11727. \xxyy{POINT\_ON\_CIRCLE(P:Point,c:Circle):Scalar\ \ttindex{POINT\_ON\_CIRCLE}
  11728. {\rm or\ }\\
  11729. POINT\_ON\_CIRCLE1(P:Point,c:Circle1):Scalar \ttindex{POINT\_ON\_CIRCLE1}}
  11730. {Zero iff $P$ is on the circle $c$.}
  11731. \xxyy{POINT\_ON\_LINE(P:Point,a:Line):Scalar \ttindex{POINT\_ON\_LINE}}
  11732. {Zero iff $P$ is on the line $a$. }
  11733. \xxyy{PP\_LINE(A,B:Point):Line \ttindex{PP\_LINE}}
  11734. {The line through $A$ and $B$.}
  11735. \xxyy{SQRDIST(A,B:Point):Scalar \ttindex{SQRDIST}}
  11736. {Square of the distance between $A$ and $B$.}
  11737. \xxyy{SYMPOINT(P:Point,l:Line):Point \ttindex{SYMPOINT}}
  11738. {The point symmetric to $P$ wrt.\ the line $l$.}
  11739. \xxyy{SYMLINE(a:Line,l:Line):Line \ttindex{SYMLINE}}
  11740. {The line symmetric to $a$ wrt.\ the line $l$.}
  11741. \xxyy{VARPOINT(A,B:Point,u):Point \ttindex{VARPOINT}}
  11742. {The point $D=u\cdot A+(1-u)\cdot B$. }
  11743. \noindent \geo \ supplies as additional tools the functions
  11744. \bigskip
  11745. \xxyy{EXTRACTMAT(polys,vars) \ttindex{EXTRACTMAT}}
  11746. {Returns the coefficient matrix of the list of equations $polys$ that are
  11747. linear in the variables $vars$. }
  11748. \xxyy{RED\_HOM\_COORDS(u:\{Line,Circle\}) \ttindex{RED\_HOM\_COORDS}}
  11749. {Returns the reduced homogeneous coordinates of $u$, i.e., divides out the
  11750. content. }
  11751. \newpage
  11752. \section{Examples}
  11753. \example
  11754. Create three points as the vertices of a generic triangle. \\
  11755. {\tt A:=Point(a1,a2); B:=Point(b1,b2); C:=Point(c1,c2);} \\
  11756. \noindent The midpoint perpendiculars of $\Delta\,ABC$ pass through
  11757. a common point since
  11758. \begin{code}\+\>
  11759. concurrent(mp(A,B),mp(B,C),mp(C,A));
  11760. \end{code}
  11761. simplifies to zero.
  11762. \medskip
  11763. \example
  11764. \noindent The intersection point of the midpoint perpendiculars
  11765. \begin{code}\+\>
  11766. M:=intersection\_point(mp(A,B),mp(B,C));
  11767. \end{code}
  11768. is the center of the circumscribed circle since
  11769. \begin{code}\+\>
  11770. sqrdist(M,A) - sqrdist(M,B);
  11771. \end{code}
  11772. simplifies to zero.
  11773. \medskip
  11774. \example
  11775. \noindent {\em Euler's line}:
  11776. \begin{quote}
  11777. The center $M$ of the circumscribed circle, the orthocenter $H$ and
  11778. the barycenter $S$ are collinear and $S$ divides $MH$ with ratio 1:2.
  11779. \end{quote}
  11780. Compute the coordinates of the corresponding points
  11781. \begin{code}\+\>
  11782. M:=intersection\_point(mp(a,b,c),mp(b,c,a));\\
  11783. H:=intersection\_point(altitude(a,b,c),altitude(b,c,a));\\
  11784. S:=intersection\_point(median(a,b,c),median(b,c,a));
  11785. \end{code}
  11786. and then prove that
  11787. \begin{code}\+\>
  11788. collinear(M,H,S);\\
  11789. sqrdist(S,varpoint(M,H,2/3));
  11790. \end{code}
  11791. both simplify to zero.
  11792. \medskip
  11793. \chapter[GNUPLOT: Plotting Functions]%
  11794. {GNUPLOT: Display of functions and surfaces}
  11795. \label{GNUPLOT}
  11796. \typeout{{GNUPLOT: Display of functions and surfaces}}
  11797. {\footnotesize
  11798. \begin{center}
  11799. Herbert Melenk \\
  11800. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  11801. Takustra\"se 7 \\
  11802. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  11803. e--mail: melenk@zib.de
  11804. \end{center}
  11805. }
  11806. \ttindex{GNUPLOT}
  11807. The {\bf gnuplot} system provides easy to use graphics output for
  11808. curves or surfaces which are defined by formulas and/or data sets.
  11809. The \REDUCE\ GNUPLOT package lets one use the GNUPLOT graphical output
  11810. directly from inside \REDUCE, either for the interactive display of
  11811. curves/surfaces or for the production of pictures on paper.
  11812. For a full understanding of use of the \REDUCE\ GNUPLOT package it is
  11813. best to be familiar with {\bf gnuplot}.
  11814. The main command is {\tt PLOT}\ttindex{PLOT}. It accepts an arbitrary
  11815. list of arguments which are either an expression to be plotted, a
  11816. range expressions or an option.
  11817. {\small\begin{verbatim}
  11818. load_package gnuplot;
  11819. plot(w=sin(a),a=(0 .. 10),xlabel="angle",ylabel="sine");
  11820. \end{verbatim}}
  11821. The expression can be in one or two unknowns, or a list of two
  11822. functions for the x and y values. It can also be an implicit equation
  11823. in 2-dimensional space.
  11824. {\small\begin{verbatim}
  11825. plot(x**3+x*y**3-9x=0);
  11826. \end{verbatim}}
  11827. The dependent and independent variables can be limited to a range with
  11828. the syntax shown in the first example. If omitted the independent
  11829. variables range from -10 to 10 and the dependent variable is limited
  11830. only by the precision of the IEEE floating point arithmetic.
  11831. There are a great deal of options, either as keywords or as
  11832. {\tt variable=string}. Options include:
  11833. {\tt title}\ttindex{title}: assign a heading (default: empty)
  11834. {\tt xlabel}\ttindex{xlabel}: set label for the x axis
  11835. {\tt ylabel}\ttindex{ylabel}: set label for the y axis
  11836. {\tt zlabel}\ttindex{zlabel}: set label for the z axis
  11837. {\tt terminal}\ttindex{terminal}: select an output device
  11838. {\tt size}\ttindex{size}: rescale the picture
  11839. {\tt view}\ttindex{view}: set a viewpoint
  11840. {\tt (no)}{\tt contour}\ttindex{contour}: 3d: add contour lines
  11841. {\tt (no)}{\tt surface}\ttindex{surface}: 3d: draw surface (default: yes)
  11842. {\tt (no)}{\tt hidden3d}\ttindex{hidden3d}: 3d: remove hidden lines (default: no)
  11843. The command {\tt PLOTRESET}\ttindex{PLOTRESET} closes the current
  11844. GNUPLOT windows. The next call to {\tt PLOT} will create a new
  11845. one.
  11846. GNUPLOT is controlled by a number of switches.
  11847. Normally all intermediate data sets are deleted after terminating
  11848. a plot session. If the switch {\tt PLOTKEEP}\ttindex{PLOTKEEP} is set on,
  11849. the data sets are kept for eventual post processing independent
  11850. of \REDUCE.
  11851. In general {\tt PLOT} tries to generate smooth pictures by evaluating
  11852. the functions at interior points until the distances are fine enough.
  11853. This can require a lot of computing time if the single function
  11854. evaluation is expensive. The refinement is controlled by the switch
  11855. {\tt PLOTREFINE}\ttindex{PLOTREFINE} which is on by default. When you
  11856. turn it off the functions will be evaluated only at the basic points.
  11857. The integer value of the global variable {\tt
  11858. PLOT\_XMESH}\ttindex{PLOT\_XMESH} defines the number of initial
  11859. function evaluations in x direction for \f{PLOT}. For 2d graphs
  11860. additional points will be used as long as {\tt
  11861. plotrefine}\ttindex{plotrefine} is on. For 3d graphs this number
  11862. defines also the number of mesh lines orthogonal to the x axis. {\tt
  11863. PLOT\_YMESH}\ttindex{PLOT\_YMESH} defines for 3d plots the number of
  11864. function evaluations in the y direction and the number of mesh lines
  11865. orthogonal to the y axis.
  11866. The grid for localising an implicitly defined curve in \f{PLOT}
  11867. consists of triangles. These are computed initially equally
  11868. distributed over the x-y plane controlled by {\tt PLOT\_XMESH}. The
  11869. grid is refined adaptively in several levels. The final grid can be
  11870. visualised by setting on the switch {\tt
  11871. SHOW\_GRID}\ttindex{SHOW\_GRID}.
  11872. \chapter{GROEBNER: A Gr\"obner basis package}
  11873. \label{GROEBNER}
  11874. \typeout{{GROEBNER: A Gr\"obner basis package}}
  11875. {\footnotesize
  11876. \begin{center}
  11877. Herbert Melenk \& Winfried Neun \\
  11878. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  11879. Takustra\"se 7 \\
  11880. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  11881. e--mail: melenk@zib.de \\[0.05in]
  11882. and \\[0.05in]
  11883. H.M. M\"oller \\
  11884. Fernuniversit\"at Hagen FB Math und Informatik\\
  11885. Postfach 940 \\
  11886. D--58084 Hagen, Germany\\[0.05in]
  11887. e--mail: Michael.Moeller@fernuni-hagen.de
  11888. \end{center}
  11889. }
  11890. \ttindex{GROEBNER}
  11891. Gr\"obner bases are a valuable tool for solving problems in
  11892. connection with multivariate polynomials, such as solving systems of
  11893. algebraic equations and analysing polynomial ideals.
  11894. \index{GROEBNER package}\index{Buchberger's Algorithm}
  11895. The GROEBNER package calculates Gr\"obner bases using the
  11896. Buchberger algorithm. It can be used over a variety of different
  11897. coefficient domains, and for different variable and term orderings.
  11898. \section{}
  11899. \subsection{Term Ordering} \par
  11900. In the theory of Gr\"obner bases, the terms of polynomials are
  11901. considered as ordered. Several order modes are available in
  11902. the current package, including the basic modes:
  11903. \index{LEX ! term order}\index{GRADLEX ! term order}
  11904. \index{REVGRADLEX ! term order}
  11905. \begin{center}
  11906. LEX, GRADLEX, REVGRADLEX
  11907. \end{center}
  11908. All orderings are based on an ordering among the variables. For each
  11909. pair of variables $(a,b)$ an order relation must be defined, {\em
  11910. e.g.\ } ``$ a\gg b $''. The greater sign $\gg$ does not represent a
  11911. numerical relation among the variables; it can be interpreted only in
  11912. terms of formula representation: ``$a$'' will be placed in front of
  11913. ``$b$'' or ``$a$'' is more complicated than ``$b$''.
  11914. The sequence of variables constitutes this order base. So the notion
  11915. of
  11916. \[
  11917. \{x1,x2,x3\}
  11918. \]
  11919. as a list of variables at the same time means
  11920. \[
  11921. x1 \gg x2 \gg x3
  11922. \]
  11923. with respect to the term order.
  11924. If terms (products of powers of variables) are compared with LEX,
  11925. that term is chosen which has a greater variable or a higher degree
  11926. if the greatest variable is the first in both. With GRADLEX the sum of
  11927. all exponents (the total degree) is compared first, and if that does
  11928. not lead to a decision, the LEX method is taken for the final decision.
  11929. The REVGRADLEX method also compares the total degree first, but
  11930. afterward it uses the LEX method in the reverse direction; this is the
  11931. method originally used by Buchberger.
  11932. Note that the LEX ordering is identical to the standard \REDUCE{}
  11933. kernel ordering, when KORDER is set explicitly to the sequence of
  11934. variables.
  11935. \index{default ! term order}
  11936. LEX is the default term order mode in the GROEBNER package.
  11937. \section{The Basic Operators}
  11938. \subsection{Term Ordering Mode}
  11939. \begin{description}
  11940. \ttindex{TORDER}
  11941. \item [{\it TORDER}]($vl$,$m$,$[p_1,p_2,\ldots]$);
  11942. where $vl$ is a variable list (or the empty list if
  11943. no variables are declared explicitly),
  11944. $m$ is the name of a term ordering mode LEX, GRADLEX,
  11945. REV\-GRAD\-LEX (or another implemented mode) and
  11946. $[p_1,p_2,\ldots]$ are additional parameters for the
  11947. term ordering mode (not needed for the basic modes).
  11948. TORDER sets variable set and the term ordering mode.
  11949. The default mode is LEX. The previous description is returned
  11950. as a list with corresponding elements. Such a list can
  11951. alternatively passed as sole argument to TORDER.
  11952. If the variable list is empty or if the TORDER declaration
  11953. is omitted, the automatic variable extraction is activated.
  11954. \ttindex{GVARS}
  11955. \item[{\it GVARS}] ({\it\{exp$1$, exp$2$, $ \ldots$, exp$n$\}});
  11956. where $\{exp1, exp2, \ldots , expn\}$ is a list of expressions or
  11957. equations.
  11958. GVARS extracts from the expressions $\{exp1, exp2, \ldots , expn\}$
  11959. the kernels, which can play the role of variables for a Gr\"obner
  11960. calculation. This can be used {\em e.g.\ } in a TORDER declaration.
  11961. \end{description}
  11962. \subsection{GROEBNER: Calculation of a Gr\"obner Basis}
  11963. \begin{description}
  11964. \ttindex{GROEBNER}
  11965. \item[{\it GROEBNER}] $\{exp1, exp2, \ldots , expm\}; $
  11966. where $\{exp1, exp2, \ldots , expm\}$ is a list of
  11967. expressions or equations.
  11968. GROEBNER calculates the Gr\"obner basis of the given set of
  11969. expressions with respect to the current TORDER setting.
  11970. The Gr\"obner basis $\{1\}$ means that the ideal generated by the
  11971. input polynomials is the whole polynomial ring, or equivalently, that
  11972. the input polynomials have no zeros in common.
  11973. As a side effect, the sequence of variables is stored as a \REDUCE\ list
  11974. in the shared variable \ttindex{gvarslast}{\tt gvarslast}.
  11975. \end{description}
  11976. \example \index{GROEBNER package ! example}
  11977. {\small\begin{verbatim}
  11978. torder({},lex)$
  11979. groebner{3*x**2*y + 2*x*y + y + 9*x**2 + 5*x - 3,
  11980. 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x + 3,
  11981. x**3*y + x**2*y + 3*x**3 + 2*x**2 };
  11982. 2
  11983. {8*X - 2*Y + 5*Y + 3,
  11984. 3 2
  11985. 2*Y - 3*Y - 16*Y + 21}
  11986. \end{verbatim}}
  11987. The operation of GROEBNER can be controlled by the following
  11988. switches:
  11989. \begin{description}
  11990. \ttindex{GROEBOPT}
  11991. \item[GROEBOPT] -- If set ON, the sequence of variables is optimized
  11992. with respect to execution speed; note that the final list of variables
  11993. is available in\ttindex{GVARSLAST} GVARSLAST.
  11994. An explicitly declared dependency supersedes the
  11995. variable optimization.
  11996. By default GROEBOPT is off, conserving the original variable
  11997. sequence.
  11998. \ttindex{GROEBFULLREDUCTION}
  11999. \item[GROEBFULLREDUCTION] -- If set off, the reduction steps during
  12000. the \linebreak[4] GROEBNER operation are limited to the pure head
  12001. term reduction; subsequent terms are reduced otherwise.
  12002. By default GROEBFULLREDUCTION is on.
  12003. \ttindex{GLTBASIS}
  12004. \item[GLTBASIS] -- If set on, the leading terms of the result basis are
  12005. extracted. They are collected in a basis of monomials, which is
  12006. available as value of the global variable with the name GLTB.
  12007. \end{description}
  12008. \subsection{GZERODIM?: Test of $\dim = 0$}
  12009. \begin{description}
  12010. \ttindex{GZERODIM?}
  12011. \item[{\it GZERODIM}!?] $bas$ \\
  12012. where {\it bas} is a Gr\"obner basis in the current setting.
  12013. The result is {\it NIL}, if {\it bas} is the basis of an ideal of
  12014. polynomials with more than finitely many common zeros.
  12015. If the ideal is zero dimensional, {\em i.e.\ } the polynomials of the
  12016. ideal have only finitely many zeros in common, the result is an
  12017. integer $k$ which is the number of these common zeros (counted with
  12018. multiplicities).
  12019. \end{description}
  12020. \subsection{GDIMENSION, GINDEPENDENT\_SETS}
  12021. The following operators can be used to compute the dimension
  12022. and the independent variable sets of an ideal which has the
  12023. Gr\"obner basis {\it bas} with arbitrary term order:
  12024. \begin{description}
  12025. \ttindex{GDIMENSION}\ttindex{GINDEPENDENT\_SETS}
  12026. \ttindex{ideal dimension}\ttindex{independent sets}
  12027. \item[Gdimension]$bas$
  12028. \item[Gindependent\_sets]$bas$
  12029. {\it Gindependent\_sets} computes the maximal
  12030. left independent variable sets of the ideal, that are
  12031. the variable sets which play the role of free parameters in the
  12032. current ideal basis. Each set is a list which is a subset of the
  12033. variable list. The result is a list of these sets. For an
  12034. ideal with dimension zero the list is empty.
  12035. {\it GDimension} computes the dimension of the ideal,
  12036. which is the maximum length of the independent sets.
  12037. \end{description}
  12038. \subsection{GLEXCONVERT: Conversion to a Lexical Base}
  12039. \begin{description}
  12040. \ttindex{GLEXCONVERT}
  12041. \item[{\it GLEXCONVERT}] $ \left(\{exp,\ldots , expm\} \left[,\{var1
  12042. \ldots , varn\}\right]\right.$ \\
  12043. $\left. \left[,MAXDEG=mx\right] \left[,NEWVARS=\{nv1, \ldots , nvk\}\right]\right) $ \\
  12044. where $\{exp1, \ldots , expm\}$ is a Gr\"obner basis with
  12045. $\{var1, \ldots , varn\}$ as variables in the current term order mode,
  12046. $mx$ is an integer, and
  12047. $\{nv1, \ldots , nvk\}$ is a subset of the basis variables.
  12048. For this operator the source and target variable sets must be specified
  12049. explicitly.
  12050. \end{description}
  12051. GLEXCONVERT converts a basis of a zero-dimensional ideal (finite number
  12052. of isolated solutions) from arbitrary ordering into a basis under {\it
  12053. lex} ordering. During the call of GLEXCONVERT the original ordering of
  12054. the input basis must be still active.
  12055. NEWVARS defines the new variable sequence. If omitted, the
  12056. original variable sequence is used. If only a subset of variables is
  12057. specified here, the partial ideal basis is evaluated. For the
  12058. calculation of a univariate polynomial, NEW\-VARS should be a list
  12059. with one element.
  12060. MAXDEG is an upper limit for the degrees. The algorithm stops with
  12061. an error message, if this limit is reached.
  12062. A warning occurs if the ideal is not zero dimensional.
  12063. GLEXCONVERT is an implementation of the FLGM algorithm. Often, the
  12064. calculation of a Gr\"obner basis
  12065. with a graded ordering and subsequent conversion to {\it lex} is
  12066. faster than a direct {\it lex} calculation. Additionally, GLEXCONVERT
  12067. can be used to transform a {\it lex} basis into one with different
  12068. variable sequence, and it supports the calculation of a univariate
  12069. polynomial. If the latter exists, the algorithm is even applicable in
  12070. the non zero-dimensional case, if such a polynomial exists.
  12071. {\small\begin{verbatim}
  12072. torder({{w,p,z,t,s,b},gradlex)
  12073. g := groebner { f1 := 45*p + 35*s -165*b -36,
  12074. 35*p + 40*z + 25*t - 27*s, 15*w + 25*p*s +30*z -18*t
  12075. -165*b**2, -9*w + 15*p*t + 20*z*s,
  12076. w*p + 2*z*t - 11*b**3, 99*w - 11*s*b +3*b**2,
  12077. b**2 + 33/50*b + 2673/10000};
  12078. G := {60000*W + 9500*B + 3969,
  12079. 1800*P - 3100*B - 1377,
  12080. 18000*Z + 24500*B + 10287,
  12081. 750*T - 1850*B + 81,
  12082. 200*S - 500*B - 9,
  12083. 2
  12084. 10000*B + 6600*B + 2673}
  12085. glexconvert(g,{w,p,z,t,s,b},maxdeg=5,newvars={w});
  12086. 2
  12087. 100000000*W + 2780000*W + 416421
  12088. glexconvert(g,{w,p,z,t,s,b},maxdeg=5,newvars={p});
  12089. 2
  12090. 6000*P - 2360*P + 3051
  12091. \end{verbatim}}
  12092. \subsection{GROEBNERF: Factorizing Gr\"obner Bases}
  12093. If Gr\"obner bases are computed in order to solve systems of equations
  12094. or to find the common roots of systems of polynomials, the factorizing
  12095. version of the Buchberger algorithm can be used. The theoretical
  12096. background is simple: if a polynomial $p$ can be represented as a
  12097. product of two (or more) polynomials, {\em e.g.\ } $h= f*g$, then $h$
  12098. vanishes if and only if one of the factors vanishes. So if during the
  12099. calculation of a Gr\"obner basis $h$ of the above form is detected,
  12100. the whole problem can be split into two (or more) disjoint branches.
  12101. Each of the branches is simpler than the complete problem; this saves
  12102. computing time and space. The result of this type of computation is a
  12103. list of (partial) Gr\"obner bases; the solution set of the original
  12104. problem is the union of the solutions of the partial problems,
  12105. ignoring the multiplicity of an individual solution. If a branch
  12106. results in a basis $\{1\}$, then there is no common zero, {\em i.e.\ }no
  12107. additional solution for the original problem, contributed by this
  12108. branch.
  12109. \subsubsection{GROEBNERF Call}
  12110. \ttindex{GROEBNERF}
  12111. The syntax of GROEBNERF is the same as for GROEBNER.
  12112. \[
  12113. \mbox{\it GROEBNERF}(\{exp1, exp2, \ldots , expm\}
  12114. [,\{\},\{nz1, \ldots nzk\});
  12115. \]
  12116. where $\{exp1, exp2, \ldots , expm\} $ is a given list of expressions or
  12117. equations, and $\{nz1, \ldots nzk\}$ is
  12118. an optional list of polynomials known to be non-zero.
  12119. GROEBNERF tries to separate polynomials into individual factors and
  12120. to branch the computation in a recursive manner (factorisation tree).
  12121. The result is a list of partial Gr\"obner bases. If no factorisation can
  12122. be found or if all branches but one lead to the trivial basis $\{1\}$,
  12123. the result has only one basis; nevertheless it is a list of lists of
  12124. polynomials. If no solution is found, the result will be $\{\{1\}\}$.
  12125. Multiplicities (one factor with a higher power, the same partial basis
  12126. twice) are deleted as early as possible in order to speed up the
  12127. calculation. The factorising is controlled by some switches.
  12128. As a side effect, the sequence of variables is stored as a \REDUCE\ list in
  12129. the shared variable
  12130. \begin{center}
  12131. gvarslast .
  12132. \end{center}
  12133. If GLTBASIS is on, a corresponding list of leading term bases is
  12134. also produced and is available in the variable GLTB.
  12135. The third parameter of GROEBNERF allows one to declare some polynomials
  12136. nonzero. If any of these is found in a branch of the calculation
  12137. the branch is cancelled. This can be used to save a substantial amount
  12138. of computing time. The second parameter must be included as an
  12139. empty list if the third parameter is to be used.
  12140. {\small\begin{verbatim}
  12141. torder({x,y},lex)$
  12142. groebnerf { 3*x**2*y + 2*x*y + y + 9*x**2 + 5*x = 3,
  12143. 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x = -3,
  12144. x**3*y + x**2*y + 3*x**3 + 2*x**2 };
  12145. {{Y - 3,X},
  12146. 2
  12147. {2*Y + 2*X - 1,2*X - 5*X - 5}}
  12148. \end{verbatim}}
  12149. %}
  12150. It is obvious here that the solutions of the equations can be read
  12151. off immediately.
  12152. All switches from GROEBNER are valid for GROEBNERF as well:
  12153. \ttindex{GROEBOPT} \ttindex{GLTBASIS}
  12154. \ttindex{GROEBFULLREDUCTION}\ttindex{GROEBSTAT}\ttindex{TRGROEB}
  12155. \ttindex{TRGROEBS}\ttindex{TRGROEB1}
  12156. \begin{center}
  12157. \begin{tabular}{l}
  12158. GROEBOPT \\
  12159. GLTBASIS \\
  12160. GROEBFULLREDUCTION \\
  12161. GROEBSTAT \\
  12162. TRGROEB \\
  12163. TRGROEBS \\
  12164. TRGROEB1
  12165. \end{tabular}
  12166. \end{center}
  12167. \subsubsection{Restriction of the Solution Space}
  12168. In some applications only a subset of the complete solution set
  12169. of a given set of equations is relevant, {\em e.g.\ } only
  12170. nonnegative values or positive definite values for the variables.
  12171. A significant amount of computing time can be saved if
  12172. nonrelevant computation branches can be terminated early.
  12173. Positivity: If a polynomial has no (strictly) positive zero, then
  12174. every system containing it has no nonnegative or strictly positive
  12175. solution. Therefore, the Buchberger algorithm tests the coefficients of
  12176. the polynomials for equal sign if requested. For example, in $13*x +
  12177. 15*y*z $ can be zero with real nonnegative values for $x, y$ and $z$
  12178. only if $x=0$ and $y=0$ or $ z=0$; this is a sort of ``factorization by
  12179. restriction''. A polynomial $13*x + 15*y*z + 20$ never can vanish
  12180. with nonnegative real variable values.
  12181. Zero point: If any polynomial in an ideal has an absolute term, the ideal
  12182. cannot have the origin point as a common solution.
  12183. By setting the shared variable
  12184. \ttindex{GROEBRESTRICTION}
  12185. \begin{center} GROEBRESTRICTION \end{center}
  12186. GROEBNERF is informed of the type of restriction the user wants to
  12187. impose on the solutions:
  12188. \begin{center}
  12189. \begin{tabular}{l}
  12190. {\it GROEBRESTRICTION:=NONEGATIVE;} \\
  12191. \hspace*{+.5cm} only nonnegative real solutions are of
  12192. interest\vspace*{4mm} \\
  12193. {\it GROEBRESTRICTION:=POSITIVE;} \\
  12194. \hspace*{+.5cm}only nonnegative and nonzero solutions are of
  12195. interest\vspace*{4mm} \\
  12196. {\it GROEBRESTRICTION:=ZEROPOINT;} \\
  12197. \hspace*{+.5cm}only solution sets which contain the point
  12198. $\{0,0,\ldots,0\}$ are or interest.
  12199. \end{tabular}
  12200. \end{center}
  12201. If GROEBNERF detects a polynomial which formally conflicts with the
  12202. restriction, it either splits the calculation into separate branches, or,
  12203. if a violation of the restriction is determined, it cancels the actual
  12204. calculation branch.
  12205. \subsection{GREDUCE, PREDUCE: Reduction of Polynomials}
  12206. \subsubsection{Background} \label{GROEBNER:background}
  12207. Reduction of a polynomial ``p'' modulo a given sets of polynomials
  12208. ``B'' is done by the reduction algorithm incorporated in the
  12209. Buchberger algorithm.
  12210. % Subsection 3.5.2
  12211. \subsubsection{Reduction via Gr\"obner Basis Calculation}
  12212. \ttindex{GREDUCE}
  12213. \[
  12214. \mbox{\it GREDUCE}(exp, \{exp1, exp2, \ldots , expm\}]);
  12215. \]
  12216. where {\it exp} is an expression, and $\{exp1, exp2,\ldots , expm\}$ is
  12217. a list of any number of expressions or equations.
  12218. GREDUCE first converts the list of expressions $\{exp1, \ldots ,
  12219. expn\}$ to a Gr\"obner basis, and then reduces the given expression
  12220. modulo that basis. An error results if the list of expressions is
  12221. inconsistent. The returned value is an expression representing the
  12222. reduced polynomial. As a side effect, GREDUCE sets the variable {\it
  12223. gvarslast} in the same manner as GROEBNER does.
  12224. \subsubsection{Reduction with Respect to Arbitrary Polynomials}
  12225. \ttindex{PREDUCE}
  12226. \[
  12227. PREDUCE(exp, \{exp1, exp2,\ldots , expm\});
  12228. \]
  12229. where $ exp $ is an expression, and $\{exp1, exp2, \ldots ,
  12230. expm \}$ is a list of any number of expressions or equations.
  12231. PREDUCE reduces the given expression modulo the set $\{exp1,
  12232. \ldots , expm\}$. If this set is a Gr\"obner basis, the obtained reduced
  12233. expression is uniquely determined. If not, then it depends on the
  12234. subsequence of the single reduction steps
  12235. (see~\ref{GROEBNER:background}). PREDUCE does not check whether
  12236. $\{exp1, exp2, \ldots , expm\}$ is a Gr\"obner basis in the actual
  12237. order. Therefore, if the expressions are a Gr\"obner basis calculated
  12238. earlier with a variable sequence given explicitly or modified by
  12239. optimisation, the proper variable sequence and term order must
  12240. be activated first.
  12241. \example (PREDUCE called with a Gr\"obner basis):
  12242. {\small\begin{verbatim}
  12243. torder({x,y},lex);
  12244. gb:=groebner{3*x**2*y + 2*x*y + y + 9*x**2 + 5*x - 3,
  12245. 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x + 3,
  12246. x**3*y + x**2*y + 3*x**3 + 2*x**2}$
  12247. preduce (5*y**2 + 2*x**2*y + 5/2*x*y + 3/2*y
  12248. + 8*x**2 + 3/2*x - 9/2, gb);
  12249. 2
  12250. Y
  12251. \end{verbatim}}
  12252. \section{Ideal Decomposition \& Equation System Solving}
  12253. Based on the elementary Gr\"obner operations, the GROEBNER package offers
  12254. additional operators, which allow the decomposition of an ideal or of a
  12255. system of equations down to the individual solutions. Details of the
  12256. operators\ttindex{GROESOLVE}\ttindex{GROEBNERF}
  12257. \ttindex{IDEALQUOTIENT}GROESOLVE, GROEBNERF and IDEALQUOTIENT can be
  12258. found in the full documentation, with associated functions.
  12259. \chapter{IDEALS: Arithmetic for polynomial ideals}
  12260. \label{IDEALS}
  12261. \typeout{{IDEALS: Arithmetic for polynomial ideals}}
  12262. {\footnotesize
  12263. \begin{center}
  12264. Herbert Melenk \\
  12265. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  12266. Takustra\"se 7 \\
  12267. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  12268. e--mail: melenk@zib.de
  12269. \end{center}
  12270. }
  12271. \ttindex{IDEALS}
  12272. This package implements the basic arithmetic for polynomial ideals
  12273. by exploiting the Gr\"obner bases package of \REDUCE.
  12274. In order to save computing time all intermediate Gr\"obner bases
  12275. are stored internally such that time consuming repetitions
  12276. are inhibited. A uniform setting facilitates the access.
  12277. \section{Initialization}
  12278. Prior to any computation the set of variables has to be declared
  12279. by calling the operator $I\_setting$ . For example in order to initiate
  12280. computations in the polynomial ring $Q[x,y,z]$ call
  12281. {\small\begin{verbatim}
  12282. I_setting(x,y,z);
  12283. \end{verbatim}}
  12284. A subsequent call to $I\_setting$ allows one to select another set
  12285. of variables; at the same time the internal data structures
  12286. are cleared in order to free memory resources.
  12287. \section{Bases}
  12288. An ideal is represented by a basis (set of polynomials) tagged
  12289. with the symbol $I$, {\em e.g.\ }
  12290. {\small\begin{verbatim}
  12291. u := I(x*z-y**2, x**3-y*z);
  12292. \end{verbatim}}
  12293. Alternatively a list of polynomials can be used as input basis; however,
  12294. all arithmetic results will be presented in the above form. The
  12295. operator $ideal2list$ allows one to convert an ideal basis into a
  12296. conventional \REDUCE\ list.
  12297. \subsection{Operators}
  12298. Because of syntactical restrictions in \REDUCE, special operators
  12299. have to be used for ideal arithmetic:
  12300. {\small\begin{verbatim}
  12301. .+ ideal sum (infix)
  12302. .* ideal product (infix)
  12303. .: ideal quotient (infix)
  12304. ./ ideal quotient (infix)
  12305. .= ideal equality test (infix)
  12306. subset ideal inclusion test (infix)
  12307. intersection ideal intersection (prefix,binary)
  12308. member test for membership in an ideal
  12309. (infix: polynomial and ideal)
  12310. gb Groebner basis of an ideal (prefix, unary)
  12311. ideal2list convert ideal basis to polynomial list
  12312. (prefix,unary)
  12313. \end{verbatim}}
  12314. Example:
  12315. {\small\begin{verbatim}
  12316. I(x+y,x^2) .* I(x-z);
  12317. 2 2 2
  12318. I(X + X*Y - X*Z - Y*Z,X*Y - Y *Z)
  12319. \end{verbatim}}
  12320. Note that ideal equality cannot be tested with the \REDUCE\ equal sign:
  12321. {\small\begin{verbatim}
  12322. I(x,y) = I(y,x) is false
  12323. I(x,y) .= I(y,x) is true
  12324. \end{verbatim}}
  12325. \chapter{INEQ: Support for solving inequalities}
  12326. \label{INEQ}
  12327. \typeout{{INEQ: Support for solving inequalities}}
  12328. {\footnotesize
  12329. \begin{center}
  12330. Herbert Melenk \\
  12331. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  12332. Takustra\"se 7 \\
  12333. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  12334. e--mail: melenk@zib.de
  12335. \end{center}
  12336. }
  12337. \ttindex{INEQ}
  12338. This package supports the operator {\bf ineq\_solve} that
  12339. tries to solves single inequalities and sets of coupled inequalities.
  12340. The following types of systems are supported
  12341. \footnote{For linear optimization problems please use the operator
  12342. {\bf simplex} of the {\bf linalg} package (section~\ref{simplex}}:
  12343. \begin{itemize}
  12344. \item only numeric coefficients (no parametric system),
  12345. \item a linear system of mixed equations and $<=$ -- $>=$
  12346. inequalities, applying the method of Fourier and Motzkin,
  12347. \item a univariate inequality with $<=$, $>=$, $>$ or $<$ operator
  12348. and polynomial or rational left--hand and right--hand sides,
  12349. or a system of such inequalities with only one variable.
  12350. \end{itemize}
  12351. Syntax:
  12352. \begin{center}
  12353. {\tt INEQ\_SOLVE($<$expr$>$ [,$<$vl$>$])}
  12354. \end{center}
  12355. where $<$expr$>$ is an inequality or a list of coupled inequalities
  12356. and equations, and the optional argument $<$vl$>$ is a single
  12357. variable (kernel) or a list of variables (kernels). If not
  12358. specified, they are extracted automatically from $<$expr$>$.
  12359. For multivariate input an explicit variable list specifies the
  12360. elimination sequence: the last member is the most specific one.
  12361. An error message occurs if the input cannot be processed by the
  12362. current algorithms.
  12363. The result is a list. It is empty if the system has no feasible
  12364. solution. Otherwise the result presents the admissible ranges as set
  12365. of equations where each variable is equated to one expression or to an
  12366. interval. The most specific variable is the first one in the result
  12367. list and each form contains only preceding variables (resolved form).
  12368. The interval limits can be formal {\bf max} or {\bf min} expressions.
  12369. Algebraic numbers are encoded as rounded number approximations.
  12370. \noindent
  12371. {\bf Examples}:
  12372. {\small\begin{verbatim}
  12373. ineq_solve({(2*x^2+x-1)/(x-1) >= (x+1/2)^2, x>0});
  12374. {x=(0 .. 0.326583),x=(1 .. 2.56777)}
  12375. reg:=
  12376. {a + b - c>=0, a - b + c>=0, - a + b + c>=0, 0>=0, 2>=0,
  12377. 2*c - 2>=0, a - b + c>=0, a + b - c>=0, - a + b + c - 2>=0,
  12378. 2>=0, 0>=0, 2*b - 2>=0, k + 1>=0, - a - b - c + k>=0,
  12379. - a - b - c + k + 2>=0, - 2*b + k>=0,
  12380. - 2*c + k>=0, a + b + c - k>=0,
  12381. 2*b + 2*c - k - 2>=0, a + b + c - k>=0}$
  12382. ineq_solve (reg,{k,a,b,c});
  12383. {c=(1 .. infinity),
  12384. b=(1 .. infinity),
  12385. a=(max( - b + c,b - c) .. b + c - 2),
  12386. k=a + b + c}
  12387. \end{verbatim}}
  12388. \chapter[INVBASE: Involutive Bases]%
  12389. {INVBASE: A package for computing involutive bases}
  12390. \label{INVBASE}
  12391. \typeout{{INVBASE: A package for computing involutive bases}}
  12392. {\footnotesize
  12393. \begin{center}
  12394. A.Yu.Zharkov, Yu.A.Blinkov\\
  12395. Saratov University\\
  12396. Astrakhanskaya 83\\
  12397. 410071 Saratov, Russia\\[0.05in]
  12398. e--mail: postmaster@scnit.saratov.su
  12399. \end{center}
  12400. }
  12401. \ttindex{INVBASE}
  12402. Involutive bases are a new tool for solving problems in connection
  12403. with multivariate polynomials, such as solving systems of polynomial
  12404. equations and analysing polynomial ideals. An involutive basis of
  12405. polynomial ideal is a special form of a redundant Gr\"obner basis.
  12406. The construction of involutive bases reduces the problem of solving
  12407. polynomial systems to simple linear algebra.
  12408. The INVBASE package can be seen as an alternative to Buchberger's
  12409. algorithm.
  12410. \section{The Basic Operators}
  12411. \subsection{Term Ordering}
  12412. The term order modes available
  12413. are\ttindex{REVGRADLEX}\ttindex{GRADLEX}\ttindex{LEX}
  12414. {\tt REVGRADLEX}, {\tt GRADLEX} and {\tt LEX}.
  12415. These modes have the same meaning as for the GROEBNER package.
  12416. All orderings are based on an ordering among the variables.
  12417. For each pair of variables an order relation $\gg$ must be defined.
  12418. The term ordering mode as well as the order of variables
  12419. are set by the operator\ttindex{INVTORDER}
  12420. {\tt INVTORDER} {\it mode},$\{x_1,...,x_n\}$
  12421. where {\it mode} is one of the term order modes listed above.
  12422. The notion of $\{x_1,...,x_n\}$ as a list of variables
  12423. at the same time means $x_1\gg \ldots \gg x_n$.
  12424. \subsection{Computing Involutive Bases}
  12425. To compute the involutive basis of ideal generated by the set of
  12426. polynomials $\{p_1,...,p_m\}$ one should type the command
  12427. \ttindex{INVBASE}
  12428. \noindent{\tt INVBASE} $\{p_1,...,p_m\} $
  12429. where $p_i$ are polynomials in variables listed in the
  12430. {\tt INVTORDER} operator. If some kernels in $p_i$ were not listed
  12431. previously in the {\tt INVTORDER} operator they are considered as
  12432. parameters, {\em i.e.\ }they are considered part of the coefficients of
  12433. polynomials. If {\tt INVTORDER} was omitted, all the kernels
  12434. in $p_i$ are considered as variables with the default \REDUCE{}
  12435. kernel order.
  12436. The coefficients of polynomials $p_i$ may be integers as well as
  12437. rational numbers (or, accordingly, polynomials and rational functions
  12438. in the parametric case). The computations modulo prime numbers are
  12439. also available. For this purpose one should type the \REDUCE\ commands
  12440. {\small\begin{verbatim}
  12441. ON MODULAR; SETMOD p;
  12442. \end{verbatim}}
  12443. where $p$ is a prime number.
  12444. The value of the \f{INVBASE} function is a list of integer polynomials
  12445. $\{g_1,...,g_n\}$ representing an involutive basis of a given ideal.
  12446. {\small\begin{verbatim}
  12447. INVTORDER REVGRADLEX, {x,y,z};
  12448. g:= INVBASE {4*x**2 + x*y**2 - z + 1/4,
  12449. 2*x + y**2*z + 1/2,
  12450. x**2*z - 1/2*x - y**2};
  12451. 3 2 3 2
  12452. g := {8*x*y*z - 2*x*y*z + 4*y - 4*y*z + 16*x*y + 17*y*z - 4*y,
  12453. 4 2 2 2
  12454. 8*y - 8*x*z - 256*y + 2*x*z + 64*z - 96*x + 20*z - 9,
  12455. 3
  12456. 2*y *z + 4*x*y + y,
  12457. 3 2 2 2
  12458. 8*x*z - 2*x*z + 4*y - 4*z + 16*x + 17*z - 4,
  12459. 3 3 2
  12460. - 4*y*z - 8*y + 6*x*y*z + y*z - 36*x*y - 8*y,
  12461. 2 2 2
  12462. 4*x*y + 32*y - 8*z + 12*x - 2*z + 1,
  12463. 2
  12464. 2*y *z + 4*x + 1,
  12465. 3 2 2
  12466. - 4*z - 8*y + 6*x*z + z - 36*x - 8,
  12467. 2 2 2
  12468. 8*x - 16*y + 4*z - 6*x - z}
  12469. \end{verbatim}}
  12470. To convert it into a lexicographical Gr\"obner basis one should type
  12471. {\small\begin{verbatim}
  12472. h := INVLEX g;
  12473. 6 5 4 3
  12474. h := {3976*x + 37104*z - 600*z + 2111*z + 122062*z
  12475. 2
  12476. + 232833*z - 680336*z + 288814,
  12477. 2 6 5 4 3
  12478. 1988*y - 76752*z + 1272*z - 4197*z - 251555*z
  12479. 2
  12480. - 481837*z + 1407741*z - 595666,
  12481. 7 6 5 4 3 2
  12482. 16*z - 8*z + z + 52*z + 75*z - 342*z + 266*z
  12483. - 60}
  12484. \end{verbatim}}
  12485. \chapter[LAPLACE: Laplace transforms etc.]%
  12486. {LAPLACE: Laplace and inverse Laplace transforms}
  12487. \label{LAPLACE}
  12488. \typeout{{LAPLACE: Laplace and inverse Laplace transforms}}
  12489. {\footnotesize
  12490. \begin{center}
  12491. C. Kazasov, M. Spiridonova, V. Tomov \\
  12492. Sofia, Bulgaria %%\\[0.05in]
  12493. %%e--mail:
  12494. \end{center}
  12495. }
  12496. \ttindex{LAPLACE}
  12497. The LAPLACE package provides both Laplace Transforms and Inverse
  12498. Laplace Transforms, with the two operators
  12499. \noindent{\tt LAPLACE(exp, s\_var, t\_var)}\ttindex{LAPLACE} \\
  12500. {\tt INVLAP(exp, s\_var, t\_var)}\ttindex{INVLAP}
  12501. The action is to transform the expression from the {\tt s\_var} or
  12502. source variable into the {\tt t\_var} or target variable. If {\tt
  12503. t\_var} is omitted, the package uses an internal variable {\tt lp!\&} or
  12504. {\tt il!\&} respectively.
  12505. Three switches control the transformations. If {\tt
  12506. lmon}\ttindex{lpon} is on then sine, cosine, hyperbolic sine and
  12507. hyperbolic cosines are converted by LAPLACE into exponentials. If
  12508. {\tt lhyp} is on then exponential functions are converted into
  12509. hyperbolic form. The last switch {\tt ltrig}\ttindex{ltrig} has the
  12510. same effect except it uses trigonometric functions.
  12511. The system can be extended by adding Laplace transformation rules for
  12512. single functions by rules or rule sets. In such a rule the source
  12513. variable {\bf must} be free, the target variable {\bf must} be {\tt
  12514. il!\&} for LAPLACE and {\tt lp!\&} for INVLAP, with the third parameter
  12515. omitted. Also rules for transforming derivatives are entered in such
  12516. a form. For example
  12517. {\small\begin{verbatim}
  12518. let {laplace(log(~x),x) => -log(gam * il!&)/il!&,
  12519. invlap(log(gam * ~x)/x,x) => -log(lp!&)};
  12520. operator f;
  12521. let {
  12522. laplace(df(f(~x),x),x) => il!&*laplace(f(x),x) - sub(x=0,f(x)),
  12523. laplace(df(f(~x),x,~n),x) => il!&**n*laplace(f(x),x) -
  12524. for i:=n-1 step -1 until 0 sum
  12525. sub(x=0, df(f(x),x,n-1-i)) * il!&**i
  12526. when fixp n,
  12527. laplace(f(~x),x) = f(il!&)
  12528. };
  12529. \end{verbatim}}
  12530. The LAPLACE system knows about the functions {\tt DELTA} and {\tt
  12531. GAMMA}, and used the operator {\tt ONE} for the unit step function and
  12532. {\tt INTL} stands for the parameterised integral function, for
  12533. instance {\tt intl(2*y**2,y,0,x)} stands for $\int^x_0 2 y^2 dx$.
  12534. {\small\begin{verbatim}
  12535. load_package laplace;
  12536. laplace(sin(17*x),x,p);
  12537. 17
  12538. ----------
  12539. 2
  12540. p + 289
  12541. on lmon;
  12542. laplace(-1/4*e**(a*x)*(x-k)**(-1/2), x, p);
  12543. 1 a*k
  12544. - ---*sqrt(pi)*e
  12545. 4
  12546. ----------------------
  12547. k*p
  12548. e *sqrt( - a + p)
  12549. invlap(c/((p-a)*(p-b)), p, t);
  12550. a*t b*t
  12551. c*(e - e )
  12552. -----------------
  12553. a - b
  12554. invlap(p**(-7/3), p, t);
  12555. 1/3
  12556. t *t
  12557. ------------
  12558. 7
  12559. gamma(---)
  12560. 3
  12561. \end{verbatim}}
  12562. \chapter[LIE: Classification of Lie algebras]%
  12563. {LIE: Functions for the classification of real n-dimensional Lie algebras}
  12564. \label{LIE}
  12565. \typeout{{LIE: Functions for the classification of real n-dimensional
  12566. Lie algebras}}
  12567. {\footnotesize
  12568. \begin{center}
  12569. Carsten and Franziska Sch\"obel\\
  12570. The Leipzig University, Computer Science Department \\
  12571. Augustusplatz 10/11, \\
  12572. O-7010 Leipzig, Germany \\[0.05in]
  12573. e--mail: cschoeb@aix550.informatik.uni-leipzig.de
  12574. \end{center}
  12575. }
  12576. \ttindex{LIE}
  12577. {\bf LIE} is a package of functions for the classification of real
  12578. n-dimensional Lie algebras. It consists of two modules: {\bf liendmc1}
  12579. and {\bf lie1234}.
  12580. \section{liendmc1}
  12581. With the help of the functions in this module real n-dimensional Lie
  12582. algebras $L$ with a derived algebra $L^{(1)}$ of dimension 1 can be
  12583. classified. $L$ has to be defined by its structure constants
  12584. $c_{ij}^k$ in the basis $\{X_1,\ldots,X_n\}$ with
  12585. $[X_i,X_j]=c_{ij}^k X_k$. The user must define an ARRAY
  12586. LIENSTRUCIN($n,n,n$) with n being
  12587. the dimension of the Lie algebra $L$. The structure constants
  12588. LIENSTRUCIN($i,j,k$):=$c_{ij}^k$ for $i<j$ should be given. Then the
  12589. procedure LIENDIMCOM1 can be called. Its syntax is:\ttindex{LIENDIMCOM1}
  12590. {\small\begin{verbatim}
  12591. LIENDIMCOM1(<number>).
  12592. \end{verbatim}}
  12593. {\tt <number>} corresponds to the dimension $n$. The procedure simplifies
  12594. the structure of $L$ performing real linear transformations. The returned
  12595. value is a list of the form
  12596. {\small\begin{verbatim}
  12597. (i) {LIE_ALGEBRA(2),COMMUTATIVE(n-2)} or
  12598. (ii) {HEISENBERG(k),COMMUTATIVE(n-k)}
  12599. \end{verbatim}}
  12600. with $3\leq k\leq n$, $k$ odd.
  12601. The returned list is also stored as\ttindex{LIE\_LIST}{\tt
  12602. LIE\_LIST}. The matrix LIENTRANS gives the transformation from the
  12603. given basis $\{X_1,\ldots ,X_n\}$ into the standard basis
  12604. $\{Y_1,\ldots ,Y_n\}$: $Y_j=($LIENTRANS$)_j^k X_k$.
  12605. \section{lie1234}
  12606. This part of the package classifies real low-dimensional Lie algebras $L$
  12607. of the dimension $n:={\rm dim}\,L=1,2,3,4$. $L$ is also given by its
  12608. structure constants $c_{ij}^k$ in the basis $\{X_1,\ldots,X_n\}$ with
  12609. $[X_i,X_j]=c_{ij}^k X_k$. An ARRAY
  12610. LIESTRIN($n,n,n$) has to be defined and LIESTRIN($i,j,k$):=$c_{ij}^k$ for
  12611. $i<j$ should be given. Then the procedure LIECLASS can be performed
  12612. whose syntax is:\ttindex{LIECLASS}
  12613. {\small\begin{verbatim}
  12614. LIECLASS(<number>).
  12615. \end{verbatim}}
  12616. {\tt <number>} should be the dimension of the Lie algebra $L$. The
  12617. procedure stepwise simplifies the commutator relations of $L$ using
  12618. properties of invariance like the dimension of the centre, of the
  12619. derived algebra, unimodularity {\em etc.} The returned value has the form:
  12620. {\small\begin{verbatim}
  12621. {LIEALG(n),COMTAB(m)},
  12622. \end{verbatim}}
  12623. where the value $m$ corresponds to the number of the standard form (basis:
  12624. $\{Y_1, \ldots ,Y_n\}$) in an enumeration scheme.
  12625. This returned value is also stored as LIE\_CLASS. The linear
  12626. transformation from the basis $\{X_1,\ldots,X_n\}$ into the basis of
  12627. the standard form $\{Y_1,\ldots,Y_n\}$ is given by the matrix LIEMAT:
  12628. $Y_j=($LIEMAT$)_j^k X_k$.
  12629. \chapter{LIMITS: A package for finding limits}
  12630. \label{LIMITS}
  12631. \typeout{{LIMITS: A package for finding limits}}
  12632. {\footnotesize
  12633. \begin{center}
  12634. Stanley L. Kameny \\
  12635. Los Angeles, U.S.A.
  12636. \end{center}
  12637. }
  12638. \ttindex{LIMITS}
  12639. LIMITS is a fast limit package for \REDUCE\ for functions which are
  12640. continuous except for computable poles and singularities, based on some
  12641. earlier work by Ian Cohen and John P. Fitch.
  12642. The Truncated Power Series
  12643. package is used for non-critical points, at which the value of the
  12644. function is the constant term in the expansion around that point.
  12645. \index{l'H\^opital's rule}
  12646. l'H\^opital's rule is used in critical cases, with preprocessing of
  12647. $\infty - \infty$ forms and reformatting of product forms in order
  12648. to apply l'H\^opital's rule. A limited amount of bounded arithmetic
  12649. is also employed where applicable.
  12650. \section{Normal entry points}
  12651. \ttindex{LIMIT}
  12652. \vspace{.1in}
  12653. \noindent {\tt LIMIT}(EXPRN:{\em algebraic}, VAR:{\em kernel},
  12654. LIMPOINT:{\em algebraic}):{\em algebraic}
  12655. \vspace{.1in}
  12656. This is the standard way of calling limit, applying all of the
  12657. methods. The result is the limit of EXPRN as VAR approaches LIMPOINT.
  12658. \section{Direction-dependent limits}
  12659. \ttindex{LIMIT+}\ttindex{LIMIT-}
  12660. \vspace{.1in}
  12661. \noindent {\tt LIMIT!+}(EXPRN:{\em algebraic}, VAR:{\em kernel},
  12662. LIMPOINT:{\em algebraic}):{\em algebraic} \\
  12663. \noindent {\tt LIMIT!-}(EXPRN:{\em algebraic}, VAR:{\em kernel},
  12664. LIMPOINT:{\em algebraic}):{\em algebraic}
  12665. \vspace{.1in}
  12666. If the limit depends upon the direction of approach to the {\tt
  12667. LIMPOINT}, the functions {\tt LIMIT!+} and {\tt LIMIT!-} may be used.
  12668. They are defined by:
  12669. \vspace{.1in}
  12670. \noindent{\tt LIMIT!+} (EXP,VAR,LIMPOINT) $\rightarrow$
  12671. \hspace*{2em}{\tt LIMIT}(EXP*,$\epsilon$,0) \\
  12672. where EXP* = sub(VAR=VAR+$\epsilon^2$,EXP)
  12673. and
  12674. \noindent{\tt LIMIT!-} (EXP,VAR,LIMPOINT) $\rightarrow$
  12675. \hspace*{2em}{\tt LIMIT}(EXP*,$\epsilon$,0) \\
  12676. where EXP* = sub(VAR=VAR-$\epsilon^2$,EXP)
  12677. Examples:
  12678. {\small\begin{verbatim}
  12679. load_package misc;
  12680. limit(sin(x)/x,x,0);
  12681. 1
  12682. limit((a^x-b^x)/x,x,0);
  12683. log(a) - log(b)
  12684. limit(x/(e**x-1), x, 0);
  12685. 1
  12686. limit!-(sin x/cos x,x,pi/2);
  12687. infinity
  12688. limit!+(sin x/cos x,x,pi/2);
  12689. - infinity
  12690. limit(x^log(1/x),x,infinity);
  12691. 0
  12692. limit((x^(1/5) + 3*x^(1/4))^2/(7*(sqrt(x + 9) - 3 - x/6))^(1/5),x,0);
  12693. 3/5
  12694. - 6
  12695. ---------
  12696. 1/5
  12697. 7
  12698. \end{verbatim}}
  12699. \chapter{LINALG: Linear algebra package}
  12700. \label{LINALG}
  12701. \typeout{{LINALG: Linear algebra package}}
  12702. {\footnotesize
  12703. \begin{center}
  12704. Matt Rebbeck \\
  12705. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  12706. Takustra\"se 7 \\
  12707. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  12708. \end{center}
  12709. }
  12710. \ttindex{LINALG}
  12711. \section{Introduction}
  12712. This package provides a selection of functions that are useful
  12713. in the world of linear algebra. They can be classified into four
  12714. sections:
  12715. \subsection{Basic matrix handling}
  12716. \begin{center}
  12717. \begin{tabular}{l l l l}
  12718. add\_columns\ttindex{ADD\_COLUMNS} &
  12719. add\_rows\ttindex{ADD\_ROWS} &
  12720. add\_to\_columns\ttindex{ADD\_TO\_COLUMNS} &
  12721. add\_to\_rows\ttindex{ADD\_TO\_ROWS} \\
  12722. augment\_columns\ttindex{AUGMENT\_COLUMNS} &
  12723. char\_poly\ttindex{CHAR\_POLY} &
  12724. column\_dim\ttindex{COLUMN\_DIM} &
  12725. copy\_into\ttindex{COPY\_INTO} \\
  12726. diagonal\ttindex{DIAGONAL} &
  12727. extend\ttindex{EXTEND} &
  12728. find\_companion\ttindex{FIND\_COMPANION} &
  12729. get\_columns\ttindex{GET\_COLUMNS} \\
  12730. get\_rows\ttindex{GET\_ROWS} &
  12731. hermitian\_tp\ttindex{HERMITIAN\_TP} &
  12732. matrix\_augment\ttindex{MATRIX\_AUGMENT} &
  12733. matrix\_stack\ttindex{MATRIX\_STACK} \\
  12734. minor\ttindex{MINOR} &
  12735. mult\_columns\ttindex{MULT\_COLUMNS} &
  12736. mult\_rows\ttindex{MULT\_ROWS} &
  12737. pivot\ttindex{PIVOT} \\
  12738. remove\_columns\ttindex{REMOVE\_COLUMNS} &
  12739. remove\_rows\ttindex{REMOVE\_ROWS} &
  12740. row\_dim\ttindex{ROW\_DIM} &
  12741. rows\_pivot\ttindex{ROWS\_PIVOT} \\
  12742. stack\_rows\ttindex{STACK\_ROWS} &
  12743. sub\_matrix\ttindex{SUB\_MATRIX} &
  12744. swap\_columns\ttindex{SWAP\_COLUMNS} &
  12745. swap\_entries\ttindex{SWAP\_ENTRIES} \\
  12746. swap\_rows\ttindex{SWAP\_ROWS} & & &
  12747. \end{tabular}
  12748. \end{center}
  12749. \subsection{Constructors}
  12750. Functions that create matrices.
  12751. \begin{center}
  12752. \begin{tabular}{l l l l}
  12753. band\_matrix\ttindex{BAND\_MATRIX} &
  12754. block\_matrix\ttindex{BLOCK\_MATRIX} &
  12755. char\_matrix\ttindex{CHAR\_MATRIX} &
  12756. coeff\_matrix\ttindex{COEFF\_MATRIX} \\
  12757. companion\ttindex{COMPANION} &
  12758. hessian\ttindex{HESSIAN} &
  12759. hilbert\ttindex{HILBERT} &
  12760. jacobian\ttindex{JACOBIAN} \\
  12761. jordan\_block\ttindex{JORDAN\_BLOCK} &
  12762. make\_identity\ttindex{MAKE\_IDENTITY} &
  12763. random\_matrix\ttindex{RANDOM\_MATRIX} &
  12764. toeplitz\ttindex{TOEPLITZ} \\
  12765. vandermonde\ttindex{VANDERMONDE} &
  12766. Kronecker\_Product\ttindex{KRONECKER\_PRODUCT} &
  12767. \end{tabular}
  12768. \end{center}
  12769. \subsection{High level algorithms}
  12770. \begin{center}
  12771. \begin{tabular}{l l l l}
  12772. char\_poly\ttindex{CHAR\_POLY} &
  12773. cholesky\ttindex{CHOLESKY} &
  12774. gram\_schmidt\ttindex{GRAM\_SCHMIDT} &
  12775. lu\_decom\ttindex{LU\_DECOM} \\
  12776. pseudo\_inverse\ttindex{PSEUDO\_INVERSE} &
  12777. simplex\ttindex{SIMPLEX} &
  12778. svd\ttindex{SVD} &
  12779. triang\_adjoint\ttindex{TRIANG\_ADJOINT} \\
  12780. \end{tabular}
  12781. \end{center}
  12782. \vspace*{5mm}
  12783. There is a separate {\small NORMFORM} package (chapter~\ref{NORMFORM})
  12784. for computing the matrix normal forms smithex, smithex\_int,
  12785. frobenius, ratjordan, jordansymbolic and jordan in \REDUCE.
  12786. \subsection{Predicates}
  12787. \begin{center}
  12788. \begin{tabular}{l l l}
  12789. matrixp\ttindex{MATRIXP} &
  12790. squarep\ttindex{SQUAREP} &
  12791. symmetricp\ttindex{SYMMETRICP}
  12792. \end{tabular}
  12793. \end{center}
  12794. \section{Explanations}
  12795. In the examples the matrix ${\cal A}$ will be
  12796. \begin{flushleft}
  12797. \begin{math}
  12798. {\cal A} = \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  12799. \end{array} \right)
  12800. \end{math}
  12801. \end{flushleft}
  12802. Throughout ${\cal I}$ is used to indicate the identity matrix and
  12803. ${\cal A}^T$ to indicate the transpose of the matrix ${\cal A}$.
  12804. Many of the functions have a fairly obvious meaning. Others need a
  12805. little explanation.
  12806. \section{Basic matrix handling}
  12807. The functions \f{ADD\_COLUMNS}\ttindex{ADD\_COLUMNS} and \f{ADD\_ROWS}
  12808. provide basic operations between rows and columns. The form is
  12809. \noindent {\tt add\_columns(${\cal A}$,c1,c2,expr);}
  12810. and it replaces column c2 of the matix by expr $*$ column(${\cal
  12811. A}$,c1) $+$ column(${\cal A}$,c2).
  12812. \f{ADD\_TO\_COLUMNS}\ttindex{ADD\_TO\_COLUMNS} and
  12813. \f{ADD\_TO\_ROWS}\ttindex{ADD\_TO\_ROWS} do a similar task, adding an
  12814. expression to each of a number of columns (or rows) specified by a
  12815. list.
  12816. \begin{math}
  12817. \begin{array}{ccc}
  12818. {\tt add\_to\_columns}({\cal A},\{1,2\},10) & = &
  12819. \left( \begin{array}{ccc} 11 & 12 & 3 \\ 14 & 15 & 6 \\ 17 & 18 & 9
  12820. \end{array} \right)
  12821. \end{array}
  12822. \end{math}
  12823. The functions \f{MULT\_COLUMNS}\ttindex{MULT\_COLUMNS} and
  12824. \f{MULT\_ROW}\ttindex{MULT\_ROW} are equivalent to multiply columns
  12825. and rows.
  12826. \f{COLUMN\_DIM}\ttindex{COLUMN\_DIM} and
  12827. \f{ROW\_DIM}\ttindex{ROW\_DIM} find the column dimension and row
  12828. dimension of their argument.
  12829. Parts of a matrix can be replaced from another by using
  12830. \f{COPY\_INTO}\ttindex{COPY\_INTO}; the last two arguments are row and
  12831. column counters for to where to copy the matrix.
  12832. \begin{flushleft}
  12833. \hspace*{0.175in}
  12834. \begin{math}
  12835. {\cal G} = \left( \begin{array}{cccc} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\
  12836. 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0
  12837. \end{array} \right)
  12838. \end{math}
  12839. \end{flushleft}
  12840. \begin{flushleft}
  12841. \hspace*{0.1in}
  12842. \begin{math}
  12843. \begin{array}{ccc}
  12844. {\tt copy\_into}({\cal A,G},1,2) & = &
  12845. \left( \begin{array}{cccc} 0 & 1 & 2 & 3 \\ 0 & 4 & 5 & 6 \\ 0 & 7 & 8
  12846. & 9 \\ 0 & 0 & 0 & 0
  12847. \end{array} \right)
  12848. \end{array}
  12849. \end{math}
  12850. \end{flushleft}
  12851. A diagonal matrix can be created with \f{DIAGONAL}\ttindex{DIAGONAL}.
  12852. The argument is a list of expressions of matrices which form the
  12853. diagonal.
  12854. An existing matrix can be extended; the call \f{EXTEND}(A,r,c,exp)\ttindex{EXTEND}
  12855. returns the matrix A extended by r rows and c columns, with the new
  12856. entries all exp.
  12857. The function \f{GET\_COLUMNS}\ttindex{GET\_COLUMNS} extracts from a
  12858. matrix a list of the specified columns as matrices.
  12859. \f{GET\_ROWS}\ttindex{GET\_ROWS} does the equivalent for rows.
  12860. \begin{flushleft}
  12861. \hspace*{0.1in}
  12862. \begin{math}
  12863. \begin{array}{ccc}
  12864. {\tt get\_columns}({\cal A},\{1,3\}) & = &
  12865. \left\{
  12866. \left( \begin{array}{c} 1 \\ 4 \\ 7 \end{array} \right),
  12867. \left( \begin{array}{c} 3 \\ 6 \\ 9 \end{array} \right)
  12868. \right\}
  12869. \end{array}
  12870. \end{math}
  12871. \end{flushleft}
  12872. The Hermitian transpose, that is a matrix in which the (i,$\,$j) entry is the conjugate of
  12873. the (j,$\,$i) entry of the input is returned by \f{HERMITIAN\_TP}\ttindex{HERMITIAN\_TP}.
  12874. \f{MATRIX\_AUGMENT}(\{mat$_{1}$,mat$_{2}$, \ldots ,mat$_{n}$\})\ttindex{MATRIX\_AUGMENT}
  12875. produces a new matrix from the list joined as new columns.
  12876. \ttindex{MATRIX\_STACK}\f{MATRIX\_STACK} joins a list of matrices by
  12877. stacking them.
  12878. \begin{flushleft}
  12879. \hspace*{0.1in}
  12880. \begin{math}
  12881. \begin{array}{ccc}
  12882. {\tt matrix\_stack}(\{{\cal A,A}\}) & = &
  12883. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  12884. \\ 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  12885. \end{array} \right)
  12886. \end{array}
  12887. \end{math}
  12888. \end{flushleft}
  12889. \f{MINOR}(A,r,c)\ttindex{MINOR} calculates the (r,c) minor of A.
  12890. \f{PIVOT}\ttindex{PIVOT} pivots a matrix about its (r,c) entry.
  12891. To do this, multiples of the $r^{th}$ row are added to every other row in
  12892. the matrix. This means that the $c^{th}$ column will be 0 except for
  12893. the (r,c) entry.
  12894. A variant on this operation is provided by
  12895. \f{ROWS\_PIVOT}\ttindex{ROWS\_PIVOT}. It applies the pivot only to the
  12896. rows specified as the last argument.
  12897. A sub matrix can be extracted, giving a list or the rows and columns
  12898. to keep.
  12899. \begin{flushleft}
  12900. \hspace*{0.1in}
  12901. \begin{math}
  12902. \begin{array}{ccc}
  12903. {\tt sub\_matrix}({\cal A},\{1,3\},\{2,3\}) & = &
  12904. \left( \begin{array}{cc} 2 & 3 \\ 8 & 9
  12905. \end{array} \right)
  12906. \end{array}
  12907. \end{math}
  12908. \end{flushleft}
  12909. The basic operation of swapping rows or columns is provided by
  12910. \f{SWAP\_ROWS}\ttindex{SWAP\_ROWS} and
  12911. \f{SWAP\_COLUMNS}\ttindex{SWAP\_COLUMNS}. Individual entries can be
  12912. swapped with \f{SWAP\_ENTRIES}\ttindex{SWAP\_ENTRIES}.
  12913. \begin{flushleft}
  12914. \hspace*{0.1in}
  12915. \begin{math}
  12916. \begin{array}{ccc}
  12917. {\tt swap\_columns}({\cal A},2,3) & = &
  12918. \left( \begin{array}{ccc} 1 & 3 & 2 \\ 4 & 6 & 5 \\ 7 & 9 & 8
  12919. \end{array} \right)
  12920. \end{array}
  12921. \end{math}
  12922. \end{flushleft}
  12923. \begin{flushleft}
  12924. \hspace*{0.1in}
  12925. \begin{math}
  12926. \begin{array}{ccc}
  12927. {\tt swap\_entries}({\cal A},\{1,1\},\{3,3\}) & = &
  12928. \left( \begin{array}{ccc} 9 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 1
  12929. \end{array} \right)
  12930. \end{array}
  12931. \end{math}
  12932. \end{flushleft}
  12933. \section{Constructors}
  12934. \f{AUGMENT\_COLUMNS}\ttindex{AUGMENT\_COLUMNS} allows just specified
  12935. columns to be selected; \f{STACK\_ROWS}\ttindex{STACK\_ROWS} does
  12936. a similar job for rows.
  12937. \begin{math}
  12938. \begin{array}{ccc}
  12939. {\tt stack\_rows}({\cal A},\{1,3\}) & = &
  12940. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 7 & 8 & 9
  12941. \end{array} \right)
  12942. \end{array}
  12943. \end{math}
  12944. Rows or columns can be removed with
  12945. \f{REMOVE\_COLUMNS}\ttindex{REMOVE\_COLUMNS} and
  12946. \f{REMOVE\_ROWS}\ttindex{REMOVE\_ROWS}.
  12947. \begin{flushleft}
  12948. \hspace*{0.1in}
  12949. \begin{math}
  12950. \begin{array}{ccc}
  12951. {\tt remove\_columns}({\cal A},2) & = &
  12952. \left( \begin{array}{cc} 1 & 3 \\ 4 & 6 \\ 7 & 9
  12953. \end{array} \right)
  12954. \end{array}
  12955. \end{math}
  12956. \end{flushleft}
  12957. {\tt BAND\_MATRIX}\ttindex{BAND\_MATRIX} creates a square matrix of
  12958. dimension its second argument. The diagonal consists of the middle
  12959. expressions of the first argument, which is an expression list. The
  12960. expressions to the left of this fill the required number of
  12961. sub\_diagonals and the expressions to the right the super\_diagonals.
  12962. \begin{math}
  12963. \begin{array}{ccc}
  12964. {\tt band\_matrix}(\{x,y,z\},6) & = &
  12965. \left( \begin{array}{cccccc} y & z & 0 & 0 & 0 & 0 \\ x & y & z & 0 & 0
  12966. & 0 \\ 0 & x & y & z & 0 & 0 \\ 0 & 0 & x & y & z & 0 \\ 0 & 0 & 0 & x &
  12967. y & z \\ 0 & 0 & 0 & 0 & x & y
  12968. \end{array} \right)
  12969. \end{array}
  12970. \end{math}
  12971. Related to the band matrix is a block matrix, which can be created by
  12972. \noindent {\tt BLOCK\_MATRIX(r,c,matrix\_list)}.\ttindex{BLOCK\_MATRIX}
  12973. The resulting matrix consists of r by c matrices filled from the
  12974. matrix\_list row wise.
  12975. \begin{flushleft}
  12976. \hspace*{0.1in}
  12977. \begin{math}
  12978. \begin{array}{ccc}
  12979. {\cal B} = \left( \begin{array}{cc} 1 & 0 \\ 0 & 1
  12980. \end{array} \right), &
  12981. {\cal C} = \left( \begin{array}{c} 5 \\ 5
  12982. \end{array} \right), &
  12983. {\cal D} = \left( \begin{array}{cc} 22 & 33 \\ 44 & 55
  12984. \end{array} \right)
  12985. \end{array}
  12986. \end{math}
  12987. \end{flushleft}
  12988. \vspace*{0.175in}
  12989. \begin{flushleft}
  12990. \hspace*{0.1in}
  12991. \begin{math}
  12992. \begin{array}{ccc}
  12993. {\tt block\_matrix}(2,3,\{{\cal B,C,D,D,C,B}\}) & = &
  12994. \left( \begin{array}{ccccc} 1 & 0 & 5 & 22 & 33 \\ 0 & 1 & 5 & 44 & 55
  12995. \\
  12996. 22 & 33 & 5 & 1 & 0 \\ 44 & 55 & 5 & 0 & 1
  12997. \end{array} \right)
  12998. \end{array}
  12999. \end{math}
  13000. \end{flushleft}
  13001. Characteristic polynomials and characteristic matrices are created by
  13002. the functions
  13003. {\tt CHAR\_POLY}\ttindex{CHAR\_POLY} and
  13004. \f{CHAR\_MATRIX}\ttindex{CHAR\_MATRIX}.
  13005. A set of linear equations can be turned into the associated
  13006. coefficient matrix and vector of unknowns and the righthandside.
  13007. \f{COEFF\_MATRIX} returns a list \{${\cal C,X,B}$\} such that ${\cal
  13008. CX} = {\cal B}$.
  13009. \begin{math}
  13010. \hspace*{0.175in}
  13011. {\tt coeff\_matrix}(\{x+y+4*z=10,y+x-z=20,x+y+4\}) =
  13012. \end{math}
  13013. \vspace*{0.1in}
  13014. \begin{flushleft}
  13015. \hspace*{0.175in}
  13016. \begin{math}
  13017. \left\{ \left( \begin{array}{ccc} 4 & 1 & 1 \\ -1 & 1 & 1 \\ 0 & 1 & 1
  13018. \end{array} \right), \left( \begin{array}{c} z \\ y \\ x \end{array}
  13019. \right), \left( \begin{array}{c} 10 \\ 20 \\ -4
  13020. \end{array} \right) \right\}
  13021. \end{math}
  13022. \end{flushleft}
  13023. \f{COMPANION}(poly,x) creates the companion matrix ${\cal C}$ of a
  13024. polynomial. That is the square matrix of dimension n, where n is the
  13025. degree of polynomial with respect to x, and the entries of ${\cal C}$ are:
  13026. ${\cal C}$(i,n) = -coeffn(poly,x,i-1) for i = 1 \ldots n, ${\cal
  13027. C}$(i,i-1) = 1 for i = 2 \ldots n and the rest are 0.
  13028. \begin{flushleft}
  13029. \hspace*{0.1in}
  13030. \begin{math}
  13031. \begin{array}{ccc}
  13032. {\tt companion}(x^4+17*x^3-9*x^2+11,x) & = &
  13033. \left( \begin{array}{cccc} 0 & 0 & 0 & -11 \\ 1 & 0 & 0 & 0 \\
  13034. 0 & 1 & 0 & 9 \\ 0 & 0 & 1 & -17
  13035. \end{array} \right)
  13036. \end{array}
  13037. \end{math}
  13038. \end{flushleft}
  13039. The polynomial associated with a companion matrix can be recovered by
  13040. calling \f{FIND\_COMPANION}\ttindex{FIND\_COMPANION}.
  13041. \f{HESSIAN}(expr, var\_list)\ttindex{HESSIAN} calculates the Hessian
  13042. matrix of the expressions with respect to the variables in the list,
  13043. or the single variable. That is the matrix with the (i,$\,$j) element
  13044. the $j^{th}$ derivative of the expressions with respect to the
  13045. $i^{th}$ variable.
  13046. \begin{flushleft}
  13047. \hspace*{0.1in}
  13048. \begin{math}
  13049. \begin{array}{ccc}
  13050. {\tt hessian}(x*y*z+x^2,\{w,x,y,z\}) & = &
  13051. \left( \begin{array}{cccc} 0 & 0 & 0 & 0 \\ 0 & 2 & z & y \\ 0 & z & 0
  13052. & x \\ 0 & y & x & 0
  13053. \end{array} \right)
  13054. \end{array}
  13055. \end{math}
  13056. \end{flushleft}
  13057. Hilbert's matrix, that is where the (i,$\,$j) element is $1/(i+j-x)$
  13058. is constructed by \f{HILBERT}(n,x)\ttindex{HILBERT}.
  13059. The Jacobian of an expression list with respect to a variable list is
  13060. calculated by
  13061. \f{JACOBIAN}(expr\_list,variable\_list)\ttindex{JACOBIAN}. This is a
  13062. matrix whose (i,$\,$j) entry is df(expr\_list(i),variable\_list(j)).
  13063. The square Jordan block matrix of dimension $n$ is calculated by the
  13064. function \f{JORDAN\_BLOCK}(exp,n).\ttindex{JORDAN\_BLOCK} The entries
  13065. of the Jordan\_block matrix are ${\cal J}$(i,i) = expr for i=1 \ldots
  13066. n, ${\cal J}$(i,i+1) = 1 for i=1 \ldots n-1, and all other entries are 0.
  13067. \begin{flushleft}
  13068. \hspace*{0.1in}
  13069. \begin{math}
  13070. \begin{array}{ccc}
  13071. {\tt jordan\_block(x,5)} & = &
  13072. \left( \begin{array}{ccccc} x & 1 & 0 & 0 & 0 \\ 0 & x & 1 & 0 & 0 \\ 0
  13073. & 0 & x & 1 & 0 \\ 0 & 0 & 0 & x & 1 \\ 0 & 0 & 0 & 0 & x
  13074. \end{array} \right)
  13075. \end{array}
  13076. \end{math}
  13077. \end{flushleft}
  13078. \f{MAKE\_IDENTITY}(n)\ttindex{MAKE\_IDENTITY} generates the $n \times
  13079. n$ identity matrix.
  13080. \f{RANDOM\_MATRIX}(r,c,limit)\ttindex{RANDOM\_MATRIX} generates and $r
  13081. \times c$ matrix with random values limited by {\tt limit}. The type
  13082. of entries is controlled by a number of switches.
  13083. \begin{description}
  13084. \item[{\tt IMAGINARY}]\ttindex{IMAGINARY}
  13085. If on then matrix entries are $x+i*y$ where $-limit < x,y < limit$.
  13086. \item[{\tt NOT\_NEGATIVE}]\ttindex{NOT\_NEGATIVE}
  13087. If on then $0 < entry < limit$. In the imaginary case we have $0 < x,y
  13088. < limit$.
  13089. \item[{\tt ONLY\_INTEGER}]\ttindex{ONLY\_INTEGER}
  13090. If on then each entry is an integer. In the imaginary case $x$ and $y$ are
  13091. integers. If off the values are rounded.
  13092. \item[{\tt SYMMETRIC}]\ttindex{SYMMETRIC}
  13093. If on then the matrix is symmetric.
  13094. \item[{\tt UPPER\_MATRIX}]\ttindex{UPPER\_MATRIX}
  13095. If on then the matrix is upper triangular.
  13096. \item[{\tt LOWER\_MATRIX}]\ttindex{LOWER\_MATRIX}
  13097. If on then the matrix is lower triangular.
  13098. \end{description}
  13099. \begin{flushleft}
  13100. \hspace*{0.1in}
  13101. \begin{math}
  13102. \begin{array}{ccc}
  13103. {\tt random\_matrix}(3,3,10) & = &
  13104. \left( \begin{array}{ccc} -4.729721 & 6.987047 & 7.521383 \\
  13105. - 5.224177 & 5.797709 & - 4.321952 \\
  13106. - 9.418455 & - 9.94318 & - 0.730980
  13107. \end{array} \right)
  13108. \end{array}
  13109. \end{math}
  13110. \end{flushleft}
  13111. \vspace*{0.2in}
  13112. \hspace*{0.165in}
  13113. {\tt on only\_integer, not\_negative, upper\_matrix, imaginary;}
  13114. \begin{flushleft}
  13115. %\hspace*{0.12in}
  13116. \begin{math}
  13117. \begin{array}{ccc}
  13118. {\tt random\_matrix}(4,4,10) & = &
  13119. \left( \begin{array}{cccc} 2*i+5 & 3*i+7 & 7*i+3 & 6 \\ 0 & 2*i+5 &
  13120. 5*i+1 & 2*i+1 \\ 0 & 0 & 8 & i \\ 0 & 0 & 0& 5*i+9
  13121. \end{array} \right)
  13122. \end{array}
  13123. \end{math}
  13124. \end{flushleft}
  13125. {\tt TOEPLITZ}\ttindex{TOEPLITZ} creates the Toeplitz matrix from the
  13126. given expression list. This is a square symmetric matrix in which the
  13127. first expression is placed on the diagonal and the $i^{th}$
  13128. expression is placed on the $(i-1)^{th}$ sub- and super-diagonals.
  13129. It has dimension equal to the number of expressions.
  13130. \begin{flushleft}
  13131. \begin{math}
  13132. \begin{array}{ccc}
  13133. {\tt toeplitz}(\{w,x,y,z\}) & = &
  13134. \left( \begin{array}{cccc} w & x & y & z \\ x & w & x & y \\
  13135. y & x & w & x \\ z & y & x & w
  13136. \end{array} \right)
  13137. \end{array}
  13138. \end{math}
  13139. \end{flushleft}
  13140. \f{VANDERMONDE}\ttindex{VANDERMONDE} creates the Vandermonde matrix
  13141. from the expression list; the square matrix in which the (i,$\,$j)
  13142. entry is expr\_list(i) $^{(j-1)}$.
  13143. \begin{flushleft}
  13144. \hspace*{0.1in}
  13145. \begin{math}
  13146. \begin{array}{ccc}
  13147. {\tt vandermonde}(\{x,2*y,3*z\}) & = &
  13148. \left( \begin{array}{ccc} 1 & x & x^2 \\ 1 & 2*y & 4*y^2 \\ 1
  13149. & 3*z & 9*z^2
  13150. \end{array} \right)
  13151. \end{array}
  13152. \end{math}
  13153. \end{flushleft}
  13154. The direct product\index{direct product} (or tensor
  13155. product\index{tensor product}) is created by the
  13156. \f{KRONECKER\_PRODUCT}\ttindex{KRONECKER\_PRODUCT} function.
  13157. {\small\begin{verbatim}
  13158. a1 := mat((1,2),(3,4),(5,6))$
  13159. a2 := mat((1,1,1),(2,z,2),(3,3,3))$
  13160. kronecker_product(a1,a2);
  13161. \end{verbatim}}
  13162. \begin{flushleft}
  13163. \hspace*{0.1in}
  13164. \begin{math}
  13165. \begin{array}{ccc}
  13166. \left( \begin{array}{cccccc} 1 & 1 & 1 & 2 & 2 & 2 \\
  13167. 2 & z & 2 & 4 &2*z &4 \\
  13168. 3 & 3 & 3 & 6 & 6 &6 \\
  13169. 3 & 3 & 3 & 4 & 4 &4 \\
  13170. 6 & 3*z& 6 & 8 &4*z &8 \\
  13171. 9 & 9 & 9 & 12 &12 &12\\
  13172. 5 & 5 & 5 & 6 & 6 &6 \\
  13173. 10 &5*z& 10& 12 &6*z &12 \\
  13174. 15 &15 & 15& 18 &18 &18 \end{array} \right)
  13175. \end{array}
  13176. \end{math}
  13177. \end{flushleft}
  13178. \section{Higher Algorithms}
  13179. The Cholesky decomposition of a matrix can be
  13180. calculated with the function \f{CHOLESKY}. It returns \{${\cal
  13181. L,U}$\} where ${\cal L}$ is a lower matrix, ${\cal U}$ is an upper
  13182. matrix, and ${\cal A} = {\cal LU}$, and ${\cal U} = {\cal L}^T$.
  13183. Gram--Schmidt orthonormalisation can be calculated by
  13184. \f{GRAM\_SCHMIDT}\ttindex{GRAM\_SCHMIDT}. It accepts a list of
  13185. linearly independent vectors, written as lists, and returns a list of
  13186. orthogonal normalised vectors.
  13187. {\small\begin{verbatim}
  13188. gram_schmidt({{1,0,0},{1,1,0},{1,1,1}});
  13189. {{1,0,0},{0,1,0},{0,0,1}}
  13190. gram_schmidt({{1,2},{3,4}});
  13191. 1 2 2*sqrt(5) - sqrt(5)
  13192. {{---------,---------},{-----------,------------}}
  13193. sqrt(5) sqrt(5) 5 5
  13194. \end{verbatim}}
  13195. The LU decomposition of a real or imaginary matrix with numeric
  13196. entries is performed by {\tt LU\_DECOM(${\cal A}$)}.\ttindex{LU\_DECOM}
  13197. It returns \{${\cal L,U}$\} where ${\cal L}$ is a lower diagonal
  13198. matrix, ${\cal U}$ an upper diagonal matrix and ${\cal A} = {\cal LU}$.
  13199. Note: the algorithm used can swap the rows of ${\cal A}$ during
  13200. the calculation. This means that ${\cal LU}$ does not equal ${\cal
  13201. A}$ but a row equivalent of it. Due to this, {\tt lu\_decom} returns
  13202. \{${\cal L,U}$,vec\}. The call {\tt CONVERT(${\cal
  13203. A}$,vec)}\ttindex{CONVERT} will return the matrix that has been
  13204. decomposed, {\em i.e.\ } ${\cal LU} = $ {\tt convert(${\cal A}$,vec)}.
  13205. \begin{flushleft}
  13206. \hspace*{0.175in}
  13207. \begin{math}
  13208. {\cal K} = \left( \begin{array}{ccc} 1 & 3 & 5 \\ -4 & 3 & 7 \\ 8 & 6 &
  13209. 4
  13210. \end{array} \right)
  13211. \end{math}
  13212. \end{flushleft}
  13213. \begin{flushleft}
  13214. %\hspace*{0.1in}
  13215. \begin{math}
  13216. \begin{array}{cccc}
  13217. $% {\tt lu} :=
  13218. {\tt lu\_decom}$({\cal K}) & = &
  13219. \left\{
  13220. \left( \begin{array}{ccc} 8 & 0 & 0 \\ -4 & 6 & 0 \\ 1 & 2.25 &
  13221. 1.125 1 \end{array} \right),
  13222. \left( \begin{array}{ccc} 1 & 0.75 & 0.5 \\ 0 & 1 & 1.5 \\ 0 &
  13223. 0 & 1 \end{array} \right),
  13224. [\; 3 \; 2 \; 3 \; ]
  13225. \right\}
  13226. \end{array}
  13227. \end{math}
  13228. \end{flushleft}
  13229. {\tt PSEUDO\_INVERSE}\ttindex{PSEUDO\_INVERSE}, also known as the
  13230. Moore--Penrose inverse\index{Moore--Penrose inverse}, computes
  13231. the pseudo inverse of ${\cal A}$.
  13232. Given the singular value decomposition of ${\cal A}$, {\em i.e.\ }
  13233. ${\cal A} = {\cal U} \sum {\cal V}^T$, then the pseudo inverse ${\cal
  13234. A}^{-1}$ is defined by ${\cal A}^{-1} = {\cal V}^T \sum^{-1} {\cal U}$.
  13235. Thus ${\cal A}$ $ * $ {\tt pseudo\_inverse}$({\cal A}) = {\cal I}$.
  13236. \begin{flushleft}
  13237. \hspace*{0.1in}
  13238. \begin{math}
  13239. \begin{array}{ccc}
  13240. {\tt pseudo\_inverse}({\cal A}) & = &
  13241. \left( \begin{array}{cc} -0.2 & 0.1 \\ -0.05 & 0.05 \\ 0.1 & 0
  13242. \\ 0.25 & -0.05
  13243. \end{array} \right)
  13244. \end{array}
  13245. \end{math}
  13246. \end{flushleft}
  13247. \label{simplex}
  13248. The simplex linear programming algorithm\index{Simplex Algorithm} for
  13249. maximising or minimising a function subject to lineal inequalities can
  13250. be used with the function \f{SIMPLEX}\ttindex{SIMPLEX}. It requires
  13251. three arguments, the first indicates where the action is to maximising
  13252. or minimising, the second is the test expressions, and the last is a
  13253. list of linear inequalities.
  13254. It returns \{optimal value,\{ values of variables at this optimal\}\}.
  13255. The algorithm implies that all the variables are non-negative.
  13256. \begin{addtolength}{\leftskip}{0.22in}
  13257. %\begin{math}
  13258. {\tt simplex($max,x+y,\{x>=10,y>=20,x+y<=25\}$);}
  13259. %\end{math}
  13260. {\tt ***** Error in simplex: Problem has no feasible solution.}
  13261. \vspace*{0.2in}
  13262. \parbox[t]{0.96\linewidth}{\tt simplex($max,10x+5y+5.5z,\{5x+3z<=200,
  13263. x+0.1y+0.5z<=12$,\\
  13264. \hspace*{0.55in} $0.1x+0.2y+0.3z<=9, 30x+10y+50z<=1500\}$);}
  13265. \vspace*{0.1in}
  13266. {\tt $\{525.0,\{x=40.0,y=25.0,z=0\}$\}}
  13267. \end{addtolength}
  13268. {\tt SVD}\ttindex{SVD} computes the singular value decomposition of
  13269. ${\cal A}$ with numeric entries. It returns \{${\cal U},\sum,{\cal V}$\} where ${\cal A} = {\cal U}
  13270. \sum {\cal V}^T$ and $\sum = diag(\sigma_{1}, \ldots ,\sigma_{n}). \;
  13271. \sigma_{i}$ for $i= (1 \ldots n)$ are the singular values of ${\cal A}$.
  13272. The singular values of ${\cal A}$ are the non-negative square roots of
  13273. the eigenvalues of ${\cal A}^T {\cal A}$.
  13274. ${\cal U}$ and ${\cal V}$ are such that ${\cal UU}^T = {\cal VV}^T =
  13275. {\cal V}^T {\cal V} = {\cal I}_n$.
  13276. \begin{flushleft}
  13277. \hspace*{0.175in}
  13278. \begin{math}
  13279. {\cal Q} = \left( \begin{array}{cc} 1 & 3 \\ -4 & 3
  13280. \end{array} \right)
  13281. \end{math}
  13282. \end{flushleft}
  13283. \begin{eqnarray}
  13284. \hspace*{0.1in}
  13285. {\tt svd({\cal Q})} & = &
  13286. \left\{
  13287. \left( \begin{array}{cc} 0.289784 & 0.957092 \\ -0.957092 &
  13288. 0.289784 \end{array} \right), \left( \begin{array}{cc} 5.149162 & 0 \\
  13289. 0 & 2.913094 \end{array} \right), \right. \nonumber \\ & & \left. \: \;
  13290. \, \left( \begin{array}{cc} -0.687215 & 0.726453 \\ -0.726453 &
  13291. -0.687215 \end{array} \right)
  13292. \right\} \nonumber
  13293. \end{eqnarray}
  13294. {\tt TRIANG\_ADJOINT}\ttindex{TRIANG\_ADJOINT} computes the trianglarizing adjoint of
  13295. the given matrix. The triangularizing adjoint is a lower triangular matrix. The
  13296. multiplication of the triangularizing adjoint with the given matrix results in an
  13297. upper triangular matrix. The i-th entry in the diagonal of this matrix is the
  13298. determinant of the principal i-th minor of the given matrix.
  13299. \begin{flushleft}
  13300. \hspace*{0.1in}
  13301. \begin{math}
  13302. \begin{array}{ccc}
  13303. {\tt triang\_adjoint}({\cal A}) & = &
  13304. \left( \begin{array}{ccc} 1 & 0 & 0 \\ -4 & 1 & 0 \\ -3 & 6 & -3
  13305. \end{array} \right)
  13306. \end{array}
  13307. \end{math}
  13308. \end{flushleft}
  13309. The multiplication of this matrix with ${\cal A}$ results in an upper triangular matrix.
  13310. \begin{flushleft}
  13311. \hspace*{0.1in}
  13312. \begin{math}
  13313. \begin{array}{cccc}
  13314. \left( \begin{array}{ccc} 1 & 0 & 0 \\ -4 & 1 & 0 \\ -3 & 6 & -3
  13315. \end{array} \right) &
  13316. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  13317. \end{array} \right)
  13318. & = &
  13319. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 0 & -3 & -6 \\ 0 & 0 & 0
  13320. \end{array} \right)
  13321. \end{array}
  13322. \end{math}
  13323. \end{flushleft}
  13324. \section{Fast Linear Algebra}
  13325. By turning the {\tt FAST\_LA}\ttindex{FAST\_LA} switch on, the speed
  13326. of the following functions will be increased:
  13327. \begin{tabular}{l l l l}
  13328. add\_columns & add\_rows & augment\_columns & column\_dim \\
  13329. copy\_into & make\_identity & matrix\_augment & matrix\_stack\\
  13330. minor & mult\_column & mult\_row & pivot \\
  13331. remove\_columns & remove\_rows & rows\_pivot & squarep \\
  13332. stack\_rows & sub\_matrix & swap\_columns & swap\_entries\\
  13333. swap\_rows & symmetricp
  13334. \end{tabular}
  13335. The increase in speed will be insignificant unless you are making a
  13336. thousands of calls. When using this switch,
  13337. error checking is minimised, and thus illegal input may give strange
  13338. error messages.
  13339. \chapter{MATHML : MathML Interface for REDUCE }
  13340. \label{MATHML}
  13341. \typeout{{MATHML : MathML Interface for REDUCE}}
  13342. {\footnotesize
  13343. \begin{center}
  13344. Luis Alvarez-Sobreviela \\
  13345. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin \\
  13346. Takustra\"se 7 \\
  13347. D-14195 Berlin-Dahlem, Germany \\
  13348. \end{center}
  13349. }
  13350. \ttindex{MATHML}
  13351. MathML is intended to facilitate the use and re-use of mathematical and
  13352. scientific content on the Web, and for other applications such as computer
  13353. algebra systems. \\
  13354. This package contains the MathML-{\REDUCE}\ interface.
  13355. This interface provides an easy to use series of commands,
  13356. allowing to evaluate and output MathML.
  13357. The principal features of this package can be resumed as:
  13358. \begin{itemize}
  13359. \item Evaluation of MathML code. Allows {\REDUCE}\ to parse MathML expressions
  13360. and evaluate them.
  13361. \item Generation of MathML compliant code. Provides the printing of REDUCE
  13362. expressions in MathML source code, to be used directly in web page
  13363. production.
  13364. \end{itemize}
  13365. We assume that the reader is familiar with MathML. If not, the
  13366. specification\footnote{This specification is subject to change, since it is
  13367. not yet a final draft. During the two month period in which this package was
  13368. developed, the specification changed, forcing a review of the code. This
  13369. package is based on the Nov 98 version.}
  13370. is available at: \qquad {\tt http://www.w3.org/TR/WD-math/ }
  13371. The MathML-{\REDUCE} interface package is loaded by supplying {\tt load mathml;}.
  13372. \subsubsection{Switches}
  13373. There are two switches which can be used alternatively and incrementally.
  13374. These are {\tt MATHML} and {\tt BOTH}. Their use can be described as
  13375. follows:
  13376. \begin{description}
  13377. \item[{\tt mathml}:]\ttindex{MATHML} All output will be printed in MathML.
  13378. \item[{\tt both}:]\ttindex{BOTH} All output will be printed in both MathML and normal
  13379. REDUCE.
  13380. \item[{\tt web}:]\ttindex{WEB} All output will be printed within an HTML $<$embed$>$ tag.
  13381. This is for direct use in an HTML web page. Only works when {\tt mathml} is on.
  13382. \end{description}
  13383. MathML has often been said to be too verbose. If {\tt BOTH} is on, an easy
  13384. interpretation of the results is possible, improving MathML readability.
  13385. \subsubsection{Operators of Package MathML}
  13386. \begin{description}
  13387. \item[\f{mml}(filename):]\ttindex{MML} This function opens and reads the file filename
  13388. containing the MathML.
  13389. \item[\f{parseml}():]\ttindex{PARSEML} To introduce a series of valid mathml tokens you
  13390. can use this function. It takes no arguments and will prompt you to enter mathml tags
  13391. stating with $<$mathml$>$ and ending with $<$/mathml$>$. It returns an expression resulting
  13392. from evaluating the input.
  13393. \end{description}
  13394. {\bf Example}
  13395. {\small\begin{verbatim}
  13396. 1: load mathml;
  13397. 3: on both;
  13398. 3: int(2*x+1,x);;
  13399. x*(x + 1)
  13400. <mathml>
  13401. <apply><plus/>
  13402. <apply><power/>
  13403. <ci>x</ci>
  13404. <cn type="integer">2</cn>
  13405. </apply>
  13406. <ci>x</ci>
  13407. </apply>
  13408. </mathml>
  13409. 4:
  13410. \end{verbatim}}
  13411. \chapter{MODSR: Modular solve and roots}
  13412. \label{MODSR}
  13413. \typeout{{MODSR: Modular solve and roots}}
  13414. {\footnotesize
  13415. \begin{center}
  13416. Herbert Melenk \\
  13417. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  13418. Takustra\"se 7 \\
  13419. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13420. e--mail: melenk@zib.de
  13421. \end{center}
  13422. }
  13423. \ttindex{MODSR}
  13424. This package supports solve (\f{M\_SOLVE}\ttindex{M\_SOLVE}) and roots
  13425. (\f{M\_ROOTS}\ttindex{M\_ROOTS}) operators for modular polynomials and
  13426. modular polynomial systems. The moduli need not be primes. {\tt
  13427. M\_SOLVE} requires a modulus to be set. {\tt M\_ROOTS} takes the
  13428. modulus as a second argument. For example:
  13429. {\small\begin{verbatim}
  13430. on modular; setmod 8;
  13431. m_solve(2x=4); -> {{X=2},{X=6}}
  13432. m_solve({x^2-y^3=3});
  13433. -> {{X=0,Y=5}, {X=2,Y=1}, {X=4,Y=5}, {X=6,Y=1}}
  13434. m_solve({x=2,x^2-y^3=3}); -> {{X=2,Y=1}}
  13435. off modular;
  13436. m_roots(x^2-1,8); -> {1,3,5,7}
  13437. m_roots(x^3-x,7); -> {0,1,6}
  13438. \end{verbatim}}
  13439. \chapter[MRVLIMIT: Limits of ``exp-log'' functions]%
  13440. {MRVLIMIT: Package for Computing Limits of "Exp-Log" Functions}
  13441. \label{MRVLIMIT}
  13442. \typeout{{MRVLIMIT: Package for Computing Limits of "Exp-Log" Functions}}
  13443. {\footnotesize
  13444. \begin{center}
  13445. Neil Langmead \\
  13446. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin (ZIB) \\
  13447. Takustra\"se 7 \\
  13448. D - 14195 Berlin-Dahlem, Germany \\
  13449. \end{center}
  13450. }
  13451. \ttindex{MRVLIMIT}
  13452. %\markboth{CHAPTER \ref{MRVLIMIT}. MRVLIMIT: LIMITS OF ``EXP-LOG'' FUNCTIONS}{}
  13453. %\thispagestyle{myheadings}
  13454. Using the LIMITS package to compute the limits of functions containing
  13455. exponential and logarithmic expressions may raise a problem. For the computation
  13456. of indefinite forms (such as $0/0$,or $\frac{\infty}{\infty}$) L'Hospital's
  13457. rule may only be applied a finite number of times in a CAS. In REDUCE it is
  13458. applied 3 times. This algorithm of Dominik Gruntz of the ETH Z\"urich
  13459. solves this particular problem, and enables the computation of many more
  13460. limit calculations in REDUCE.
  13461. {\small\begin{verbatim}
  13462. 1: load limits;
  13463. 2: limit(x^7/e^x,x,infinity);
  13464. 7
  13465. x
  13466. limit(----,x,infinity)
  13467. x
  13468. e
  13469. 3: load mrvlimit;
  13470. 4: mrv_limit(x^7/e^x,x,infinity);
  13471. 0
  13472. \end{verbatim}}
  13473. For this example, the MRVLIMIT package is able to compute the correct limit. \\
  13474. \ttindex{MRV\_LIMIT}
  13475. \vspace{.1in}
  13476. \noindent {\tt MRV\_LIMIT}(EXPRN:{\em algebraic}, VAR:{\em kernel},
  13477. LIMPOINT:{\em algebraic}):{\em algebraic} \ttindex{MRV\_LIMIT} \par
  13478. The result is the limit of EXPRN as VAR approaches LIMPOINT.
  13479. \vspace{.1in}
  13480. A switch {\tt TRACELIMIT} is available to inform the user about the computed
  13481. Taylor expansion, all recursive calls and the return value of the
  13482. internally called function {\tt MRV}. \\
  13483. \\
  13484. {\bf Examples}:
  13485. \\
  13486. {\small\begin{verbatim}
  13487. 5: b:=e^x*(e^(1/x-e^-x)-e^(1/x));
  13488. -1 - x
  13489. x + x - e
  13490. b:= e *(e - 1)
  13491. 6: mrv_limit(b,x,infinity);
  13492. -1
  13493. -1
  13494. 7: ex:= - log(log(log(log(x))) + log(x)) *log(x)
  13495. *(log(log(x)) - log(log(log(x)) + log(x)));
  13496. - log(x)*(log(log(x)) - log(log(log(x)) + log(x)))
  13497. ex:= -----------------------------------------------------
  13498. log(log(log(log(x))) + log(x))
  13499. 8: off mcd;
  13500. 9: mrv_limit(ex,x,infinity);
  13501. 1
  13502. \end{verbatim}}
  13503. \chapter[NCPOLY: Ideals in non--comm case]%
  13504. {NCPOLY: Non--commutative polynomial ideals}
  13505. \label{NCPOLY}
  13506. \typeout{{NCPOLY: Non--commutative polynomial ideals}}
  13507. {\footnotesize
  13508. \begin{center}
  13509. Herbert Melenk\\
  13510. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  13511. Takustra\"se 7 \\
  13512. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13513. e--mail: melenk@zib.de \\[0.1in]
  13514. Joachim Apel\\
  13515. Institut f\"ur Informatik, Universit\"at Leipzig \\
  13516. Augustusplatz 10--11\\
  13517. D--04109 Leipzig, Germany \\[0.05in]
  13518. e--mail: apel@informatik.uni--leipzig.de
  13519. \end{center}
  13520. }
  13521. \ttindex{NCPOLY}\index{Groebner Bases}
  13522. \REDUCE\ supports a very general mechanism for computing with objects
  13523. under a non--commutative multiplication, where commutator relations
  13524. must be introduced explicitly by rule sets when needed. The package
  13525. {\bf NCPOLY} allows the user to set up automatically a consistent
  13526. environment for computing in an algebra where the non--commutativity
  13527. is defined by Lie-bracket commutators. The package uses the \REDUCE\
  13528. {\bf noncom} mechanism for elementary polynomial arithmetic; the
  13529. commutator rules are automatically computed from the Lie brackets.
  13530. Polynomial arithmetic may be performed directly, including {\bf
  13531. division} and {\bf factorisation}. Additionally {\bf NCPOLY} supports
  13532. computations in a one sided ideal (left or right), especially one
  13533. sided {\bf Gr\"obner} bases and {\bf polynomial reduction}.
  13534. \section{Setup, Cleanup}
  13535. Before the computations can start the environment for a
  13536. non--commutative computation must be defined by a
  13537. call to {\tt nc\_setup}:\ttindex{nc\_setup}
  13538. {\small\begin{verbatim}
  13539. nc_setup(<vars>[,<comms>][,<dir>]);
  13540. \end{verbatim}}
  13541. where
  13542. $<vars>$ is a list of variables; these must include the
  13543. non--commutative quantities.
  13544. $<comms>$ is a list of equations \verb&<u>*<v> - <v>*<u>=<rh>&
  13545. where $<u>$ and $<v>$ are members of $<vars>$, and $<rh>$ is
  13546. a polynomial.
  13547. $<dir>$ is either $left$ or $right$ selecting a left or a
  13548. right one sided ideal. The initial direction is $left$.
  13549. {\tt nc\_setup} generates from $<comms>$ the necessary
  13550. rules to support an algebra where all monomials are
  13551. ordered corresponding to the given variable sequence.
  13552. All pairs of variables which are not explicitly covered in
  13553. the commutator set are considered as commutative and the
  13554. corresponding rules are also activated.
  13555. The second parameter in {\tt nc\_setup} may be
  13556. omitted if the operator is called for the second time,
  13557. {\em e.g.\ } with a reordered variable sequence. In such a case
  13558. the last commutator set is used again.
  13559. Remarks: \begin{itemize}
  13560. \item The variables need not be declared {\bf noncom} -
  13561. {\bf nc\_setup} performs all necessary declarations.
  13562. \item The variables need not be formal operator expressions;
  13563. {\bf nc\_setup} encapsulates a variable $x$ internally
  13564. as \verb+nc!*(!_x)+ expressions anyway where the operator $nc!*$
  13565. keeps the noncom property.
  13566. \item The commands {\bf order} and {\bf korder} should be avoided
  13567. because {\bf nc\_setup} sets these such that the computation
  13568. results are printed in the correct term order.
  13569. \end{itemize}
  13570. Example:
  13571. {\small\begin{verbatim}
  13572. nc_setup({KK,NN,k,n},
  13573. {NN*n-n*NN= NN, KK*k-k*KK= KK});
  13574. NN*N; -> NN*N
  13575. N*NN; -> NN*N - NN
  13576. nc_setup({k,n,KK,NN});
  13577. NN*N - NN -> N*NN;
  13578. \end{verbatim}}
  13579. Here $KK,NN,k,n$ are non--commutative variables where
  13580. the commutators are described as $[NN,n]=NN$, $[KK,k]=KK$.
  13581. The current term order must be compatible with the commutators:
  13582. the product $<u>*<v>$ must precede all terms on the right hand
  13583. side $<rh>$ under the current term order. Consequently
  13584. \begin{itemize}
  13585. \item the maximal degree of $<u>$ or $<v>$ in $<rh>$ is 1,
  13586. \item in a total degree ordering the total degree of $<rh>$ may be not
  13587. higher than 1,
  13588. \item in an elimination degree order ({\em e.g.\ }$lex$) all variables in
  13589. $<rh>$ must be below the minimum of $<u>$ and $<v>$.
  13590. \item If $<rh>$ does not contain any variables or has at most $<u>$ or
  13591. $<v>$, any term order can be selected.
  13592. \end{itemize}
  13593. To use the non--commutative variables or results from
  13594. non--commutative computations later in commutative operations
  13595. it might be necessary to switch off the non--commutative
  13596. evaluation mode because not
  13597. all operators in \REDUCE\ are prepared for that environment. In
  13598. such a case use the command\ttindex{nc\_cleanup}
  13599. {\small\begin{verbatim}
  13600. nc_cleanup;
  13601. \end{verbatim}}
  13602. without parameters. It removes all internal rules and definitions
  13603. which {\tt nc\_setup} had introduced. To reactive non--commutative
  13604. call {\tt nc\_setup} again.
  13605. \section{Left and right ideals}
  13606. A (polynomial) left ideal $L$ is defined by the axioms
  13607. $u \in L, v \in L \Longrightarrow u+v \in L$
  13608. $u \in L \Longrightarrow k*u \in L$ for an arbitrary polynomial $k$
  13609. where ``*'' is the non--commutative multiplication. Correspondingly,
  13610. a right ideal $R$ is defined by
  13611. $u \in R, v \in R \Longrightarrow u+v \in R$
  13612. $u \in R \Longrightarrow u*k \in R$ for an arbitrary polynomial $k$
  13613. \section{Gr\"obner bases}
  13614. When a non--commutative environment has been set up
  13615. by {\tt nc\_setup}, a basis for a left or right polynomial ideal
  13616. can be transformed into a Gr\"obner basis by the operator
  13617. {\tt nc\_groebner}\ttindex{nc\_groebner}
  13618. {\small\begin{verbatim}
  13619. nc_groebner(<plist>);
  13620. \end{verbatim}}
  13621. Note that the variable set and variable sequence must be
  13622. defined before in the {\tt nc\_setup} call. The term order
  13623. for the Gr\"obner calculation can be set by using the
  13624. {\tt torder} declaration.
  13625. For details about {\tt torder}
  13626. see the {\bf \REDUCE\ GROEBNER} manual, or chapter~\ref{GROEBNER}.
  13627. {\small\begin{verbatim}
  13628. 2: nc_setup({k,n,NN,KK},{NN*n-n*NN=NN,KK*k-k*KK=KK},left);
  13629. 3: p1 := (n-k+1)*NN - (n+1);
  13630. p1 := - k*nn + n*nn - n + nn - 1
  13631. 4: p2 := (k+1)*KK -(n-k);
  13632. p2 := k*kk + k - n + kk
  13633. 5: nc_groebner ({p1,p2});
  13634. {k*nn - n*nn + n - nn + 1,
  13635. k*kk + k - n + kk,
  13636. n*nn*kk - n*kk - n + nn*kk - kk - 1}
  13637. \end{verbatim}}
  13638. Important: Do not use the operators of the GROEBNER
  13639. package directly as they would not consider the non--commutative
  13640. multiplication.
  13641. \section{Left or right polynomial division}
  13642. The operator {\tt nc\_divide}\ttindex{nc\_divide} computes the one
  13643. sided quotient and remainder of two polynomials:
  13644. {\small\begin{verbatim}
  13645. nc_divide(<p1>,<p2>);
  13646. \end{verbatim}}
  13647. The result is a list with quotient and remainder.
  13648. The division is performed as a pseudo--division, multiplying
  13649. $<p1>$ by coefficients if necessary. The result $\{<q>,<r>\}$
  13650. is defined by the relation
  13651. $<c>*<p1>=<q>*<p2> + <r>$ for direction $left$ and
  13652. $<c>*<p1>=<p2>*<q> + <r>$ for direction $right$,
  13653. where $<c>$ is an expression that does not contain any of the
  13654. ideal variables, and the leading term of $<r>$ is lower than
  13655. the leading term of $<p2>$ according to the actual term order.
  13656. \section{Left or right polynomial reduction}
  13657. For the computation of the one sided remainder of a polynomial
  13658. modulo a given set of other polynomials the operator
  13659. {\tt nc\_preduce} may be used:\ttindex{nc\_preduce}
  13660. {\small\begin{verbatim}
  13661. nc_preduce(<polynomial>,<plist>);
  13662. \end{verbatim}}
  13663. The result of the reduction is unique (canonical) if
  13664. and only if $<plist>$ is a one sided Gr\"obner basis.
  13665. Then the computation is at the same time an ideal
  13666. membership test: if the result is zero, the
  13667. polynomial is member of the ideal, otherwise not.
  13668. \section{Factorisation}
  13669. Polynomials in a non--commutative ring cannot be factored
  13670. using the ordinary {\tt factorize} command of \REDUCE.
  13671. Instead one of the operators of this section must be
  13672. used:\ttindex{nc\_factorize}
  13673. {\small\begin{verbatim}
  13674. nc_factorize(<polynomial>);
  13675. \end{verbatim}}
  13676. The result is a list of factors of $<polynomial>$. A list
  13677. with the input expression is returned if it is irreducible.
  13678. As non--commutative factorisation is not unique, there is
  13679. an additional operator which computes all possible
  13680. factorisations\ttindex{nc\_factorize\_all}
  13681. {\small\begin{verbatim}
  13682. nc_factorize_all(<polynomial>);
  13683. \end{verbatim}}
  13684. The result is a list of factor decompositions of $<polynomial>$.
  13685. If there are no factors at all the result list has only one
  13686. member which is a list containing the input polynomial.
  13687. \section{Output of expressions}
  13688. It is often desirable to have the commutative parts (coefficients)
  13689. in a non--commutative operation condensed by factorisation. The
  13690. operator\ttindex{nc\_compact}
  13691. {\small\begin{verbatim}
  13692. nc_compact(<polynomial>)
  13693. \end{verbatim}}
  13694. collects the coefficients to the powers of the lowest possible
  13695. non-commutative variable.
  13696. {\small\begin{verbatim}
  13697. load_package ncpoly;
  13698. nc_setup({n,NN},{NN*n-n*NN=NN})$
  13699. p1 := n**4 + n**2*nn + 4*n**2 + 4*n*nn + 4*nn + 4;
  13700. 4 2 2
  13701. p1 := n + n *nn + 4*n + 4*n*nn + 4*nn + 4
  13702. nc_compact p1;
  13703. 2 2 2
  13704. (n + 2) + (n + 2) *nn
  13705. \end{verbatim}}
  13706. \chapter[NORMFORM: matrix normal forms]%
  13707. {NORMFORM: Computation of matrix normal forms}
  13708. \label{NORMFORM}
  13709. \typeout{{NORMFORM: Computation of matrix normal forms}}
  13710. {\footnotesize
  13711. \begin{center}
  13712. Matt Rebbeck \\
  13713. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  13714. Takustra\"se 7 \\
  13715. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13716. \end{center}
  13717. }
  13718. \ttindex{NORMFORM}
  13719. This package contains routines for computing the following
  13720. normal forms of matrices:
  13721. \begin{itemize}
  13722. \item smithex\_int
  13723. \item smithex
  13724. \item frobenius
  13725. \item ratjordan
  13726. \item jordansymbolic
  13727. \item jordan.
  13728. \end{itemize}
  13729. By default all calculations are carried out in ${\cal Q}$ (the rational
  13730. numbers). For {\tt smithex}, {\tt frobenius}, {\tt ratjordan},
  13731. {\tt jordansymbolic}, and {\tt jordan}, this field can be extended to
  13732. an algebraic number field using ARNUM (chapter~\ref{ARNUM}).
  13733. The {\tt frobenius}, {\tt ratjordan}, and {\tt jordansymbolic} normal
  13734. forms can also be computed in a modular base.
  13735. \section{Smithex}
  13736. \ttindex{smithex}
  13737. {\tt Smithex}(${\cal A},\, x$) computes the Smith normal form ${\cal S}$
  13738. of the matrix ${\cal A}$.
  13739. It returns \{${\cal S}, {\cal P}, {\cal P}^{-1}$\} where ${\cal S},
  13740. {\cal P}$, and ${\cal P}^{-1}$ are such that
  13741. ${\cal P S P}^{-1} = {\cal A}$.
  13742. ${\cal A}$ is a rectangular matrix of univariate polynomials in $x$
  13743. where $x$ is the variable name.
  13744. {\tt load\_package normform;}
  13745. \begin{displaymath}
  13746. {\cal A} = \left( \begin{array}{cc} x & x+1 \\ 0 & 3*x^2 \end{array}
  13747. \right)
  13748. \end{displaymath}
  13749. \begin{displaymath}
  13750. \hspace{-0.5in}
  13751. \begin{array}{ccc}
  13752. {\tt smithex}({\cal A},\, x) & = &
  13753. \left\{ \left( \begin{array}{cc} 1 & 0 \\
  13754. 0 & x^3 \end{array} \right), \left( \begin{array}{cc} 1 & 0 \\ 3*x^2
  13755. & 1 \end{array} \right), \left( \begin{array}{cc} x & x+1 \\ -3 & -3
  13756. \end{array} \right) \right\} \end{array}
  13757. \end{displaymath}
  13758. \section{Smithex\_int}
  13759. \ttindex{smithex\_int}
  13760. Given an $n$ by $m$ rectangular matrix ${\cal A}$ that contains
  13761. {\it only} integer entries, {\tt smithex\_int}(${\cal A}$) computes the
  13762. Smith normal form ${\cal S}$ of ${\cal A}$.
  13763. It returns \{${\cal S}, {\cal P}, {\cal P}^{-1}$\} where ${\cal S},
  13764. {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P S P}^{-1} =
  13765. {\cal A}$.
  13766. {\tt load\_package normform;}
  13767. \begin{displaymath}
  13768. {\cal A} = \left( \begin{array}{ccc} 9 & -36 & 30 \\ -36 & 192 & -180 \\
  13769. 30 & -180 & 180 \end{array}
  13770. \right)
  13771. \end{displaymath}
  13772. {\tt smithex\_int}(${\cal A}$) =
  13773. \begin{center}
  13774. \begin{displaymath}
  13775. \left\{ \left( \begin{array}{ccc} 3 & 0 & 0 \\ 0 & 12 & 0 \\ 0 & 0 & 60
  13776. \end{array} \right), \left( \begin{array}{ccc} -17 & -5 & -4 \\ 64 & 19
  13777. & 15 \\ -50 & -15 & -12 \end{array} \right), \left( \begin{array}{ccc}
  13778. 1 & -24 & 30 \\ -1 & 25 & -30 \\ 0 & -1 & 1 \end{array} \right) \right\}
  13779. \end{displaymath}
  13780. \end{center}
  13781. \section{Frobenius}
  13782. \ttindex{frobenius}
  13783. {\tt Frobenius}(${\cal A}$) computes the Frobenius normal form
  13784. ${\cal F}$ of the matrix ${\cal A}$.
  13785. It returns \{${\cal F}, {\cal P}, {\cal P}^{-1}$\} where ${\cal F},
  13786. {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P F P}^{-1} =
  13787. {\cal A}$.
  13788. ${\cal A}$ is a square matrix.
  13789. {\tt load\_package normform;}
  13790. \begin{displaymath}
  13791. {\cal A} = \left( \begin{array}{cc} \frac{-x^2+y^2+y}{y} &
  13792. \frac{-x^2+x+y^2-y}{y} \\ \frac{-x^2-x+y^2+y}{y} & \frac{-x^2+x+y^2-y}
  13793. {y} \end{array} \right)
  13794. \end{displaymath}
  13795. {\tt frobenius}(${\cal A}$) =
  13796. \begin{center}
  13797. \begin{displaymath}
  13798. \left\{ \left( \begin{array}{cc} 0 & \frac{x*(x^2-x-y^2+y)}{y} \\ 1 &
  13799. \frac{-2*x^2+x+2*y^2}{y} \end{array} \right), \left( \begin{array}{cc}
  13800. 1 & \frac{-x^2+y^2+y}{y} \\ 0 & \frac{-x^2-x+y^2+y}{y} \end{array}
  13801. \right), \left( \begin{array}{cc} 1 & \frac{-x^2+y^2+y}{x^2+x-y^2-y} \\
  13802. 0 & \frac{-y}{x^2+x-y^2-y} \end{array} \right) \right\}
  13803. \end{displaymath}
  13804. \end{center}
  13805. \section{Ratjordan}
  13806. \ttindex{ratjordan}
  13807. {\tt Ratjordan}(${\cal A}$) computes the rational Jordan normal form
  13808. ${\cal R}$ of the matrix ${\cal A}$.
  13809. It returns \{${\cal R}, {\cal P}, {\cal P}^{-1}$\} where ${\cal R},
  13810. {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P R P}^{-1} =
  13811. {\cal A}$.
  13812. ${\cal A}$ is a square matrix.
  13813. {\tt load\_package normform;}
  13814. \begin{displaymath}
  13815. {\cal A} = \left( \begin{array}{cc} x+y & 5 \\ y & x^2 \end{array}
  13816. \right)
  13817. \end{displaymath}
  13818. {\tt ratjordan}(${\cal A}$) =
  13819. \begin{center}
  13820. \begin{displaymath}
  13821. \left\{ \left( \begin{array}{cc} 0 & -x^3-x^2*y+5*y \\ 1 &
  13822. x^2+x+y \end{array} \right), \left( \begin{array}{cc}
  13823. 1 & x+y \\ 0 & y \end{array} \right), \left( \begin{array}{cc} 1 &
  13824. \frac{-(x+y)}{y} \\ 0 & \hspace{0.2in} \frac{1}{y} \end{array} \right)
  13825. \right\}
  13826. \end{displaymath}
  13827. \end{center}
  13828. \section{Jordansymbolic}
  13829. \ttindex{jordansymbolic}
  13830. {\tt Jordansymbolic}(${\cal A}$) \hspace{0in} computes the Jordan
  13831. normal form ${\cal J}$of the matrix ${\cal A}$.
  13832. It returns \{${\cal J}, {\cal L}, {\cal P}, {\cal P}^{-1}$\}, where
  13833. ${\cal J}, {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P J P}^
  13834. {-1} = {\cal A}$. ${\cal L}$ = \{~{\it ll},~$\xi$~\}, where $\xi$ is
  13835. a name and {\it ll} is a list of irreducible factors of ${\it p}(\xi)$.
  13836. ${\cal A}$ is a square matrix.
  13837. {\tt load\_package normform;}\\
  13838. \begin{displaymath}
  13839. {\cal A} = \left( \begin{array}{cc} 1 & y \\ y^2 & 3 \end{array}
  13840. \right)
  13841. \end{displaymath}
  13842. {\tt jordansymbolic}(${\cal A}$) =
  13843. \begin{eqnarray}
  13844. & & \left\{ \left( \begin{array}{cc} \xi_{11} & 0 \\ 0 & \xi_{12}
  13845. \end{array} \right) ,
  13846. \left\{ \left\{ -y^3+\xi^2-4*\xi+3 \right\}, \xi \right\}, \right.
  13847. \nonumber \\ & & \hspace{0.1in} \left. \left( \begin{array}{cc}
  13848. \xi_{11} -3 & \xi_{12} -3 \\ y^2 & y^2
  13849. \end{array} \right), \left( \begin{array}{cc} \frac{\xi_{11} -2}
  13850. {2*(y^3-1)} & \frac{\xi_{11} + y^3 -1}{2*y^2*(y^3+1)} \\
  13851. \frac{\xi_{12} -2}{2*(y^3-1)} & \frac{\xi_{12}+y^3-1}{2*y^2*(y^3+1)}
  13852. \end{array} \right) \right\} \nonumber
  13853. \end{eqnarray}
  13854. \vspace{0.2in}
  13855. \begin{flushleft}
  13856. \begin{math}
  13857. {\tt solve(-y^3+xi^2-4*xi+3,xi)}${\tt ;}$
  13858. \end{math}
  13859. \end{flushleft}
  13860. \vspace{0.1in}
  13861. \begin{center}
  13862. \begin{math}
  13863. \{ \xi = \sqrt{y^3+1} + 2,\, \xi = -\sqrt{y^3+1}+2 \}
  13864. \end{math}
  13865. \end{center}
  13866. \vspace{0.1in}
  13867. \begin{math}
  13868. {\tt {\cal J} = sub}{\tt (}{\tt \{ xi(1,1)=sqrt(y^3+1)+2,\, xi(1,2) =
  13869. -sqrt(y^3+1)+2\},}
  13870. \end{math}
  13871. \\ \hspace*{0.29in} {\tt first jordansymbolic (${\cal A}$));}
  13872. \vspace{0.2in}
  13873. \begin{displaymath}
  13874. {\cal J} = \left( \begin{array}{cc} \sqrt{y^3+1} + 2 & 0 \\ 0 &
  13875. -\sqrt{y^3+1} + 2 \end{array} \right)
  13876. \end{displaymath}
  13877. \section{Jordan}
  13878. \ttindex{jordan}
  13879. {\tt Jordan}(${\cal A}$) computes the Jordan normal form
  13880. ${\cal J}$ of the matrix ${\cal A}$.
  13881. It returns \{${\cal J}, {\cal P}, {\cal P}^{-1}$\}, where
  13882. ${\cal J}, {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P J P}^
  13883. {-1} = {\cal A}$.
  13884. ${\cal A}$ is a square matrix.
  13885. {\tt load\_package normform;}
  13886. \begin{displaymath}
  13887. {\cal A} = \left( \begin{array}{cccccc} -9 & -21 & -15 & 4 & 2 & 0 \\
  13888. -10 & 21 & -14 & 4 & 2 & 0 \\ -8 & 16 & -11 & 4 & 2 & 0 \\ -6 & 12 & -9
  13889. & 3 & 3 & 0 \\ -4 & 8 & -6 & 0 & 5 & 0 \\ -2 & 4 & -3 & 0 & 1 & 3
  13890. \end{array} \right)
  13891. \end{displaymath}
  13892. \begin{flushleft}
  13893. {\tt ${\cal J}$ = first jordan$({\cal A})$;}
  13894. \end{flushleft}
  13895. \begin{displaymath}
  13896. {\cal J} = \left( \begin{array}{cccccc} 3 & 0 & 0 & 0 & 0 & 0 \\ 0 & 3
  13897. & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\
  13898. 0 & 0 & 0 & 0 & i+2 & 0 \\ 0 & 0 & 0 & 0 & 0 & -i+2
  13899. \end{array} \right)
  13900. \end{displaymath}
  13901. \chapter{NUMERIC: Solving numerical problems}
  13902. \label{NUMERIC}
  13903. \typeout{{NUMERIC: Solving numerical problems}}
  13904. {\footnotesize
  13905. \begin{center}
  13906. Herbert Melenk \\
  13907. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  13908. Takustra\"se 7 \\
  13909. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13910. e--mail: melenk@zib.de
  13911. \end{center}
  13912. }
  13913. \ttindex{NUMERIC}
  13914. \ttindex{NUM\_SOLVE}\index{Newton's method}\ttindex{NUM\_ODESOLVE}
  13915. \ttindex{BOUNDS}\index{Chebyshev fit}
  13916. \ttindex{NUM\_MIN}\index{Minimum}\ttindex{NUM\_INT}\index{Quadrature}
  13917. The {\small NUMERIC} package implements some numerical (approximative)
  13918. algorithms for \REDUCE\, based on the \REDUCE\ rounded mode
  13919. arithmetic. These algorithms are implemented for standard cases. They
  13920. should not be called for ill-conditioned problems; please use standard
  13921. mathematical libraries for these.
  13922. \section{Syntax}
  13923. \subsection{Intervals, Starting Points}
  13924. Intervals are generally coded as lower bound and
  13925. upper bound connected by the operator \verb+`..'+, usually
  13926. associated to a variable in an
  13927. equation.\index{Interval}
  13928. {\small\begin{verbatim}
  13929. x= (2.5 .. 3.5)
  13930. \end{verbatim}}
  13931. means that the variable x is taken in the range from 2.5 up to
  13932. 3.5. Note, that the bounds can be algebraic
  13933. expressions, which, however, must evaluate to numeric results.
  13934. In cases where an interval is returned as the result, the lower
  13935. and upper bounds can be extracted by the \verb+PART+ operator
  13936. as the first and second part respectively.
  13937. A starting point is specified by an equation with a numeric
  13938. righthand side,
  13939. {\small\begin{verbatim}
  13940. x=3.0
  13941. \end{verbatim}}
  13942. If for multivariate applications several coordinates must be
  13943. specified by intervals or as a starting point, these
  13944. specifications can be collected in one parameter (which is then
  13945. a list) or they can be given as separate parameters
  13946. alternatively. The list form is more appropriate when the
  13947. parameters are built from other \REDUCE\ calculations in an
  13948. automatic style, while the flat form is more convenient
  13949. for direct interactive input.
  13950. \subsection{Accuracy Control}
  13951. The keyword parameters $accuracy=a$ and $iterations=i$, where
  13952. $a$ and $i$ must be positive integer numbers, control the
  13953. iterative algorithms: the iteration is continued until
  13954. the local error is below $10^{-a}$; if that is impossible
  13955. within $i$ steps, the iteration is terminated with an
  13956. error message. The values reached so far are then returned
  13957. as the result.
  13958. \section{Minima}
  13959. The function to be minimised must have continuous partial derivatives
  13960. with respect to all variables. The starting point of the search can
  13961. be specified; if not, random values are taken instead. The steepest
  13962. descent algorithms in general find only local minima.
  13963. Syntax:\ttindex{NUM\_MIN}
  13964. \begin{description}
  13965. \item[NUM\_MIN] $(exp, var_1[=val_1] [,var_2[=val_2] \ldots]$
  13966. $ [,accuracy=a][,iterations=i]) $
  13967. or
  13968. \item[NUM\_MIN] $(exp, \{ var_1[=val_1] [,var_2[=val_2] \ldots] \}$
  13969. $ [,accuracy=a][,iterations=i]) $
  13970. where $exp$ is a function expression,
  13971. $var_1, var_2, \ldots$ are the variables in $exp$ and
  13972. $val_1,val_2, \ldots$ are the (optional) start values.
  13973. NUM\_MIN tries to find the next local minimum along the descending
  13974. path starting at the given point. The result is a list
  13975. with the minimum function value as first element followed by a list
  13976. of equations, where the variables are equated to the coordinates
  13977. of the result point.
  13978. \end{description}
  13979. Examples:
  13980. {\small\begin{verbatim}
  13981. num_min(sin(x)+x/5, x);
  13982. {4.9489585606,{X=29.643767785}}
  13983. num_min(sin(x)+x/5, x=0);
  13984. { - 1.3342267466,{X= - 1.7721582671}}
  13985. % Rosenbrock function (well known as hard to minimize).
  13986. fktn := 100*(x1**2-x2)**2 + (1-x1)**2;
  13987. num_min(fktn, x1=-1.2, x2=1, iterations=200);
  13988. {0.00000021870228295,{X1=0.99953284494,X2=0.99906807238}}
  13989. \end{verbatim}}
  13990. \section{Roots of Functions/ Solutions of Equations}
  13991. An adaptively damped Newton iteration is used to find an approximative
  13992. zero of a function, a function vector or the solution of an equation
  13993. or an equation system. The expressions must have continuous
  13994. derivatives for all variables. A starting point for the iteration can
  13995. be given. If not given, random values are taken instead. If the number
  13996. of forms is not equal to the number of variables, the Newton method
  13997. cannot be applied. Then the minimum of the sum of absolute squares is
  13998. located instead.
  13999. With {\tt ON COMPLEX} solutions with imaginary parts can be
  14000. found, if either the expression(s) or the starting point
  14001. contain a nonzero imaginary part.
  14002. Syntax:\ttindex{NUM\_SOLVE}
  14003. \begin{description}
  14004. \item[NUM\_SOLVE] $(exp_1, var_1[=val_1][,accuracy=a][,iterations=i])$
  14005. or
  14006. \item[NUM\_SOLVE] $(\{exp_1,\ldots,exp_n\},
  14007. var_1[=val_1],\ldots,var_1[=val_n]$
  14008. \item[\ \ \ \ \ \ \ \ ]$[,accuracy=a][,iterations=i])$
  14009. or
  14010. \item[NUM\_SOLVE] $(\{exp_1,\ldots,exp_n\},
  14011. \{var_1[=val_1],\ldots,var_1[=val_n]\}$
  14012. \item[\ \ \ \ \ \ \ \ ]$[,accuracy=a][,iterations=i])$
  14013. where $exp_1, \ldots,exp_n$ are function expressions,
  14014. $var_1, \ldots, var_n$ are the variables,
  14015. $val_1, \ldots, val_n$ are optional start values.
  14016. NUM\_SOLVE tries to find a zero/solution of the expression(s).
  14017. Result is a list of equations, where the variables are
  14018. equated to the coordinates of the result point.
  14019. The Jacobian matrix is stored as a side effect in the shared
  14020. variable JACOBIAN.\ttindex{JACOBIAN}
  14021. \end{description}
  14022. Example:
  14023. {\small\begin{verbatim}
  14024. num_solve({sin x=cos y, x + y = 1},{x=1,y=2});
  14025. {X= - 1.8561957251,Y=2.856195584}
  14026. jacobian;
  14027. [COS(X) SIN(Y)]
  14028. [ ]
  14029. [ 1 1 ]
  14030. \end{verbatim}}
  14031. \section{Integrals}
  14032. Numerical integration uses a polyalgorithm, explained in the full
  14033. documentation.\ttindex{NUM\_INT}
  14034. \begin{description}
  14035. \item[NUM\_INT] $(exp,var_1=(l_1 .. u_1)[,var_2=(l_2 .. u_2)\ldots]$
  14036. \item[\ \ \ \ \ \ ]$[,accuracy=a][,iterations=i])$
  14037. where $exp$ is the function to be integrated,
  14038. $var_1, var_2 , \ldots$ are the integration variables,
  14039. $l_1, l_2 , \ldots$ are the lower bounds,
  14040. $u_1, u_2 , \ldots$ are the upper bounds.
  14041. Result is the value of the integral.
  14042. \end{description}
  14043. Example:
  14044. {\small\begin{verbatim}
  14045. num_int(sin x,x=(0 .. pi));
  14046. 2.0000010334
  14047. \end{verbatim}}
  14048. \section{Ordinary Differential Equations}
  14049. A Runge-Kutta method of order 3 finds an approximate graph for
  14050. the solution of a ordinary differential equation
  14051. real initial value problem.
  14052. Syntax:\ttindex{NUM\_ODESOLVE}
  14053. \begin{description}
  14054. \item[NUM\_ODESOLVE]($exp$,$depvar=dv$,$indepvar$=$(from .. to)$
  14055. $ [,accuracy=a][,iterations=i]) $
  14056. where
  14057. $exp$ is the differential expression/equation,
  14058. $depvar$ is an identifier representing the dependent variable
  14059. (function to be found),
  14060. $indepvar$ is an identifier representing the independent variable,
  14061. $exp$ is an equation (or an expression implicitly set to zero) which
  14062. contains the first derivative of $depvar$ wrt $indepvar$,
  14063. $from$ is the starting point of integration,
  14064. $to$ is the endpoint of integration (allowed to be below $from$),
  14065. $dv$ is the initial value of $depvar$ in the point $indepvar=from$.
  14066. The ODE $exp$ is converted into an explicit form, which then is
  14067. used for a Runge-Kutta iteration over the given range. The
  14068. number of steps is controlled by the value of $i$
  14069. (default: 20).
  14070. If the steps are too coarse to reach the desired
  14071. accuracy in the neighbourhood of the starting point, the number is
  14072. increased automatically.
  14073. Result is a list of pairs, each representing a point of the
  14074. approximate solution of the ODE problem.
  14075. \end{description}
  14076. Example:
  14077. {\small\begin{verbatim}
  14078. num_odesolve(df(y,x)=y,y=1,x=(0 .. 1), iterations=5);
  14079. {{0.0,1.0},{0.2,1.2214},{0.4,1.49181796},{0.6,1.8221064563},
  14080. {0.8,2.2255208258},{1.0,2.7182511366}}
  14081. \end{verbatim}}
  14082. \section{Bounds of a Function}
  14083. Upper and lower bounds of a real valued function over an
  14084. interval or a rectangular multivariate domain are computed
  14085. by the operator \f{BOUNDS}. Some knowledge
  14086. about the behaviour of special functions like ABS, SIN, COS, EXP, LOG,
  14087. fractional exponentials etc. is integrated and can be evaluated
  14088. if the operator BOUNDS is called with rounded mode on
  14089. (otherwise only algebraic evaluation rules are available).
  14090. If BOUNDS finds a singularity within an interval, the evaluation
  14091. is stopped with an error message indicating the problem part
  14092. of the expression.
  14093. \newpage
  14094. Syntax:\ttindex{BOUNDS}
  14095. \begin{description}
  14096. \item[BOUNDS]$(exp,var_1=(l_1 .. u_1) [,var_2=(l_2 .. u_2) \ldots])$
  14097. \item[{\it BOUNDS}]$(exp,\{var_1=(l_1 .. u_1) [,var_2=(l_2 .. u_2)\ldots]\})$
  14098. where $exp$ is the function to be investigated,
  14099. $var_1, var_2 , \ldots$ are the variables of exp,
  14100. $l_1, l_2 , \ldots$ and $u_1, u_2 , \ldots$ specify the area (intervals).
  14101. {\tt BOUNDS} computes upper and lower bounds for the expression in the
  14102. given area. An interval is returned.
  14103. \end{description}
  14104. Example:
  14105. {\small\begin{verbatim}
  14106. bounds(sin x,x=(1 .. 2));
  14107. {-1,1}
  14108. on rounded;
  14109. bounds(sin x,x=(1 .. 2));
  14110. 0.84147098481 .. 1
  14111. bounds(x**2+x,x=(-0.5 .. 0.5));
  14112. - 0.25 .. 0.75
  14113. \end{verbatim}}
  14114. \section{Chebyshev Curve Fitting}
  14115. The operator family $Chebyshev\_\ldots$ implements approximation
  14116. and evaluation of functions by the Chebyshev method.
  14117. The operator {\tt Chebyshev\_fit}\ttindex{Chebyshev\_fit} computes
  14118. this approximation and returns a list, which has as first element the
  14119. sum expressed as a polynomial and as second element the sequence of
  14120. Chebyshev coefficients ${c_i}$. {\tt
  14121. Chebyshev\_df}\ttindex{Chebyshev\_df} and {\tt
  14122. Chebyshev\_int}\ttindex{Chebyshev\_int} transform a Chebyshev
  14123. coefficient list into the coefficients of the corresponding derivative
  14124. or integral respectively. For evaluating a Chebyshev approximation at
  14125. a given point in the basic interval the operator {\tt
  14126. Chebyshev\_eval}\ttindex{Chebyshev\_eval} can be used. Note that {\tt
  14127. Chebyshev\_eval} is based on a recurrence relation which is in general
  14128. more stable than a direct evaluation of the complete polynomial.
  14129. \begin{description}
  14130. \item[CHEBYSHEV\_FIT] $(fcn,var=(lo .. hi),n)$
  14131. \item[CHEBYSHEV\_EVAL] $(coeffs,var=(lo .. hi),var=pt)$
  14132. \item[CHEBYSHEV\_DF] $(coeffs,var=(lo .. hi))$
  14133. \item[CHEBYSHEV\_INT] $(coeffs,var=(lo .. hi))$
  14134. where $fcn$ is an algebraic expression (the function to be
  14135. fitted), $var$ is the variable of $fcn$, $lo$ and $hi$ are
  14136. numerical real values which describe an interval ($lo < hi$),
  14137. $n$ is the approximation order,an integer $>0$, set to 20 if missing,
  14138. $pt$ is a numerical value in the interval and $coeffs$ is
  14139. a series of Chebyshev coefficients, computed by one of
  14140. $CHEBYSHEV\_COEFF$, $\_DF$ or $\_INT$.
  14141. \end{description}
  14142. Example:
  14143. {\small\begin{verbatim}
  14144. on rounded;
  14145. w:=chebyshev_fit(sin x/x,x=(1 .. 3),5);
  14146. 3 2
  14147. w := {0.03824*x - 0.2398*x + 0.06514*x + 0.9778,
  14148. {0.8991,-0.4066,-0.005198,0.009464,-0.00009511}}
  14149. chebyshev_eval(second w, x=(1 .. 3), x=2.1);
  14150. 0.4111
  14151. \end{verbatim}}
  14152. \section{General Curve Fitting}
  14153. The operator {\tt NUM\_FIT}\ttindex{NUM\_FIT} finds for a set of
  14154. points the linear combination of a given set of
  14155. functions (function basis) which approximates the
  14156. points best under the objective of the least squares
  14157. criterion (minimum of the sum of the squares of the deviation).
  14158. The solution is found as zero of the
  14159. gradient vector of the sum of squared errors.
  14160. Syntax:
  14161. \begin{description}
  14162. \item[NUM\_FIT] $(vals,basis,var=pts)$
  14163. where $vals$ is a list of numeric values,
  14164. $var$ is a variable used for the approximation,
  14165. $pts$ is a list of coordinate values which correspond to $var$,
  14166. $basis$ is a set of functions varying in $var$ which is used
  14167. for the approximation.
  14168. \end{description}
  14169. The result is a list containing as first element the
  14170. function which approximates the given values, and as
  14171. second element a list of coefficients which were used
  14172. to build this function from the basis.
  14173. Example:
  14174. {\small\begin{verbatim}
  14175. % approximate a set of factorials by a polynomial
  14176. pts:=for i:=1 step 1 until 5 collect i$
  14177. vals:=for i:=1 step 1 until 5 collect
  14178. for j:=1:i product j$
  14179. num_fit(vals,{1,x,x**2},x=pts);
  14180. 2
  14181. {14.571428571*X - 61.428571429*X + 54.6,{54.6,
  14182. - 61.428571429,14.571428571}}
  14183. num_fit(vals,{1,x,x**2,x**3,x**4},x=pts);
  14184. 4 3
  14185. {2.2083333234*X - 20.249999879*X
  14186. 2
  14187. + 67.791666154*X - 93.749999133*X
  14188. + 44.999999525,
  14189. {44.999999525, - 93.749999133,67.791666154,
  14190. - 20.249999879,2.2083333234}}
  14191. \end{verbatim}}
  14192. \section{Function Bases}
  14193. The following procedures compute sets of functions
  14194. for example to be used for approximation.
  14195. All procedures have
  14196. two parameters, the expression to be used as $variable$
  14197. (an identifier in most cases) and the
  14198. order of the desired system.
  14199. The functions are not scaled to a specific interval, but
  14200. the $variable$ can be accompanied by a scale factor
  14201. and/or a translation
  14202. in order to map the generic interval of orthogonality to another
  14203. ({\em e.g.\ }$(x- 1/2 ) * 2 pi$).
  14204. The result is a function list with ascending order, such that
  14205. the first element is the function of order zero and (for
  14206. the polynomial systems) the function of order $n$ is the $n+1$-th
  14207. element.
  14208. \ttindex{monomial\_base}\ttindex{trigonometric\_base}\ttindex{Bernstein\_base}
  14209. \ttindex{Legendre\_base}\ttindex{Laguerre\_base}\ttindex{Hermite\_base}
  14210. \ttindex{Chebyshev\_base\_T}\ttindex{Chebyshev\_base\_U}
  14211. {\small\begin{verbatim}
  14212. monomial_base(x,n) {1,x,...,x**n}
  14213. trigonometric_base(x,n) {1,sin x,cos x,sin(2x),cos(2x)...}
  14214. Bernstein_base(x,n) Bernstein polynomials
  14215. Legendre_base(x,n) Legendre polynomials
  14216. Laguerre_base(x,n) Laguerre polynomials
  14217. Hermite_base(x,n) Hermite polynomials
  14218. Chebyshev_base_T(x,n) Chebyshev polynomials first kind
  14219. Chebyshev_base_U(x,n) Chebyshev polynomials second kind
  14220. \end{verbatim}}
  14221. Example:
  14222. {\small\begin{verbatim}
  14223. Bernstein_base(x,5);
  14224. 5 4 3 2
  14225. { - X + 5*X - 10*X + 10*X - 5*X + 1,
  14226. 4 3 2
  14227. 5*X*(X - 4*X + 6*X - 4*X + 1),
  14228. 2 3 2
  14229. 10*X *( - X + 3*X - 3*X + 1),
  14230. 3 2
  14231. 10*X *(X - 2*X + 1),
  14232. 4
  14233. 5*X *( - X + 1),
  14234. 5
  14235. X }
  14236. \end{verbatim}}
  14237. \chapter[ODESOLVE: Ordinary differential eqns]%
  14238. {ODESOLVE: \protect\\ Ordinary differential equations solver}
  14239. \label{ODESOLVE}
  14240. \typeout{[ODESOLVE: Ordinary differential equations solver]}
  14241. {\footnotesize
  14242. \begin{center}
  14243. Malcolm A.H. MacCallum \\
  14244. School of Mathematical Sciences, Queen Mary and Westfield College \\
  14245. University of London \\
  14246. Mile End Road \\
  14247. London E1 4NS, England \\[0.05in]
  14248. e--mail: mm@maths.qmw.ac.uk
  14249. \end{center}
  14250. }
  14251. \ttindex{ODESOLVE}
  14252. \index{ordinary differential equations}
  14253. The ODESOLVE package is a solver for ordinary differential equations.
  14254. At the present time it has very limited capabilities,
  14255. \begin{enumerate}
  14256. \item it can handle only a single scalar equation presented as an
  14257. algebraic expression or equation, and
  14258. \item it can solve only first-order equations of simple types,
  14259. linear equations with constant coefficients and Euler equations.
  14260. \end{enumerate}
  14261. \noindent These solvable types are exactly those for
  14262. which Lie symmetry techniques give no useful information.
  14263. \section{Use}
  14264. The only top-level function the user should normally invoke is:
  14265. \ttindex{ODESOLVE}
  14266. \vspace{.1in}
  14267. \begin{tabbing}
  14268. {\tt ODESOLVE}(\=EXPRN:{\em expression, equation}, \\
  14269. \>VAR1:{\em variable}, \\
  14270. \>VAR2:{\em variable}):{\em list-algebraic}
  14271. \end{tabbing}
  14272. \vspace{.1in}
  14273. \noindent {\tt ODESOLVE} returns a list containing an equation (like solve):
  14274. \begin{description}
  14275. \item[EXPRN] is a single scalar expression such that EXPRN = 0 is the
  14276. ordinary differential equation (ODE for short) to be solved,
  14277. or is an equivalent equation.
  14278. \item[VAR1] is the name of the dependent variable.
  14279. \item[VAR2] is the name of the independent variable
  14280. \end{description}
  14281. \noindent (For simplicity these will be called y and x in the sequel)
  14282. The returned value is a list containing the equation giving the
  14283. general solution of the ODE (for simultaneous equations this will be a
  14284. list of equations eventually). It will contain occurrences of the
  14285. \index{ARBCONST operator}
  14286. operator {\tt ARBCONST} for the arbitrary constants in the general
  14287. solution. The arguments of {\tt ARBCONST} should be new, as with {\tt
  14288. ARBINT} etc. in SOLVE. A counter {\tt !!ARBCONST} is used to arrange
  14289. this (similar to the way {\tt ARBINT} is implemented).
  14290. Some other top-level functions may be of use elsewhere, especially:
  14291. \ttindex{SORTOUTODE}
  14292. \vspace{.1in}
  14293. \noindent{\tt SORTOUTODE}(EXPRN:{\em algebraic}, Y:{\em var}, X:{\em var}):
  14294. {\em expression}
  14295. \vspace{.1in}
  14296. \noindent which finds the order and degree of the EXPRN as a
  14297. differential equation for Y with respect to Y and sets the linearity
  14298. and highest derivative occurring in reserved variables ODEORDER,
  14299. ODEDEGREE,\ttindex{ODEORDER}\ttindex{ODEDEGREE}\ttindex{ODELINEARITY}\ttindex{HIGHESTDERIV}ODELINEARITY
  14300. and HIGHESTDERIV. An expression equivalent to the ODE is
  14301. returned, or zero if EXPRN (equated to 0) is not an ODE in the
  14302. given variables.
  14303. \section{Commentary}
  14304. The methods used by this package are described in detail in the full
  14305. documentation, which should be inspected together with the examples
  14306. file.
  14307. \chapter[ORTHOVEC: scalars and vectors]%
  14308. {ORTHOVEC: Three-dimensional vector analysis}
  14309. \label{ORTHOVEC}
  14310. \typeout{{ORTHOVEC: Three-dimensional vector analysis}}
  14311. {\footnotesize
  14312. \begin{center}
  14313. James W.~Eastwood \\
  14314. AEA Technology, Culham Laboratory \\
  14315. Abingdon \\
  14316. Oxon OX14 3DB, England \\[0.05in]
  14317. e--mail: jim\_eastwood@aeat.co.uk
  14318. \end{center}
  14319. }
  14320. \ttindex{ORTHOVEC}
  14321. The ORTHOVEC package is a collection of \REDUCE\ procedures and
  14322. operations which provide a simple to use environment for the
  14323. manipulation of scalars and vectors. Operations include addition,
  14324. subtraction, dot and cross products, division, modulus, div, grad,
  14325. curl, laplacian, differentiation, integration, ${\bf a \cdot \nabla}$
  14326. and Taylor expansion.
  14327. \section{Initialisation}\label{vstart}
  14328. \ttindex{VSTART}
  14329. The procedure \f{START} initialises ORTHOVEC. VSTART provides a
  14330. menu of standard coordinate systems:-
  14331. \begin{enumerate}
  14332. \index{cartesian coordinates}
  14333. \item cartesian $(x, y, z) = $ {\tt (x, y, z)}
  14334. \index{cylindrical coordinates}
  14335. \item cylindrical $(r, \theta, z) = $ {\tt (r, th, z)}
  14336. \index{spherical coordinates}
  14337. \item spherical $(r, \theta, \phi) = $ {\tt (r, th, ph) }
  14338. \item general $( u_1, u_2, u_3 ) = $ {\tt (u1, u2, u3) }
  14339. \item others
  14340. \end{enumerate}
  14341. which the user selects by number. Selecting options (1)-(4)
  14342. automatically sets up the coordinates and scale factors. Selection
  14343. option (5) shows the user how to select another coordinate system. If
  14344. VSTART is not called, then the default cartesian coordinates are used.
  14345. ORTHOVEC may be re-initialised to a new coordinate system at any time
  14346. during a given \REDUCE\ session by typing
  14347. {\small\begin{verbatim}
  14348. VSTART $.
  14349. \end{verbatim}}
  14350. \section{Input-Output}
  14351. ORTHOVEC assumes all quantities are either scalars or 3 component
  14352. vectors. To define a vector $a$ with components $(c_1, c_2, c_3)$ use
  14353. the procedure SVEC:\ttindex{SVEC}
  14354. {\small\begin{verbatim}
  14355. a := svec(c1, c2, c3);
  14356. \end{verbatim}}
  14357. The procedure\ttindex{VOUT} \f{VOUT} (which returns the value of its
  14358. argument) can be used to give labelled output of components
  14359. in algebraic form:
  14360. {\small\begin{verbatim}
  14361. b := svec (sin(x)**2, y**2, z)$
  14362. vout(b)$
  14363. \end{verbatim}}
  14364. The operator {\tt \_} can be used to select a particular
  14365. component (1, 2 or 3) for output {\em e.g.}
  14366. {\small\begin{verbatim}
  14367. b_1 ;
  14368. \end{verbatim}}
  14369. \section{Algebraic Operations}
  14370. Six infix operators, sum, difference, quotient, times, exponentiation
  14371. and cross product, and four prefix
  14372. operators, plus, minus, reciprocal
  14373. and modulus are defined in ORTHOVEC. These operators can take suitable
  14374. combinations of scalar and vector arguments,
  14375. and in the case of scalar arguments reduce to the usual definitions of
  14376. $ +, -, *, /, $ etc.
  14377. The operators are represented by symbols
  14378. \index{+ ! 3-D vector}\index{- ! 3-D vector}\index{/ ! 3-D vector}
  14379. \index{* ! 3-D vector}\index{* ! 3-D vector}\index{"\^{} ! 3-D vector}
  14380. \index{$><$ ! 3-D vector}
  14381. {\small\begin{verbatim}
  14382. +, -, /, *, ^, ><
  14383. \end{verbatim}}
  14384. \index{$><$ ! diphthong} The composite {\tt ><} is an
  14385. attempt to represent the cross product symbol
  14386. $\times$ in ASCII characters.
  14387. If we let ${\bf v}$ be a vector and $s$ be a scalar, then
  14388. valid combinations of arguments of the
  14389. procedures and operators and the type of the result
  14390. are as summarised below. The notation used is\\
  14391. {\em result :=procedure(left argument, right argument) } or\\
  14392. {\em result :=(left operand) operator (right operand) } . \\
  14393. \underline{Vector Addition} \\
  14394. \ttindex{VECTORPLUS}\ttindex{VECTORADD}\index{vector ! addition}
  14395. \begin{tabular}{rclcrcl}
  14396. {\bf v} &:=& VECTORPLUS({\bf v}) &{\rm or}& {\bf v} &:=& + {\bf v} \\
  14397. s &:=& VECTORPLUS(s) &{\rm or} & s &:=& + s \\
  14398. {\bf v} &:=& VECTORADD({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  14399. {\bf v} + {\bf v} \\
  14400. s &:=& VECTORADD(s,s) &{\rm or }& s &:=& s + s \\
  14401. \end{tabular} \\
  14402. \underline{Vector Subtraction} \\
  14403. \ttindex{VECTORMINUS}\ttindex{VECTORDIFFERENCE}\index{vector ! subtraction}
  14404. \begin{tabular}{rclcrcl}
  14405. {\bf v} &:=& VECTORMINUS({\bf v}) &{\rm or}&
  14406. {\bf v} &:=& - {\bf v} \\
  14407. s &:=& VECTORMINUS(s) &{\rm or} & s &:=& - s \\
  14408. {\bf v} &:=& VECTORDIFFERENCE({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  14409. {\bf v} - {\bf v} \\
  14410. s &:=& VECTORDIFFERENCE(s,s) &{\rm or }& s &:=& s - s \\
  14411. \end{tabular} \\
  14412. \underline{Vector Division}\\
  14413. \ttindex{VECTORRECIP}\ttindex{VECTORQUOTIENT}\index{vector ! division}
  14414. \begin{tabular}{rclcrcl}
  14415. {\bf v} &:=& VECTORRECIP({\bf v}) &{\rm or}& {\bf v} &:=& /
  14416. {\bf v} \\
  14417. s &:=& VECTORRECIP(s) &{\rm or} & s &:=& / s \\
  14418. {\bf v} &:=& VECTORQUOTIENT({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  14419. {\bf v} / {\bf v} \\
  14420. {\bf v} &:=& VECTORQUOTIENT({\bf v}, s ) &{\rm or }& {\bf v} &:=&
  14421. {\bf v} / s \\
  14422. {\bf v} &:=& VECTORQUOTIENT( s ,{\bf v}) &{\rm or }& {\bf v} &:=&
  14423. s / {\bf v} \\
  14424. s &:=& VECTORQUOTIENT(s,s) &{\rm or }& s &:=& s / s
  14425. \\
  14426. \end{tabular} \\
  14427. \underline{Vector Multiplication}\\
  14428. \ttindex{VECTORTIMES}\index{vector ! multiplication}
  14429. \begin{tabular}{rclcrcl}
  14430. {\bf v} &:=& VECTORTIMES( s ,{\bf v}) &{\rm or }& {\bf v} &:=&
  14431. s * {\bf v} \\
  14432. {\bf v} &:=& VECTORTIMES({\bf v}, s ) &{\rm or }& {\bf v} &:=& {\bf
  14433. v} * s \\
  14434. s &:=& VECTORTIMES({\bf v},{\bf v}) &{\rm or }& s &:=& {\bf
  14435. v} * {\bf v} \\
  14436. s &:=& VECTORTIMES( s , s ) &{\rm or }& s &:=&
  14437. s * s \\
  14438. \end{tabular} \\
  14439. \underline{Vector Cross Product} \\
  14440. \ttindex{VECTORCROSS}\index{cross product}\index{vector ! cross product}
  14441. \begin{tabular}{rclcrcl}
  14442. {\bf v} &:=& VECTORCROSS({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=& {\bf
  14443. v} $\times$ {\bf v} \\
  14444. \end{tabular} \\
  14445. \underline{Vector Exponentiation}\\
  14446. \ttindex{VECTOREXPT}\index{vector ! exponentiation}
  14447. \begin{tabular}{rclcrcl}
  14448. s &:=& VECTOREXPT ({\bf v}, s ) &{\rm or }& s &:=& {\bf
  14449. v} \^{} s \\
  14450. s &:=& VECTOREXPT ( s , s ) &{\rm or }& s &:=& s
  14451. \^{} s \\
  14452. \end{tabular} \\
  14453. \underline{Vector Modulus}\\
  14454. \ttindex{VMOD}\index{vector ! modulus}
  14455. \begin{tabular}{rcl}
  14456. s &:=& VMOD (s)\\
  14457. s &:=& VMOD ({\bf v}) \\
  14458. \end{tabular} \\
  14459. All other combinations of operands for these operators lead to error
  14460. messages being issued. The first two instances of vector
  14461. multiplication are scalar multiplication of vectors, the third is the
  14462. \index{vector ! dot product}\index{vector ! inner product}
  14463. \index{inner product}\index{dot product}
  14464. product of two scalars and the last is the inner (dot) product. The
  14465. prefix operators {\tt +, -, /} can take either scalar or vector
  14466. arguments and return results of the same type as their arguments.
  14467. VMOD returns a scalar.
  14468. In compound expressions, parentheses may be used to specify the order of
  14469. combination. If parentheses are omitted the ordering of the
  14470. operators, in increasing order of precedence is
  14471. {\small\begin{verbatim}
  14472. + | - | dotgrad | * | >< | ^ | _
  14473. \end{verbatim}}
  14474. and these are placed in the precedence list defined in \REDUCE{}
  14475. after $<$.
  14476. Vector divisions are defined as follows: If ${\bf a}$ and ${\bf b}$ are
  14477. vectors and $c$ is a scalar, then
  14478. \begin{eqnarray*}
  14479. {\bf a} / {\bf b} & = & \frac{{\bf a} \cdot {\bf b}}{ \mid {\bf b}
  14480. \mid^2}\\
  14481. c / {\bf a} & = & \frac{c {\bf a} }{ \mid {\bf a} \mid^2}
  14482. \end{eqnarray*}
  14483. Both scalar multiplication and dot products are given by the same symbol,
  14484. braces are advisable to ensure the correct
  14485. precedences in expressions such as $({\bf a} \cdot {\bf b})
  14486. ({\bf c} \cdot {\bf d})$.
  14487. Vector exponentiation is defined as the power of the modulus:\\
  14488. ${\bf a}^n \equiv {\rm VMOD}(a)^n = \mid {\bf a} \mid^n$
  14489. \section{Differential Operations}
  14490. Differential operators provided are div, grad, curl, delsq, and dotgrad.
  14491. \index{div operator}\index{grad operator}\index{curl operator}
  14492. \index{delsq operator}\index{dotgrad operator}
  14493. All but the last of these are prefix operators having a single
  14494. vector or scalar argument as appropriate. Valid combinations of
  14495. operator and argument, and the type of the result are shown in
  14496. table~\ref{vvecttable}.
  14497. \begin{table}
  14498. \begin{center}
  14499. \begin{tabular}{rcl}
  14500. s & := & div ({\bf v}) \\
  14501. {\bf v} & := & grad(s) \\
  14502. {\bf v} & := & curl({\bf v}) \\
  14503. {\bf v} & := & delsq({\bf v}) \\
  14504. s & := & delsq(s) \\
  14505. {\bf v} & := & {\bf v} dotgrad {\bf v} \\
  14506. s & := & {\bf v} dotgrad s
  14507. \end{tabular}
  14508. \end{center}
  14509. \caption{ORTHOVEC valid combinations of operator and argument}\label{vvecttable}
  14510. \end{table}
  14511. All other combinations of operator and argument type cause error
  14512. messages to be issued. The differential operators have their usual
  14513. meanings. The coordinate system used by these operators is
  14514. set by invoking VSTART (cf. Sec.~\ref{vstart}). The names {\tt h1},
  14515. {\tt h2} and {\tt h3 } are
  14516. reserved for the scale factors, and {\tt u1}, {\tt u2} and {\tt u3} are
  14517. used for the coordinates.
  14518. A vector extension, VDF, of the \REDUCE\ procedure DF allows the
  14519. differentiation of a vector (scalar) with respect to a scalar to be
  14520. performed. Allowed forms are\ttindex{VDF}
  14521. VDF({\bf v}, s) $\rightarrow$ {\bf v} and
  14522. VDF(s, s) $\rightarrow$ s ,
  14523. where, for example\\
  14524. \begin{eqnarray*}
  14525. {\tt vdf( B,x)} \equiv \frac{\partial {\bf B}}{\partial x}
  14526. \end{eqnarray*}
  14527. The standard \REDUCE\ procedures DEPEND and NODEPEND have been redefined
  14528. to allow dependences of vectors to be compactly
  14529. defined. For example\index{DEPEND statement}\index{NODEPEND statement}
  14530. {\small\begin{verbatim}
  14531. a := svec(a1,a2,a3)$;
  14532. depend a,x,y;
  14533. \end{verbatim}}
  14534. causes all three components {\tt a1},{\tt a2} and {\tt a3} of {\tt a}
  14535. to be treated as functions of {\tt x} and {\tt y}.
  14536. Individual component dependences can still be defined if desired.
  14537. {\small\begin{verbatim}
  14538. depend a3,z;
  14539. \end{verbatim}}
  14540. The procedure VTAYLOR gives truncated Taylor series expansions of scalar
  14541. or vector functions:-\ttindex{VTAYLOR}
  14542. {\small\begin{verbatim}
  14543. vtaylor(vex,vx,vpt,vorder);
  14544. \end{verbatim}}
  14545. returns the series expansion of the expression
  14546. VEX with respect to variable VX\ttindex{VORDER}
  14547. about point VPT to order VORDER. Valid
  14548. combinations of argument types are shown in table~\ref{ORTHOVEC:validexp}. \\
  14549. \begin{table}
  14550. \begin{center}
  14551. \begin{tabular}{cccc}
  14552. VEX & VX & VPT & VORDER \\[2ex]
  14553. {\bf v} & {\bf v} & {\bf v} & {\bf v}\\
  14554. {\bf v} & {\bf v} & {\bf v} & s\\
  14555. {\bf v} & s & s & s \\
  14556. s & {\bf v} & {\bf v} & {\bf v} \\
  14557. s & {\bf v} & {\bf v} & s\\
  14558. s & s & s & s\\
  14559. \end{tabular}
  14560. \end{center}
  14561. \caption{ORTHOVEC valid combination of argument types.}\label{ORTHOVEC:validexp}
  14562. \end{table}
  14563. Any other combinations cause error messages to be issued. Elements of
  14564. VORDER must be non-negative integers, otherwise error messages are
  14565. issued. If scalar VORDER is given for a vector expansion, expansions
  14566. in each component are truncated at the same order, VORDER.
  14567. The new version of Taylor expansion applies\index{l'H\^opital's rule}
  14568. l'H\^opital's rule in evaluating coefficients, so handle cases such as
  14569. $\sin(x) / (x) $ , etc. which the original version of ORTHOVEC could
  14570. not. The procedure used for this is LIMIT,\ttindex{LIMIT} which can
  14571. be used directly to find the limit of a scalar function {\tt ex} of
  14572. variable {\tt x} at point {\tt pt}:-
  14573. {\small\begin{verbatim}
  14574. ans := limit(ex,x,pt);
  14575. \end{verbatim}}
  14576. \section{Integral Operations}
  14577. Definite and indefinite vector, volume and scalar line integration
  14578. procedures are included in ORTHOVEC. They are defined as follows:
  14579. \ttindex{VINT}\ttindex{DVINT}
  14580. \ttindex{VOLINT}\ttindex{DVOLINT}\ttindex{LINEINT}\ttindex{DLINEINT}
  14581. \begin{eqnarray*}
  14582. {\rm VINT} ({\bf v},x) & = & \int {\bf v}(x)dx\\
  14583. %
  14584. {\rm DVINT} ({\bf v},x, a, b) & = & \int^b_a {\bf v} (x) dx\\
  14585. %
  14586. {\rm VOLINT} ({\bf v}) & = & \int {\bf v} h_1 h_2 h_3 du_1 du_2 du_3\\
  14587. %
  14588. {\rm DVOLINT}({\bf v},{\bf l},{\bf u},n) & = & \int^{\bf u}_{\bf l}
  14589. {\bf v} h_1 h_2 h_3 du_1 du_2 du_3\\
  14590. %
  14591. {\rm LINEINT} ({\bf v, \omega}, t) & = & \int {\bf v} \cdot {\bf dr}
  14592. \equiv \int v_i h_i \frac{\partial \omega_i}{\partial t} dt\\
  14593. %
  14594. {\rm DLINEINT} ({\bf v, \omega} t, a, b) & = & \int^b_a v_i h_i
  14595. \frac{\partial \omega_i}{\partial t} dt\\
  14596. \end{eqnarray*}
  14597. In the vector and volume integrals, ${\bf v}$ are vector or scalar,
  14598. $a, b,x$ and $n$ are scalar. Vectors ${\bf l}$ and ${\bf u}$ contain
  14599. expressions for lower and upper bounds to the integrals. The integer
  14600. index $n$ defines the order in which the integrals over $u_1, u_2$ and
  14601. $u_3$ are performed in order to allow for functional dependencies in
  14602. the integral bounds:
  14603. \begin{center}
  14604. \begin{tabular}{ll}
  14605. n & order\\ 1 & $u_1~u_2~u_3$\\
  14606. %
  14607. 2 & $u_3~u_1~u_2$\\
  14608. %
  14609. 3 & $u_2~u_3~u_1$\\
  14610. %
  14611. 4 & $u_1~u_3~u_2$\\
  14612. %
  14613. 5 & $u_2~u_1~u_3$\\ otherwise & $u_3~u_2~u_1$\\
  14614. \end{tabular}
  14615. \end{center}
  14616. The vector ${\bf \omega}$ in the line integral's arguments contain
  14617. explicit parameterisation of the coordinates $u_1, u_2, u_3$ of the
  14618. line ${\bf u}(t)$ along which the integral is taken.
  14619. \chapter[PHYSOP: Operator Calculus]%
  14620. {PHYSOP: Operator calculus in quantum theory}
  14621. \label{PHYSOP}
  14622. \typeout{{PHYSOP: Operator calculus in quantum theory}}
  14623. {\footnotesize
  14624. \begin{center}
  14625. Mathias Warns \\
  14626. Physikalisches Institut der Universit\"at Bonn \\
  14627. Endenicher Allee 11--13 \\
  14628. D--5300 BONN 1, Germany \\[0.05in]
  14629. e--mail: UNP008@DBNRHRZ1.bitnet
  14630. \end{center}
  14631. }
  14632. \ttindex{PHYSOP}
  14633. The package PHYSOP has been designed to meet the requirements of
  14634. theoretical physicists looking for a
  14635. computer algebra tool to perform complicated calculations
  14636. in quantum theory
  14637. with expressions containing operators. These operations
  14638. consist mainly in the calculation of commutators between operator
  14639. expressions and in the evaluations of operator matrix elements
  14640. in some abstract space.
  14641. \section{The NONCOM2 Package}
  14642. The package NONCOM2 redefines some standard \REDUCE\ routines
  14643. in order to modify the way noncommutative operators are handled by the
  14644. system. It redefines the \f{NONCOM}\ttindex{NONCOM} statement in
  14645. a way more suitable for calculations in physics. Operators have now to
  14646. be declared noncommutative pairwise, {\em i.e.\ }coding: \\
  14647. {\small\begin{verbatim}
  14648. NONCOM A,B;
  14649. \end{verbatim}}
  14650. declares the operators \f{A} and \f{B} to be noncommutative but allows them
  14651. to commute with any other (noncommutative or not) operator present in
  14652. the expression. In a similar way if one wants {\em e.g.\ }\f{A(X)} and
  14653. \f{A(Y)} not to commute, one has now to code:
  14654. {\small\begin{verbatim}
  14655. NONCOM A,A;
  14656. \end{verbatim}}
  14657. A final example should make
  14658. the use of the redefined \f{NONCOM} statement clear:
  14659. {\small\begin{verbatim}
  14660. NONCOM A,B,C;
  14661. \end{verbatim}}
  14662. declares \f{A} to be noncommutative with \f{B} and \f{C},
  14663. \f{B} to be noncommutative
  14664. with \f{A} and \f{C} and \f{C} to be noncommutative
  14665. with \f{A} and \f{B}.
  14666. Note that after these declaration
  14667. {\em e.g.\ }\f{A(X)} and \f{A(Y)}
  14668. are still commuting kernels.
  14669. Finally to keep the compatibility with standard \REDUCE\, declaring a
  14670. \underline{single} identifier using the \f{NONCOM} statement has the same
  14671. effect as in
  14672. standard \REDUCE.
  14673. From the user's point of view there are no other
  14674. new commands implemented by the package.
  14675. \section{The PHYSOP package}
  14676. The package PHYSOP implements a new \REDUCE\ data type to perform
  14677. calculations with physical operators. The noncommutativity of
  14678. operators is
  14679. implemented using the NONCOM2 package so this file should be loaded
  14680. prior to the use of PHYSOP.
  14681. \subsection{Type declaration commands}
  14682. The new \REDUCE\ data type PHYSOP implemented by the package allows the
  14683. definition of a new kind of operators ({\em i.e.\ }kernels carrying
  14684. an arbitrary
  14685. number of arguments). Throughout this manual, the name
  14686. ``operator''
  14687. will refer, unless explicitly stated otherwise, to this new data type.
  14688. This data type is in turn
  14689. divided into 5 subtypes. For each of this subtype, a declaration command
  14690. has been defined:
  14691. \begin{description}
  14692. \item[\f{SCALOP A;} ]\ttindex{SCALOP} declares \f{A} to be a scalar
  14693. operator. This operator may
  14694. carry an arbitrary number of arguments; after the
  14695. declaration: \f{ SCALOP A; }
  14696. all kernels of the form
  14697. \f{A(J), A(1,N), A(N,L,M)}
  14698. are recognised by the system as being scalar operators.
  14699. \item[\f{VECOP V;} ]\ttindex{VECOP} declares \f{V} to be a vector operator.
  14700. As for scalar operators, the vector operators may carry an arbitrary
  14701. number of arguments. For example \f{V(3)} can be used to represent
  14702. the vector operator $\vec{V}_{3}$. Note that the dimension of space
  14703. in which this operator lives is \underline{arbitrary}.
  14704. One can however address a specific component of the
  14705. vector operator by using a special index declared as \f{PHYSINDEX} (see
  14706. below). This index must then be the first in the argument list
  14707. of the vector operator.
  14708. \item[\f{TENSOP C(3);} ] \ttindex{TENSOP}
  14709. declares \f{C} to be a tensor operator of rank 3. Tensor operators
  14710. of any fixed integer rank larger than 1 can be declared.
  14711. Again this operator may carry an arbitrary number of arguments
  14712. and the space dimension is not fixed.
  14713. The tensor
  14714. components can be addressed by using special \f{PHYSINDEX} indices
  14715. (see below) which have to be placed in front of all other
  14716. arguments in the argument list.
  14717. \item[\f{STATE U;} ]\ttindex{STATE} declares \f{U} to be a state, {\em i.e.\ }an
  14718. object on
  14719. which operators have a certain action. The state U can also carry an
  14720. arbitrary number of arguments.
  14721. \item[\f{PHYSINDEX X;} ]\ttindex{PHYSINDEX} declares \f{X} to be a special
  14722. index which will be used
  14723. to address components of vector and tensor operators.
  14724. \end{description}
  14725. A command \f{CLEARPHYSOP}\ttindex{CLEARPHYSOP}
  14726. removes
  14727. the PHYSOP type from an identifier in order to use it for subsequent
  14728. calculations. However it should be
  14729. remembered that \underline{no}
  14730. substitution rule is cleared by this function. It
  14731. is therefore left to the user's responsibility to clear previously all
  14732. substitution rules involving the identifier from which the PHYSOP type
  14733. is removed.
  14734. \subsection{Ordering of operators in an expression}
  14735. The ordering of kernels in an expression is performed according to
  14736. the following rules: \\
  14737. 1. \underline{Scalars} are always ordered ahead of
  14738. PHYSOP operators in an expression.
  14739. The \REDUCE\ statement \f{KORDER}\ttindex{KORDER} can be used to control the
  14740. ordering of scalars but has no
  14741. effect on the ordering of operators.
  14742. 2. The default ordering of operators follows the
  14743. order in which they have been declared (not the alphabetical one).
  14744. This ordering scheme can be changed using the command \f{OPORDER}.
  14745. \ttindex{OPORDER}
  14746. Its syntax is similar to the \f{KORDER} statement, {\em i.e.\ }coding:
  14747. \f{OPORDER A,V,F;}
  14748. means that all occurrences of the operator \f{A} are ordered ahead of
  14749. those of \f{V} etc. It is also possible to include operators
  14750. carrying
  14751. indices (both normal and special ones) in the argument list of
  14752. \f{OPORDER}. However including objects \underline{not}
  14753. defined as operators ({\em i.e.\ }scalars or indices) in the argument list
  14754. of the \f{OPORDER} command leads to an error.
  14755. 3. Adjoint operators are placed by the declaration commands just
  14756. after the original operators on the \f{OPORDER} list. Changing the
  14757. place of an operator on this list means \underline{not} that the
  14758. adjoint operator is moved accordingly. This adjoint operator can
  14759. be moved freely by including it in the argument list of the
  14760. \f{OPORDER} command.
  14761. \subsection{Arithmetic operations on operators}
  14762. The following arithmetic operations are possible with
  14763. operator expressions: \\
  14764. 1. Multiplication or division of an operator by a scalar.
  14765. 2. Addition and subtraction of operators of the \underline{same}
  14766. type.
  14767. 3. Multiplication of operators is only defined between two
  14768. \underline{scalar} operators.
  14769. 4. The scalar product of two VECTOR operators is implemented
  14770. with a new function \f{DOT}\ttindex{DOT}. The system expands
  14771. the product of
  14772. two vector operators into an ordinary product of the components of these
  14773. operators by inserting a special index generated by the program.
  14774. To give an example, if one codes:
  14775. {\small\begin{verbatim}
  14776. VECOP V,W;
  14777. V DOT W;
  14778. \end{verbatim}}
  14779. the system will transform the product into:
  14780. {\small\begin{verbatim}
  14781. V(IDX1) * W(IDX1)
  14782. \end{verbatim}}
  14783. where \f{IDX1} is a \f{PHYSINDEX} generated by the system (called a
  14784. DUMMY INDEX in the following) to express the summation over the
  14785. components. The identifiers \f{IDXn} (\f{n} is a nonzero integer) are
  14786. reserved variables for this purpose and should not be used for other
  14787. applications. The arithmetic operator
  14788. \f{DOT} can be used both in infix and prefix form with two arguments.
  14789. 5. Operators (but not states) can only be raised to an
  14790. \underline{integer} power. The system expands this power
  14791. expression into a product of the corresponding number of terms
  14792. inserting dummy indices if necessary. The following examples explain
  14793. the transformations occurring on power expressions (system output
  14794. is indicated with an \f{-->}):
  14795. {\small\begin{verbatim}
  14796. SCALOP A; A**2;
  14797. --> A*A
  14798. VECOP V; V**4;
  14799. --> V(IDX1)*V(IDX1)*V(IDX2)*V(IDX2)
  14800. TENSOP C(2); C**2;
  14801. --> C(IDX3,IDX4)*C(IDX3,IDX4)
  14802. \end{verbatim}}
  14803. Note in particular the way how the system interprets powers of
  14804. tensor operators which is different from the notation used in matrix
  14805. algebra.
  14806. 6. Quotients of operators are only defined between
  14807. scalar operator expressions.
  14808. The system transforms the quotient of 2 scalar operators into the
  14809. product of the first operator times the inverse of the second one.
  14810. {\small\begin{verbatim}
  14811. SCALOP A,B; A / B;
  14812. -1
  14813. A *( B )
  14814. \end{verbatim}}
  14815. 7. Combining the last 2 rules explains the way how the system
  14816. handles negative powers of operators:
  14817. \noindent
  14818. {\small\begin{verbatim}
  14819. SCALOP B;
  14820. B**(-3);
  14821. -1 -1 -1
  14822. --> (B )*(B )*(B )
  14823. \end{verbatim}}
  14824. The method of inserting dummy indices and expanding powers of
  14825. operators has been chosen to facilitate the handling of
  14826. complicated operator
  14827. expressions and particularly their application on states.
  14828. However it may be useful to get rid of these
  14829. dummy indices in order to enhance the readability of the
  14830. system's final output.
  14831. For this purpose the switch \f{CONTRACT}\ttindex{CONTRACT} has to
  14832. be turned on (\f{CONTRACT} is normally set to \f{OFF}).
  14833. The system in this case contracts over dummy indices reinserting the
  14834. \f{DOT} operator and reassembling the expanded powers. However due to
  14835. the predefined operator ordering the system may not remove all the
  14836. dummy indices introduced previously.
  14837. %%file).
  14838. \subsection{Special functions}
  14839. \subsubsection{Commutation relations}
  14840. If two PHYSOPs have been declared noncommutative using the (redefined)
  14841. \f{NONCOM}\ttindex{NONCOM} statement, it is possible to introduce in the environment
  14842. elementary (anti-) commutation relations between them. For
  14843. this purpose,
  14844. two scalar operators \f{COMM}\ttindex{COMM} and
  14845. \f{ANTICOMM}\ttindex{ANTICOMM} are available.
  14846. These operators are used in conjunction with \f{LET} statements.
  14847. Example:
  14848. {\small\begin{verbatim}
  14849. SCALOP A,B,C,D;
  14850. LET COMM(A,B)=C;
  14851. FOR ALL N,M LET ANTICOMM(A(N),B(M))=D;
  14852. VECOP U,V,W; PHYSINDEX X,Y,Z;
  14853. FOR ALL X,Y LET COMM(V(X),W(Y))=U(Z);
  14854. \end{verbatim}}
  14855. Note that if special indices are used as dummy variables in
  14856. \f{FOR ALL ... LET} constructs then these indices should have been
  14857. declared previously using the \f{PHYSINDEX} command.\ttindex{PHYSINDEX}
  14858. Every time the system
  14859. encounters a product term involving two
  14860. noncommutative operators which have to be reordered on account of the
  14861. given operator ordering, the list of available (anti-) commutators is
  14862. checked in the following way: First the system looks for a
  14863. \underline{commutation} relation which matches the product term. If it
  14864. fails then the defined \underline{anticommutation} relations are
  14865. checked. If there is no successful match the product term
  14866. \f{A*B} is replaced by: \\
  14867. {\small\begin{verbatim}
  14868. A*B;
  14869. --> COMM(A,B) + B*A
  14870. \end{verbatim}}
  14871. so that the user may introduce the commutation relation later on.
  14872. The user may want to force the system to look for
  14873. \underline{anticommutators} only; for this purpose a switch \f{ANTICOM}
  14874. \ttindex{ANTICOM}
  14875. is defined which has to be turned on ( \f{ANTICOM} is normally set to
  14876. \f{OFF}). In this case, the above example is replaced by:
  14877. {\small\begin{verbatim}
  14878. ON ANTICOM;
  14879. A*B;
  14880. --> ANTICOMM(A,B) - B*A
  14881. \end{verbatim}}
  14882. For the calculation of (anti-) commutators between complex
  14883. operator
  14884. expressions, the functions \f{COMMUTE}\ttindex{COMMUTE} and
  14885. \f{ANTICOMMUTE}\ttindex{ANTICOMMUTE} have been defined.
  14886. {\small\begin{verbatim}
  14887. VECOP P,A,K;
  14888. PHYSINDEX X,Y;
  14889. FOR ALL X,Y LET COMM(P(X),A(Y))=K(X)*A(Y);
  14890. COMMUTE(P**2,P DOT A);
  14891. \end{verbatim}}
  14892. \subsubsection{Adjoint expressions}
  14893. As has been already mentioned, for each operator and state defined
  14894. using the declaration commands, the system
  14895. generates automatically the corresponding adjoint operator. For the
  14896. calculation of the adjoint representation of a complicated
  14897. operator expression, a function \f{ADJ}\ttindex{ADJ} has been defined.
  14898. {\small\begin{verbatim}
  14899. SCALOP A,B;
  14900. ADJ(A*B);
  14901. + +
  14902. --> (A )*(B )
  14903. \end{verbatim}}
  14904. \subsubsection{Application of operators on states}
  14905. A function \f{OPAPPLY}\ttindex{OPAPPLY} has been
  14906. defined for the application of operators to states.
  14907. It has two arguments and is used in the following combinations:
  14908. {\bf (i)} \f{LET OPAPPLY(}{\it operator, state}\f{) =} {\it state};
  14909. This is to define a elementary
  14910. action of an operator on a state in analogy to the way
  14911. elementary commutation relations are introduced to the system.
  14912. {\small\begin{verbatim}
  14913. SCALOP A; STATE U;
  14914. FOR ALL N,P LET OPAPPLY((A(N),U(P))= EXP(I*N*P)*U(P);
  14915. \end{verbatim}}
  14916. {\bf (ii)} \f{LET OPAPPLY(}{\it state, state}\f{) =} {\it scalar exp.};
  14917. This form is to define scalar products between states and normalisation
  14918. conditions.
  14919. {\small\begin{verbatim}
  14920. STATE U;
  14921. FOR ALL N,M LET OPAPPLY(U(N),U(M)) = IF N=M THEN 1 ELSE 0;
  14922. \end{verbatim}}
  14923. {\bf (iii)} {\it state} \f{:= OPAPPLY(}{\it operator expression, state});
  14924. In this way, the action of an operator expression on a given state
  14925. is calculated using elementary relations defined as explained in {\bf
  14926. (i)}. The result may be assigned to a different state vector.
  14927. {\bf (iv)} \f{OPAPPLY(}{\it state}\f{, OPAPPLY(}{\it operator expression,
  14928. state}\f{))}; This is the way how to calculate matrix elements of
  14929. operator
  14930. expressions. The system proceeds in the following way: first the
  14931. rightmost operator is applied on the right state, which means that the
  14932. system tries
  14933. to find an elementary relation which match the application of the
  14934. operator on the state. If it fails
  14935. the system tries to apply the leftmost operator of the expression on the
  14936. left state using the adjoint representations. If this fails also,
  14937. the system prints out a warning message and stops the evaluation.
  14938. Otherwise the next operator occuring in the expression is
  14939. taken and so on until the complete expression is applied. Then the
  14940. system
  14941. looks for a relation expressing the scalar product of the two
  14942. resulting states and prints out the final result. An example of such
  14943. a calculation is given in the test file.
  14944. The infix version of the \f{OPAPPLY} function is the vertical bar
  14945. $\mid$. It is \underline{right} associative and placed in the
  14946. precedence
  14947. list just above the minus ($-$) operator.
  14948. \chapter{PM: A REDUCE pattern matcher}
  14949. \label{PM}
  14950. \typeout{{PM: A REDUCE pattern matcher}}
  14951. {\footnotesize
  14952. \begin{center}
  14953. Kevin McIsaac \\
  14954. The University of Western Australia \\
  14955. Australia\\[0.05in]
  14956. e--mail: kevin@wri.com
  14957. \end{center}
  14958. }
  14959. \ttindex{PM}
  14960. PM is a general pattern matcher similar in style to those found in systems
  14961. such as SMP and Mathematica.
  14962. A template is any expression composed of literal elements ({\em e.g.\ }{\tt
  14963. 5}, {\tt a} or {\tt a+1}) and specially denoted pattern variables
  14964. ({\em e.g.\ }{\tt ?a} or {\tt ??b}). Atoms
  14965. beginning with `?' are called generic variables and match any expression.
  14966. Atoms beginning with `??' are called multi-generic variables and match any
  14967. expression or any sequence of expressions including the null or empty
  14968. sequence. A sequence is an expression of the form `[a1, a2,...]'. When
  14969. placed in a function argument list the brackets are removed, {\em
  14970. i.e.\ }f([a,1]) $\rightarrow$ f(a,1) and f(a,[1,2],b) $\rightarrow$ f(a,1,2,b).
  14971. A template is said to match an expression if the template is literally
  14972. equal to the expression or if by replacing any of the generic or
  14973. multi-generic symbols occurring in the template, the template can be made
  14974. to be literally equal to the expression. These replacements are called the
  14975. bindings for the generic variables. A replacement is an expression of the
  14976. form {\tt exp1 -> exp2}, which means exp1 is replaced by exp2, or
  14977. {\tt exp1 --> exp2}, which is the same except exp2 is not simplified
  14978. until after the
  14979. substitution for exp1 is made. If the expression has any of the
  14980. properties; associativity, commutativity, or an identity element, they are
  14981. used to determine if the expressions match. If an attempt to match the
  14982. template to the expression fails the matcher backtracks, unbinding generic
  14983. variables, until it reached a place were it can make a different choice.
  14984. The matcher also supports semantic matching. Briefly, if a subtemplate
  14985. does not match the corresponding subexpression because they have different
  14986. structures then the two are equated and the matcher continues matching the
  14987. rest of the expression until all the generic variables in the subexpression
  14988. are bound. The equality is then checked. This is controlled by the switch
  14989. \ttindex{SEMANTIC}{\tt semantic}. By default it is on.
  14990. \section{The Match Function}
  14991. {\tt M(exp,template)}\ttindex{M}
  14992. The template is matched against the expression. If the template is
  14993. literally equal to the expression {\tt T} is returned. If the
  14994. template is literally equal to the expression after replacing the
  14995. generic variables by their bindings then the set of bindings is
  14996. returned as a set of replacements. Otherwise {\tt NIL} is returned.
  14997. {\small\begin{verbatim}
  14998. OPERATOR F;
  14999. M(F(A),F(A));
  15000. T
  15001. M(F(A,B),F(A,?A));
  15002. {?A->B}
  15003. M(F(A,B),F(??A));
  15004. {??A->[A,B]}
  15005. m(a+b+c,c+?a+?b);
  15006. {?a->a,?b->b}
  15007. m(a+b+c,b+?a);
  15008. {?a->a + c}
  15009. \end{verbatim}}
  15010. This example shows the effects of semantic matching, using the
  15011. associativity and commutativity of {\tt +}.
  15012. \section {Qualified Matching}
  15013. A template may be qualified by the use of the conditional operator
  15014. {\tt \_=',}\ttindex{\_=} standing for {\bf such that}. When a
  15015. such-that condition is encountered in a template it is held until all
  15016. generic variables appearing in logical-exp are bound. On the binding
  15017. of the last generic variable logical-exp is simplified and if the
  15018. result is not {\tt T} the condition fails and the pattern matcher
  15019. backtracks. When the template has been fully parsed any remaining
  15020. held such-that conditions are evaluated and compared to {\tt T}.
  15021. {\small\begin{verbatim}
  15022. load_package pm;
  15023. operator f;
  15024. if (m(f(a,b),f(?a,?b_=(?a=?b)))) then write "yes" else write"no";
  15025. no
  15026. m(f(a,a),f(?a,?b_=(?a=?b)));
  15027. {?B->A,?A->A}
  15028. \end{verbatim}}
  15029. {\typeout {This is not true}}
  15030. \section{Substituting for replacements}
  15031. The operator {\tt S}\ttindex{S} substitutes the replacements in an
  15032. expression.
  15033. {\tt S(exp,{temp1->sub1,temp2->sub2,...},rept, depth);}
  15034. will do the substitutions for a maximum of {\tt rept} and to a depth of
  15035. {\tt depth}, using a breadth-first search and replace. {\tt rept} and
  15036. {\tt depth} may be omitted when they default to 1 and infinity.
  15037. {\tt SI(exp,{temp1->sub1,temp2->sub2,...}, depth)}\ttindex{SI}
  15038. will substitute infinitely many times until expression stops
  15039. changing.
  15040. {\tt SD(exp,{temp1->sub1,temp2->sub2,...},rept, depth)}\ttindex{SD}
  15041. is a depth-first version of {\tt S}.
  15042. {\small\begin{verbatim}
  15043. s(f(a,b),f(a,?b)->?b^2);
  15044. 2
  15045. b
  15046. s(a+b,a+b->a*b);
  15047. a*b
  15048. operator nfac;
  15049. s(nfac(3),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)});
  15050. 3*nfac(2)
  15051. s(nfac(3),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)},2);
  15052. 6*nfac(1)
  15053. si(nfac(4),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)});
  15054. 24
  15055. s(a+b+f(a+b),a+b->a*b,inf,0);
  15056. f(a + b) + a*b
  15057. \end{verbatim}}
  15058. \section{Programming with Patterns}
  15059. There are also facilities to use this pattern-matcher as a programming
  15060. language. The operator {\tt :-}\ttindex{:-} can be used to declare
  15061. that while simplifying all matches of a template should be replaced by
  15062. some expression. The operator {\tt ::-} is the same except that the
  15063. left hand side is not simplified.
  15064. {\small\begin{verbatim}
  15065. operator fac, gamma;
  15066. fac(?x_=Natp(?x)) ::- ?x*fac(?x-1);
  15067. HOLD(FAC(?X-1)*?X)
  15068. fac(0) :- 1;
  15069. 1
  15070. fac(?x) :- Gamma(?x+1);
  15071. GAMMA(?X + 1)
  15072. fac(3);
  15073. 6
  15074. fac(3/2);
  15075. GAMMA(5/2)
  15076. \end{verbatim}}
  15077. \chapter[QSUM: {\slshape q}-hypergeometric sums]%
  15078. {QSUM : Package for {\slshape q}-hypergeometric sums}
  15079. \label{QSUM}
  15080. \typeout{{QSUM : Package for summation of
  15081. $q$-hypergeometric terms}}
  15082. \newcommand{\funkdef}[3]{\left\{\!\!\!\begin{array}{cc}
  15083. #1 & \!\!\!\mbox{\rm{if} $#2$ } \\
  15084. #3 & \!\!\!\mbox{\rm{otherwise}}
  15085. \end{array}
  15086. \right.}
  15087. \newcommand{\funkdefff}[6]{\left\{\begin{array}{ccc}
  15088. #1 && \mbox{{if} $#2$ } \\
  15089. #3 && \mbox{{if} $#4$ } \\
  15090. #5 && \mbox{{if} $#6$ }
  15091. \end{array}
  15092. \right.}
  15093. \newcommand{\qphihyp}[5]{{}_{#1}\phi_{#2}\left.\left[\begin{array}{c}
  15094. #3 \\ #4 \end{array}\right|q,#5\right]}
  15095. \newcommand{\qpsihyp}[5]{{}_{#1}\psi_{#2}\left.\left[\begin{array}{c}
  15096. #3 \\ #4 \end{array}\right|q,#5\right]}
  15097. \newcommand{\hyp}[5]{{}_{#1}F_{#2}\left.\left[\begin{array}{c}
  15098. #3 \\ #4 \end{array}\right|#5\right]}
  15099. \newcommand{\fcn}[2]{{\mathrm #1}(#2)}
  15100. \newcommand{\ifcn}[3]{{\mathrm #1}_{#2}(#3)}
  15101. \newcommand{\qgosper}{$q$-Gosper\ }
  15102. \newcommand{\qgosperalg}{\qgosper algorithm\ }
  15103. \newcommand{\qzeilalg}{$q$-Zeilberger algorithm\ }
  15104. \newcommand{\qfac}[2]{\left(#1;\,q\right)_{#2}}
  15105. \newcommand{\qatom}[1]{\left(#1;\,q\right)_{\infty}}
  15106. %\newcommand{\qbinomial}[2]{\left(\begin{array}{c}#1\\#2\end{array}\right)_q}
  15107. %\newcommand{\binomial}[2]{\left(\begin{array}{c}#1\\#2\end{array}\right)}
  15108. \newcommand{\binomial}[2]{{#1 \choose #2}}
  15109. \newcommand{\qbinomial}[2]{{{#1 \choose #2}\!}_q}
  15110. \newcommand{\qfactorial}[2]{}
  15111. \newcounter{redprompt}
  15112. {\setcounter{redprompt}{0}}
  15113. \newcommand{\redprompt}{\stepcounter{redprompt}\theredprompt:}
  15114. \newenvironment{redoutput}{\small\begin{alltt}}{\end{alltt}\noindent{}}
  15115. {\footnotesize
  15116. \begin{center}
  15117. Harald B\"oing \\
  15118. Wolfram Koepf \\
  15119. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin \\
  15120. Takustra\"se 7 \\
  15121. D-14195 Berlin-Dahlem \\
  15122. e-mail: koepf@zib.de
  15123. \end{center}
  15124. }
  15125. \ttindex{QSUM}
  15126. %\markboth{CHAPTER \ref{QSUM}. QSUM: SUMMATION OF Q-HYPERGEOMETRIC TERMS}{}
  15127. %\thispagestyle{myheadings}
  15128. This package is an implementation of the $q$-analogues of Gosper's
  15129. and Zeilberger's
  15130. %
  15131. \footnote{The {\tt ZEILBERG} package (Chap. \ref{ZEILBERG}
  15132. p. \pageref{ZEILBERG}, see also \cite{Koepf:95})
  15133. contains the hypergeometric versions.}
  15134. %
  15135. algorithm for indefinite and definite summation of
  15136. $q$-hypergeometric terms, respectively.
  15137. An expression $a_k$ is called a {\sl $q$-hypergeometric term}, if
  15138. $a_{k}/a_{k-1}$ is a rational function with respect to $q^k$. Most
  15139. $q$-terms are based on the {\sl $q$-shifted factorial} or
  15140. {\sl qpochhammer}. Other typical $q$-hypergeometric terms are ratios
  15141. of products of powers, $q$-factorials, $q$-binomial coefficients, and
  15142. $q$-shifted factorials that are integer-linear in their arguments. \\
  15143. The package is loaded with {\tt load\_package qsum}.
  15144. \section{Elementary {\slshape q}-Functions}
  15145. The package supports the input of the following elementary
  15146. {\slshape q}-functions:
  15147. \begin{itemize}
  15148. \item {\verb@qpochhammer(a,q,infinity)@}
  15149. \ttindex{QPOCHHAMMER}
  15150. \[ \qfac{a}{\infty}:= \prod_{j=0}^{\infty}{\left(1-a\,q^j\right)} \]
  15151. \item {\verb@qpochhammer(a,q,k)@}
  15152. \[ \qfac{a}{k}:= \funkdefff{\prod_{j=0}^{k-1}{\left(1-a\,q^j\right)}}%
  15153. {k>0}{1}{k=0}{\prod_{j=1}^{k}{\left(1-a\,q^{-j}\right)^{-1}}}{k<0}
  15154. \]
  15155. \item {\verb@qbrackets(k,q)@}
  15156. \ttindex{QBRACKETS}
  15157. \[ {}[q,k]:=\frac{q^k-1}{q-1} \]
  15158. \item {\verb@qfactorial(k,q)@}
  15159. \ttindex{QFACTORIAL}
  15160. \[ {}[k]_q!:= \frac{\qfac{q}{k}}{(1-q)^k} \]
  15161. \item {\verb@qbinomial(n,k,q)@}
  15162. \ttindex{QBINOMIAL}
  15163. \[ \qbinomial{n}{k}:=
  15164. \frac{\qfac{q}{n}}{\qfac{q}{k}\cdot\qfac{q}{n-k}} \]
  15165. \item {\protect\verb@qphihyperterm({a1,a2,...,ar},{b1,b2,...,bs},q,z,k)@}
  15166. \ttindex{QPHIHYPERTERM}
  15167. \[ \sum_{k=0}^{\infty}{\frac{\qfac{a_1,a_2,\ldots,a_r}{k}}
  15168. {\qfac{b_1,b_2,\ldots,b_s}{k}}
  15169. \,\frac{z^k}{\qfac{q}{k}}\,\left[(-1)^k\,
  15170. q^{\binomial{k}{2}}\right]^{1+s-r}} \]
  15171. \item {\protect\verb@qpsihyperterm({a1,a2,...,ar},{b1,b2,...,bs},q,z,k)@}
  15172. \ttindex{QPSIHYPERTERM}
  15173. \[\sum_{k=-\infty}^{\infty}{\frac{\qfac{a_1,a_2,\ldots,a_r}{k}}
  15174. {\qfac{b_1,b_2,\ldots,b_s}{k}}\,z^k\,
  15175. \left[(-1)^k\,q^{\binomial{k}{2}}\right]^{s-r}} \]
  15176. \end{itemize}
  15177. where $\qfac{a_1,a_2,\ldots,a_r}{k}$ stands for the
  15178. product $\prod_{j=1}^r{\qfac{a_j}{k}}$.
  15179. \section{The {\ttfamily QGOSPER} operator}
  15180. The {\tt qgosper} operator is an implementation of the $q$-Gosper
  15181. algorithm \cite{Koornwinder:93}.
  15182. \begin{itemize}
  15183. \item {\verb@qgosper(a,q,k)@} determines a $q$-hypergeometric
  15184. antidifference. (By default it returns a {\sl downward}
  15185. antidifference, which may be changed by the switch
  15186. {\verb@qgosper_down@}.)
  15187. If it does not return a \textsl{q}-hypergeometric antidifference,
  15188. then such an antidifference does not exist.
  15189. \item {\verb@qgosper(a,q,k,m,n)@} determines a closed formula
  15190. for the definite sum \[\sum\limits_{k=m}^n a_k\] using the
  15191. $q$-analogue of Gosper's algorithm.
  15192. This is only successful if \textsl{q}-Gosper's algorithm applies.
  15193. \end{itemize}
  15194. {\bf Example:}
  15195. {\small\begin{verbatim}
  15196. 1: qgosper(qpochhammer(a,q,k)*q^k/qpochhammer(q,q,k),q,k);
  15197. k
  15198. (q *a - 1)*qpochhammer(a,q,k)
  15199. -------------------------------
  15200. (a - 1)*qpochhammer(q,q,k)
  15201. \end{verbatim}}
  15202. \section{The {\ttfamily QSUMRECURSION} operator}
  15203. \label{QSUMRECURSION}
  15204. The \f{QSUMRECURSION\ttindex{QSUMRECURSION}} operator is an implementation
  15205. of the $q$-Zeilberger algorithm \cite{Koornwinder:93}.
  15206. It tries to determine a homogeneous recurrence equation for
  15207. $\fcn{summ}{n}$ wrt. $n$ with polynomial coefficients (in $n$), where
  15208. \[
  15209. \fcn{summ}{n}:= \sum_{k=-\infty}^{\infty}{\fcn{f}{n,k}}.
  15210. \]
  15211. There are three different ways to pass a summand $\fcn{f}{n,k}$
  15212. to {\verb@qsumrecursion@}:
  15213. \begin{itemize}
  15214. \item {\verb@qsumrecursion(f,q,k,n)@}, where {\tt f} is a
  15215. $q$-hypergeometric term wrt. {\tt k} and {\tt n},
  15216. {\tt k} is the summation variable and {\tt n} the recursion
  15217. variable, {\tt q} is a symbol.
  15218. \item {\verb@qsumrecursion(upper,lower,q,z,n)@} is a shortcut for \\
  15219. {\verb@qsumrecursion(qphihyperterm(upper,lower,q,z,k),q,k,n)@}
  15220. \item {\verb@qsumrecursion(f,upper,lower,q,z,n)@} is a similar
  15221. shortcut for\\
  15222. {\verb@qsumrecursion(f*qphihyperterm(upper,lower,q,z,k),q,k,n)@},
  15223. \end{itemize}
  15224. i.\,e.\ {\tt upper} and {\tt lower} are lists of upper and lower
  15225. parameters of the generalized $q$-hypergeometric function.
  15226. The third form is handy if you have any additional factors.
  15227. For all three instances it is possible to pass the order, if known
  15228. in advance, as additional argument at the end of the parameter sequence.
  15229. You can also specifiy a range by a list of two positive integers, the first
  15230. one specifying the lowest and the second one the highest order. By default
  15231. \f{QSUMRECURSION} will search for recurrences of order from 1 to 5. Usually
  15232. it uses {\tt summ} as name for the summ-function. If you want to change this
  15233. behaviour then use the following syntax: \f{QSUMRECURSION(f,q,k,s(n))}.
  15234. {\small\begin{verbatim}
  15235. 2: qsumrecursion(qpochhammer(q^(-n),q,k)*z^k /
  15236. qpochhammer(q,q,k),q,k,n);
  15237. n n
  15238. - ((q - z)*summ(n - 1) - q *summ(n))
  15239. \end{verbatim}}
  15240. \section{Global Variables and Switches}
  15241. There are several switches defined in the \f{QSUM} package. Please take a
  15242. look in the accompanying documentation file {\tt qsum.tex} in
  15243. \$REDUCEPATH/packages/. \\
  15244. The most important switches are:
  15245. \begin{itemize}
  15246. \item \verb@qgosper_down@, default setting is on. It determines
  15247. whether \verb@qgosper@ returns a downward or an upward
  15248. antidifference $g_k$ for the input term $a_k$,
  15249. .\,e.\ $a_k=g_k-g_{k-1}$ or $a_k=g_{k+1}-g_k$ respectively.
  15250. \item \verb@qsumrecursion_certificate@, default off.
  15251. As Zeilberger's algorithm
  15252. delivers a recurrence equation for a $q$-hypergeometric term
  15253. $\mathrm{f}(n,k)$ this switch is used to get all necessary
  15254. informations for proving this recurrence equation.
  15255. If it is set on, instead of simply returning the
  15256. resulting recurrence equation (for the sum)---if one
  15257. exists---\verb@qsumrecursion@ returns
  15258. a list \verb@{rec,cert,f,k,dir}@ with
  15259. five items: The first entry contains the
  15260. recurrence equation, while the other items enable you to
  15261. prove the recurrence a posteriori by rational arithmetic.
  15262. If we denote by \verb@r@ the recurrence
  15263. \verb@rec@ where we substituted the \verb@summ@-function
  15264. by the input term \verb@f@ (with the corresponding shifts
  15265. in \verb@n@) then the following equation is valid:
  15266. \[ \verb@r = cert*f - sub(k=k-1,cert*f)@ \]
  15267. or
  15268. \[ \verb@r = sub(k=k+1,cert*f) - cert*f@ \]
  15269. if \verb@dir=downward_antidifference@ or
  15270. \verb@dir=upward_antidifference@ respectively.
  15271. \end{itemize}
  15272. There is one global variable:
  15273. \begin{itemize}
  15274. \item \verb@qsumrecursion_recrange!*@ controls for
  15275. which recursion orders the procedure \verb@qsumrecursion@ looks.
  15276. It has to be a list with two entries, the first one representing
  15277. the lowest and the second one the highest order of a recursion
  15278. to search for. By default it is set to \verb@{1,5}@.
  15279. \end{itemize}
  15280. \chapter[RANDPOLY: Random polynomials]%
  15281. {RANDPOLY: A random polynomial generator}
  15282. \label{RANDPOLY}
  15283. \typeout{{RANDPOLY: A random polynomial generator}}
  15284. {\footnotesize
  15285. \begin{center}
  15286. Francis J. Wright \\
  15287. School of Mathematical Sciences, Queen Mary and Westfield College \\
  15288. University of London \\
  15289. Mile End Road \\
  15290. London E1 4NS, England \\[0.05in]
  15291. e--mail: F.J.Wright@QMW.ac.uk
  15292. \end{center}
  15293. }
  15294. \ttindex{RANDPOLY}
  15295. The operator {\tt RANDPOLY}\ttindex{RANDPOLY} requires at least one
  15296. argument corresponding to the polynomial variable or variables, which
  15297. must be either a single expression or a list of expressions.
  15298. In effect, {\tt RANDPOLY} replaces each input expression by an
  15299. internal variable and then substitutes the input expression for the
  15300. internal variable in the generated polynomial (and by default expands
  15301. the result as usual). The rest of this document
  15302. uses the term ``variable'' to refer to a general input expression or
  15303. the internal variable used to represent it, and all references to the
  15304. polynomial structure, such as its degree, are with respect to these
  15305. internal variables. The actual degree of a generated polynomial might
  15306. be different from its degree in the internal variables.
  15307. By default, the polynomial generated has degree 5 and contains 6
  15308. terms. Therefore, if it is univariate it is dense whereas if it is
  15309. multivariate it is sparse.
  15310. \section{Optional arguments}
  15311. Other arguments can optionally be specified, in any order, after the
  15312. first compulsory variable argument. All arguments receive full
  15313. algebraic evaluation, subject to the current switch settings etc. The
  15314. arguments are processed in the order given, so that if more than one
  15315. argument relates to the same property then the last one specified
  15316. takes effect. Optional arguments are either keywords or equations
  15317. with keywords on the left.
  15318. In general, the polynomial is sparse by default, unless the keyword
  15319. {\tt dense}\index{randpoly ! {\tt dense}} is specified as an optional
  15320. argument. (The keyword {\tt sparse}\index{randpoly ! {\tt sparse}} is
  15321. also accepted, but is the default.) The default degree can be changed
  15322. by specifying an optional argument of the form\index{randpoly
  15323. ! {\tt degree}}
  15324. \begin{center}
  15325. {\tt degree = {\it natural number}}.
  15326. \end{center}
  15327. In the multivariate case this is the total degree, {\em i.e.\ }the sum of
  15328. the degrees with respect to the individual variables.
  15329. More complicated monomial degree bounds can be constructed by using
  15330. the coefficient function described below to return a monomial or
  15331. polynomial coefficient expression. Moreover, {\tt randpoly} respects
  15332. internally the \REDUCE\ ``asymptotic'' commands {\tt let}, {\tt weight}
  15333. {\em etc.\ }described in section~\ref{sec-asymp}, which can be used
  15334. to exercise additional control over the polynomial generated.
  15335. In the sparse case (only), the default maximum number of terms
  15336. generated can be changed by specifying an optional argument of the
  15337. form\index{randpoly ! {\tt terms}}
  15338. \begin{center}
  15339. {\tt terms = {\it natural number}}.
  15340. \end{center}
  15341. The actual number of terms generated will be the minimum of the value
  15342. of {\tt terms} and the number of terms in a dense polynomial of the
  15343. specified degree, number of variables, {\em etc.}
  15344. \section{Advanced use of RANDPOLY}
  15345. The default order (or minimum or trailing degree) can be changed by
  15346. specifying an optional argument of the form\index{randpoly ! {\tt ord}}
  15347. \begin{center}
  15348. {\tt ord = {\it natural number}}.
  15349. \end{center}
  15350. The order normally defaults to 0.
  15351. The input expressions to {\tt randpoly} can also be
  15352. equations, in which case the order defaults to 1 rather than 0. Input
  15353. equations are converted to the difference of their two sides before
  15354. being substituted into the generated polynomial. This makes it easy
  15355. to generate polynomials with a specified zero -- for example
  15356. \begin{center}\tt
  15357. randpoly(x = a);
  15358. \end{center}
  15359. generates a polynomial that is guaranteed to vanish at $x = a$, but is
  15360. otherwise random.
  15361. The operator {\tt randpoly} accepts two further optional arguments in
  15362. the form of equations with the keywords {\tt coeffs}
  15363. \index{randpoly ! {\tt coeffs}} and {\tt expons}\index{randpoly ! {\tt expons}}
  15364. on the left. The right sides of each of these equations must evaluate
  15365. to objects that can be applied as functions of no variables. These
  15366. functions should be normal algebraic procedures; the {\tt coeffs}
  15367. procedure may return any algebraic expression, but the {\tt expons}
  15368. procedure must return an integer. The values returned by
  15369. the functions should normally be random, because it is the randomness
  15370. of the coefficients and, in the sparse case, of the exponents that
  15371. makes the constructed polynomial random.
  15372. A convenient special case is to use the function {\tt rand} on the
  15373. right of one or both of these equations; when called with a single
  15374. argument {\tt rand} returns an anonymous function of no variables that
  15375. generates a random integer. The single argument of {\tt rand} should
  15376. normally be an integer range in the form $a~..~b$, where $a$, $b$ are
  15377. integers such that $a < b$. For example, the {\tt expons} argument might
  15378. take the form
  15379. \begin{center}\tt
  15380. expons = rand(0~..~n)
  15381. \end{center}
  15382. where {\tt n} will be the maximum degree with respect to each variable
  15383. {\em independently}. In the case of {\tt coeffs} the lower limit will
  15384. often be the negative of the upper limit to give a balanced
  15385. coefficient range, so that the {\tt coeffs} argument might take the
  15386. form
  15387. \begin{center}\tt
  15388. coeffs = rand(-n~..~n)
  15389. \end{center}
  15390. which will generate random integer coefficients in the range $[-n,n]$.
  15391. Further information on the the auxiliary functions of RANDPOLY can be
  15392. found in the extended documentation and examples.
  15393. \section{Examples}
  15394. \label{sec:Examples}
  15395. {\small\begin{verbatim}
  15396. randpoly(x);
  15397. 5 4 3 2
  15398. - 54*x - 92*x - 30*x + 73*x - 69*x - 67
  15399. randpoly({x, y}, terms = 20);
  15400. 5 4 4 3 2 3 3
  15401. 31*x - 17*x *y - 48*x - 15*x *y + 80*x *y + 92*x
  15402. 2 3 2 2 4 3 2
  15403. + 86*x *y + 2*x *y - 44*x + 83*x*y + 85*x*y + 55*x*y
  15404. 5 4 3 2
  15405. - 27*x*y + 33*x - 98*y + 51*y - 2*y + 70*y - 60*y - 10
  15406. \end{verbatim}}
  15407. \newpage
  15408. {\small\begin{verbatim}
  15409. randpoly({x, sin(x), cos(x)});
  15410. 4 3 3
  15411. sin(x)*( - 4*cos(x) - 85*cos(x) *x + 50*sin(x)
  15412. 2
  15413. - 20*sin(x) *x + 76*sin(x)*x + 96*sin(x))
  15414. \end{verbatim}}
  15415. \chapter[RATAPRX: Rational Approximations]%
  15416. {RATAPRX : Rational Approximations Package}
  15417. \label{RATAPRX}
  15418. \typeout{{RATAPRX : Rational Approximations Package}}
  15419. {\footnotesize
  15420. \begin{center}
  15421. Lisa Temme\\
  15422. Wolfram Koepf\\
  15423. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin\\
  15424. Takustra\"se 7 \\
  15425. D-14195 Berlin-Dahlem, Germany \\
  15426. e-mail: koepf@zib.de
  15427. \end{center}
  15428. }
  15429. \ttindex{RATAPRX}
  15430. This package provides functions to
  15431. \begin{itemize}
  15432. \item convert rational numbers in their periodic representation and vice versa,
  15433. \item to compute continued fractions and
  15434. \item to compute the Pad\'{e} approximant of a function.
  15435. \end{itemize}
  15436. The package can be loaded using {\tt load\_package rataprx;} it supersedes
  15437. the {\tt contfr} package.
  15438. \section{}
  15439. \subsection{Periodic Representation}
  15440. The function \f{rational2periodic(n)\ttindex{RATIONAL2PERIODIC}}
  15441. converts a rational number {\tt n} in its periodic representation.
  15442. For example $59/70$ is converted to $0.8\overline{428571}$. \\
  15443. Depending on the print function of your \REDUCE\ system, calling the
  15444. function \f{rational2periodic} might result in an expression of
  15445. the form {\tt periodic(\{a,b\},\{c$_1$,...,c$_n$\})\ttindex{PERIODIC}}.
  15446. {\tt a} and {\tt b} is the non-periodic part of the rational number
  15447. {\tt n} and {\tt c$_1$,...,c$_n$} are the digits of the periodic part.
  15448. In this case $59/70$ would result in {\tt periodic(\{8,10\},\{4,2,8,5,7,1\})}. \\
  15449. The function \f{periodic2rational(periodic(\{a,b\},\{c$_1$,...,c$_n$\}))
  15450. \ttindex{PERIODIC2RATIONAL}} is the
  15451. inverse function and computes the rational expression for a periodic one.
  15452. Note that {\tt b} is 1,-1 or a integer multiple of 10. If {\tt a} is zero,
  15453. then the input number {\tt b} indicates how many places after the decimal
  15454. point the period occurs.
  15455. {\small\begin{verbatim}
  15456. rational2periodic(6/17);
  15457. periodic({0,1},{3,5,2,9,4,1,1,7,6,4,7,0,5,8,8,2})
  15458. periodic2rational(ws);
  15459. 6
  15460. ----
  15461. 17
  15462. \end{verbatim}}
  15463. \subsection{Continued Fractions}
  15464. A continued fraction (see \cite{Baker:81a} \S 4.2) has the general form
  15465. \[b_0 + \frac{a_1}{b_1 +
  15466. \frac{a_2}{b_2+
  15467. \frac{a_3}{b_3 + \ldots
  15468. }}}
  15469. \;.\]
  15470. A more compact way of writing this is as
  15471. \[b_0 + \frac{a_1|}{|b_1} + \frac{a_2|}{|b_2} + \frac{a_3|}{|b_3} + \ldots\,.\]
  15472. \\
  15473. This is represented in \REDUCE\ as
  15474. \[{\tt
  15475. contfrac({\mbox{\sl Rational\hspace{2mm} approximant}},
  15476. \{b_0, \{a_1,b_1\}, \{a_2,b_2\},.....\}).\ttindex{CONTFRAC}
  15477. }\]
  15478. There are four different functions to determine the continued fractions
  15479. for real numbers and functions {\tt f} in the variable {\tt var}:
  15480. \begin{center}
  15481. {\tt
  15482. \begin{tabular}{l l}
  15483. cfrac(number); & cfrac(number,length); \\
  15484. cfrac(f, var); & cfrac(f, var, length);
  15485. \end{tabular}} \\[1mm]
  15486. \end{center}
  15487. \ttindex{CFRAC}
  15488. The {\tt length} argument is optional and specifies the number of
  15489. ordered pairs $\{a_i,b_i\}$ to be returned. It's default value is five.
  15490. {\small\begin{verbatim}
  15491. cfrac pi;
  15492. 1146408
  15493. contfrac(---------),
  15494. 364913
  15495. {3,{1,7},{1,15},{1,1},{1,292},{1,1},{1,1},{1,1},
  15496. {1,2},{1,1}})
  15497. \end{verbatim}}
  15498. \newpage
  15499. {\small\begin{verbatim}
  15500. cfrac((x+2/3)^2/(6*x-5),x);
  15501. 2
  15502. 9*x + 12*x + 4 6*x + 13 24*x - 20
  15503. contfrac(-----------------,{----------,{1,-----------}})
  15504. 54*x - 45 36 9
  15505. cfrac(e^x,x);
  15506. 3 2
  15507. x + 9*x + 36*x + 60
  15508. contfrac(-----------------------,
  15509. 2
  15510. 3*x - 24*x + 60
  15511. {1,{x,1},{ - x,2},{x,3},{ - x,2},{x,5}})
  15512. \end{verbatim}}
  15513. \subsection{Pad\'{e} Approximation}
  15514. The Pad\'{e} approximant represents a function by the ratio of two
  15515. polynomials. The coefficients of the powers occuring in the polynomials
  15516. are determined by the coefficients in the Taylor series
  15517. expansion of the function (see \cite{Baker:81a}). Given a power series
  15518. \[ f(x) = c_0 + c_1 (x-h) + c_2 (x-h)^2 \ldots \]
  15519. and the degree of numerator, $n$, and of the denominator, $d$,
  15520. the {\tt pade} function finds the unique coefficients
  15521. $a_i,\, b_i$ in the Pad\'{e} approximant
  15522. \[ \frac{a_0+a_1 x+ \cdots + a_n x^n}{b_0+b_1 x+ \cdots + b_d x^d} \; .\]
  15523. The function \f{pade(f, x, h ,n ,d)\ttindex{PAD\'{E}}} takes as input the
  15524. function {\tt f} in the variable {\tt x} to be approximated , where
  15525. {\tt h} is the point at which the approximation is evaluated. {\tt n}
  15526. and {\tt d} are the (specified) degrees of the numerator and the denominator.
  15527. It returns the Pad\'{e} Approximant, ie. a rational function. \par
  15528. Error Messages may occur in the following different cases:
  15529. \begin{itemize}
  15530. \item The Taylor series expansion for the function {\tt f} has not yet been
  15531. implemented in the \REDUCE\ Taylor Package.
  15532. \item A Pad\'{e} Approximant of this function does not exist.
  15533. \item A Pad\'{e} Approximant of this order (ie. the specified numerator and
  15534. denominator orders) does not exist. Please note, there might exist an
  15535. approximant of a different order.
  15536. \end{itemize}
  15537. \newpage
  15538. {\small\begin{verbatim}
  15539. pade(sin(x),x,0,3,3);
  15540. 2
  15541. x*( - 7*x + 60)
  15542. ------------------
  15543. 2
  15544. 3*(x + 20)
  15545. pade(tanh(x),x,0,5,5);
  15546. 4 2
  15547. x*(x + 105*x + 945)
  15548. -----------------------
  15549. 4 2
  15550. 15*(x + 28*x + 63)
  15551. pade(exp(1/x),x,0,5,5);
  15552. ***** no Pade Approximation exists
  15553. pade(factorial(x),x,1,3,3);
  15554. ***** not yet implemented
  15555. 30: pade(sin(x)/x^2,x,0,10,0);
  15556. ***** Pade Approximation of this order does not exist
  15557. 31: pade(sin(x)/x^2,x,0,10,2);
  15558. 10 8 6 4 2
  15559. - x + 110*x - 7920*x + 332640*x - 6652800*x + 39916800
  15560. --------------------------------------------------------------
  15561. 39916800*x
  15562. \end{verbatim}}
  15563. \chapter[REACTEQN: Chemical reaction equations]%
  15564. {REACTEQN: Support for chemical reaction equations}
  15565. \label{REACTEQN}
  15566. \typeout{{REACTEQN: Support for chemical reaction equations}}
  15567. {\footnotesize
  15568. \begin{center}
  15569. Herbert Melenk \\
  15570. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  15571. Takustra\"se 7 \\
  15572. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  15573. e--mail: melenk@zib.de
  15574. \end{center}
  15575. }
  15576. \ttindex{REACTEQN}
  15577. The \REDUCE\ package REACTEQN allows one to transform chemical reaction
  15578. systems into ordinary differential equation systems corresponding to
  15579. the laws of pure mass action.
  15580. It provides the single function
  15581. {\small\begin{verbatim}
  15582. reac2ode { <reaction> [,<rate> [,<rate>]]
  15583. [,<reaction> [,<rate> [,<rate>]]]
  15584. ....
  15585. };
  15586. \end{verbatim}}
  15587. A rate is any \REDUCE\ expression, and two rates are applicable only
  15588. for forward and backward reactions. A reaction is coded as a linear
  15589. sum of the series variables, with the operator $->$ for forward
  15590. reactions and $<>$ for two-way reactions.
  15591. The result is a system of explicit ordinary differential equations
  15592. with polynomial righthand sides. As side effect the following
  15593. variables are set:
  15594. \newpage
  15595. \begin{description}
  15596. \item[{\tt rates}]
  15597. \index{reacteqn ! {\tt rates}} A list of the rates in the system.
  15598. \item[{\tt species}]
  15599. \index{reacteqn ! {\tt species}} A list of the species in the system.
  15600. \item[{\tt inputmat}]
  15601. \index{reacteqn ! {\tt inputmat}} A matrix of the input coefficients.
  15602. \item[{\tt outputmat}]
  15603. \index{reacteqn ! {\tt outputmat}} A matrix of the output coefficients.
  15604. \end{description}
  15605. In the matrices the row number corresponds to the input reaction
  15606. number, while the column number corresponds to the species index.
  15607. If the rates are numerical values, it will be in most cases
  15608. appropriate to select a \REDUCE\ evaluation mode for floating point numbers.
  15609. {\tt Inputmat} and {\tt outputmat} can be used for linear algebra type
  15610. investigations of the reaction system. The classical reaction
  15611. matrix is the difference of these matrices; however, the two
  15612. matrices contain more information than their differences because
  15613. the appearance of a species on both sides is not reflected by
  15614. the reaction matrix.
  15615. \chapter{REDLOG: Logic System}
  15616. \label{REDLOG}
  15617. \typeout{{REDLOG: Logic System}}
  15618. {\footnotesize
  15619. \begin{center}
  15620. Andreas Dolzmann \\
  15621. Thomas Sturm \\
  15622. University of Passau, Germany \\
  15623. e-mail: dolzmann@uni-passau.de, sturm@uni-passau.de
  15624. \end{center}
  15625. }
  15626. \ttindex{REDLOG}
  15627. \section{Introduction}
  15628. This package extends \REDUCE\ to a computer logic system implementing
  15629. symbolic algorithms on first-order formulas wrt.~temporarily fixed
  15630. first-order languages and theories.
  15631. \subsection{Contexts}
  15632. REDLOG is designed for working with several languages and theories in
  15633. the sense of first-order logic. Both a language and a theory make up a
  15634. context. There are the following contexts available:
  15635. \begin{description}
  15636. \item[\textsc{OFSF}]
  15637. \textsc{OF} stands for \emph{ordered fields}, which is a little imprecise.
  15638. The quantifier elimination actually requires the more restricted class
  15639. of \emph{real closed fields}, while most of the tool-like algorithms
  15640. are generally correct for ordered fields. One usually has in mind real
  15641. numbers with ordering when using \textsc{OFSF}.
  15642. \item[\textsc{DVFSF}]
  15643. \emph{Discretely valued fields}. This is for computing with formulas
  15644. over classes of $p$-adic valued extension fields of the rationals,
  15645. usually the fields of $p$-adic numbers for some prime $p$.
  15646. \item[\textsc{ACFSF}]
  15647. \emph{Algebraically closed fields} such as the complex numbers.
  15648. \end{description}
  15649. \subsection{Overview}
  15650. REDLOG origins from the implementation of quantifier elimination
  15651. procedures. Successfully applying such methods to both academic and
  15652. real-world problems, the authors have developed over the time a large
  15653. set of formula-manipulating tools, many of which are meanwhile
  15654. interesting in their own right:
  15655. \begin{itemize}
  15656. \item
  15657. Numerous tools for comfortably inputing, decomposing, and analyzing
  15658. formulas.
  15659. \item
  15660. Several techniques for the \emph{simplification} of formulas.
  15661. \item
  15662. Various \emph{normal form computations}. The
  15663. \emph{\textsc{CNF}/\textsc{DNF}} computation includes both Boolean and
  15664. algebraic simplification strategies. The \emph{prenex normal form}
  15665. computation minimizes the number of quantifier changes.
  15666. \item
  15667. \emph{Quantifier elimination} computes quantifier-free equivalents for
  15668. given first-order formulas. For \textsc{OFSF} and \textsc{DVFSF} the
  15669. formulas have to obey certain degree restrictions.
  15670. \item
  15671. The context \textsc{OFSF} allows a variant of quantifier elimination
  15672. called \emph{generic quantifier elimination}: There are certain
  15673. non-degeneracy assumptions made on the parameters, which considerably
  15674. speeds up the elimination.
  15675. \item
  15676. The contexts \textsc{OFSF} and \textsc{DVFSF} provide variants of
  15677. (generic) quantifier elimination that additionally compute
  15678. \emph{answers} such as satisfying sample points for existentially
  15679. quantified formulas.
  15680. \item
  15681. \textsc{OFSF}
  15682. includes linear \emph{optimization} techniques based on quantifier
  15683. elimination.
  15684. \end{itemize}
  15685. To avoid ambiguities with other packages, all \textsc{REDLOG} functions and
  15686. switches are prefixed by ``\texttt{RL}''.
  15687. The package is loaded by typing: \qquad {\tt load\_package redlog;} \\
  15688. It is recommended to read the documentation which comes with this
  15689. package. This manual chapter gives an overview on the features of
  15690. \textsc{REDLOG}, which is by no means complete.
  15691. \section{Context Selection}
  15692. The context to be used has to be selected explicitly. One way
  15693. to do this is using the command \f{RLSET}\ttindex{RLSET}. As argument it takes one
  15694. of the
  15695. valid choices \f{ACFSF}\ttindex{ACFSF} (algebraically closed fields
  15696. standard form),
  15697. \f{OFSF}\ttindex{OFSF} (ordered fields standard form), and
  15698. \f{DVFSF}\ttindex{DVFSF}
  15699. (discretely valued fields standard form). By default, \f{DVFSF}\ttindex{DVFSF}
  15700. computes
  15701. uniformly over the class of all $p$-adic valued fields. For the sake
  15702. of efficiency, this can be restricted by means of an extra
  15703. \f{RLSET}\ttindex{RLSET} argument.
  15704. \f{RLSET}\ttindex{RLSET} returns the old setting as a list.
  15705. \section{Format and Handling of Formulas}
  15706. \subsection{First-order Operators}
  15707. REDLOG knows the following operators for constructing Boolean
  15708. combinations and quantifications of atomic formulas:
  15709. \begin{center}
  15710. \begin{tabular}{llll}
  15711. \f{NOT}\ttindex{NOT}: Unary &
  15712. \f{AND}\ttindex{AND}: N-ary Infix &
  15713. \f{OR}\ttindex{OR}: N-ary Infix &
  15714. \f{IMPL}\ttindex{IMPL}: Binary Infix \\
  15715. \f{REPL}\ttindex{REPL}: Binary Infix &
  15716. \f{EQUIV}\ttindex{EQUIV}: Binary Infix &
  15717. \f{EX}\ttindex{EX}: Binary \\
  15718. \f{ALL}\ttindex{ALL}: Binary &
  15719. \f{TRUE}\ttindex{TRUE}: Variable &
  15720. \f{FALSE}\ttindex{FALSE}: Variable &
  15721. \end{tabular}
  15722. \end{center}
  15723. The \f{EX} and the \f{ALL} operators are the quantifiers. Their first
  15724. argument is the quantified variable, the second one a matrix formula.
  15725. There are operators \f{MKAND}\ttindex{MKAND} and
  15726. \f{MKOR}\ttindex{MKOR} for the construction of large systematic
  15727. conjunctions/disjunctions via for loops available. They are used in
  15728. the style of \f{SUM} and \f{COLLECT}.
  15729. \vspace{0.5cm}
  15730. {\bf Example:}
  15731. {\small\begin{verbatim}
  15732. 1: load_package redlog;
  15733. 2: rlset ofsf;
  15734. {}
  15735. 3: g := for i:=1:3 mkand
  15736. for j:=1:3 mkor
  15737. if j<>i then mkid(x,i) + mkid(x,j)=0;
  15738. true and (false or false or x1 + x2 = 0 or x1 + x3 = 0)
  15739. and (false or x1 + x2 = 0 or false or x2 + x3 = 0)
  15740. and (false or x1 + x3 = 0 or x2 + x3 = 0 or false)
  15741. \end{verbatim}}
  15742. \subsection{OFSF Operators}
  15743. The \f{OFSF}\ttindex{OFSF} context implements {\it ordered fields}
  15744. over the language of {\it ordered rings}. There are the following
  15745. binary operators available:
  15746. \begin{center}
  15747. \begin{tabular}{llllllll}
  15748. \f{EQUAL}\ttindex{EQUAL} &
  15749. \f{NEQ}\ttindex{NEQ} &
  15750. \f{LEQ}\ttindex{LEQ} &
  15751. \f{GEQ}\ttindex{GEQ} &
  15752. \f{LESSP}\ttindex{LESSP} &
  15753. \f{GREATERP}\ttindex{GREATERP}
  15754. \end{tabular}
  15755. \end{center}
  15756. They can also be written as \f{=}, \f{<>}, \f{<=}, \f{>=}, \f{<}, and
  15757. \f{>}.
  15758. For {\sc OFSF}
  15759. there is specified that all right hand sides must be zero. Non-zero right
  15760. hand sides are immediately subtracted.
  15761. \subsection{DVFSF Operators}\ttindex{DVFSF}
  15762. Discretely valued fields are implemented as a one-sorted language
  15763. using in addition to \f{=} and \f{<>} the
  15764. binary operators \f{|}, \f{||}, \f{\~{}}, and \f{/\~{}}, which encode
  15765. $\leq$, $<$, $=$, and $\neq$ in the
  15766. value group, respectively.
  15767. \begin{center}
  15768. \begin{tabular}{llllll}
  15769. \f{EQUAL}\ttindex{EQUAL} &
  15770. \f{NEQ}\ttindex{NEQ} &
  15771. \f{DIV}\ttindex{DIV} &
  15772. \f{SDIV}\ttindex{SDIV} &
  15773. \f{ASSOC}\ttindex{ASSOC} &
  15774. \f{NASSOC}\ttindex{NASSOC} \\
  15775. \end{tabular}
  15776. \end{center}
  15777. \subsection{ACFSF Operators}\ttindex{ACFSF}
  15778. For algebraically closed fields there are only equations and
  15779. inequalities allowed:
  15780. \begin{center}
  15781. \begin{tabular}{ll}
  15782. \f{EQUAL}\ttindex{EQUAL} &
  15783. \f{NEQ}\ttindex{NEQ}
  15784. \end{tabular}
  15785. \end{center}
  15786. As in \textsc{OFSF}, they can be conveniently written as \f{=} and
  15787. \f{<>}, respectively. All right hand sides are zero.
  15788. \subsection{Extended Built-in Commands}
  15789. The operators
  15790. \f{SUB}\ttindex{SUB},
  15791. \f{PART}\ttindex{PART},
  15792. and \f{LENGTH}\ttindex{LENGTH} work on formulas in a reasonable way.
  15793. \subsection{Global Switches}
  15794. The switch \f{RLSIMPL}\ttindex{RLSIMPL} causes the function
  15795. \f{RLSIMPL} to be automatically applied at the expression evaluation stage.
  15796. The switch \f{RLREALTIME}\ttindex{RLREALTIME} protocols the wall clock
  15797. time needed for {\sc REDLOG} commands in seconds.
  15798. The switch \f{RLVERBOSE}\ttindex{RLVERBOSE} toggles verbosity output
  15799. with some {\sc REDLOG} procedures.
  15800. \section{Simplification}
  15801. {\sc REDLOG} knows three types of simplifiers to reduce the size of a
  15802. given first-order formula: the standard simplifier, tableau
  15803. simplifiers, and Gr\"obner simplifiers.
  15804. \subsection{Standard Simplifier}
  15805. The standard simplifier \f{RLSIMPL}\ttindex{RLSIMPL} returns a
  15806. simplified equivalent of its argument formula. It is much faster
  15807. though less powerful than the other simplifiers.
  15808. As an optional argument there can be a \emph{theory} passed. This is a
  15809. list of atomic formulas assumed to hold. Simplification is then
  15810. performed on the basis of these assumptions.
  15811. \vspace{0.5cm}
  15812. {\bf Example:}
  15813. {\small\begin{verbatim}
  15814. 4: rlsimpl g;
  15815. (x1 + x2 = 0 or x1 + x3 = 0) and (x1 + x2 = 0 or x2 + x3 = 0)
  15816. and (x1 + x3 = 0 or x2 + x3 = 0)
  15817. \end{verbatim}}
  15818. \subsection{Tableau Simplifier}
  15819. The standard simplifier preserves the basic Boolean structure of a formula. The
  15820. tableau methods, in contrast, provide a technique for changing the Boolean
  15821. structure of a formula by constructing case distinctions.
  15822. The function \f{RLATAB}\ttindex{RLATAB} automatically finds a suitable
  15823. case distinction. Based on \f{RLATAB}, the function
  15824. \f{RLITAB}\ttindex{RLITAB} iterates this process until no further
  15825. simplification can be detected. There is a more fundamental entry
  15826. point \f{RLTAB}\ttindex{RLTAB} for manually entering case
  15827. distinctions.
  15828. \subsection{Gr\"obner Simplifier}
  15829. The Gr\"obner simplifier considers algebraic simplification rules
  15830. between the atomic formulas of the input formula. The usual procedure
  15831. called for Gr\"obner simplification is \f{RLGSN}\ttindex{RLGSN}.
  15832. Similar to the standard simplifier, there is an optional theory
  15833. argument.
  15834. \begin{samepage}
  15835. \vspace{0.5cm}
  15836. {\bf Example:}
  15837. {\small\begin{verbatim}
  15838. 5: rlgsn(x*y+1<>0 or y*z+1<>0 or x-z=0);
  15839. true
  15840. \end{verbatim}}
  15841. \end{samepage}
  15842. \section{Normal Forms}
  15843. \subsection{Boolean Normal Forms}
  15844. \f{RLCNF}\ttindex{RLCNF} and \f{RLDNF}\ttindex{RLDNF} compute conjunctive
  15845. resp.~disjunctive normal forms of their formula arguments. Subsumption
  15846. and cut strategies are applied to decrease the number of clauses.
  15847. \subsection{Miscellaneous Normal Forms}
  15848. \f{RLNNF}\ttindex{RLNNF} computes a
  15849. negation normal form. This is an {\tt and}-\texttt{or}-combination of
  15850. atomic formulas.
  15851. \f{RLPNF}\ttindex{RLPNF} computes a prenex normal form of its
  15852. argument. That is, all quantifiers are moved outside such that they
  15853. form a block in front of a quantifier-free matrix formula.
  15854. \section{Quantifier Elimination and Variants}
  15855. Quantifier elimination computes quantifier-free equivalents for given
  15856. first-order formulas. For \textsc{OFSF} and \textsc{DVFSF}, REDLOG
  15857. uses a technique based on elimination set ideas. The \textsc{OFSF}
  15858. implementation is restricted to at most quadratic occurrences of the
  15859. quantified variables, but includes numerous heuristic strategies for
  15860. coping with higher degrees. The \textsc{DVFSF} implementation is
  15861. restricted to formulas that are linear in the quantified variables.
  15862. The \textsc{ACFSF} quantifier elimination is based on comprehensive
  15863. Gr\"obner basis computation; there are no degree restrictions for this
  15864. context
  15865. \subsection{Quantifier Elimination}
  15866. \f{RLQE}\ttindex{RLQE} performs quantifier elimination on its argument
  15867. formula. There is an optional theory argument in the style of
  15868. \f{RLSIMPL} supported.
  15869. \begin{samepage}
  15870. \vspace{0.5cm}
  15871. {\bf Example:}
  15872. {\small\begin{verbatim}
  15873. 6: rlqe(ex(x,a*x**2+b*x+c>0),{a<0});
  15874. 2
  15875. 4*a*c - b < 0
  15876. \end{verbatim}}
  15877. \end{samepage}
  15878. For \textsc{OFSF} and \textsc{DVFSF} there is a variant
  15879. \f{RLQEA}\ttindex{RLQEA} available. It returns instead of a
  15880. quantifier-free equivalent, a list of condition-solution pairs
  15881. containing, e.g., satisfying sample points for outermost existential
  15882. quantifier blocks.
  15883. \begin{samepage}
  15884. \vspace{0.5cm}
  15885. {\bf Example:}
  15886. {\small\begin{verbatim}
  15887. 7: rlqea(ex(x,a*x**2+b*x+c>0),{a<0});
  15888. 2
  15889. {{4*a*c - b < 0,
  15890. 2
  15891. - sqrt( - 4*a*c + b ) - 2*a*epsilon1 - b
  15892. {x = -------------------------------------------}}}
  15893. 2*a
  15894. \end{verbatim}}
  15895. \end{samepage}
  15896. \subsection{Generic Quantifier Elimination}
  15897. \textsc{OFSF} allows generic quantifier elimination
  15898. \f{RLGQE}\ttindex{RLGQE}, which enlarges the theory by disequations,
  15899. i.e.~\f{<>}-atomic formulas, wherever this supports the quantifier
  15900. elimination. There is also generic quantifier elimination with answer
  15901. available: \f{RLGQEA}\ttindex{RLGQEA}.
  15902. \begin{samepage}
  15903. \vspace{0.5cm}
  15904. {\bf Example:}
  15905. {\small\begin{verbatim}
  15906. 8: rlgqe ex(x,a*x**2+b*x+c>0);
  15907. {{a <> 0},
  15908. 2
  15909. 4*a*c - b < 0 or a >= 0}
  15910. \end{verbatim}}
  15911. \end{samepage}
  15912. \subsection{Linear Optimization}
  15913. \f{RLOPT}\ttindex{RLOPT} uses quantifier elimination for linear
  15914. optimization. It takes as arguments a list of constraints and the
  15915. target function. The target function is minimized subject to the
  15916. constraints.
  15917. \chapter{RESET: Reset REDUCE to its initial state}
  15918. \label{RESET}
  15919. \typeout{{RESET: Code to reset REDUCE to its initial state}}
  15920. {\footnotesize
  15921. \begin{center}
  15922. J. P. Fitch \\
  15923. School of Mathematical Sciences, University of Bath\\
  15924. BATH BA2 7AY, England \\[0.05in]
  15925. e--mail: jpff@maths.bath.ac.uk
  15926. \end{center}
  15927. }
  15928. \ttindex{RESET}
  15929. This package defines a command {\tt RESETREDUCE}
  15930. \ttindex{RESETREDUCE} that works through the history of previous
  15931. commands, and clears any values which have been assigned, plus any
  15932. rules, arrays and the like. It also sets the various switches to
  15933. their initial values. It is not complete, but does work for most
  15934. things that cause a gradual loss of space.
  15935. \chapter{RESIDUE: A residue package}
  15936. \label{RESIDUE}
  15937. \typeout{{RESIDUE: A residue package}}
  15938. {\footnotesize
  15939. \begin{center}
  15940. Wolfram Koepf\\
  15941. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  15942. Takustra\"se 7 \\
  15943. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  15944. e--mail: Koepf@zib.de
  15945. \end{center}
  15946. }
  15947. \ttindex{RESIDUE}
  15948. \def\Res{\mathop{\rm Res}\limits}
  15949. \newcommand{\C}{{\rm {\mbox{C{\llap{{\vrule height1.52ex}\kern.4em}}}}}}
  15950. This package supports the calculation of residues. The residue
  15951. $\Res_{z=a} f(z)$ of a function $f(z)$ at the point $a\in\C$ is defined
  15952. as
  15953. \[
  15954. \Res_{z=a} f(z)=
  15955. \frac{1}{2 \pi i}\oint f(z)\,dz
  15956. \;,
  15957. \]
  15958. with integration along a closed curve around $z=a$ with winding number 1.
  15959. It contains two \REDUCE\ operators:
  15960. \begin{itemize}
  15961. \item
  15962. {\tt residue(f,z,a)}\ttindex{residue} determines the residue of $f$ at
  15963. the point $z=a$ if $f$ is meromorphic at $z=a$. The calculation of
  15964. residues at essential singularities of $f$ is not supported.
  15965. \item
  15966. {\tt poleorder(f,z,a)}\ttindex{poleorder} determines the pole order
  15967. of $f$ at the point $z=a$ if $f$ is meromorphic at $z=a$.
  15968. \end{itemize}
  15969. Note that both functions use the {\tt TAYLOR} package (chapter~\ref{TAYLOR}).
  15970. {\small\begin{verbatim}
  15971. load_package residue;
  15972. residue(x/(x^2-2),x,sqrt(2));
  15973. 1
  15974. ---
  15975. 2
  15976. poleorder(x/(x^2-2),x,sqrt(2));
  15977. 1
  15978. residue(sin(x)/(x^2-2),x,sqrt(2));
  15979. sqrt(2)*sin(sqrt(2))
  15980. ----------------------
  15981. 4
  15982. poleorder(sin(x)/(x^2-2),x,sqrt(2));
  15983. 1
  15984. residue((x^n-y^n)/(x-y)^2,x,y);
  15985. n
  15986. y *n
  15987. ------
  15988. y
  15989. poleorder((x^n-y^n)/(x-y)^2,x,y);
  15990. 1
  15991. \end{verbatim}}
  15992. \chapter{RLFI: REDUCE LaTeX formula interface}
  15993. \label{RLFI}
  15994. \typeout{{RLFI: REDUCE LaTeX formula interface}}
  15995. {\footnotesize
  15996. \begin{center}
  15997. Richard Liska, Ladislav Drska\\
  15998. Computational Physics Group \\
  15999. Faculty of Nuclear Sciences and Physical Engineering\\
  16000. Czech Technical University in Prague, Brehova 7, 115 19 Prague 1 \\
  16001. Czech Republic\\[0.05in]
  16002. e--mail: liska@siduri.fjfi.cvut.cz
  16003. \end{center}
  16004. }
  16005. \ttindex{RLFI}
  16006. The RLFI package provides the printing of \REDUCE\ expressions in
  16007. \LaTeX\ format, so it can be used directly for document production.
  16008. Various mathematical
  16009. constructions are supported by the interface including subscripts,
  16010. superscripts, font changing, Greek letters, divide-bars, integral and
  16011. sum signs, derivatives etc.
  16012. The interface is connected to \REDUCE\ by three new switches and
  16013. several statements. To activate the \LaTeX\ output mode the switch {\tt
  16014. latex}\ttindex{latex} must be set {\tt on}. This switch causes all
  16015. outputs to be written in the \LaTeX\ syntax of formulas. The switch
  16016. {\tt VERBATIM}\ttindex{VERBATIM} is used for input printing control.
  16017. If it is {\tt on} input to \REDUCE{} system is typeset in \LaTeX{}
  16018. verbatim environment after the line containing the string {\tt REDUCE Input:}.
  16019. The switch {\tt lasimp}\ttindex{lasimp} controls the algebraic
  16020. evaluation of input
  16021. formulas. If it is {\tt on} every formula is evaluated, simplified and
  16022. written in the form given by ordinary \REDUCE\ statements and switches
  16023. such as {\tt factor}, {\tt order}, {\tt rat} etc. In the case when the
  16024. {\tt lasimp} switch is {\tt off} evaluation, simplification or
  16025. reordering of formulas is not performed and \REDUCE\ acts only as a
  16026. formula parser and the form of the formula output is exactly the same as
  16027. that of the input, the only difference remains in the syntax. The mode
  16028. {\tt off lasimp} is designed especially for typesetting of formulas for
  16029. which the user needs preservation of their structure. This switch has
  16030. no meaning if the switch {\tt Latex} is {\tt off} and thus is working
  16031. only for \LaTeX\ output.
  16032. For every identifier used in the typeset \REDUCE\ formula
  16033. the following properties can be defined by the statement {\tt defid}:
  16034. \ttindex{defid}
  16035. \begin{itemize}
  16036. \item its printing symbol (Greek letters can be used).
  16037. \item the font in which the symbol will be typeset.
  16038. \item accent which will be typeset above the symbol.
  16039. \end{itemize}
  16040. Symbols with indexes are treated in \REDUCE\ as operators. Each index
  16041. corresponds to an argument of the operator. The meaning of operator
  16042. arguments (where one wants to typeset them) is declared by the
  16043. statement\ttindex{defindex}
  16044. {\tt defindex}. This statement causes the arguments to be typeset as
  16045. subscripts or superscripts (on left or right-hand side of the operator)
  16046. or as arguments of the operator.
  16047. The statement {\tt mathstyle}\ttindex{mathstyle} defines the style of
  16048. formula typesetting. The variable {\tt laline!*}\ttindex{laline"!*}
  16049. defines the length of output lines.
  16050. The fractions with horizontal divide bars are typeset by using the
  16051. new \REDUCE\ infix operator \verb+\+. This operator is not
  16052. algebraically simplified. During typesetting of powers the checking on
  16053. the form of the power base and exponent is performed to determine the
  16054. form of the typeset expression ({\em e.g.\ }sqrt symbol, using parentheses).
  16055. Some special forms can be typeset by using \REDUCE\ prefix operators.
  16056. These are as follows:
  16057. \begin{itemize}
  16058. \item {\tt int} - integral of an expression.
  16059. \item {\tt dint} - definite integral of an expression.
  16060. \item {\tt df} - derivative of an expression.
  16061. \item {\tt pdf} - partial derivative of an expression.
  16062. \item {\tt sum} - sum of expressions.
  16063. \item {\tt product} - product of expressions.
  16064. \item {\tt sqrt} - square root of expression.
  16065. \end{itemize}
  16066. There are still some problems unsolved in the present version of the
  16067. interface as follows:
  16068. \begin{itemize}
  16069. \item breaking the formulas which do not fit on one line.
  16070. \item automatic decision where to use divide bars in fractions.
  16071. \item distinction of two- or more-character identifiers from the product
  16072. of one-character symbols.
  16073. \item typesetting of matrices.
  16074. \end{itemize}
  16075. \chapter{ROOTS: A REDUCE root finding package}
  16076. \label{ROOTS}
  16077. \typeout{{ROOTS: A REDUCE root finding package}}
  16078. {\footnotesize
  16079. \begin{center}
  16080. Stanley L. Kameny \\
  16081. Los Angeles, U.S.A.
  16082. \end{center}
  16083. }
  16084. \ttindex{ROOTS}
  16085. The root finding package is designed so that it can be used as an
  16086. independent package, or it can be integrated with and called by {\tt
  16087. SOLVE}.\index{SOLVE package ! with ROOTS package}
  16088. \section{Top Level Functions}
  16089. The top level functions can be called either as symbolic operators from
  16090. algebraic mode, or they can be called directly from symbolic mode with
  16091. symbolic mode arguments. Outputs are expressed in forms that print out
  16092. correctly in algebraic mode.
  16093. \subsection{Functions that refer to real roots only}
  16094. The three functions \f{REALROOTS}, \f{ISOLATER} and \f{RLROOTNO} can
  16095. receive 1, 2 or 3 arguments.
  16096. The first argument is the polynomial p, that can be complex and can
  16097. have multiple or zero roots. If arg2 and arg3 are not present, all real
  16098. roots are found. If the additional arguments are present, they restrict
  16099. the region of consideration.
  16100. \begin{itemize}
  16101. \item If there are two arguments the second is either POSITIVE or NEGATIVE.
  16102. The function will only find positive or negative roots
  16103. \item If arguments are (p,arg2,arg3) then
  16104. \ttindex{EXCLUDE}\ttindex{POSITIVE}\ttindex{NEGATIVE}\ttindex{INFINITY}
  16105. Arg2 and Arg3 must be r (a real number) or EXCLUDE r, or a member of
  16106. the list POSITIVE, NEGATIVE, INFINITY, -INFINITY. EXCLUDE r causes the
  16107. value r to be excluded from the region. The order of the sequence
  16108. arg2, arg3 is unimportant. Assuming that arg2 $\leq$ arg3 when both are
  16109. numeric, then
  16110. \begin{tabular}{l c l}
  16111. \{-INFINITY,INFINITY\} & (or \{\}) & all roots; \\
  16112. \{arg2,NEGATIVE\} & represents & $-\infty < r < arg2$; \\
  16113. \{arg2,POSITIVE\} & represents & $arg2 < r < \infty$;
  16114. \end{tabular}
  16115. In each of the following, replacing an {\em arg} with EXCLUDE {\em arg}
  16116. converts the corresponding inclusive $\leq$ to the exclusive $<$
  16117. \begin{tabular}{l c l}
  16118. \{arg2,-INFINITY\} & represents & $-\infty < r \leq arg2$; \\
  16119. \{arg2,INFINITY\} & represents & $arg2 \leq r < \infty$; \\
  16120. \{arg2,arg3\} & represents & $arg2 \leq r \leq arg3$;
  16121. \end{tabular}
  16122. \item If zero is in the interval the zero root is included.
  16123. \end{itemize}
  16124. \begin{description}
  16125. \ttindex{REALROOTS}
  16126. \item[REALROOTS] finds the real roots of the polynomial
  16127. p. Precision of computation is guaranteed to be sufficient to
  16128. separate all real roots in the specified region. (cf. MULTIROOT for
  16129. treatment of multiple roots.)
  16130. \ttindex{ISOLATER}
  16131. \item[ISOLATER] produces a list of rational intervals, each
  16132. containing a single real root of the polynomial p, within the specified
  16133. region, but does not find the roots.
  16134. \ttindex{RLROOTNO}
  16135. \item[RLROOTNO] computes the number of real roots of p in
  16136. the specified region, but does not find the roots.
  16137. \end{description}
  16138. \subsection{Functions that return both real and complex roots}
  16139. \begin{description}
  16140. \ttindex{ROOTS}
  16141. \item[ROOTS p;] This is the main top level function of the roots package.
  16142. It will find all roots, real and complex, of the polynomial p to an
  16143. accuracy that is sufficient to separate them and which is a minimum of 6
  16144. decimal places. The value returned by ROOTS is a
  16145. list of equations for all roots. In addition, ROOTS stores separate lists
  16146. of real roots and complex roots in the global variables ROOTSREAL and
  16147. ROOTSCOMPLEX.\ttindex{ROOTSREAL}\ttindex{ROOTSCOMPLEX}
  16148. The output of ROOTS is normally sorted into a standard order:
  16149. a root with smaller real part precedes a root with larger real part; roots
  16150. with identical real parts are sorted so that larger imaginary part
  16151. precedes smaller imaginary part.
  16152. However, when a polynomial has been factored algebraically then the
  16153. root sorting is applied to each factor separately. This makes the
  16154. final resulting order less obvious.
  16155. \ttindex{ROOTS\_AT\_PREC}
  16156. \item[ROOTS\_AT\_PREC p;] Same as ROOTS except that roots values are
  16157. returned to a minimum of the number of decimal places equal to the current
  16158. system precision.
  16159. \ttindex{ROOT\_VAL}
  16160. \item[ROOT\_VAL p;] Same as ROOTS\_AT\_PREC, except that instead of
  16161. returning a list of equations for the roots, a list of the root value is
  16162. returned. This is the function that SOLVE calls.
  16163. \ttindex{NEARESTROOT}
  16164. \item[NEARESTROOT(p,s);] This top level function finds the root to
  16165. which the method converges given the initial starting origin s, which
  16166. can be complex. If there are several roots in the vicinity of s and s
  16167. is not significantly closer to one root than it is to all others, the
  16168. convergence could arrive at a root that is not truly the nearest root.
  16169. This function should therefore be used only when the user is certain
  16170. that there is only one root in the immediate vicinity of the
  16171. starting point s.
  16172. \ttindex{FIRSTROOT}
  16173. \item[FIRSTROOT p;] ROOTS is called, but only a single root is computed.
  16174. \end{description}
  16175. \subsection{Other top level functions}
  16176. \begin{description}
  16177. \ttindex{GETROOT}\ttindex{ROOTS}\ttindex{REALROOTS}\ttindex{NEARESTROOTS}
  16178. \item[GETROOT(n,rr);] If rr has the form of the output of ROOTS, REALROOTS,
  16179. or NEARESTROOTS; GETROOT returns the rational, real, or complex value of
  16180. the root equation. An error occurs if $n<1$ or $n>$ the number of roots in
  16181. rr.
  16182. \ttindex{MKPOLY}
  16183. \item[MKPOLY rr;] This function can be used to reconstruct a polynomial
  16184. whose root equation list is rr and whose denominator is 1. Thus one can
  16185. verify that if $rr := ROOTS~p$, and $rr1 := ROOTS~MKPOLY~rr$, then
  16186. $rr1 = rr$. (This will be true if {\tt MULTIROOT} and {\tt RATROOT} are ON,
  16187. and {\tt ROUNDED} is off.)
  16188. However, $MKPOLY~rr - NUM~p = 0$ will be true if and only if all roots of p
  16189. have been computed exactly.
  16190. \end{description}
  16191. \section{Switches Used in Input}
  16192. The input of polynomials in algebraic mode is sensitive to the switches
  16193. {\tt COMPLEX}, {\tt ROUNDED}, and {\tt ADJPREC}. The correct choice of
  16194. input method is important since incorrect choices will result in
  16195. undesirable truncation or rounding of the input coefficients.
  16196. Truncation or rounding may occur if {\tt ROUNDED} is on and
  16197. one of the following is true:
  16198. \begin{enumerate}
  16199. \item a coefficient is entered in floating point form or rational form.
  16200. \item {\tt COMPLEX} is on and a coefficient is imaginary or complex.
  16201. \end{enumerate}
  16202. Therefore, to avoid undesirable truncation or rounding, then:
  16203. \begin{enumerate}
  16204. \item {\tt ROUNDED} should be off and input should be
  16205. in integer or rational form; or
  16206. \item {\tt ROUNDED} can be on if it is acceptable to truncate or round
  16207. input to the current value of system precision; or both {\tt ROUNDED} and
  16208. {\tt ADJPREC} can be on, in which case system precision will be adjusted
  16209. to accommodate the largest coefficient which is input; or \item if the
  16210. input contains complex coefficients with very different magnitude for the
  16211. real and imaginary parts, then all three switches {\tt ROUNDED}, {\tt
  16212. ADJPREC} and {\tt COMPLEX} must be on.
  16213. \end{enumerate}
  16214. \begin{description}
  16215. \item[integer and complex modes] (off {\tt ROUNDED}) any real
  16216. polynomial can be input using integer coefficients of any size; integer or
  16217. rational coefficients can be used to input any real or complex polynomial,
  16218. independent of the setting of the switch {\tt COMPLEX}. These are the most
  16219. versatile input modes, since any real or complex polynomial can be input
  16220. exactly.
  16221. \item[modes rounded and complex-rounded] (on {\tt ROUNDED}) polynomials can be
  16222. input using
  16223. integer coefficients of any size. Floating point coefficients will be
  16224. truncated or rounded, to a size dependent upon the system. If complex
  16225. is on, real coefficients can be input to any precision using integer
  16226. form, but coefficients of imaginary parts of complex coefficients will
  16227. be rounded or truncated.
  16228. \end{description}
  16229. \section{Root Package Switches}
  16230. \begin{description}
  16231. \ttindex{RATROOT}
  16232. \item[RATROOT] (Default OFF) If {\tt RATROOT} is on all root equations are
  16233. output in rational form. Assuming that the mode is {\tt COMPLEX}
  16234. ({\em i.e.\ }
  16235. {\tt ROUNDED} is off,) the root equations are
  16236. guaranteed to be able to be input into \REDUCE\ without truncation or
  16237. rounding errors. (Cf. the function MKPOLY described above.)
  16238. \ttindex{MULTIROOT}
  16239. \item[MULTIROOT] (Default ON) Whenever the polynomial has complex
  16240. coefficients or has real coefficients and has multiple roots, as
  16241. \ttindex{SQFRF} determined by the Sturm function, the function {\tt SQFRF}
  16242. is called automatically to factor the polynomial into square-free factors.
  16243. If {\tt MULTIROOT} is on, the multiplicity of the roots will be indicated
  16244. in the output of ROOTS or REALROOTS by printing the root output
  16245. repeatedly, according to its multiplicity. If {\tt MULTIROOT} is off,
  16246. each root will be printed once, and all roots should be normally be
  16247. distinct. (Two identical roots should not appear. If the initial
  16248. precision of the computation or the accuracy of the output was
  16249. insufficient to separate two closely-spaced roots, the program attempts to
  16250. increase accuracy and/or precision if it detects equal roots. If,
  16251. however, the initial accuracy specified was too low, and it was not
  16252. possible to separate the roots, the program will abort.)
  16253. \end{description}
  16254. \chapter[RSOLVE: Rational polynomial solver]%
  16255. {RSOLVE: \protect\\ Rational/integer polynomial solvers}
  16256. \label{RSOLVE}
  16257. \typeout{[RSOLVE: Rational polynomial solver]}
  16258. {\footnotesize
  16259. \begin{center}
  16260. Francis J. Wright \\
  16261. School of Mathematical Sciences, Queen Mary and Westfield College \\
  16262. University of London \\
  16263. Mile End Road \\
  16264. London E1 4NS, England \\[0.05in]
  16265. e--mail: F.J.Wright@QMW.ac.uk
  16266. \end{center}
  16267. }
  16268. \ttindex{RSOLVE}
  16269. The exact rational zeros of a single univariate polynomial using fast
  16270. modular methods can be calculated.
  16271. The operator \verb|r_solve|\ttindex{R\_SOLVE} computes
  16272. all rational zeros and the operator \verb|i_solve|
  16273. \ttindex{I\_SOLVE} computes only
  16274. integer zeros in a way that is slightly more efficient than extracting
  16275. them from the rational zeros.
  16276. The first argument is either a univariate polynomial expression or
  16277. equation with integer, rational or rounded coefficients. Symbolic
  16278. coefficients are not allowed. The argument is simplified to a
  16279. quotient of integer polynomials and the denominator is silently
  16280. ignored.
  16281. Subsequent arguments are optional. If the polynomial variable is to
  16282. be specified then it must be the first optional argument. However,
  16283. since the variable in a non-constant univariate polynomial can be
  16284. deduced from the polynomial it is unnecessary to specify it
  16285. separately, except in the degenerate case that the first argument
  16286. simplifies to either 0 or $0 = 0$. In this case the result is
  16287. returned by \verb|i_solve| in terms of the operator \verb|arbint| and
  16288. by \verb|r_solve| in terms of the (new) analogous operator
  16289. \verb|arbrat|. The operator \verb|i_solve| will generally run
  16290. slightly faster than \verb|r_solve|.
  16291. The (rational or integer) zeros of the first argument are returned as
  16292. a list and the default output format is the same as that used by
  16293. \verb|solve|. Each distinct zero is returned in the form of an
  16294. equation with the variable on the left and the multiplicities of the
  16295. zeros are assigned to the variable \verb|root_multiplicities| as a
  16296. list. However, if the switch {\ttfamily multiplicities} is turned on then
  16297. each zero is explicitly included in the solution list the appropriate
  16298. number of times (and \verb|root_multiplicities| has no value).
  16299. \begin{sloppypar}
  16300. Optional keyword arguments acting as local switches allow other output
  16301. formats. They have the following meanings:
  16302. \begin{description}
  16303. \item[{\ttfamily separate}:] assign the multiplicity list to the global
  16304. variable \verb|root_multiplicities| (the default);
  16305. \item[{\ttfamily expand} or {\ttfamily multiplicities}:] expand the solution
  16306. list to include multiple zeros multiple times (the default if the
  16307. {\ttfamily multiplicities} switch is on);
  16308. \item[{\ttfamily together}:] return each solution as a list whose second
  16309. element is the multiplicity;
  16310. \item[{\ttfamily nomul}:] do not compute multiplicities (thereby saving
  16311. some time);
  16312. \item[{\ttfamily noeqs}:] do not return univariate zeros as equations but
  16313. just as values.
  16314. \end{description}
  16315. \end{sloppypar}
  16316. \section{Examples}
  16317. {\small\begin{verbatim}
  16318. r_solve((9x^2 - 16)*(x^2 - 9), x);
  16319. \end{verbatim}}
  16320. \[
  16321. \left\{x=\frac{-4}{3},x=3,x=-3,x=\frac{4}{3}\right\}
  16322. \]
  16323. {\small\begin{verbatim}
  16324. i_solve((9x^2 - 16)*(x^2 - 9), x);
  16325. \end{verbatim}}
  16326. \[
  16327. \{x=3,x=-3\}
  16328. \]
  16329. \chapter[SCOPE: Source code optimisation package]
  16330. {SCOPE: REDUCE source code optimisation package}
  16331. \label{SCOPE}
  16332. \typeout{{SCOPE: REDUCE source code optimisation package}}
  16333. {\footnotesize
  16334. \begin{center}
  16335. J.A. van Hulzen \\
  16336. University of Twente, Department of Computer Science \\
  16337. P.O. Box 217, 7500 AE Enschede \\
  16338. The Netherlands \\[0.05in]
  16339. e--mail: infhvh@cs.utwente.nl
  16340. \end{center}
  16341. }
  16342. SCOPE is a package to produce optimised versions of algebraic
  16343. expressions. It can be used in two distinct fashions, as an adjunct
  16344. to numerical code generation (using GENTRAN, described in
  16345. chapter~\ref{GENTRAN}) or as a stand alone way of investigating
  16346. structure in an expression.
  16347. When used with GENTRAN\ttindex{GENTRAN} it is sufficient to set the
  16348. switch {\tt GENTRANOPT}\ttindex{GENTRANOPT} on, and GENTRAN will then
  16349. use SCOPE internally. This is described in its internal detail in the
  16350. GENTRAN manual and the SCOPE documentation.
  16351. As a stand-alone package SCOPE provides the operator {\tt OPTIMIZE}.
  16352. \ttindex{OPTIMIZE}
  16353. A SCOPE application is easily performed and based on the use of
  16354. the following syntax:
  16355. {\small
  16356. \begin{flushleft}
  16357. \begin{tabular}{lcl}
  16358. $<$SCOPE\_application$>$ & $\Rightarrow$ & {\tt OPTIMIZE} $<$object\_seq$>$
  16359. [{\tt INAME} $<$cse\_prefix$>$]\\
  16360. $<$object\_seq$>$ & $\Rightarrow$ & $<$object$>$[,$<$object\_seq$>$]\\
  16361. $<$object$>$ & $\Rightarrow$ & $<$stat$>~\mid~<$alglist$>~\mid~<$alglist\_production$>$ \\
  16362. $<$stat$>$ & $\Rightarrow$ & $<$name$>~<$assignment operator$>~<$expression$>$\\
  16363. $<$assignment operator$>$ & $\Rightarrow$ & $:=~\mid~::=~\mid~::=:~\mid~:=:$\\
  16364. $<$alglist$>$ & $\Rightarrow$ & \{$<$eq\_seq$>$\}\\
  16365. $<$eq\_seq$>$ & $\Rightarrow$ & $<$name$>~=~<$expression$>$[,$<$eq\_seq$>$]\\
  16366. $<$alglist\_production$>$ & $\Rightarrow$ & $<$name$>~\mid~<$function\_application$>$\\
  16367. $<$name$>$ & $\Rightarrow$ & $<$id$>~\mid~<$id$>(<$a\_subscript\_seq$>)$\\
  16368. $<$a\_subscript\_seq$>$ & $\Rightarrow$ & $<$a\_subscript$>$[,$<$a\_subscript\_seq$>$]\\
  16369. $<$a\_subscript$>$ & $\Rightarrow$ & $<$integer$>~\mid~<$integer infix\_expression$>$\\
  16370. $<$cse\_prefix$>$ & $\Rightarrow$ & $<$id$>$
  16371. \end{tabular}
  16372. \end{flushleft}}
  16373. A SCOPE action can be applied on one assignment statement, or to a
  16374. sequence of such statements, separated by commas, or a list of expressions.
  16375. \index{SCOPE option ! {\tt INAME}}
  16376. The optional use of the {\tt INAME} extension in an {\tt OPTIMIZE}
  16377. command is introduced to allow the user to influence the generation of
  16378. cse-names. The cse\_prefix is an identifier, used to generate
  16379. cse-names, by extending it with an integer part. If the cse\_prefix
  16380. consists of letters only, the initially selected integer part is 0.
  16381. If the user-supplied cse\_prefix ends with an integer its value
  16382. functions as initial integer part.
  16383. {\small\begin{verbatim}
  16384. z:=a^2*b^2+10*a^2*m^6+a^2*m^2+2*a*b*m^4+2*b^2*m^6+b^2*m^2;
  16385. 2 2 2 6 2 2 4 2 6 2 2
  16386. z := a *b + 10*a *m + a *m + 2*a*b*m + 2*b *m + b *m
  16387. OPTIMIZE z:=:z ;
  16388. G0 := b*a
  16389. G4 := m*m
  16390. G1 := G4*b*b
  16391. G2 := G4*a*a
  16392. G3 := G4*G4
  16393. z := G1 + G2 + G0*(2*G3 + G0) + G3*(2*G1 + 10*G2)
  16394. \end{verbatim}}
  16395. it can be desirable
  16396. to rerun an optimisation request with a restriction on the minimal size of
  16397. the righthandsides. The command
  16398. \index{SCOPE function ! {\tt SETLENGTH}}
  16399. \hspace*{1cm} {\tt SETLENGTH} $<$integer$>$\$
  16400. can be used to produce rhs's with a minimal arithmetic complexity,
  16401. dictated by the value of
  16402. its integer argument. Statements, used to rename function applications, are
  16403. not affected by the {\tt SETLENGTH} command. The default setting is restored
  16404. with the command
  16405. \hspace*{1cm} {\tt RESETLENGTH}\$
  16406. \index{SCOPE function ! {\tt RESETLENGTH}}
  16407. {\em Example:}
  16408. {\small\begin{verbatim}
  16409. SETLENGTH 2$
  16410. OPTIMIZE z:=:z INAME s$
  16411. 2 2
  16412. s1 := b *m
  16413. 2 2
  16414. s2 := a *m
  16415. 4 4
  16416. z := (a*b + 2*m )*a*b + 2*(s1 + 5*s2)*m + s1 + s2
  16417. \end{verbatim}}
  16418. Details of the algorithm used is given in the Scope User's Manual.
  16419. \chapter{SETS: A basic set theory package}
  16420. \label{SETS}
  16421. \typeout{{SETS: A basic set theory package}}
  16422. {\footnotesize
  16423. \begin{center}
  16424. Francis J. Wright \\
  16425. School of Mathematical Sciences, Queen Mary and Westfield College \\
  16426. University of London \\
  16427. Mile End Road \\
  16428. London E1 4NS, England \\[0.05in]
  16429. e--mail: F.J.Wright@QMW.ac.uk
  16430. \end{center}
  16431. }
  16432. \ttindex{SETS}
  16433. The SETS package provides set theoretic operations on lists and represents
  16434. the results as normal algebraic-mode lists, so that all other \REDUCE{}
  16435. facilities that apply to lists can still be applied to lists that have
  16436. been constructed by explicit set operations.
  16437. \section{Infix operator precedence}
  16438. The set operators are currently inserted into the standard \REDUCE{}
  16439. precedence list (see section~\ref{sec-operators}) as follows:
  16440. {\small\begin{verbatim}
  16441. or and not member memq = set_eq neq eq >= > <= < subset_eq
  16442. subset freeof + - setdiff union intersection * / ^ .
  16443. \end{verbatim}}
  16444. \section{Explicit set representation and MKSET}
  16445. Explicit sets are represented by lists, and there is a need to convert
  16446. standard \REDUCE\ lists into a set by removing duplicates. The
  16447. package also orders the members of the set so the standard {\tt =}
  16448. predicate will provide set equality.\ttindex{MKSET}
  16449. {\small\begin{verbatim}
  16450. mkset {1,2,y,x*y,x+y};
  16451. {x + y,x*y,y,1,2}
  16452. \end{verbatim}}
  16453. The empty set is represented by the empty list \verb|{}|.
  16454. \section{Union and intersection}
  16455. The intersection operator has the name\ttindex{intersect} {\tt
  16456. intersect}, and set union is denotes by\ttindex{union}{\tt union}.
  16457. These operators will probably most commonly be used as binary infix
  16458. operators applied to explicit sets,
  16459. {\small\begin{verbatim}
  16460. {1,2,3} union {2,3,4};
  16461. {1,2,3,4}
  16462. {1,2,3} intersect {2,3,4};
  16463. {2,3}
  16464. \end{verbatim}}
  16465. \section{Symbolic set expressions}
  16466. If one or more of the arguments evaluates to an unbound identifier
  16467. then it is regarded as representing a symbolic implicit set, and the
  16468. union or intersection will evaluate to an expression that still
  16469. contains the union or intersection operator. These two operators are
  16470. symmetric, and so if they remain symbolic their arguments will be
  16471. sorted as for any symmetric operator. Such symbolic set expressions
  16472. are simplified, but the simplification may not be complete in
  16473. non-trivial cases. For example:
  16474. {\small\begin{verbatim}
  16475. a union b union {} union b union {7,3};
  16476. {3,7} union a union b
  16477. a intersect {};
  16478. {}
  16479. \end{verbatim}}
  16480. Intersection distributes over union, which is not applied by default
  16481. but is implemented as a rule list assigned to the variable {\tt
  16482. set\_distribution\_rule}, {\em e.g.}
  16483. {\small\begin{verbatim}
  16484. a intersect (b union c);
  16485. (b union c) intersection a
  16486. a intersect (b union c) where set_distribution_rule;
  16487. a intersection b union a intersection c
  16488. \end{verbatim}}
  16489. \section{Set difference}
  16490. The set difference operator is represented by the symbol \verb|\| and
  16491. is always output using this symbol, although it can also be input using
  16492. \ttindex{setdiff} {\tt setdiff}. It is a binary operator.
  16493. {\small\begin{verbatim}
  16494. {1,2,3} \ {2,4};
  16495. {1,3}
  16496. a \ {1,2};
  16497. a\{1,2}
  16498. a \ a;
  16499. {}
  16500. \end{verbatim}}
  16501. \section{Predicates on sets}
  16502. Set membership, inclusion or equality are all binary infix operators.
  16503. They can only be used within conditional statements or within the
  16504. argument of the {\tt evalb}\ttindex{evalb} operator provided by this
  16505. package, and they cannot remain symbolic -- a predicate that cannot be
  16506. evaluated to a Boolean value causes a normal \REDUCE\ error.
  16507. The {\tt evalb} operator provides a convenient shorthand for an {\tt
  16508. if} statement designed purely to display the value of any Boolean
  16509. expression (not only predicates defined in this package).
  16510. {\small\begin{verbatim}
  16511. if a = a then true else false;
  16512. true
  16513. evalb(a = a);
  16514. true
  16515. if a = b then true else false;
  16516. false
  16517. \end{verbatim}}
  16518. \subsection{Set membership}
  16519. Set membership is tested by the predicate \ttindex{member}{\tt member}.
  16520. Its left operand is regarded as a potential set element and
  16521. its right operand {\em must\/} evaluate to an explicit set. There is
  16522. currently no sense in which the right operand could be an implicit set.
  16523. {\small\begin{verbatim}
  16524. evalb(1 member {1,2,3});
  16525. true
  16526. evalb(2 member {1,2} intersect {2,3});
  16527. true
  16528. evalb(a member b);
  16529. ***** b invalid as list
  16530. \end{verbatim}}
  16531. \subsection{Set inclusion}
  16532. Set inclusion is tested by the predicate {\tt subset\_eq}
  16533. \ttindex{subset\_eq} where {\tt a subset\_eq b} is true if the set $a$
  16534. is either a subset of or equal to the set $b$; strict inclusion is
  16535. tested by the predicate {\tt subset}\ttindex{subset}
  16536. where {\tt a subset b} is true if the set $a$ is {\em strictly\/} a
  16537. subset of the set $b$ and is false is $a$ is equal to $b$. These
  16538. predicates provide some support for symbolic set expressions, but is
  16539. incomplete.
  16540. {\small\begin{verbatim}
  16541. evalb({1,2} subset_eq {1,2,3});
  16542. true
  16543. evalb({1,2} subset_eq {1,2});
  16544. true
  16545. evalb({1,2} subset {1,2});
  16546. false
  16547. evalb(a subset a union b);
  16548. true
  16549. \end{verbatim}}
  16550. \newpage
  16551. {\small\begin{verbatim}
  16552. evalb(a\b subset a);
  16553. true
  16554. \end{verbatim}}
  16555. An undecidable predicate causes a normal \REDUCE\ error, {\em e.g.\ }
  16556. {\small\begin{verbatim}
  16557. evalb(a subset_eq {b});
  16558. ***** Cannot evaluate a subset_eq {b} as Boolean-valued set
  16559. expression
  16560. \end{verbatim}}
  16561. \subsection{Set equality}
  16562. As explained above, equality of two sets in canonical form can be
  16563. reliably tested by the standard \REDUCE\ equality predicate ({\tt =}).
  16564. \chapter{SPARSE: Sparse Matrices}
  16565. \label{SPARSE MATRICES}
  16566. \typeout{{SPARSE: Sparse Matrices}}
  16567. {\footnotesize
  16568. \begin{center}
  16569. Stephen Scowcroft \\
  16570. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin \\
  16571. Takustra\"se 7 \\
  16572. D-14195 Berlin-Dahlem, Germany \\
  16573. \end{center}
  16574. }
  16575. \ttindex{SPARSE, Sparse matrices}
  16576. \ttindex{MATRIX, see also SPARSE}
  16577. \section{Introduction}
  16578. This package extends the available matrix feature to enable
  16579. calculations with sparse matrices. It also provides
  16580. a selection of functions that are useful in the world of linear
  16581. algebra with respect to sparse matrices. \\
  16582. The package is loaded by: {\tt load\_package sparse;}
  16583. \section{Sparse Matrix Calculations}
  16584. To extend the syntax of this class of calculations an expression type
  16585. {\tt sparse \ttindex{SPARSE}} is added. An identifier may be declared a
  16586. sparse variable by the declaration {\tt sparse}. The size of the
  16587. sparse matrix must be declared explicitly in the matrix declaration.
  16588. This declaration \f{SPARSE} is similar to the declaration \f{MATRIX}.
  16589. Once a matrix has been declared a sparse matrix all elements of the
  16590. matrix are treated as if they were initialized to 0. When printing out
  16591. a sparse matrix only the non-zero elements are printed due to the fact
  16592. that only the non-zero elements of the matrix are stored. To assign values
  16593. to the elements of the declared sparse matrix we use the same syntax as for
  16594. matrices.
  16595. {\small\begin{verbatim}
  16596. sparse aa(10,1),bb(200,200);
  16597. aa(1,1):=10;
  16598. bb(100,150):=a;
  16599. \end{verbatim}}
  16600. \section{Linear Algebra Package for Sparse Matrices}
  16601. Most of the functions of this package are related to the functions
  16602. of the linear algebra package \f{LINALG}. For further explanation and
  16603. examples of the various functions please refer to the \f{LINALG}
  16604. package.
  16605. \subsection{Basic matrix handling}
  16606. {\small\begin{tabular}{l l l l}
  16607. spadd\_columns \ttindex{SPADD\_COLUMNS} &
  16608. spadd\_rows \ttindex{SPADD\_ROWS} &
  16609. spadd\_to\_columns \ttindex{SPADD\_TO\_COLUMNS} &
  16610. spadd\_to\_rows \ttindex{SPADD\_TO\_ROWS} \\
  16611. spaugment\_columns \ttindex{SPAUGMENT\_COLUMNS} &
  16612. spchar\_poly \ttindex{SPCHAR\_POLY} &
  16613. spcol\_dim \ttindex{SPCOL\_DIM} &
  16614. spcopy\_into \ttindex{SPCOPY\_INTO} \\
  16615. spdiagonal \ttindex{SPDIAGONAL} &
  16616. spextend \ttindex{SPEXTEND} &
  16617. spfind\_companion \ttindex{SPFIND\_COMPANION} &
  16618. spget\_columns \ttindex{SPGET\_COLUMNS} \\
  16619. spget\_rows \ttindex{SPGET\_ROWS} &
  16620. sphermitian\_tp \ttindex{SPHERMITIAN\_TP} &
  16621. spmatrix\_augment \ttindex{SPMATRIX\_AUGMENT} &
  16622. spmatrix\_stack \ttindex{SPMATRIX\_STACK} \\
  16623. spminor \ttindex{SPMINOR} &
  16624. spmult\_columns \ttindex{SPMULT\_COLUMNS} &
  16625. spmult\_rows \ttindex{SPMULT\_ROWS} &
  16626. sppivot \ttindex{SPPIVOT} \\
  16627. spremove\_columns \ttindex{SPREMOVE\_COLUMNS} &
  16628. spremove\_rows \ttindex{SPREMOVE\_ROWS} &
  16629. sprow\_dim \ttindex{SPROW\_DIM} &
  16630. sprows\_pivot \ttindex{SPROWS\_PIVOT} \\
  16631. spstack\_rows \ttindex{SPSTACK\_ROWS} &
  16632. spsub\_matrix \ttindex{SPSUB\_MATRIX} &
  16633. spswap\_columns \ttindex{SPSWAP\_COLUMNS} &
  16634. spswap\_entries \ttindex{SPSWAP\_ENTRIES} \\
  16635. spswap\_rows \ttindex{SPSWAP\_ROWS}
  16636. \end{tabular}}
  16637. \subsection{Constructors}
  16638. Functions that create sparse matrices.
  16639. \begin{tabular}{l l l l}
  16640. spband\_matrix \ttindex{SPBAND\_MATRIX} &
  16641. spblock\_matrix \ttindex{SPBLOCK\_MATRIX} &
  16642. spchar\_matrix \ttindex{SPCHAR\_MATRIX} &
  16643. spcoeff\_matrix \ttindex{SPCOEFF\_MATRIX} \\
  16644. spcompanion \ttindex{SPCOMPANION} &
  16645. sphessian \ttindex{SPHESSIAN} &
  16646. spjacobian \ttindex{SPJACOBIAN} &
  16647. spjordan\_block \ttindex{SPJORDAN\_BLOCK} \\
  16648. spmake\_identity \ttindex{SPMAKE\_IDENTITY}
  16649. \end{tabular}
  16650. \subsection{High level algorithms}
  16651. \begin{tabular}{l l l l}
  16652. spchar\_poly \ttindex{SPCHAR\_POLY} &
  16653. spcholesky \ttindex{SPCHOLESKY} &
  16654. spgram\_schmidt \ttindex{SPGRAM\_SCHMIDT} &
  16655. splu\_decom \ttindex{SPLU\_DECOM} \\
  16656. sppseudo\_inverse \ttindex{SPPSEUDO\_INVERSE} &
  16657. svd \ttindex{SVD}
  16658. \end{tabular}
  16659. \subsection{Predicates}
  16660. \begin{tabular}{l l l l}
  16661. matrixp \ttindex{MATRIXP} &
  16662. sparsematp \ttindex{SPARSEMATP} &
  16663. squarep \ttindex{SQUAREP} &
  16664. symmetricp \ttindex{SYMMETRICP}
  16665. \end{tabular}
  16666. \chapter[SPDE: Symmetry groups of {PDE}'s]%
  16667. {SPDE: A package for finding symmetry groups of {PDE}'s}
  16668. \label{SPDE}
  16669. \typeout{{SPDE: A package for finding symmetry groups of {PDE}'s}}
  16670. {\footnotesize
  16671. \begin{center}
  16672. Fritz Schwarz \\
  16673. GMD, Institut F1 \\
  16674. Postfach 1240 \\
  16675. 5205 St. Augustin, Germany \\[0.05in]
  16676. e--mail: fritz.schwarz@gmd.de
  16677. \end{center}
  16678. }
  16679. \ttindex{SPDE}
  16680. The package SPDE provides a set of functions which may be applied
  16681. to determine the symmetry group of Lie- or point-symmetries of a
  16682. given system of partial differential equations. Preferably it is
  16683. used interactively on a computer terminal. In many cases the
  16684. determining system is solved completely automatically. In some
  16685. other cases the user has to provide some additional input
  16686. information for the solution algorithm to terminate.
  16687. \section{System Functions and Variables}
  16688. The symmetry analysis of partial differential equations logically
  16689. falls into three parts. Accordingly the most important functions
  16690. provided by the package are:
  16691. \begin{table}
  16692. \begin{center}
  16693. \begin{tabular}{| c | c | }\hline
  16694. Function name & Operation \\ \hline \hline
  16695. \ttindex{CRESYS}
  16696. CRESYS(\s{arguments}) & Constructs determining system \\ \hline
  16697. \ttindex{SIMPSYS}
  16698. SIMPSYS() & Solves determining system \\ \hline
  16699. \ttindex{RESULT}
  16700. RESULT() & Prints infinitesimal generators \\
  16701. & and commutator table \\ \hline
  16702. \end{tabular}
  16703. \end{center}
  16704. \caption{SPDE Functions}
  16705. \end{table}
  16706. Some other useful functions for obtaining various kinds of output
  16707. are:
  16708. \begin{table}
  16709. \begin{center}
  16710. \begin{tabular}{| c | c |} \hline
  16711. Function name & Operation \\ \hline \hline
  16712. \ttindex{PRSYS}
  16713. PRSYS() & Prints determining system \\ \hline
  16714. \ttindex{PRGEN}
  16715. PRGEN() & Prints infinitesimal generators \\ \hline
  16716. \ttindex{COMM}
  16717. COMM(U,V) & Prints commutator of generators U and V \\ \hline
  16718. \end{tabular}
  16719. \end{center}
  16720. \caption{SPDE Useful Output Functions}\label{spde:useful}
  16721. \end{table}
  16722. SPDE expects a system of differential equations to be defined as the
  16723. values of the operator {\tt deq} and other operators. A simple
  16724. example follows.
  16725. {\small\begin{verbatim}
  16726. load_package spde;
  16727. deq 1:=u(1,1)+u(1,2,2);
  16728. deq(1) := u(1,2,2) + u(1,1)
  16729. CRESYS deq 1;
  16730. PRSYS();
  16731. GL(1):=2*df(eta(1),u(1),x(2)) - df(xi(2),x(2),2) - df(xi(2),x(1))
  16732. GL(2):=df(eta(1),u(1),2) - 2*df(xi(2),u(1),x(2))
  16733. GL(3):=df(eta(1),x(2),2) + df(eta(1),x(1))
  16734. GL(4):=df(xi(2),u(1),2)
  16735. GL(5):=df(xi(2),u(1)) - df(xi(1),u(1),x(2))
  16736. GL(6):=2*df(xi(2),x(2)) - df(xi(1),x(2),2) - df(xi(1),x(1))
  16737. GL(7):=df(xi(1),u(1),2)
  16738. GL(8):=df(xi(1),u(1))
  16739. GL(9):=df(xi(1),x(2))
  16740. The remaining dependencies
  16741. xi(2) depends on u(1),x(2),x(1)
  16742. xi(1) depends on u(1),x(2),x(1)
  16743. eta(1) depends on u(1),x(2),x(1)
  16744. \end{verbatim}}
  16745. A detailed description can be found in the SPDE documentation and
  16746. examples.
  16747. \chapter{SPECFN: Package for special functions}
  16748. \label{SPECFN}
  16749. \typeout{{SPECFN: Package for special functions}}
  16750. {\footnotesize
  16751. \begin{center}
  16752. Chris Cannam \& Winfried Neun \\
  16753. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  16754. Takustra\"se 7 \\
  16755. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  16756. e--mail: neun@zib.de
  16757. \end{center}
  16758. }
  16759. \ttindex{SPECFN}
  16760. \index{Orthogonal polynomials}
  16761. This package is designed to provide algebraic and numeric manipulations of
  16762. several common special functions, namely:
  16763. \begin{itemize}
  16764. \item Bernoulli Numbers and Polynomials;
  16765. \item Euler numbers and Polynomials;
  16766. \item Fibonacci numbers and Polynomials;
  16767. \item Stirling Numbers;
  16768. \item Binomial Coefficients;
  16769. \item Pochhammer notation;
  16770. \item The Gamma function;
  16771. \item The Psi function and its derivatives;
  16772. \item The Riemann Zeta function;
  16773. \item The Bessel functions J and Y of the first and second kinds;
  16774. \item The modified Bessel functions I and K;
  16775. \item The Hankel functions H1 and H2;
  16776. \item The Kummer hypergeometric functions M and U;
  16777. \item The Beta function, and Struve, Lommel and Whittaker functions;
  16778. \item The Airy functions;
  16779. \item The Exponential Integral, the Sine and Cosine Integrals;
  16780. \item The Hyperbolic Sine and Cosine Integrals;
  16781. \item The Fresnel Integrals and the Error function;
  16782. \item The Dilog function;
  16783. \item The Polylogarithm and Lerch Phi function;
  16784. \item Hermite Polynomials;
  16785. \item Jacobi Polynomials;
  16786. \item Legendre Polynomials;
  16787. \item Associated Legendre Functions (Spherical and Solid Harmonics);
  16788. \item Laguerre Polynomials;
  16789. \item Chebyshev Polynomials;
  16790. \item Gegenbauer Polynomials;
  16791. \item Lambert's $\omega$ function;
  16792. \item Jacobi Elliptic Functions and Integrals;
  16793. \item 3j symbols, 6j symbols and Clebsch Gordan coefficients;
  16794. \item and some well-known constants.
  16795. \end{itemize}
  16796. \section{Simplification and Approximation}
  16797. All of the operators supported by this package have certain algebraic
  16798. simplification rules to handle special cases, poles, derivatives and so
  16799. on. Such rules are applied whenever they are appropriate. However, if
  16800. the {\tt ROUNDED} switch is on, numeric evaluation is also carried out.
  16801. Unless otherwise stated below, the result of an application of a special
  16802. function operator to real or complex numeric arguments in rounded mode
  16803. will be approximated numerically whenever it is possible to do so. All
  16804. approximations are to the current precision.
  16805. \section{Constants}
  16806. \ttindex{Euler\_Gamma}\ttindex{Khinchin}\ttindex{Golden\_Ratio}
  16807. \ttindex{Catalan}
  16808. Some well-known constants are defined in the special function package.
  16809. Important properties of these constants which can be used to define them
  16810. are also known. Numerical values are computed at arbitrary precision
  16811. if the switch ROUNDED is on.
  16812. \begin{itemize}
  16813. \item Euler\_Gamma : Euler's constants, also available as -$\psi(1)$;
  16814. \item Catalan : Catalan's constant;
  16815. \item Khinchin : Khinchin's constant;
  16816. \item Golden\_Ratio : $\frac{1 + \sqrt{5}}{2}$
  16817. \end{itemize}
  16818. \section{Functions}
  16819. The functions provided by this package are given in the following
  16820. tables.
  16821. %%\index{Spherical and Solid Harmonics}\ttindex{SphericalHarmonicY}
  16822. %%\ttindex{SolidHarmonicY}
  16823. %%\ttindex{Jacobiamplitude}
  16824. %%\ttindex{JacobiZeta}
  16825. \begin{center}
  16826. \fbox{
  16827. \begin{tabular}{r l}\\
  16828. Function & Operator \\\\
  16829. %\hline
  16830. $\left( { n \atop m } \right)$ & {\tt Binomial(n,m)}\ttindex{Binomial}\index{Binomial coefficients} \\
  16831. Motzkin($n$) & {\tt Motzkin(n)}\ttindex{Motzkin}\index{Motzkin} \\
  16832. Bernoulli($n$) or $ B_n $ & {\tt Bernoulli(n)}\ttindex{Bernoulli}\index{Bernoulli numbers} \\
  16833. Euler($n$) or $ E_n $ & {\tt Euler(n)}\ttindex{Euler}\index{Euler polynomials} \\
  16834. Fibonacci($n$) or $ F_n $ & {\tt Fibonacci(n)}\ttindex{Fibonacci}\index{Fibonacci} \\
  16835. $S_n^{(m)}$ & {\tt Stirling1(n,m)}\ttindex{Stirling1}\index{Stirling numbers} \\
  16836. ${\bf S}_n^{(m)}$ & {\tt Stirling2(n,m)}\ttindex{Stirling2} \\
  16837. $B(z,w)$ & {\tt Beta(z,w)}\ttindex{Beta}\index{Beta function} \\
  16838. $\Gamma(z)$ & {\tt Gamma(z)}\ttindex{Gamma}\index{Gamma function} \\
  16839. incomplete Beta $B_x(a,b)$ & {\tt iBeta(a,b,x)}\ttindex{iBeta}\index{incomplete Beta function} \\
  16840. incomplete Gamma $\Gamma(a,z)$ & {\tt iGamma(a,z)}\ttindex{iGamma}\index{incomplete Gamma function} \\
  16841. $(a)_k$ & {\tt Pochhammer(a,k)}\ttindex{Pochhammer}\index{Pochhammer's symbol} \\
  16842. $\psi(z)$ & {\tt Psi(z)}\ttindex{Psi}\index{Psi function} \\
  16843. $\psi^{(n)}(z)$ & {\tt Polygamma(n,z)}\ttindex{Polygamma}\index{Polygamma functions} \\
  16844. Riemann's $\zeta(z)$ & {\tt Zeta(z)}\ttindex{Zeta}\index{Zeta function (Riemann's)} \\
  16845. $J_\nu(z)$ & {\tt BesselJ(nu,z)}\ttindex{BesselJ}\index{Bessel functions}\\
  16846. $Y_\nu(z)$ & {\tt BesselY(nu,z)}\ttindex{BesselY}\\
  16847. $I_\nu(z)$ & {\tt BesselI(nu,z)}\ttindex{BesselI}\\
  16848. $K_\nu(z)$ & {\tt BesselK(nu,z)}\ttindex{BesselK}\\
  16849. $H^{(1)}_\nu(z)$ & {\tt Hankel1(nu,z)}\ttindex{Hankel1}\index{Hankel functions}\\
  16850. $H^{(2)}_\nu(z)$ & {\tt Hankel2(nu,z)}\ttindex{Hankel2}\\
  16851. $B(z,w)$ & {\tt Beta(z,w)}\ttindex{Beta}\index{Beta function}\\
  16852. \end{tabular}}
  16853. \end{center}
  16854. \begin{center}
  16855. \fbox{
  16856. \begin{tabular}{r l}\\
  16857. Function & Operator \\\\
  16858. %\hline
  16859. ${\bf H}_{\nu}(z)$ & {\tt StruveH(nu,z)}\ttindex{StruveH}\index{Struve functions}\\
  16860. ${\bf L}_{\nu}(z)$ & {\tt StruveL(nu,z)}\ttindex{StruveL}\\
  16861. $s_{a,b}(z)$ & {\tt Lommel1(a,b,z)}\ttindex{Lommel1}\index{Lommel functions}\\
  16862. $S_{a,b}(z)$ & {\tt Lommel2(a,b,z)}\ttindex{Lommel2}\\
  16863. $Ai(z)$ & {\tt Airy\_Ai(z)}\ttindex{Airy\_Ai}\index{Airy functions}\\
  16864. $Bi(z)$ & {\tt Airy\_Bi(z)}\ttindex{Airy\_Bi}\\
  16865. $Ai'(z)$ & {\tt Airy\_Aiprime(z)}\ttindex{Airy\_Aiprime}\\
  16866. $Bi'(z)$ & {\tt Airy\_Biprime(z)}\ttindex{Airy\_Biprime}\\
  16867. $M(a, b, z)$ or $_1F_1(a, b; z)$ or $\Phi(a, b; z)$ &
  16868. {\tt KummerM(a,b,z)}\ttindex{KummerM}\index{Kummer functions} \\
  16869. $U(a, b, z)$ or $z^{-a}{_2F_0(a, b; z)}$ or $\Psi(a, b; z)$ &
  16870. {\tt KummerU(a,b,z)}\ttindex{KummerU}\\
  16871. $M_{\kappa,\mu}(z)$ & {\tt WhittakerM(kappa,mu,z)}\ttindex{WhittakerM}\index{Whittaker functions}\\
  16872. $W_{\kappa,\mu}(z)$ & {\tt WhittakerW(kappa,mu,z)}\ttindex{WhittakerW}\\
  16873. $B_n(x)$ & {\tt BernoulliP(n,x)}\ttindex{BernoulliP}\index{Bernoulli polynomials} \\
  16874. $E_n(x)$ & {\tt EulerP(n,x)}\ttindex{EulerP} \\
  16875. Fibonacci Polynomials $F_n(x)$ & {\tt FibonacciP(n,x)}\ttindex{FibonacciP}\index{Fibonacci polynomials} \\
  16876. $C_n^{(\alpha)}(x)$ & {\tt GegenbauerP(n,alpha,x)}\ttindex{GegenbauerP}\index{Gegenbauer polynomials}\\
  16877. $H_n(x)$ & {\tt HermiteP(n,x)}\ttindex{HermiteP}\index{Hermite polynomials} \\
  16878. $L_n(x)$ & {\tt LaguerreP(n,x)}\ttindex{LaguerreP}\index{Laguerre polynomials}\\
  16879. $L_n^{(m)}(x)$ & {\tt LaguerreP(n,m,x)}\ttindex{LaguerreP}\\
  16880. $P_n(x)$ & {\tt LegendreP(n,x)}\ttindex{LegendreP}\index{Legendre polynomials}\\
  16881. $P_n^{(m)}(x)$ & {\tt LegendreP(n,m,x)}\ttindex{LegendreP}\\
  16882. $P_n^{(\alpha,\beta)} (x)$ & {\tt JacobiP(n,alpha,beta,x)}\ttindex{JacobiP}\index{Jacobi's polynomials} \\
  16883. $U_n(x)$ & {\tt ChebyshevU(n,x)}\ttindex{ChebyshevU}\index{Chebyshev polynomials} \\
  16884. $T_n(x)$ & {\tt ChebyshevT(n,x)}\ttindex{ChebyshevT}\\
  16885. \end{tabular}}
  16886. \end{center}
  16887. \begin{center}
  16888. \fbox{
  16889. \begin{tabular}{r l}\\
  16890. Function & Operator \\\\
  16891. %\hline
  16892. $Y_n^{m}(x,y,z,r2)$ & {\tt SolidHarmonicY(n,m,x,y,z,r2)}\ttindex{SolidHarmonicY}\\
  16893. $Y_n^{m}(\theta,\phi)$ & {\tt SphericalHarmonicY(n,m,theta,phi)}\ttindex{SphericalHarmonicY}\\
  16894. $\left( {j_1 \atop m_1} {j_2 \atop m_2}
  16895. {j_3 \atop m_3} \right)$ & {\tt ThreeJSymbol(\{j1,m1\},\{j2,m2\},\{j3,m3\})}\ttindex{ThreeJSymbol}\index{3j and 6j symbols}\\
  16896. $\left( {j_1m_1j_2m_2 | j_1j_2j_3 - m_3} \right)$ &
  16897. {\tt Clebsch\_Gordan(\{j1,m1\},\{j2,m2\},\{j3,m3\})}\ttindex{Clebsch\_Gordan}\index{Clebsch Gordan coefficients}\\
  16898. $\left\{ {j_1 \atop l_1} {j_2 \atop l_2}
  16899. {j_3 \atop l_3} \right\}$ & {\tt SixJSymbol(\{j1,j2,j3\},\{l1,l2,l3\})}\ttindex{SixJSymbol}\\
  16900. \end{tabular}}
  16901. \end{center}
  16902. \begin{center}
  16903. \fbox{
  16904. \begin{tabular}{r l}\\
  16905. Function & Operator \\\\
  16906. %\hline
  16907. $Si(z)$ & {\tt Si(z) }\ttindex{Si}\\
  16908. $si(z)$ & {\tt s\_i(z) }\ttindex{s\_i}\\
  16909. $Ci(z)$ & {\tt Ci(z) }\ttindex{Ci}\\
  16910. $Shi(z)$ & {\tt Shi(z) }\ttindex{Shi}\\
  16911. $Chi(z)$ & {\tt Chi(z) }\ttindex{Chi}\\
  16912. $erf(z)$ & {\tt erf(z) }\ttindex{erf}\\
  16913. $erfc(z)$ & {\tt erfc(z) }\ttindex{erfc}\\
  16914. $Ei(z)$ & {\tt Ei(z) }\ttindex{Ei}\\
  16915. $li(z)$ & {\tt li(z) }\ttindex{li}\\
  16916. $C(x)$ & {\tt Fresnel\_C(x)}\ttindex{Fresnel\_C} \\
  16917. $S(x)$ & {\tt Fresnel\_S(x)}\ttindex{Fresnel\_S} \\
  16918. \\
  16919. $dilog(z)$ & {\tt dilog(z)}\ttindex{dilog}\index{Dilogarithm function} \\
  16920. $Li_n(z)$ & {\tt Polylog(n,z)}\ttindex{Polylog}\index{Polylogarithm function} \\
  16921. Lerch $\Phi(z,s,a)$ & {\tt Lerch\_Phi(z,s,a)}\ttindex{Lerch\_Phi}\index{Lerch Phi function} \\
  16922. \\
  16923. $sn(u|m)$ & {\tt Jacobisn(u,m)}\ttindex{Jacobisn}\index{Jacobi Elliptic Functions and {Integrals}}\\
  16924. $dn(u|m)$ & {\tt Jacobidn(u,m)}\ttindex{Jacobidn}\\
  16925. $cn(u|m)$ & {\tt Jacobicn(u,m)}\ttindex{Jacobicn}\\
  16926. $cd(u|m)$ & {\tt Jacobicd(u,m)}\ttindex{Jacobicd}\\
  16927. $sd(u|m)$ & {\tt Jacobisd(u,m)}\ttindex{Jacobisd}\\
  16928. $nd(u|m)$ & {\tt Jacobind(u,m)}\ttindex{Jacobind}\\
  16929. $dc(u|m)$ & {\tt Jacobidc(u,m)}\ttindex{Jacobidc}\\
  16930. $nc(u|m)$ & {\tt Jacobinc(u,m)}\ttindex{Jacobinc}\\
  16931. $sc(u|m)$ & {\tt Jacobisc(u,m)}\ttindex{Jacobisc}\\
  16932. $ns(u|m)$ & {\tt Jacobins(u,m)}\ttindex{Jacobins}\\
  16933. $ds(u|m)$ & {\tt Jacobids(u,m)}\ttindex{Jacobids}\\
  16934. $cs(u|m)$ & {\tt Jacobics(u,m)}\ttindex{Jacobics}\\
  16935. $F(\phi|m)$ & {\tt EllipticF(phi,m)}\ttindex{EllipticF}\\
  16936. $K(m)$ & {\tt EllipticK(m)}\ttindex{EllipticK}\\
  16937. $E(\phi|m) or E(m)$ & {\tt EllipticE(phi,m) or}\\
  16938. ~ & {\tt EllipticE(m)}\ttindex{EllipticE}\\
  16939. $H(u|m), H_1(u|m), \Theta_1(u|m), \Theta(u|m)$ & {\tt EllipticTheta(a,u,m)}\ttindex{EllipticTheta}\\
  16940. $\theta_1(u|m), \theta_2(u|m), \theta_3(u|m), \theta_4(u|m)$
  16941. & {\tt EllipticTheta(a,u,m)}\ttindex{EllipticTheta}\\
  16942. $Z(u|m)$ & {\tt Zeta\_function(u,m)}\ttindex{Zeta\_function} \\
  16943. \\
  16944. Lambert $\omega(z)$ & {\tt Lambert\_W(z)}\ttindex{Lambert\_W}\index{Lambert $\omega$ function}
  16945. \end{tabular}}
  16946. \end{center}
  16947. \chapter{SPECFN2: Special special functions}
  16948. \label{SPECFN2}
  16949. \typeout{{SPECFN2: Package for special special functions}}
  16950. {\footnotesize
  16951. \begin{center}
  16952. Victor S. Adamchik \\
  16953. Byelorussian University \\
  16954. Minsk, Belorus \\[0.1in]
  16955. and\\[0.05in]
  16956. Winfried Neun \\
  16957. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  16958. Takustra\"se 7 \\
  16959. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  16960. e--mail: neun@zib.de
  16961. \end{center}
  16962. }
  16963. \ttindex{SPECFN2}
  16964. \index{Generalised Hypergeometric functions}
  16965. \index{Meijer's G function}
  16966. The (generalised) hypergeometric functions
  16967. \begin{displaymath}
  16968. _pF_q \left( {{a_1, \ldots , a_p} \atop {b_1, \ldots ,b_q}} \Bigg\vert z \right)
  16969. \end{displaymath}
  16970. are defined in textbooks on special functions.
  16971. \section{\REDUCE{} operator HYPERGEOMETRIC}
  16972. The operator {\tt hypergeometric} expects 3 arguments, namely the
  16973. list of upper parameters (which may be empty), the list of lower
  16974. parameters (which may be empty too), and the argument, e.g:
  16975. {\small\begin{verbatim}
  16976. hypergeometric ({},{},z);
  16977. Z
  16978. E
  16979. hypergeometric ({1/2,1},{3/2},-x^2);
  16980. ATAN(X)
  16981. ---------
  16982. X
  16983. \end{verbatim}}
  16984. \section{Enlarging the HYPERGEOMETRIC operator}
  16985. Since hundreds of particular cases for the generalised hypergeometric
  16986. functions can be found in the literature, one cannot expect that all
  16987. cases are known to the {\tt hypergeometric} operator.
  16988. Nevertheless the set of special cases can be augmented by adding
  16989. rules to the \REDUCE{} system, {\em e.g.}
  16990. {\small\begin{verbatim}
  16991. let {hypergeometric({1/2,1/2},{3/2},-(~x)^2) => asinh(x)/x};
  16992. \end{verbatim}}
  16993. \chapter{SUM: A package for series summation}
  16994. \label{SUM}
  16995. \typeout{{SUM: A package for series summation}}
  16996. {\footnotesize
  16997. \begin{center}
  16998. Fujio Kako \\
  16999. Department of Mathematics, Faculty of Science \\
  17000. Hiroshima University \\
  17001. Hiroshima 730, JAPAN \\[0.05in]
  17002. e--mail: kako@ics.nara-wu.ac.jp
  17003. \end{center}
  17004. }
  17005. \ttindex{SUM}
  17006. \index{Gosper's Algorithm}\index{SUM operator}\index{PROD operator}
  17007. This package implements the Gosper algorithm for the summation of series.
  17008. It defines operators SUM and PROD. The operator SUM returns the indefinite
  17009. or definite summation of a given expression, and the operator PROD returns
  17010. the product of the given expression. These are used with the syntax:
  17011. \vspace{.1in}
  17012. \noindent{\tt SUM}(EXPR:{\em expression}, K:{\em kernel},
  17013. [LOLIM:{\em expression} [, UPLIM:{\em expression}]]) \\
  17014. \noindent{\tt PROD}(EXPR:{\em expression}, K:{\em kernel},
  17015. [LOLIM:{\em expression} [, UPLIM:{\em expression}]])
  17016. If there is no closed form solution, these operators return the input
  17017. unchanged. UPLIM and LOLIM are optional parameters specifying the lower
  17018. limit and upper limit of the summation (or product), respectively. If UPLIM
  17019. is not supplied, the upper limit is taken as K (the summation variable
  17020. itself).
  17021. For example:
  17022. {\small\begin{verbatim}
  17023. sum(n**3,n);
  17024. sum(a+k*r,k,0,n-1);
  17025. sum(1/((p+(k-1)*q)*(p+k*q)),k,1,n+1);
  17026. prod(k/(k-2),k);
  17027. \end{verbatim}}
  17028. Gosper's algorithm succeeds whenever the ratio
  17029. \[ \frac{\sum_{k=n_0}^n f(k)}{\sum_{k=n_0}^{n-1} f(k)} \]
  17030. \noindent is a rational function of $n$. The function SUM!-SQ
  17031. handles basic functions such as polynomials, rational functions and
  17032. exponentials.\ttindex{SUM-SQ}
  17033. The trigonometric functions sin, cos, {\em etc.\ }are converted to exponentials
  17034. and then Gosper's algorithm is applied. The result is converted back into
  17035. sin, cos, sinh and cosh.
  17036. Summations of logarithms or products of exponentials are treated by the
  17037. formula:
  17038. \vspace{.1in}
  17039. \hspace*{2em} \[ \sum_{k=n_0}^{n} \log f(k) = \log \prod_{k=n_0}^n f(k) \]
  17040. \vspace{.1in}
  17041. \hspace*{2em} \[ \prod_{k=n_0}^n \exp f(k) = \exp \sum_{k=n_0}^n f(k) \]
  17042. \vspace{.1in}
  17043. Other functions can be summed by providing LET rules which must relate the
  17044. functions evaluated at $k$ and $k - 1$ ($k$ being the summation variable).
  17045. {\small\begin{verbatim}
  17046. operator f,gg; % gg used to avoid possible conflict with high energy
  17047. % physics operator.
  17048. for all n,m such that fixp m let
  17049. f(n+m)=if m > 0 then f(n+m-1)*(b*(n+m)**2+c*(n+m)+d)
  17050. else f(n+m+1)/(b*(n+m+1)**2+c*(n+m+1)+d);
  17051. for all n,m such that fixp m let
  17052. gg(n+m)=if m > 0 then gg(n+m-1)*(b*(n+m)**2+c*(n+m)+e)
  17053. else gg(n+m+1)/(b*(n+m+1)**2+c*(n+m+1)+e);
  17054. sum(f(n-1)/gg(n),n);
  17055. f(n)
  17056. ---------------
  17057. gg(n)*(d - e)
  17058. \end{verbatim}}
  17059. \chapter{SUSY2: Super Symmetry}
  17060. \label{SUSY2}
  17061. \typeout{{SUSY2: Super Symmetry}}
  17062. {\footnotesize
  17063. \begin{center}
  17064. Ziemowit Popowicz \\
  17065. Institute of Theoretical Physics, University of Wroclaw\\
  17066. pl. M. Borna 9 50-205 Wroclaw, Poland \\
  17067. e-mail: ziemek@ift.uni.wroc.pl
  17068. \end{center}
  17069. }
  17070. \ttindex{SUSY2}
  17071. This package deals with supersymmetric functions and with algebra
  17072. of supersymmetric operators in the extended N=2 as well as in the
  17073. nonextended N=1 supersymmetry. It allows us
  17074. to make the realization of SuSy algebra of differential operators,
  17075. compute the gradients of given SuSy Hamiltonians and to obtain
  17076. SuSy version of soliton equations using the SuSy Lax approach. There
  17077. are also many additional procedures encountered in the SuSy soliton
  17078. approach, as for example: conjugation of a given SuSy operator, computation
  17079. of general form of SuSy Hamiltonians (up to SuSy-divergence equivalence),
  17080. checking of the validity of the Jacobi identity for some SuSy
  17081. Hamiltonian operators.
  17082. To load the package, type \quad {\tt load susy2;} \\
  17083. \\
  17084. For full explanation and further examples, please refer to the
  17085. detailed documentation and the susy2.tst which comes with this package.
  17086. \section{Operators}
  17087. \subsection{Operators for constructing Objects}
  17088. The superfunctions are represented in this package by \f{BOS}(f,n,m) for superbosons
  17089. and \f{FER}(f,n,m) for superfermions. The first index denotes the name of the given
  17090. superobject, the second denotes the value of SuSy derivatives, and the last gives the
  17091. value of usual derivative. \\
  17092. In addition to the definitions of the superfunctions, also the inverse and the exponential
  17093. of superbosons can be defined (where the inverse is defined as \f{BOS}(f,n,m,-1)
  17094. with the property {\it bos(f,n,m,-1)*bos(f,n,m,1)=1}). The exponential of the superboson
  17095. function is \f{AXP}(\f{BOS}(f,0,0)). \\
  17096. The operator \f{FUN} and \f{GRAS} denote the classical and the Grassmann function. \\
  17097. Three different realizations of supersymmetric derivatives are implemented. To select
  17098. traditional realization declare \f{LET TRAD}. In order to select chiral or chiral1 algebra
  17099. declare \f{LET CHIRAL} or \f{LET CHIRAL1}. For usual differentiation the operator
  17100. \f{D}(1) stands for right and \f{D}(2) for left differentiation. SuSy derivatives are
  17101. denoted as {\it der} and {\it del}. \f{DER} and \f{DEL} are one component argument operations
  17102. and represent the left and right operators. The action of these operators on the
  17103. superfunctions depends on the choice of the supersymmetry algebra.
  17104. \flushleft
  17105. {\small\begin{center}
  17106. \begin{tabular}{ l l l l l l}
  17107. \f{BOS}(f,n,m)\ttindex{BOS} & \f{BOS}(f,n,m,k)\ttindex{BOS} &
  17108. \f{FER}(f,n,m)\ttindex{FER} & \f{AXP}(f)\ttindex{AXP} &
  17109. \f{FUN}(f,n)\ttindex{FUN} & \f{FUN}(f,n,m)\ttindex{FUN} \cr
  17110. \f{GRAS}(f,n)\ttindex{GRAS} & \f{AXX}(f)\ttindex{AXX} &
  17111. \f{D}(1)\ttindex{D} & \f{D}(2)\ttindex{D} &
  17112. \f{D}(3)\ttindex{D} & \f{D}(-1)\ttindex{D} \cr
  17113. \f{D}(-2)\ttindex{D} & \f{D}(-3)\ttindex{D} &
  17114. \f{D}(-4)\ttindex{D} & \f{DR}(-n)\ttindex{DR} &
  17115. \f{DER}(1)\ttindex{DER} & \f{DER}(2)\ttindex{DER} \cr
  17116. \f{DEL}(1)\ttindex{DEL} & \f{DEL}(2)\ttindex{DEL}
  17117. \end{tabular}
  17118. \end{center} }
  17119. \vspace{1cm}
  17120. {\bf Example}:
  17121. {\small\begin{verbatim}
  17122. 1: load susy2;
  17123. 2: bos(f,0,2,-2)*axp(fer(k,1,2))*del(1); %first susy derivative
  17124. 2*fer(f,1,2)*bos(f,0,2,-3)*axp(fer(k,1,2))
  17125. - bos(k,0,3)*bos(f,0,2,-2)*axp(fer(k,1,2))
  17126. + del(1)*bos(f,0,2,-2)*axp(fer(k,1,2))
  17127. 3: sub(del=der,ws);
  17128. bos(f,0,2,-2)*axp(fer(k,1,2))*der(1)
  17129. \end{verbatim}}
  17130. \subsection{Commands}
  17131. There are plenty of operators on superfunction objects. Some of them are introduced
  17132. here briefly.
  17133. \begin{itemize}
  17134. \item By using the operators \f{FPART}, \f{BPART}, \f{BFPART} and \f{BF\_PART}
  17135. it is possible to compute the coordinates of the arbitrary SuSy expressions.
  17136. \item With \f{W\_COMB}, \f{FCOMB} and \f{PSE\_ELE} there are three operators to be able to
  17137. construct different possible combinations of superfunctions and
  17138. super-pseudo-differential elements with the given conformal dimensions .
  17139. \item The three operators \f{S\_PART}, \f{D\_PART} and \f{SD\_PART} are implemented to
  17140. obtain the components of the (pseudo)-SuSy element.
  17141. \item \f{RZUT} is used to obtain the projection onto the invariant subspace (with respect
  17142. to commutator) of algebra of pseudo-SuSy-differential algebra.
  17143. \item To obtain the list of the same combinations of some superfunctions and (SuSy)
  17144. derivatives from some given operator-valued expression, the operators
  17145. \f{LYST}, \f{LYST1} and \f{LYST2} are constructed.
  17146. \end{itemize}
  17147. \begin{center}
  17148. \begin{tabular}{ l l}
  17149. \f{FPART}(expression)\ttindex{FPART} &
  17150. \f{BPART}(expression)\ttindex{BPART} \cr
  17151. \f{BF\_PART}(expression,n)\ttindex{BF\_PART} &
  17152. \f{B\_PART}(expression,n)\ttindex{B\_PART} \cr
  17153. \f{PR}(n,expression)\ttindex{PR} &
  17154. \f{PG}(n,expression)\ttindex{PG} \cr
  17155. \f{W\_COMB}(\{\{f,n,x\},...\},m,z,y)\ttindex{W\_COMB} &
  17156. \f{FCOMB}(\{\{f,n,x\},...\},m,z,y)\ttindex{FCOMB} \cr
  17157. \f{PSE\_ELE}(n,\{\{f,n\},...\},z)\ttindex{PSE\_ELE} \cr
  17158. \f{S\_PART}(expression,n)\ttindex{S\_PART} &
  17159. \f{D\_PART}(expression,n)\ttindex{D\_PART} \cr
  17160. \f{SD\_PART}(expression,n,m)\ttindex{SD\_PART} &
  17161. \f{CP}(expression)\ttindex{CP} \cr
  17162. \f{RZUT}(expression,n)\ttindex{RZUT} &
  17163. \f{LYST}(expression)\ttindex{LYST} \cr
  17164. \f{LYST1}(expression)\ttindex{LYST1} &
  17165. \f{LYST2}(expression)\ttindex{LYST2} \cr
  17166. \f{CHAN}(expression)\ttindex{CHAN} &
  17167. \f{ODWA}(expression)\ttindex{ODWA} \cr
  17168. \f{GRA}(expression,f)\ttindex{GRA} &
  17169. \f{DYW}(expression,f)\ttindex{DYW} \cr
  17170. \f{WAR}(expression,f)\ttindex{WAR} &
  17171. \f{DOT\_HAM}(equations,expression)\ttindex{DOT\_HAM} \cr
  17172. \f{N\_GAT}(operator,list)\ttindex{N\_GAT} &
  17173. \f{FJACOB}(operator,list)\ttindex{FJACOB} \cr
  17174. \f{JACOB}(operator,list,\{$\alpha,\beta,\gamma$\})\ttindex{JACOB} &
  17175. \f{MACIERZ}(expression,x,y)\ttindex{MACIERZ} \cr
  17176. \f{S\_INT}(number,expression,list)\ttindex{S\_INT}
  17177. \end{tabular}
  17178. \end{center}
  17179. \vspace{1cm}
  17180. {\bf Example}:
  17181. {\small\begin{verbatim}
  17182. 4: xxx:=fer(f,2,3);
  17183. xxx := fer(f,2,3)
  17184. 5: fpart(xxx); % all components
  17185. - fun(f0,4) + 2*fun(f1,3) gras(ff2,4)
  17186. {gras(ff2,3), ----------------------------,0, -------------}
  17187. 2 2
  17188. 6: bpart(xxx); % bosonic sector
  17189. - fun(f0,4) + 2*fun(f1,3)
  17190. {0,----------------------------,0,0}
  17191. 2
  17192. 9: b_part(xxx,1); %the given component in the bosonic sector
  17193. - fun(f0,4) + 2*fun(f1,3)
  17194. ----------------------------
  17195. 2
  17196. \end{verbatim}}
  17197. \section{Options}
  17198. The are several options defined in this package. Please note that they are
  17199. activated by typing \f{let $<$option$>$}. See also above. \\
  17200. The \f{TRAD}, \f{CHIRAL} and \f{CHIRAL1} select the different realizations of the
  17201. supersymmetric derivatives. By default traditional algebra is selected. \\
  17202. If the command {\tt LET INVERSE} is used, then three indices {\it bos} objects are
  17203. transformed onto four indices objects.
  17204. \begin{center}
  17205. \begin{tabular}{ l l l l l l }
  17206. \f{TRAD}\ttindex{TRAD} & \f{CHIRAL}\ttindex{CHIRAL} &
  17207. \f{CHIRAL1}\ttindex{CHIRAL1} & \f{INVERSE}\ttindex{INVERSE} &
  17208. \f{DRR}\ttindex{DRR} & \f{NODRR}\ttindex{NODRR}
  17209. \end{tabular}
  17210. \end{center}
  17211. \vspace{1cm}
  17212. {\bf Example}:
  17213. {\small\begin{verbatim}
  17214. 10: let inverse;
  17215. 11: bos(f,0,3)**3*bos(k,3,1)**40*bos(f,0,3,-2);
  17216. bos(k,3,1,40)*bos(f,0,3,1);
  17217. 12: clearrules inverse;
  17218. 13: xxx:=fer(f,1,2)*bos(k,0,2,-2);
  17219. xxx := fer(f,1,2)*bos(k,0,2,-2)
  17220. 14: pr(1,xxx); % first susy derivative
  17221. - 2*fer(k,1,2)*fer(f,1,2)*bos(k,0,2,-3) + bos(k,0,2,-2)*bos(f,0,3)
  17222. 15: pr(2,xxx); %second susy derivative
  17223. - 2*fer(k,2,2)*fer(f,1,2)*bos(k,0,2,-3) - bos(k,0,2,-2)*bos(f,3,2)
  17224. 16: clearrules trad;
  17225. 17: let chiral; % changing to chiral algebra
  17226. 18: pr(1,xxx);
  17227. - 2*fer(k,1,2)*fer(f,1,2)*bos(k,0,2,-3)
  17228. \end{verbatim}}
  17229. \chapter{SYMMETRY: Symmetric matrices}
  17230. \label{SYMMETRY}
  17231. \typeout{{SYMMETRY: Operations on symmetric matrices}}
  17232. {\footnotesize
  17233. \begin{center}
  17234. Karin Gatermann\\
  17235. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  17236. Takustra\"se 7 \\
  17237. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  17238. e--mail: gatermann@zib.de
  17239. \end{center}
  17240. }
  17241. \ttindex{SYMMETRY}
  17242. The SYMMETRY package provides procedures
  17243. that compute symmetry-adapted bases and block diagonal forms
  17244. of matrices which have the symmetry of a group.
  17245. \section{Operators for linear representations}
  17246. The data structure for a linear representation, a {\em
  17247. representation}, is a list consisting of the group identifier and
  17248. equations which assign matrices to the generators of the group.
  17249. {\bf Example:}
  17250. {\small\begin{verbatim}
  17251. rr:=mat((0,1,0,0),
  17252. (0,0,1,0),
  17253. (0,0,0,1),
  17254. (1,0,0,0));
  17255. sp:=mat((0,1,0,0),
  17256. (1,0,0,0),
  17257. (0,0,0,1),
  17258. (0,0,1,0));
  17259. representation:={D4,rD4=rr,sD4=sp};
  17260. \end{verbatim}}
  17261. For orthogonal (unitarian) representations the following operators
  17262. are available.
  17263. {\tt canonicaldecomposition(representation);}\ttindex{canonicaldecomposition}
  17264. returns an equation giving the canonical decomposition of the linear
  17265. representation.
  17266. {\tt character(representation);}\ttindex{character}
  17267. computes the character of the linear representation. The result is a list
  17268. of the group identifier and of lists consisting of a
  17269. list of group elements in one equivalence class and a real or complex number.
  17270. {\tt symmetrybasis(representation,nr);}\ttindex{symmetrybasis}
  17271. computes the basis of the isotypic component corresponding to the irreducible
  17272. representation of type nr. If the nr-th irreducible representation is
  17273. multidimensional, the basis is symmetry adapted. The output is a matrix.
  17274. {\tt symmetrybasispart(representation,nr);}\ttindex{symmetrybasispart}
  17275. is similar as {\tt symmetrybasis}, but for multidimensional
  17276. irreducible representations only the first part of the
  17277. symmetry adapted basis is computed.
  17278. {\tt allsymmetrybases(representation);}\ttindex{allsymmetrybases}
  17279. is similar as {\tt symmetrybasis} and {\tt symmetrybasispart},
  17280. but the bases of all
  17281. isotypic components are computed and thus a
  17282. complete coordinate transformation is returned.
  17283. {\tt diagonalize(matrix,representation);}\ttindex{diagonalize}
  17284. returns the block diagonal form of matrix which has the symmetry
  17285. of the given linear representation. Otherwise an error message occurs.
  17286. \section{Display Operators}
  17287. Access is provided to the information for a group, and for adding
  17288. knowledge for other groups. This is explained in detail in the
  17289. Symmetry on-line documentation.
  17290. \chapter{TAYLOR: Manipulation of Taylor series}
  17291. \label{TAYLOR}
  17292. \typeout{{TAYLOR: Manipulation of Taylor series}}
  17293. {\footnotesize
  17294. \begin{center}
  17295. Rainer Sch\"opf\\
  17296. Zentrum f\"ur Datenverarbeitung der Universit\"at Mainz\\
  17297. Anselm-Franz-von-Bentzel-Weg~12\\
  17298. D-55055 Mainz, Germany \\[0.05in]
  17299. e--mail: Schoepf@Uni-Mainz.DE
  17300. \end{center}
  17301. }
  17302. \ttindex{TAYLOR}\index{Taylor Series}\index{TAYLOR package}
  17303. \index{Laurent series}
  17304. The TAYLOR package of \REDUCE\ allow Taylor expansion in one or
  17305. several variables, and efficient manipulation of the resulting Taylor
  17306. series. Capabilities include basic operations (addition, subtraction,
  17307. multiplication and division), and also application of certain
  17308. algebraic and transcendental functions. To a certain extent, Laurent
  17309. and Puiseux expansions can be performed as well. In many cases,
  17310. separable singularities are detected and factored out.
  17311. \noindent {\tt TAYLOR}(EXP:{\em exprn}[,VAR:{\em kernel},
  17312. VAR$_0$:{\em exprn},ORDER:{\em integer}]\ldots):{\em exprn}
  17313. where EXP is the expression to be expanded. It can be any \REDUCE\
  17314. object, even an expression containing other Taylor kernels. VAR is
  17315. the kernel with respect to which EXP is to be expanded. VAR$_0$
  17316. denotes the point about which and ORDER the order up to which
  17317. expansion is to take place. If more than one (VAR, VAR0, ORDER) triple
  17318. is specified {\tt TAYLOR} will expand its first argument independently
  17319. with respect to each variable in turn. For example,
  17320. {\small\begin{verbatim}
  17321. taylor(e^(x^2+y^2),x,0,2,y,0,2);
  17322. \end{verbatim}}
  17323. will calculate the Taylor expansion up to order $X^{2}*Y^{2}$.
  17324. Note that once the expansion has been done it is not possible to
  17325. calculate higher orders.
  17326. Instead of a kernel, VAR may also
  17327. be a list of kernels. In this case expansion will take place in a way
  17328. so that the {\em sum\/} of the degrees of the kernels does not exceed
  17329. ORDER.
  17330. If VAR$_0$ evaluates to the special identifier \verb|INFINITY|
  17331. {\tt TAYLOR} tries to expand EXP in a series in 1/VAR.
  17332. The expansion is performed variable per variable, {\em i.e.\ }in the
  17333. example above by first expanding $\exp(x^{2}+y^{2})$ with respect
  17334. to $x$ and then expanding every coefficient with respect to $y$.
  17335. \index{IMPLICIT\_TAYLOR operator}\index{INVERSE\_TAYLOR} There are two
  17336. extra operators to compute the Taylor expansions of implicit and
  17337. inverse functions:
  17338. \noindent {\tt IMPLICIT\_TAYLOR}(F:{\em exprn},VAR1,VAR2:{\em kernel},\\
  17339. \hphantom{{\tt IMPLICIT\_TAYLOR}(}VAR1$_0$,VAR2$_0$:{\em exprn},
  17340. ORDER:{\em integer}):{\em exprn}
  17341. takes a function F depending on two variables VAR1 and VAR2 and
  17342. computes the Taylor series of the implicit function VAR2(VAR1)
  17343. given by the equation F(VAR1,VAR2) = 0. For example,
  17344. {\small\begin{verbatim}
  17345. implicit_taylor(x^2 + y^2 - 1,x,y,0,1,5);
  17346. \end{verbatim}}
  17347. \noindent {\tt INVERSE\_TAYLOR}(F:{\em exprn},VAR1,VAR2:{\em kernel},\\
  17348. \hphantom{{\tt INVERSE\_TAYLOR}(}VAR1$_0$:{\em exprn},
  17349. ORDER:{\em integer}):{\em exprn}
  17350. takes a function F depending on VAR1 and computes the Taylor series of
  17351. the inverse of F with respect to VAR2. For example,
  17352. {\small\begin{verbatim}
  17353. inverse_taylor(exp(x)-1,x,y,0,8);
  17354. \end{verbatim}}
  17355. \index{TAYLORPRINTTERMS variable}
  17356. When a Taylor kernel is printed, only a certain number of (non-zero)
  17357. coefficients are shown. If there are more, an expression of the form
  17358. \verb|(|$n$\verb| terms)| is printed to indicate how many non-zero
  17359. terms have been suppressed. The number of terms printed is given by
  17360. the value of the shared algebraic variable \verb|TAYLORPRINTTERMS|.
  17361. Allowed values are integers and the special identifier \verb|ALL|. The
  17362. latter setting specifies that all terms are to be printed. The default
  17363. setting is $5$.
  17364. \index{TAYLORKEEPORIGINAL switch}
  17365. If the switch \verb|TAYLORKEEPORIGINAL| is set to \verb|ON| the
  17366. original expression EXP is kept for later reference.
  17367. It can be recovered by means of the operator
  17368. \hspace*{2em} {\tt TAYLORORIGINAL}(EXP:{\em exprn}):{\em exprn}
  17369. An error is signalled if EXP is not a Taylor kernel or if the original
  17370. expression was not kept, {\em i.e.\ }if \verb|TAYLORKEEPORIGINAL| was
  17371. \verb|OFF| during expansion. The template of a Taylor kernel, {\em i.e.\ }
  17372. the list of all variables with respect to which expansion took place
  17373. together with expansion point and order can be extracted using
  17374. \ttindex{TAYLORTEMPLATE}
  17375. \hspace*{2em} {\tt TAYLORTEMPLATE}(EXP:{\em exprn}):{\em list}
  17376. This returns a list of lists with the three elements (VAR,VAR0,ORDER).
  17377. As with \verb|TAYLORORIGINAL|, an error is signalled if EXP is not a
  17378. Taylor kernel.
  17379. \hspace*{2em} {\tt TAYLORTOSTANDARD}(EXP:{\em exprn}):{\em exprn}
  17380. converts all Taylor kernels in EXP into standard form and
  17381. \ttindex{TAYLORTOSTANDARD} resimplifies the result.
  17382. \hspace*{2em} {\tt TAYLORSERIESP}(EXP:{\em exprn}):{\em boolean}
  17383. may be used to determine if EXP is a Taylor kernel.
  17384. \ttindex{TAYLORSERIESP} Note that this operator is subject to the same
  17385. restrictions as, {\em e.g.}, ORDP or NUMBERP, {\em i.e.\ }it may only be used in
  17386. boolean expressions in \verb|IF| or \verb|LET| statements. Finally
  17387. there is
  17388. \hspace*{2em} {\tt TAYLORCOMBINE}(EXP:{\em exprn}):{\em exprn}
  17389. which tries to combine all Taylor kernels found in EXP into one.
  17390. \ttindex{TAYLORCOMBINE}
  17391. Operations currently possible are:
  17392. \index{Taylor series ! arithmetic}
  17393. \begin{itemize}
  17394. \item Addition, subtraction, multiplication, and division.
  17395. \item Roots, exponentials, and logarithms.
  17396. \item Trigonometric and hyperbolic functions and their inverses.
  17397. \end{itemize}
  17398. Application of unary operators like \verb|LOG| and \verb|ATAN| will
  17399. nearly always succeed. For binary operations their arguments have to be
  17400. Taylor kernels with the same template. This means that the expansion
  17401. variable and the expansion point must match. Expansion order is not so
  17402. important, different order usually means that one of them is truncated
  17403. before doing the operation.
  17404. \ttindex{TAYLORKEEPORIGINAL}\ttindex{TAYLORCOMBINE}
  17405. If \verb|TAYLORKEEPORIGINAL| is set to \verb|ON| and if all Taylor
  17406. kernels in \verb|exp| have their original expressions kept
  17407. \verb|TAYLORCOMBINE| will also combine these and store the result
  17408. as the original expression of the resulting Taylor kernel.
  17409. \index{TAYLORAUTOEXPAND switch}
  17410. There is also the switch \verb|TAYLORAUTOEXPAND| (see below).
  17411. There are a few restrictions to avoid mathematically undefined
  17412. expressions: it is not possible to take the logarithm of a Taylor
  17413. kernel which has no terms ({\em i.e.\ }is zero), or to divide by such a
  17414. beast. There are some provisions made to detect singularities during
  17415. expansion: poles that arise because the denominator has zeros at the
  17416. expansion point are detected and properly treated, {\em i.e.\ }the Taylor
  17417. kernel will start with a negative power. (This is accomplished by
  17418. expanding numerator and denominator separately and combining the
  17419. results.) Essential singularities of the known functions (see above)
  17420. are handled correctly.
  17421. \index{Taylor series ! differentiation}
  17422. Differentiation of a Taylor expression is possible. Differentiating
  17423. with respect to one of the Taylor variables will decrease the order by one.
  17424. \index{Taylor series ! substitution}
  17425. Substitution is a bit restricted: Taylor variables can only be replaced
  17426. by other kernels. There is one exception to this rule: one can always
  17427. substitute a Taylor variable by an expression that evaluates to a
  17428. constant. Note that \REDUCE\ will not always be able to determine
  17429. that an expression is constant.
  17430. \index{Taylor series ! integration}
  17431. Only simple Taylor kernels can be integrated. More complicated
  17432. expressions that contain Taylor kernels as parts of themselves are
  17433. automatically converted into a standard representation by means of the
  17434. TAYLORTOSTANDARD operator. In this case a suitable warning is printed.
  17435. \index{Taylor series ! reversion} It is possible to revert a Taylor
  17436. series of a function $f$, {\em i.e.}, to compute the first terms of the
  17437. expansion of the inverse of $f$ from the expansion of $f$. This is
  17438. done by the operator
  17439. \hspace*{2em} {\tt TAYLORREVERT}(EXP:{\em exprn},OLDVAR:{\em kernel},
  17440. NEWVAR:{\em kernel}):{\em exprn}
  17441. EXP must evaluate to a Taylor kernel with OLDVAR being one of its
  17442. expansion variables. Example:
  17443. {\small\begin{verbatim}
  17444. taylor (u - u**2, u, 0, 5);
  17445. taylorrevert (ws, u, x);
  17446. \end{verbatim}}
  17447. This package introduces a number of new switches:
  17448. \begin{itemize}
  17449. \index{TAYLORAUTOCOMBINE switch}
  17450. \item If \verb|TAYLORAUTOCOMBINE| is set to \verb|ON| \REDUCE\
  17451. automatically combines Taylor expressions during the simplification
  17452. process. This is equivalent to applying \verb|TAYLORCOMBINE| to
  17453. every expression that contains Taylor kernels.
  17454. Default is \verb|ON|.
  17455. \index{TAYLORAUTOEXPAND switch}
  17456. \item \verb|TAYLORAUTOEXPAND| makes Taylor expressions ``contagious''
  17457. in the sense that \verb|TAYLORCOMBINE| tries to Taylor expand
  17458. all non-Taylor subexpressions and to combine the result with the
  17459. rest. Default is \verb|OFF|.
  17460. \index{TAYLORKEEPORIGINAL switch}
  17461. \item \verb|TAYLORKEEPORIGINAL|, if set to \verb|ON|, forces the
  17462. package to keep the original expression, {\em i.e.\ }the expression
  17463. that was Taylor expanded. All operations performed on the
  17464. Taylor kernels are also applied to this expression which can
  17465. be recovered using the operator \verb|TAYLORORIGINAL|.
  17466. Default is \verb|OFF|.
  17467. \index{TAYLORPRINTORDER switch}
  17468. \item \verb|TAYLORPRINTORDER|, if set to \verb|ON|, causes the
  17469. remainder to be printed in big-$O$ notation. Otherwise, three
  17470. dots are printed. Default is \verb|ON|.
  17471. \end{itemize}
  17472. \chapter{TPS: A truncated power series package}
  17473. \label{TPS}
  17474. \typeout{{TPS: A truncated power series package}}
  17475. {\footnotesize
  17476. \begin{center}
  17477. Alan Barnes \\
  17478. Dept. of Computer Science and Applied Mathematics \\
  17479. Aston University, Aston Triangle, \\
  17480. Birmingham B4 7ET, England \\[0.05in]
  17481. e--mail: barnesa@aston.ac.uk \\[0.1in]
  17482. and \\[0.1in]
  17483. Julian Padget \\
  17484. School of Mathematics, University of Bath \\
  17485. Bath, BA2 7AY, England \\[0.05in]
  17486. e--mail: jap@maths.bath.ac.uk
  17487. \end{center}
  17488. }
  17489. \ttindex{TPS}\ttindex{PS}
  17490. \index{power series}\index{truncated power series}
  17491. \index{Laurent series expansions}
  17492. This package implements formal Laurent series expansions in one
  17493. variable using the domain mechanism of \REDUCE. This means that power
  17494. series objects can be added, multiplied, differentiated {\em etc}. like other
  17495. first class objects in the system. A lazy evaluation scheme is used in
  17496. the package and thus terms of the series are not evaluated until they
  17497. are required for printing or for use in calculating terms in other
  17498. power series. The series are extendible giving the user the impression
  17499. that the full infinite series is being manipulated. The errors that
  17500. can sometimes occur using series that are truncated at some fixed depth
  17501. (for example when a term in the required series depends on terms of an
  17502. intermediate series beyond the truncation depth) are thus avoided.
  17503. \newpage
  17504. \section{Basic Truncated Power Series}
  17505. \subsection{PS Operator}
  17506. Syntax:
  17507. \noindent{\tt PS}(EXPRN:{\em algebraic},DEPVAR:{\em kernel},ABOUT:{\em algebraic}):{\em ps object}
  17508. \index{PS operator}
  17509. The {\tt PS} operator returns a power series object
  17510. representing the univariate formal power series expansion of EXPRN with
  17511. respect to the dependent variable DEPVAR about the expansion point
  17512. ABOUT. EXPRN may itself contain power series objects.
  17513. The algebraic expression ABOUT should simplify to an expression
  17514. which is independent of the dependent variable DEPVAR, otherwise
  17515. an error will result. If ABOUT is the identifier {\tt INFINITY}
  17516. then the power series expansion about DEPVAR = $\infty$ is
  17517. obtained in ascending powers of 1/DEPVAR.
  17518. \index{PSEXPLIM operator}
  17519. The power series object
  17520. representing EXPRN is compiled and then a number of terms of the
  17521. power series expansion are evaluated. The expansion is
  17522. carried out as far as the value specified by {\tt PSEXPLIM}. If,
  17523. subsequently, the value of {\tt PSEXPLIM} is increased, sufficient
  17524. information is stored in the power series object to enable the
  17525. additional terms to be calculated without recalculating the terms
  17526. already obtained.
  17527. If the function has a pole at the expansion point then the correct
  17528. Laurent series expansion will be produced.
  17529. \noindent The following examples are valid uses of {\tt PS}:
  17530. {\small\begin{verbatim}
  17531. psexplim 6;
  17532. ps(log x,x,1);
  17533. ps(e**(sin x),x,0);
  17534. ps(x/(1+x),x,infinity);
  17535. ps(sin x/(1-cos x),x,0);
  17536. \end{verbatim}}
  17537. \index{power series ! of user defined function}
  17538. New user-defined functions may be expanded provided the user provides
  17539. LET rules giving
  17540. \begin{enumerate}
  17541. \item the value of the function at the expansion point
  17542. \item a differentiation rule for the new function.
  17543. \end{enumerate}
  17544. \noindent For example
  17545. {\small\begin{verbatim}
  17546. operator sech;
  17547. forall x let df(sech x,x)= - sech x * tanh x;
  17548. let sech 0 = 1;
  17549. ps(sech(x**2),x,0);
  17550. \end{verbatim}}
  17551. \index{power series ! of integral}
  17552. The power series expansion of an integral may also be obtained (even if
  17553. \REDUCE\ cannot evaluate the integral in closed form). An example of
  17554. this is
  17555. {\small\begin{verbatim}
  17556. ps(int(e**x/x,x),x,1);
  17557. \end{verbatim}}
  17558. Note that if the integration variable is the same as the expansion
  17559. variable then \REDUCE's integration package is not called; if on the
  17560. other hand the two variables are different then the integrator is
  17561. called to integrate each of the coefficients in the power series
  17562. expansion of the integrand. The constant of integration is zero by
  17563. default. If another value is desired, then the shared variable {\tt
  17564. PSINTCONST} should be set to required value.\index{PSINTCONST (shared)}
  17565. \subsection{PSORDLIM Operator}
  17566. \index{PSORDLIM operator}
  17567. Syntax:
  17568. \hspace*{2em} {\tt PSORDLIM}(UPTO:{\em integer}):{\em integer}
  17569. \hspace*{4em} or
  17570. \hspace*{2em} {\tt PSORDLIM}():{\em integer}
  17571. An internal variable is set to the value of {\tt UPTO} (which should
  17572. evaluate to an integer). The value returned is the previous value of
  17573. the variable. The default value is 15.
  17574. If {\tt PSORDLIM} is called with no argument, the current value is
  17575. returned.
  17576. The significance of this control is that the system attempts to find
  17577. the order of the power series required, that is the order is the
  17578. degree of the first non-zero term in the power series. If the order
  17579. is greater than the value of this variable an error message is given
  17580. and the computation aborts. This prevents infinite loops in examples
  17581. such as
  17582. {\small\begin{verbatim}
  17583. ps(1 - (sin x)**2 - (cos x)**2,x,0);
  17584. \end{verbatim}}
  17585. where the expression being expanded is identically zero, but is not
  17586. recognised as such by \REDUCE.
  17587. \section{Controlling Power Series}
  17588. \subsection{PSTERM Operator}
  17589. \index{PSTERM operator}
  17590. Syntax:
  17591. \hspace*{2em} {\tt PSTERM}(TPS:{\em power series object},NTH:{\em integer}):{\em algebraic}
  17592. The operator {\tt PSTERM} returns the NTH term of the existing
  17593. power series object TPS. If NTH does not evaluate to
  17594. an integer or TPS to a power series object an error results. It
  17595. should be noted that an integer is treated as a power series.
  17596. \subsection{PSORDER Operator}
  17597. \index{PSORDER operator}
  17598. Syntax:
  17599. \hspace*{2em} {\tt PSORDER}(TPS:{\em power series object}):{\em integer}
  17600. The operator {\tt PSORDER} returns the order, that is the degree of
  17601. the first non-zero term, of the power series object TPS.
  17602. TPS should evaluate to a power series object or an error results. If
  17603. TPS is zero, the identifier {\tt UNDEFINED} is returned.
  17604. \subsection{PSSETORDER Operator}
  17605. \index{PSSETORDER operator}
  17606. Syntax:
  17607. \hspace*{2em} {\tt PSSETORDER}(TPS:{\em power series object}, ORD:{\em integer}):{\em integer}
  17608. The operator {\tt PSSETORDER} sets the order of the power series TPS to the
  17609. value ORD, which should evaluate to an integer. If
  17610. TPS does not evaluate to a power series object, then an error
  17611. occurs. The value returned by this operator is the previous order of
  17612. TPS, or 0 if the order of TPS was undefined. This
  17613. operator is useful for setting the order of the power series of a
  17614. function defined by a differential equation in cases where the power
  17615. series package is inadequate to determine the order automatically.
  17616. \subsection{PSDEPVAR Operator}
  17617. \index{PSDEPVAR operator}
  17618. Syntax:
  17619. \hspace*{2em} {\tt PSDEPVAR}(TPS:{\em power series object}):{\em identifier}
  17620. The operator {\tt PSDEPVAR} returns the expansion variable of the
  17621. power series object TPS. TPS should evaluate to a power
  17622. series object or an integer, otherwise an error results. If TPS
  17623. is an integer, the identifier {\tt UNDEFINED} is returned.
  17624. \subsection{PSEXPANSIONPT operator}
  17625. \index{PSEXPANSIONPT operator}
  17626. Syntax:
  17627. \hspace*{2em} {\tt PSEXPANSIONPT}(TPS:{\em power series object}):{\em algebraic}
  17628. The operator {\tt PSEXPANSIONPT} returns the expansion point of the
  17629. power series object TPS. TPS should evaluate to a power
  17630. series object or an integer, otherwise an error results. If TPS
  17631. is integer, the identifier {\tt UNDEFINED} is returned. If the
  17632. expansion is about infinity, the identifier {\tt INFINITY} is
  17633. returned.
  17634. \subsection{PSFUNCTION Operator}
  17635. \index{PSFUNCTION operator}
  17636. Syntax:
  17637. \hspace*{2em} {\tt PSFUNCTION}(TPS:{\em power series object}):{\em algebraic}
  17638. The operator {\tt PSFUNCTION} returns the function whose expansion
  17639. gave rise to the power series object TPS. TPS should
  17640. evaluate to a power series object or an integer, otherwise an error
  17641. results.
  17642. \subsection{PSCHANGEVAR Operator}
  17643. \index{PSCHANGEVAR operator}
  17644. Syntax:
  17645. \hspace*{2em} {\tt PSCHANGEVAR}(TPS:{\em power series object}, X:{\em kernel}):{\em power series object}
  17646. The operator {\tt PSCHANGEVAR} changes the dependent variable of the
  17647. power series object TPS to the variable X. TPS
  17648. should evaluate to a power series object and X to a kernel,
  17649. otherwise an error results. Also X should not appear as a
  17650. parameter in TPS. The power series with the new dependent
  17651. variable is returned.
  17652. \subsection{PSREVERSE Operator}
  17653. \index{PSREVERSE operator}
  17654. Syntax:
  17655. \hspace*{2em} {\tt PSREVERSE}(TPS:{\em power series object}):{\em power series}
  17656. Power series reversion. The power series TPS is functionally
  17657. inverted. Four cases arise:
  17658. \begin{enumerate}
  17659. \item If the order of the series is 1, then the expansion point of the
  17660. inverted series is 0.
  17661. \item If the order is 0 {\em and} if the first order term in TPS
  17662. is non-zero, then the expansion point of the inverted series is taken
  17663. to be the coefficient of the zeroth order term in TPS.
  17664. \item If the order is -1 the expansion point of the inverted series
  17665. is the point at infinity. In all other cases a \REDUCE\ error is
  17666. reported because the series cannot be inverted as a power series. Puiseux
  17667. \index{Puiseux expansion} expansion would be required to handle these cases.
  17668. \item If the expansion point of TPS is finite it becomes the
  17669. zeroth order term in the inverted series. For expansion about 0 or the
  17670. point at infinity the order of the inverted series is one.
  17671. \end{enumerate}
  17672. If TPS is not a power series object after evaluation an error results.
  17673. \noindent Here are some examples:
  17674. {\small\begin{verbatim}
  17675. ps(sin x,x,0);
  17676. psreverse(ws); % produces series for asin x about x=0.
  17677. ps(exp x,x,0);
  17678. psreverse ws; % produces series for log x about x=1.
  17679. ps(sin(1/x),x,infinity);
  17680. psreverse(ws); % produces series for 1/asin(x) about x=0.
  17681. \end{verbatim}}
  17682. \subsection{PSCOMPOSE Operator}
  17683. \index{PSCOMPOSE operator}
  17684. Syntax:
  17685. \hspace*{2em} {\tt PSCOMPOSE}(TPS1:{\em power series}, TPS2:{\em power series}):{\em power series}
  17686. \index{power series ! composition}
  17687. {\tt PSCOMPOSE} performs power series composition.
  17688. The power series TPS1 and TPS2 are functionally composed.
  17689. That is to say that TPS2 is substituted for the expansion
  17690. variable in TPS1 and the result expressed as a power series. The
  17691. dependent variable and expansion point of the result coincide with
  17692. those of TPS2. The following conditions apply to power series
  17693. composition:
  17694. \begin{enumerate}
  17695. \item If the expansion point of TPS1 is 0 then the order of the
  17696. TPS2 must be at least 1.
  17697. \item If the expansion point of TPS1 is finite, it should
  17698. coincide with the coefficient of the zeroth order term in TPS2.
  17699. The order of TPS2 should also be non-negative in this case.
  17700. \item If the expansion point of TPS1 is the point at infinity
  17701. then the order of TPS2 must be less than or equal to -1.
  17702. \end{enumerate}
  17703. If these conditions do not hold the series cannot be composed (with
  17704. the current algorithm terms of the inverted series would involve
  17705. infinite sums) and a \REDUCE\ error occurs.
  17706. \noindent Examples of power series composition include the following.
  17707. {\small\begin{verbatim}
  17708. a:=ps(exp y,y,0); b:=ps(sin x,x,0);
  17709. pscompose(a,b);
  17710. % Produces the power series expansion of exp(sin x)
  17711. % about x=0.
  17712. a:=ps(exp z,z,1); b:=ps(cos x,x,0);
  17713. pscompose(a,b);
  17714. % Produces the power series expansion of exp(cos x)
  17715. % about x=0.
  17716. a:=ps(cos(1/x),x,infinity); b:=ps(1/sin x,x,0);
  17717. pscompose(a,b);
  17718. % Produces the power series expansion of cos(sin x)
  17719. % about x=0.
  17720. \end{verbatim}}
  17721. \subsection{PSSUM Operator}
  17722. \index{PSSUM operator}
  17723. Syntax:
  17724. \begin{tabbing}
  17725. \hspace*{2em} {\tt PSSUM}(\=J:{\em kernel} = LOWLIM:{\em integer}, COEFF:{\em algebraic}, X:{\em kernel}, \\
  17726. \> ABOUT:{\em algebraic}, POWER:{\em algebraic}):{\em power series}
  17727. \end{tabbing}
  17728. The formal power series sum for J from LOWLIM to {\tt INFINITY} of
  17729. {\small\begin{verbatim}
  17730. COEFF*(X-ABOUT)**POWER
  17731. \end{verbatim}}
  17732. or if ABOUT is given as {\tt INFINITY}
  17733. {\small\begin{verbatim}
  17734. COEFF*(1/X)**POWER
  17735. \end{verbatim}}
  17736. is constructed and returned. This enables power series whose general
  17737. term is known to be constructed and manipulated using the other
  17738. procedures of the power series package.
  17739. J and X should be distinct simple kernels. The algebraics
  17740. ABOUT, COEFF and POWER should not depend on the
  17741. expansion variable X, similarly the algebraic ABOUT should
  17742. not depend on the summation variable J. The algebraic POWER should be
  17743. a strictly increasing integer valued function of J for J in the range
  17744. LOWLIM to {\tt INFINITY}.
  17745. {\small\begin{verbatim}
  17746. pssum(n=0,1,x,0,n*n);
  17747. % Produces the power series summation for n=0 to
  17748. % infinity of x**(n*n).
  17749. pssum(m=1,(-1)**(m-1)/(2m-1),y,1,2m-1);
  17750. % Produces the power series expansion of atan(y-1)
  17751. % about y=1.
  17752. pssum(j=1,-1/j,x,infinity,j);
  17753. % Produces the power series expansion of log(1-1/x)
  17754. % about the point at infinity.
  17755. pssum(n=0,1,x,0,2n**2+3n) + pssum(n=1,1,x,0,2n**2-3n);
  17756. % Produces the power series summation for n=-infinity
  17757. % to +infinity of x**(2n**2+3n).
  17758. \end{verbatim}}
  17759. \subsection{Arithmetic Operations}
  17760. \index{power series ! arithmetic}
  17761. As power series objects are domain elements they may be combined
  17762. together in algebraic expressions in algebraic mode of \REDUCE\ in the
  17763. normal way.
  17764. For example if A and B are power series objects then the commands such as:
  17765. \index{+ ! power series}\index{- ! power series}\index{/ ! power series}
  17766. \index{* ! power series}\index{** ! power series}
  17767. {\small\begin{verbatim}
  17768. a*b;
  17769. a**2+b**2;
  17770. \end{verbatim}}
  17771. will produce power series objects representing the product and the sum
  17772. of the squares of the power series objects A and B respectively.
  17773. \subsection{Differentiation}
  17774. \index{power series ! differentiation}
  17775. If A is a power series object depending on X then the input
  17776. {\tt df(a,x);} will produce the power series expansion of the derivative
  17777. of A with respect to X.
  17778. \section{Restrictions and Known Bugs}
  17779. If A and B are power series objects and X is a variable
  17780. which evaluates to itself then currently expressions such as {\tt a/b} and
  17781. {\tt a*x} do not evaluate to a single power series object (although the
  17782. results are in each case formally valid). Instead use {\tt ps(a/b,x,0)}
  17783. and {\tt ps(a*x,x,0)} {\em etc.}.
  17784. \chapter{TRI: TeX REDUCE interface}
  17785. \label{TRI}
  17786. \typeout{{TRI: TeX REDUCE interface}}
  17787. {\footnotesize
  17788. \begin{center}
  17789. Werner Antweiler, Andreas Strotmann and Volker Winkelmann \\
  17790. University of Cologne Computer Center,
  17791. Abt. Anwendungssoftware, Robert-Koch-Stra\ss{e} 10 \\
  17792. 5000 K"oln 41, Germany \\[0.05in]
  17793. e--mail: antweil@epas.utoronto.ca strotmann@rrz.uni-koeln.de winkelmann@rrz.uni-koeln.de
  17794. \end{center}
  17795. }
  17796. \ttindex{TRI}
  17797. The \REDUCE-\TeX-Interface incorporates three
  17798. levels of \TeX\ output: without line breaking, with line breaking,
  17799. and with line breaking plus indentation.
  17800. During loading the package some default initialisations are performed.
  17801. The default page width is set to 15 centimetres, the tolerance for
  17802. page breaking is set to 20 by default. Moreover, TRI is enabled
  17803. to translate Greek names, {\em e.g.\ }TAU or PSI, into equivalent \TeX\
  17804. symbols, {\em e.g.\ } $\tau$ or $\psi$, respectively. Letters are
  17805. printed lowercase as defined through assertion of the set
  17806. LOWERCASE.
  17807. \section{Switches for TRI}
  17808. The three TRI modes can be selected by switches, which can be used
  17809. alternatively and incrementally. Switching {\tt TEX}\ttindex{TEX} on
  17810. gives standard \TeX-output; switching {\tt TEXBREAK}\ttindex{TEXBREAK}
  17811. gives broken \TeX-output, and {\tt TEXINDENT}\ttindex{TEXINDENT} to
  17812. give broken \TeX-output plus indentation. Thus the three levels of
  17813. TRI are enabled or disabled according to:
  17814. {\small\begin{verbatim}
  17815. On TeX; % switch TeX is on
  17816. On TeXBreak; % switches TeX and TeXBreak are on
  17817. On TeXIndent; % switches TeX, TeXBreak and TeXIndent are on
  17818. Off TeXIndent; % switch TeXIndent is off
  17819. Off TeXBreak; % switches TeXBreak and TeXIndent are off
  17820. Off TeX; % all three switches are off
  17821. \end{verbatim}}
  17822. How TRI breaks multiple lines of \TeX-code may be controlled by
  17823. setting values for page width and tolerance\ttindex{TeXsetbreak}
  17824. {\small\begin{verbatim}
  17825. TeXsetbreak(page_width, tolerance);
  17826. \end{verbatim}}
  17827. Page width is measured in millimetres, and tolerance is a positive
  17828. integer in the closed interval $[0\ldots10000]$.\index{TRI ! page-width}
  17829. The higher the tolerance, the more breakpoints become feasible.
  17830. A tolerance of 0 means that actually no breakpoint will be considered
  17831. feasible, while a value of 10000 allows any breakpoint to be
  17832. considered feasible.\index{TRI ! tolerance}
  17833. For line-breaking without indentation, suitable values for the
  17834. tolerance lie between 10 and 100. As a rule of thumb, use
  17835. higher values the deeper the term is nested. If using indentation,
  17836. use much higher tolerance values; reasonable values for
  17837. tolerance here lie between 700 and 1500.
  17838. \subsection{Adding Translations}
  17839. Sometimes it is desirable to add special REDUCE-symbol-to-\TeX-item
  17840. translations. For such a task TRI provides a function
  17841. {\tt TeXlet} which binds any REDUCE-symbol to one of the predefined
  17842. \TeX-items. A call to this function has the following syntax:
  17843. \ttindex{TeXlet}
  17844. {\tt TeXlet}({\em REDUCE-symbol}, {\em \TeX-item});
  17845. For example
  17846. {\small\begin{verbatim}
  17847. TeXlet('velocity,'!v);
  17848. TeXlet('gamma,\verb|'!\!G!a!m!m!a! |);
  17849. TeXlet('acceleration,\verb|'!\!v!a!r!t!h!e!t!a! |);
  17850. \end{verbatim}}
  17851. Besides this method of single assertions one can assert
  17852. one of (currently) two standard sets providing substitutions
  17853. for lowercase and Greek letters. These sets are loaded by default.
  17854. These sets can be switched on or off using the functions
  17855. \noindent{\tt TeXassertset} {\em setname};\\
  17856. \noindent{\tt TeXretractset} {\em setname};
  17857. where the setnames currently defined are {\tt 'GREEK} and {\tt 'LOWERCASE}.
  17858. There are facilities for creating other sets of substitutions, using
  17859. the function {\tt TeXitem}\ttindex{TeXitem}.
  17860. \section{Examples of Use}
  17861. Some representative examples demonstrate the capabilities of TRI.
  17862. {\small\begin{verbatim}
  17863. load_package tri;
  17864. % TeX-REDUCE-Interface 0.50
  17865. % set greek asserted
  17866. % set lowercase asserted
  17867. % \tolerance 10
  17868. % \hsize=150mm
  17869. TeXsetbreak(150,250);
  17870. % \tolerance 250
  17871. % \hsize=150mm
  17872. on TeXindent;
  17873. (x+y)^16/(v-w)^16;
  17874. $$\displaylines{\qdd
  17875. \(x^{16}
  17876. +16\cdot x^{15}\cdot y
  17877. +120\cdot x^{14}\cdot y^{2}
  17878. +560\cdot x^{13}\cdot y^{3}
  17879. +1820\cdot x^{12}\cdot y^{4}
  17880. +4368\cdot x^{11}\cdot y^{5}\nl
  17881. \off{327680}
  17882. +8008\cdot x^{10}\cdot y^{6}
  17883. +11440\cdot x^{9}\cdot y^{7}
  17884. +12870\cdot x^{8}\cdot y^{8}
  17885. +11440\cdot x^{7}\cdot y^{9}
  17886. +8008\cdot x^{6}\cdot y^{10}\nl
  17887. \off{327680}
  17888. +4368\cdot x^{5}\cdot y^{11}
  17889. +1820\cdot x^{4}\cdot y^{12}
  17890. +560\cdot x^{3}\cdot y^{13}
  17891. +120\cdot x^{2}\cdot y^{14}
  17892. +16\cdot x\cdot y^{15}
  17893. +y^{16}
  17894. \)
  17895. /\nl
  17896. \(v^{16}
  17897. -16\cdot v^{15}\cdot w
  17898. +120\cdot v^{14}\cdot w^{2}
  17899. -560\cdot v^{13}\cdot w^{3}
  17900. +1820\cdot v^{12}\cdot w^{4}
  17901. -4368\cdot v^{11}\cdot w^{5}\nl
  17902. \off{327680}
  17903. +8008\cdot v^{10}\cdot w^{6}
  17904. -11440\cdot v^{9}\cdot w^{7}
  17905. +12870\cdot v^{8}\cdot w^{8}
  17906. -11440\cdot v^{7}\cdot w^{9}
  17907. +8008\cdot v^{6}\cdot w^{10}
  17908. -4368\cdot v^{5}\cdot w^{11}\nl
  17909. \off{327680}
  17910. +1820\cdot v^{4}\cdot w^{12}
  17911. -560\cdot v^{3}\cdot w^{13}
  17912. +120\cdot v^{2}\cdot w^{14}
  17913. -16\cdot v\cdot w^{15}
  17914. +w^{16}
  17915. \)
  17916. \Nl}$$
  17917. \end{verbatim}}
  17918. A simple example using matrices:
  17919. {\small\begin{verbatim}
  17920. load_package ri;
  17921. % TeX-REDUCE-Interface 0.50
  17922. % set greek asserted
  17923. % set lowercase asserted
  17924. % \tolerance 10
  17925. % \hsize=150mm
  17926. on Tex;
  17927. mat((1,a-b,1/(c-d)),(a^2-b^2,1,sqrt(c)),((a+b)/(c-d),sqrt(d),1));
  17928. $$
  17929. \pmatrix{1&a
  17930. -b&
  17931. \frac{1}{
  17932. c
  17933. -d}\cr
  17934. a^{2}
  17935. -b^{2}&1&
  17936. \sqrt{c}\cr
  17937. \frac{a
  17938. +b}{
  17939. c
  17940. -d}&
  17941. \sqrt{d}&1\cr
  17942. }
  17943. $$
  17944. \end{verbatim}}
  17945. Note that the resulting output uses a number of \TeX\ macros which are
  17946. defined in the file {\tt tridefs.tex} which is distributed with the
  17947. example file.
  17948. \chapter[TRIGSIMP: Trigonometric simplification]%
  17949. {TRIGSIMP: Simplification and factorisation of trigonometric
  17950. and hyperbolic functions}
  17951. \label{TRIGSIMP}
  17952. \typeout{{TRIGSIMP: Simplification and factorisation of trigonometric
  17953. and hyperbolic functions}}
  17954. {\footnotesize
  17955. \begin{center}
  17956. Wolfram Koepf, Andreas Bernig and Herbert Melenk\\
  17957. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  17958. Takustra\"se 7 \\
  17959. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  17960. e--mail: Koepf@zib.de
  17961. \end{center}
  17962. }
  17963. \ttindex{TRIGSIMP}
  17964. There are three
  17965. procedures included in TRIGSIMP: trigsimp, trigfactorize and triggcd.
  17966. The first is for finding simplifications of trigonometric or
  17967. hyperbolic expressions with many options, the second for factorising
  17968. them and the third
  17969. for finding the greatest common divisor of two trigonometric or
  17970. hyperbolic polynomials.
  17971. \section{Simplifiying trigonometric expressions}
  17972. As there is no normal form for trigonometric and hyperbolic functions,
  17973. the same function can convert in many different directions, {\em e.g. }
  17974. $\sin(2x) \leftrightarrow 2\sin(x)\cos(x)$.
  17975. The user has the possibility to give several parameters to the
  17976. procedure {\tt trigsimp} in order to influence the direction of
  17977. transformations. The decision whether a rational expression in
  17978. trigonometric and hyperbolic functions vanishes or not is possible.
  17979. \ttindex{trigsimp}
  17980. To simplify a function {\tt f}, one uses {\tt trigsimp(f[,options])}. Example:
  17981. {\small\begin{verbatim}
  17982. 2: trigsimp(sin(x)^2+cos(x)^2);
  17983. 1
  17984. \end{verbatim}}
  17985. Possible options are (* denotes the default):
  17986. \begin{enumerate}
  17987. \item {\tt sin} (*) or {\tt cos}\index{trigsimp ! sin}\index{trigsimp ! cos}
  17988. \item {\tt sinh} (*) or {\tt cosh}\index{trigsimp ! sinh}\index{trigsimp ! cosh}
  17989. \item {\tt expand} (*) or {\tt combine} or {\tt compact}\index{trigsimp ! expand}\index{trigsimp ! combine}\index{trigsimp ! compact}
  17990. \item {\tt hyp} or {\tt trig} or {\tt expon}\index{trigsimp ! hyp}\index{trigsimp ! trig}\index{trigsimp ! expon}
  17991. \item {\tt keepalltrig}\index{trigsimp ! keepalltrig}
  17992. \end{enumerate}
  17993. From each group one can use at most one option, otherwise an error
  17994. message will occur. The first group fixes the preference used while
  17995. transforming a trigonometric expression.
  17996. The second group is the equivalent for the hyperbolic functions.
  17997. The third group determines the type of transformations. With
  17998. the default {\tt expand}, an expression is written in a form only using
  17999. single arguments and no sums of arguments. With {\tt combine},
  18000. products of trigonometric functions are transformed to trigonometric
  18001. functions involving sums of arguments.
  18002. {\small\begin{verbatim}
  18003. trigsimp(sin(x)^2,cos);
  18004. 2
  18005. - cos(x) + 1
  18006. trigsimp(sin(x)*cos(y),combine);
  18007. sin(x - y) + sin(x + y)
  18008. -------------------------
  18009. 2
  18010. \end{verbatim}}
  18011. With {\tt compact}, the \REDUCE\ operator {\tt compact} (see
  18012. chapter~\ref{COMPACT}) is applied to {\tt f}.
  18013. This leads often to a simple form, but in contrast to {\tt expand} one
  18014. doesn't get a normal form.
  18015. {\small\begin{verbatim}
  18016. trigsimp((1-sin(x)**2)**20*(1-cos(x)**2)**20,compact);
  18017. 40 40
  18018. cos(x) *sin(x)
  18019. \end{verbatim}}
  18020. With the fourth group each expression is transformed to a
  18021. trigonometric, hyperbolic or exponential form:
  18022. {\small\begin{verbatim}
  18023. trigsimp(sin(x),hyp);
  18024. - sinh(i*x)*i
  18025. trigsimp(e^x,trig);
  18026. x x
  18027. cos(---) + sin(---)*i
  18028. i i
  18029. \end{verbatim}}
  18030. Usually, {\tt tan}, {\tt cot}, {\tt sec}, {\tt csc} are expressed in terms of
  18031. {\tt sin} and {\tt cos}. It can
  18032. be sometimes useful to avoid this, which is handled by the option
  18033. {\tt keepalltrig}:
  18034. {\small\begin{verbatim}
  18035. trigsimp(tan(x+y),keepalltrig);
  18036. - (tan(x) + tan(y))
  18037. ----------------------
  18038. tan(x)*tan(y) - 1
  18039. \end{verbatim}}
  18040. It is possible to use the options of different groups simultaneously.
  18041. \section{Factorising trigonometric expressions}
  18042. With {\tt trigfactorize(p,x)} one can factorise the trigonometric or
  18043. hyperbolic polynomial {\tt p} with respect to the argument x. Example:
  18044. \ttindex{trigfactorize}
  18045. {\small\begin{verbatim}
  18046. trigfactorize(sin(x),x/2);
  18047. x x
  18048. {2,cos(---),sin(---)}
  18049. 2 2
  18050. \end{verbatim}}
  18051. If the polynomial is not coordinated or balanced the output will equal
  18052. the input. In this case, changing the value for x can help to find a
  18053. factorisation:
  18054. {\small\begin{verbatim}
  18055. trigfactorize(1+cos(x),x);
  18056. {cos(x) + 1}
  18057. trigfactorize(1+cos(x),x/2);
  18058. x x
  18059. {2,cos(---),cos(---)}
  18060. 2 2
  18061. \end{verbatim}}
  18062. \section{GCDs of trigonometric expressions}
  18063. The operator {\tt triggcd}\ttindex{triggcd} is an application of {\tt
  18064. trigfactorize}. With its help the user can find the greatest common
  18065. divisor of two trigonometric or hyperbolic polynomials. The syntax is: {\tt
  18066. triggcd(p,q,x)}, where p and q are the polynomials and x is the
  18067. smallest unit to use. Example:
  18068. {\small\begin{verbatim}
  18069. triggcd(sin(x),1+cos(x),x/2);
  18070. x
  18071. cos(---)
  18072. 2
  18073. triggcd(sin(x),1+cos(x),x);
  18074. 1
  18075. \end{verbatim}}
  18076. See also the ASSIST package (chapter~\ref{ASSIST}).
  18077. \chapter{WU: Wu algorithm for poly systems}
  18078. \label{WU}
  18079. \typeout{{WU: Wu algorithm for polynomial systems}}
  18080. {\footnotesize
  18081. \begin{center}
  18082. Russell Bradford \\
  18083. School of Mathematical Sciences, University of Bath,\\
  18084. Bath, BA2 7AY, England \\[0.05in]
  18085. e--mail: rjb@maths.bath.ac.uk
  18086. \end{center}
  18087. }
  18088. \ttindex{WU}
  18089. The interface:
  18090. {\small\begin{verbatim}
  18091. wu( {x^2+y^2+z^2-r^2, x*y+z^2-1, x*y*z-x^2-y^2-z+1}, {x,y,z});
  18092. \end{verbatim}}
  18093. calls {\tt wu}\ttindex{WU} with the named polynomials, and with the
  18094. variable ordering ${\tt x} > {\tt y} > {\tt z}$. In this example, {\tt
  18095. r} is a parameter.
  18096. The result is
  18097. {\small\begin{verbatim}
  18098. 2 3 2
  18099. {{{r + z - z - 1,
  18100. 2 2 2 2 4 2 2 2
  18101. r *y + r *z + r - y - y *z + z - z - 2,
  18102. 2
  18103. x*y + z - 1},
  18104. y},
  18105. 6 4 6 2 6 4 7 4 6 4 5 4 4
  18106. {{r *z - 2*r *z + r + 3*r *z - 3*r *z - 6*r *z + 3*r *z + 3*
  18107. 4 3 4 2 4 2 10 2 9 2 8 2 7
  18108. r *z + 3*r *z - 3*r + 3*r *z - 6*r *z - 3*r *z + 6*r *z +
  18109. 2 6 2 5 2 4 2 3 2 13 12 11
  18110. 3*r *z + 6*r *z - 6*r *z - 6*r *z + 3*r + z - 3*z + z
  18111. 10 9 8 7 6 4 3 2
  18112. + 2*z + z + 2*z - 6*z - z + 2*z + 3*z - z - 1,
  18113. 2 2 3 2
  18114. y *(r + z - z - 1),
  18115. 2
  18116. x*y + z - 1},
  18117. 2 3 2
  18118. y*(r + z - z - 1)}}
  18119. \end{verbatim}}
  18120. namely, a list of pairs of characteristic sets and initials for the
  18121. characteristic sets.
  18122. Thus, the first pair above has the characteristic set
  18123. $$ r^2 + z^3 - z^2 - 1,
  18124. r^2 y^2 + r^2 z + r^2 - y^4 - y^2 z^2 + z^2 - z - 2,
  18125. x y + z^2 - 1$$
  18126. and initial $y$.
  18127. According to Wu's theorem, the set of roots of the original polynomials
  18128. is the union of the sets of roots of the characteristic sets,
  18129. with the additional constraints that the corresponding initial is
  18130. non-zero. Thus, for the first pair above, we find the roots of
  18131. $\{r^2 + z^3 - z^2 - 1, \ldots~\}$ under the constraint that $y \neq 0$.
  18132. These roots, together with the roots of the other characteristic set
  18133. (under the constraint of $y(r^2+z^3-z^2-1) \neq 0$), comprise all the
  18134. roots of the original set.
  18135. \chapter[XCOLOR: Color factor in gauge theory]%
  18136. {XCOLOR: Calculation of the color factor in non-abelian gauge
  18137. field theories}
  18138. \label{XCOLOR}
  18139. \typeout{{XCOLOR: Calculation of the color factor in non-abelian gauge
  18140. field theories}}
  18141. {\footnotesize
  18142. \begin{center}
  18143. A. Kryukov \\
  18144. Institute for Nuclear Physics, Moscow State University \\
  18145. 119899, Moscow, Russia \\[0.05in]
  18146. e--mail: kryukov@npi.msu.su
  18147. \end{center}
  18148. }
  18149. \ttindex{XCOLOR}
  18150. XCOLOR calculates the colour factor in non-abelian gauge field
  18151. theories. It provides two commands and two operators.
  18152. \noindent{\tt SUdim} integer\ttindex{SUdim}
  18153. Sets the order of the SU group. The default value is 3.
  18154. \noindent{\tt SpTT} expression\ttindex{SpTT}
  18155. Sets the normalisation coefficient A in the equation
  18156. $Sp(T_i T_j) = A \Delta(i,j)$. The default value is 1/2.
  18157. \noindent{\tt QG}(inQuark, outQuark, Gluon)\ttindex{QG}
  18158. Describes the quark-gluon vertex. The parameters may be any identifiers.
  18159. The first and second of then must be in- and out- quarks correspondingly.
  18160. Third one is a gluon.
  18161. \noindent{\tt G3}(Gluon1, Gluon2, Gluon3)\ttindex{G3}
  18162. Describes the three-gluon vertex. The parameters may be any identifiers.
  18163. The order of gluons must be clockwise.
  18164. In terms of QG and G3 operators one can input a diagram in ``color'' space as
  18165. a product of these operators. For example
  18166. \newpage
  18167. {\small\begin{verbatim}
  18168. e1
  18169. ---->---
  18170. / \
  18171. / \
  18172. | e2 |
  18173. v1*............*v2
  18174. | |
  18175. \ /
  18176. \ e3 /
  18177. ----<---
  18178. \end{verbatim}}
  18179. where \verb+--->---+ is a quark and \verb+.......+ is a gluon.
  18180. The related \REDUCE\ expression is {\tt QG(e3,e1,e2)*QG(e1,e3,e2)}.
  18181. \chapter{XIDEAL: Gr\"obner for exterior algebra}
  18182. \label{XIDEAL}
  18183. \typeout{{XIDEAL: Gr\"obner Bases for exterior algebra}}
  18184. {\footnotesize
  18185. \begin{center}
  18186. David Hartley \\
  18187. GMD, Institute I1, Schloss Birlinghoven \\
  18188. D--53757 St. Augustin, Germany \\[0.05in]
  18189. e--mail: David.Hartley@gmd.de \\[0.1in]
  18190. and \\
  18191. Philip A.~Tuckey \\
  18192. Max Planck Institute for Physics \\
  18193. Foehringer Ring 6 \\
  18194. D--80805 Munich, Germany \\[0.05in]
  18195. e--mail: pht@iws170.mppmu.mpg.de
  18196. \end{center}
  18197. }
  18198. \ttindex{XIDEAL}
  18199. XIDEAL extends the Gr\"obner base method to exterior algebras.
  18200. XIDEAL constructs Gr\"obner bases for solving the left ideal membership
  18201. problem: Gr\"obner left ideal bases or GLIBs. For graded ideals, where each
  18202. form is homogeneous in degree, the distinction between left and right
  18203. ideals vanishes. Furthermore, if the generating forms are all homogeneous,
  18204. then the Gr\"obner bases for the non-graded and graded ideals are
  18205. identical. In this case, XIDEAL is able to save time by truncating the
  18206. Gr\"obner basis at some maximum degree if desired.
  18207. XIDEAL uses the EXCALC package (chapter~\ref{EXCALC}).
  18208. \section{Operators}
  18209. \subsubsection*{XIDEAL}
  18210. \f{XIDEAL} calculates a Gr\"obner left ideal basis in
  18211. an exterior algebra. The syntax is\ttindex{XIDEAL}
  18212. {\small\begin{verbatim}
  18213. XIDEAL(S:list of forms[,R:integer]):list of forms.
  18214. \end{verbatim}}
  18215. \f{XIDEAL} calculates the Gr\"obner left ideal basis for the left ideal
  18216. generated by \f{S} using graded lexicographical ordering based on the
  18217. current kernel ordering. The resulting list can be used for subsequent
  18218. reductions with \f{XMODULOP} as long as the kernel ordering is not
  18219. changed. If the set of generators \f{S} is graded, an optional parameter
  18220. \f{R} can be given, and \f{XIDEAL} produces a truncated basis suitable for
  18221. reducing exterior forms of degree less than or equal to \f{R} in the left
  18222. ideal. This can save time and space with large expressions, but the result
  18223. cannot be used for exterior forms of degree greater than \f{R}. See also
  18224. the switches \f{XSTATS} and \f{XFULLREDUCTION}.
  18225. \subsubsection*{XMODULO}
  18226. \f{XMODULO} reduces exterior forms to their (unique) normal forms modulo a
  18227. left ideal. The syntax is\ttindex{XMODULO}
  18228. {\small\begin{verbatim}
  18229. XMODULO(F:form, S:list of forms):form
  18230. \end{verbatim}}
  18231. or
  18232. {\small\begin{verbatim}
  18233. XMODULO(F:list of forms, S:list of forms):list of forms.
  18234. \end{verbatim}}
  18235. An alternative infix syntax is also available:
  18236. {\small\begin{verbatim}
  18237. F XMODULO S.
  18238. \end{verbatim}}
  18239. \f{XMODULO(F,S)} first calculates a Gr\"obner basis for the left ideal
  18240. generated by \f{S}, and then reduces \f{F}. \f{F} may be either a single
  18241. exterior form, or a list of forms, and \f{S} is a list of forms. If \f{F}
  18242. is a list of forms, each element is reduced, and any which vanish are
  18243. deleted from the result. If this operator is used more than once, and
  18244. \f{S} does not change between calls, then the Gr\"obner basis is not
  18245. recalculated. If the set of generators \f{S} is graded, then a truncated
  18246. Gr\"obner basis is calculated using the degree of \f{F} (or the maximal
  18247. degree in \f{F}).
  18248. \subsubsection*{XMODULOP}
  18249. \f{XMODULOP} reduces exterior forms to their (not necessarily unique)
  18250. normal forms modulo a set of exterior polynomials. The syntax
  18251. is\ttindex{XMODULOP}
  18252. {\small\begin{verbatim}
  18253. XMODULOP(F:form, S:list of forms):form
  18254. \end{verbatim}}
  18255. or
  18256. {\small\begin{verbatim}
  18257. XMODULOP(F:list of forms, S:list of forms):list of forms.
  18258. \end{verbatim}}
  18259. An alternative infix syntax is also available:
  18260. {\small\begin{verbatim}
  18261. F XMODULOP S.
  18262. \end{verbatim}}
  18263. \f{XMODULOP(F,S)} reduces \f{F} with respect to the set of exterior
  18264. polynomials \f{S}, which is not necessarily a Gr\"obner basis. \f{F} may be
  18265. either a single exterior form, or a list of forms, and \f{S} is a list of
  18266. forms. This operator can be used in conjunction with \f{XIDEAL} to produce
  18267. the same effect as \f{XMODULO}: for a single form \f{F} in an ideal
  18268. generated by the graded set \f{S}, \f{F XMODULO S} is equivalent to \f{F
  18269. XMODULOP XIDEAL(S,EXDEGREE F)}.
  18270. \section{Switches}
  18271. \subsubsection*{XFULLREDUCE}
  18272. \f{ON XFULLREDUCE}\ttindex{XFULLREDUCE} allows \f{XIDEAL} and
  18273. \f{XMODULO} to calculate reduced (but not necessarily normed)
  18274. Gr\"obner bases, which speeds up subsequent reductions, and guarantees
  18275. a unique form (up to scaling) for the Gr\"obner basis. \f{OFF
  18276. XFULLREDUCE} turns of this feature, which may speed up calculation of
  18277. the Gr\"obner basis. \f{XFULLREDUCE} is \f{ON} by default.
  18278. \subsubsection*{XSTATS}
  18279. \f{ON XSTATS}\ttindex{XSTATS} produces counting and timing
  18280. information. As \f{XIDEAL} is running, a hash mark (\verb.#.) is
  18281. printed for each form taken from the input list, followed by a
  18282. sequences of carets (\verb.^.) and dollar signs (\verb.$.). Each caret
  18283. represents a new basis element obtained by a simple wedge product, and
  18284. each dollar sign represents a new basis element obtained from an
  18285. S-polynomial. At the end, a table is printed summarising the
  18286. calculation. \f{XSTATS} is \f{OFF} by default.
  18287. \section{Examples}
  18288. Suppose EXCALC and XIDEAL have been loaded, the switches are at their
  18289. default settings, and the following exterior variables have been declared:
  18290. {\small\begin{verbatim}
  18291. pform x=0,y=0,z=0,t=0,f(i)=1,h=0,hx=0,ht=0;
  18292. \end{verbatim}}
  18293. In a commutative polynomial ring, a single polynomial is its own Gr\"obner
  18294. basis. This is no longer true for exterior algebras because of the presence
  18295. of zero divisors, and can lead to some surprising reductions:
  18296. {\small\begin{verbatim}
  18297. xideal {d x^d y - d z^d t};
  18298. {d T^d Z + d X^d Y,
  18299. d X^d Y^d Z,
  18300. d T^d X^d Y}
  18301. f(3)^f(4)^f(5)^f(6)
  18302. xmodulo {f(1)^f(2) + f(3)^f(4) + f(5)^f(6)};
  18303. 0
  18304. \end{verbatim}}
  18305. The heat equation, $h_{xx}=h_t$ can be represented by the following
  18306. exterior differential system.
  18307. {\small\begin{verbatim}
  18308. S := {d h - ht*d t - hx*d x,
  18309. d ht^d t + d hx^d x,
  18310. d hx^d t - ht*d x^d t};
  18311. \end{verbatim}}
  18312. \f{XMODULO} can be used to check that the exterior differential system is
  18313. closed under exterior differentiation.
  18314. {\small\begin{verbatim}
  18315. d S xmodulo S;
  18316. {}
  18317. \end{verbatim}}
  18318. Non-graded left and right ideals are no longer the same:
  18319. {\small\begin{verbatim}
  18320. d t^(d z+d x^d y) xmodulo {d z+d x^d y};
  18321. 0
  18322. (d z+d x^d y)^d t xmodulo {d z+d x^d y};
  18323. - 2*d t^d z
  18324. \end{verbatim}}
  18325. Higher order forms can now reduce lower order ones:
  18326. {\small\begin{verbatim}
  18327. d x xmodulo {d y^d z + d x,d x^d y + d z};
  18328. 0
  18329. \end{verbatim}}
  18330. Any form containing a 0-form term generates the whole ideal:
  18331. {\small\begin{verbatim}
  18332. xideal {1 + f(1) + f(1)^f(2) + f(2)^f(3)^f(4)};
  18333. {1}
  18334. \end{verbatim}}
  18335. \chapter[ZEILBERG: Indef \& definite summation]%
  18336. {ZEILBERG: A package for indefinite and definite summation}
  18337. \label{ZEILBERG}
  18338. \typeout{{ZEILBERG: A package for indefinite and definite summation}}
  18339. {\footnotesize
  18340. \begin{center}
  18341. Wolfram Koepf and Gregor St\"olting \\
  18342. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  18343. Takustra\"se 7 \\
  18344. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  18345. e--mail: Koepf@zib.de
  18346. \end{center}
  18347. }
  18348. \ttindex{ZEILBERG}
  18349. \newcommand{\N} {{\rm {\mbox{\protect\makebox[.15em][l]{I}N}}}}
  18350. The ZEILBERG package provides an implementation of the Gosper and
  18351. Zeilberger algorithms for indefinite, and definite summation of
  18352. hypergeometric terms, respectively, with extensions for ratios of
  18353. products of powers, factorials, $\Gamma$ function terms, binomial
  18354. coefficients, and shifted factorials that are rational-linear in their
  18355. arguments.
  18356. \section{The GOSPER summation operator}
  18357. The {\tt gosper}\ttindex{gosper} operator is an implementation of the
  18358. Gosper algorithm.
  18359. \begin{itemize}
  18360. \item
  18361. {\tt gosper(a,k)} determines a closed form antidifference. If it does
  18362. not return a closed form solution, then a closed form solution does
  18363. not exist.
  18364. \item
  18365. {\tt gosper(a,k,m,n)} determines
  18366. \[
  18367. \sum_{k=m}^n a_k
  18368. \]
  18369. using Gosper's algorithm. This is only successful if Gosper's
  18370. algorithm applies.
  18371. \end{itemize}
  18372. Example:
  18373. {\small\begin{verbatim}
  18374. gosper((-1)^(k+1)*(4*k+1)*factorial(2*k)/
  18375. (factorial(k)*4^k*(2*k-1)*factorial(k+1)),k);
  18376. k
  18377. - ( - 1) *factorial(2*k)
  18378. ------------------------------------
  18379. 2*k
  18380. 2 *factorial(k + 1)*factorial(k)
  18381. gosper(binomial(k,n),k);
  18382. (k + 1)*binomial(k,n)
  18383. -----------------------
  18384. n + 1
  18385. \end{verbatim}}
  18386. \section{EXTENDED\_GOSPER operator}
  18387. The {\tt extended\_gosper}\ttindex{extended\_gosper} operator is an
  18388. implementation of an extended version of Gosper's algorithm.
  18389. \begin{itemize}
  18390. \item
  18391. {\tt extended\_gosper(a,k)} determines an antidifference $g_k$ of $a_k$
  18392. whenever there is a number $m$ such that $h_{k}-h_{k-m}=a_k$, and $h_k$ is an
  18393. {\sl $m$-fold hypergeometric term}, i.\ e.
  18394. \[
  18395. h_{k}/h_{k-m}\quad\mbox{is a rational function with respect to $k$.}
  18396. \]
  18397. If it does not return a solution, then such a solution does not exist.
  18398. \item
  18399. {\tt extended\_gosper(a,k,m)}
  18400. determines an {\sl $m$-fold antidifference} $h_k$ of $a_k$,
  18401. i.\ e.\ $h_{k}-h_{k-m}=a_k$, if it is an $m$-fold hypergeometric term.
  18402. \end{itemize}
  18403. Examples:
  18404. {\small\begin{verbatim}
  18405. extended_gosper(binomial(k/2,n),k);
  18406. k k - 1
  18407. (k + 2)*binomial(---,n) + (k + 1)*binomial(-------,n)
  18408. 2 2
  18409. -------------------------------------------------------
  18410. 2*(n + 1)
  18411. extended_gosper(k*factorial(k/7),k,7);
  18412. k
  18413. (k + 7)*factorial(---)
  18414. 7
  18415. \end{verbatim}}
  18416. \section{SUMRECURSION operator}
  18417. The {\tt sumrecursion}\ttindex{sumrecursion} operator is an
  18418. implementation of the (fast) Zeilberger algorithm.
  18419. \begin{itemize}
  18420. \item
  18421. {\tt sumrecursion(f,k,n)} determines a holonomic recurrence equation
  18422. for
  18423. \[
  18424. {\tt sum(n)} =\sum\limits_{k=-\infty}^\infty f(n,k)
  18425. \]
  18426. with respect to $n$. %%, applying {\tt extended\_sumrecursion} if necessary
  18427. %%(section~\ref{sec:EXTENDED_SUMRECURSION}).
  18428. The resulting expression equals zero.
  18429. \item
  18430. {\tt sumrecursion(f,k,n,j)}
  18431. searches for a holonomic recurrence equation of order $j$.%% This
  18432. %%operator does not use
  18433. %%{\tt extended\_sumrecursion} automatically.
  18434. Note that if $j$ is too large, the recurrence equation
  18435. may not be unique, and only one particular solution is returned.
  18436. \end{itemize}
  18437. {\small\begin{verbatim}
  18438. sumrecursion(binomial(n,k),k,n);
  18439. 2*sum(n - 1) - sum(n)
  18440. \end{verbatim}}
  18441. %%\section{EXTENDED\_SUMRECURSION operator}
  18442. %%\label{sec:EXTENDED_SUMRECURSION}
  18443. %%
  18444. %%The {\tt extended\_sumrecursion}\ttindex{extended\_sumrecursion}
  18445. %%operator uses extension to handle hypergeometric terms. As {\tt
  18446. %%sumrecusion} uses this algorithm automatically in the case of three
  18447. %%arguments, it is only needed in the four argument case, or for
  18448. %%detailed investigations. More details may be found in the on-line
  18449. %%documentation.
  18450. \section{HYPERRECURSION operator}
  18451. If a recursion for a generalised hypergeometric function is to be
  18452. established, one can use
  18453. \begin{itemize}
  18454. \item
  18455. {\tt hyperrecursion(upper,lower,x,n)}\ttindex{hyperrecursion}
  18456. determines a holonomic recurrence equation with respect to $n$ for
  18457. \[_{p}F_{q}\left.\left(\begin{array}{cccc}
  18458. a_{1},&a_{2},&\cdots,&a_{p}\\
  18459. b_{1},&b_{2},&\cdots,&b_{q}\\
  18460. \end{array}\right| x\right) ,
  18461. \] where {\tt upper}$=\{a_{1}, a_{2}, \ldots, a_{p}\}$
  18462. is the list of upper parameters, and
  18463. {\tt lower}$=\{b_{1}, b_{2}, \ldots, b_{q}\}$
  18464. is the list of lower parameters depending on $n$.
  18465. \item
  18466. {\tt hyperrecursion(upper,lower,x,n,j)} $(j\in\N)$
  18467. searches only for a holonomic recurrence equation of order $j$. This
  18468. operator does not automatically use {\tt extended\_sumrecursion}.
  18469. \end{itemize}
  18470. {\small\begin{verbatim}
  18471. hyperrecursion({-n,b},{c},1,n);
  18472. (b - c - n + 1)*sum(n - 1) + (c + n - 1)*sum(n)
  18473. \end{verbatim}}
  18474. If a hypergeometric expression is given in hypergeometric notation, then
  18475. the use of {\tt hyperrecursion} is more natural than the use of
  18476. {\tt sumrecursion}.
  18477. Moreover the \REDUCE\ operator
  18478. \begin{itemize}
  18479. \item
  18480. {\tt hyperterm(upper,lower,x,k)}\ttindex{hyperterm} yields the
  18481. hypergeometric term
  18482. \[
  18483. \frac
  18484. {(a_{1})_{k}\cdot(a_{2})_{k}\cdots(a_{p})_{k}}
  18485. {(b_{1})_{k}\cdot(b_{2})_{k}\cdots(b_{q})_{k}\,k!}x^{k}
  18486. \]
  18487. with upper parameters {\tt upper}$=\{a_{1}, a_{2}, \ldots, a_{p}\}$,
  18488. and lower parameters {\tt lower}$=\{b_{1}, b_{2}, \ldots, b_{q}\}$
  18489. \end{itemize}
  18490. in connection with hypergeometric terms.
  18491. \section{HYPERSUM operator}
  18492. With the operator {\tt hypersum}\ttindex{hypersum}, hypergeometric
  18493. sums are directly evaluated in closed form whenever the extended
  18494. Zeilberger algorithm leads to a recurrence equation containing only
  18495. two terms:
  18496. \begin{itemize}
  18497. \item
  18498. {\tt hypersum(upper,lower,x,n)} determines a closed form representation
  18499. for\\
  18500. $_{p}F_{q}\left.\left(\begin{array}{cccc}
  18501. a_{1},&a_{2},&\cdots,&a_{p}\\
  18502. b_{1},&b_{2},&\cdots,&b_{q}\\
  18503. \end{array}\right| x\right)
  18504. $, where {\tt upper}$=\{a_{1}, a_{2}, \ldots, a_{p}\}$
  18505. is the list of upper parameters, and
  18506. {\tt lower}$=\{b_{1}, b_{2}, \ldots, b_{q}\}$
  18507. is the list of lower parameters depending on $n$. The result is given as a
  18508. hypergeometric term with respect to $n$.
  18509. If the result is a list of length $m$, we call it $m$-{\sl fold symmetric},
  18510. which is to be interpreted as follows:
  18511. Its $j^{th}$ part is the solution valid for all $n$ of the form $n=mk+j-1
  18512. \;(k\in\N_0)$.
  18513. In particular, if the resulting list contains two terms, then the
  18514. first part is the solution for even $n$, and the second part is the
  18515. solution for odd $n$.
  18516. \end{itemize}
  18517. {\small\begin{verbatim}
  18518. hypersum({a,1+a/2,c,d,-n},{a/2,1+a-c,1+a-d,1+a+n},1,n);
  18519. pochhammer(a - c - d + 1,n)*pochhammer(a + 1,n)
  18520. -------------------------------------------------
  18521. pochhammer(a - c + 1,n)*pochhammer(a - d + 1,n)
  18522. hypersum({a,1+a/2,d,-n},{a/2,1+a-d,1+a+n},-1,n);
  18523. pochhammer(a + 1,n)
  18524. -------------------------
  18525. pochhammer(a - d + 1,n)
  18526. \end{verbatim}}
  18527. Note that the operator {\tt togamma}\ttindex{togamma} converts
  18528. expressions given in factorial-$\Gamma$-binomial-Pochhammer notation
  18529. into a pure $\Gamma$ function representation:
  18530. {\small\begin{verbatim}
  18531. togamma(hypersum({a,1+a/2,d,-n},{a/2,1+a-d,1+a+n},-1,n));
  18532. gamma(a - d + 1)*gamma(a + n + 1)
  18533. -----------------------------------
  18534. gamma(a - d + n + 1)*gamma(a + 1)
  18535. \end{verbatim}}
  18536. \section{SUMTOHYPER operator}
  18537. With the operator {\tt sumtohyper}\ttindex{sumtohyper}, sums given in
  18538. factorial-$\Gamma$-binomial-Poch\-hammer notation are converted into
  18539. hypergeometric notation.
  18540. \begin{itemize}
  18541. \item
  18542. {\tt sumtohyper(f,k)} determines the hypergeometric representation
  18543. of\linebreak
  18544. $\sum\limits_{k=-\infty}^\infty f_k$, {\em i.e.\ } its output is {\tt
  18545. c*hypergeometric(upper,lower,x)}, corresponding to
  18546. the representation
  18547. \[
  18548. \sum\limits_{k=-\infty}^\infty f_k=c\cdot\;
  18549. _{p}F_{q}\left.\left(\begin{array}{cccc}
  18550. a_{1},&a_{2},&\cdots,&a_{p}\\
  18551. b_{1},&b_{2},&\cdots,&b_{q}\\
  18552. \end{array}\right| x\right)
  18553. \;,
  18554. \]
  18555. where {\tt upper}$=\{a_{1}, a_{2}, \ldots, a_{p}\}$
  18556. and {\tt lower}$=\{b_{1}, b_{2}, \ldots, b_{q}\}$
  18557. are the lists of upper and lower parameters.
  18558. \end{itemize}
  18559. Examples:
  18560. {\small\begin{verbatim}
  18561. sumtohyper(binomial(n,k)^3,k);
  18562. hypergeometric({ - n, - n, - n},{1,1},-1)
  18563. \end{verbatim}}
  18564. \section{Simplification Operators}
  18565. For the decision that an expression $a_k$ is a hypergeometric term, it is
  18566. necessary to find out whether or not $a_{k}/a_{k-1}$ is a rational
  18567. function with respect to $k$. For the purpose to decide
  18568. whether or not an expression involving powers, factorials,
  18569. $\Gamma$ function terms,
  18570. binomial coefficients, and Pochhammer symbols is a hypergeometric term,
  18571. the following simplification operators can be used:
  18572. \begin{itemize}
  18573. \item
  18574. {\tt simplify\_gamma(f)}\ttindex{simplify\_gamma} simplifies an
  18575. expression {\tt f} involving only rational, powers and $\Gamma$
  18576. function terms.
  18577. \item
  18578. {\tt simplify\_combinatorial(f)}\ttindex{simplify\_combinatorial}
  18579. simplifies an expression {\tt f} involving powers, factorials,
  18580. $\Gamma$ function terms, binomial coefficients, and Pochhammer symbols
  18581. by converting factorials, binomial coefficients, and Poch\-hammer
  18582. symbols into $\Gamma$ function terms, and applying {\tt
  18583. simplify\_gamma} to its result. If the output is not rational, it is
  18584. given in terms of $\Gamma$ functions. If factorials are preferred use
  18585. \item
  18586. {\tt gammatofactorial} (rule)\ttindex{gammatofactorial} converting $\Gamma$ function terms into
  18587. factorials using $\Gamma\:(x)\rightarrow (x-1)!$.
  18588. \item
  18589. {\tt simplify\_gamma2(f)}\ttindex{simplify\_gamma2}
  18590. uses the duplication formula of the $\Gamma$ function to simplify $f$.
  18591. \item
  18592. {\tt simplify\_gamman(f,n)}\ttindex{simplify\_gamman}
  18593. uses the multiplication formula of the $\Gamma$ function to simplify $f$.
  18594. \end{itemize}
  18595. The use of {\tt simplify\_combinatorial(f)} is a safe way to
  18596. decide the rationality for any ratio of products of powers, factorials,
  18597. $\Gamma$ function terms, binomial coefficients, and Pochhammer symbols.
  18598. Example:
  18599. {\small\begin{verbatim}
  18600. simplify_gamma2(gamma(2*n)/gamma(n));
  18601. 2*n 2*n + 1
  18602. 2 *gamma(---------)
  18603. 2
  18604. -----------------------
  18605. 2*sqrt(pi)
  18606. \end{verbatim}}
  18607. \chapter{ZTRANS: $Z$-transform package}
  18608. \label{ZTRANS}
  18609. \typeout{{ZTRANS: $Z$-transform package}}
  18610. {\footnotesize
  18611. \begin{center}
  18612. Wolfram Koepf and Lisa Temme \\
  18613. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  18614. Takustra\"se 7 \\
  18615. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  18616. e--mail: Koepf@zib.de
  18617. \end{center}
  18618. }
  18619. \ttindex{ZTRANS}
  18620. The $Z$-Transform of a sequence $\{f_n\}$ is the discrete analogue
  18621. of the Laplace Transform, and
  18622. \[{\cal Z}\{f_n\} = F(z) = \sum^\infty_{n=0} f_nz^{-n}\;.\] \\
  18623. This series converges in the region outside the circle
  18624. $|z|=|z_0|= \limsup\limits_{n \rightarrow \infty} \sqrt[n]{|f_n|}\;.$
  18625. In the same way that a Laplace Transform can be used to
  18626. solve differential equations, so $Z$-Transforms can be used
  18627. to solve difference equations.
  18628. \begin{tabbing}
  18629. {\bf SYNTAX:}\ \ {\tt ztrans($f_n$, n, z)}\ \ \ \ \ \ \ \
  18630. \=where $f_n$ is an expression, and $n$,$z$ \\
  18631. \> are identifiers.\\
  18632. \end{tabbing}
  18633. \ttindex{ztrans}
  18634. \begin{tabbing}
  18635. This pack\=age can compute the \= $Z$-Transforms of the \=following
  18636. list of $f_n$, and \\ certain combinations thereof.\\ \\
  18637. \>$1$
  18638. \>$e^{\alpha n}$
  18639. \>$\frac{1}{(n+k)}$ \\ \\
  18640. \>$\frac{1}{n!}$
  18641. \>$\frac{1}{(2n)!}$
  18642. \>$\frac{1}{(2n+1)!}$ \\ \\
  18643. \>$\frac{\sin(\beta n)}{n!}$
  18644. \>$\sin(\alpha n+\phi)$
  18645. \>$e^{\alpha n} \sin(\beta n)$ \\ \\
  18646. \>$\frac{\cos(\beta n)}{n!}$
  18647. \>$\cos(\alpha n+\phi)$
  18648. \>$e^{\alpha n} \cos(\beta n)$ \\ \\
  18649. \>$\frac{\sin(\beta (n+1))}{n+1}$
  18650. \>$\sinh(\alpha n+\phi)$
  18651. \>$\frac{\cos(\beta (n+1))}{n+1}$ \\ \\
  18652. \>$\cosh(\alpha n+\phi)$
  18653. \>${n+k \choose m}$\\
  18654. \end{tabbing}
  18655. \begin{tabbing}
  18656. \underline {{\bf Other Combinations}}\= \\ \\
  18657. \underline {Linearity}
  18658. \>${\cal Z} \{a f_n+b g_n \} = a{\cal Z} \{f_n\}+b{\cal Z}\{g_n\}$
  18659. \\ \\
  18660. \underline {Multiplication by $n$}
  18661. \>${\cal Z} \{n^k \cdot f_n\} = -z \frac{d}{dz} \left({\cal Z}\{n^{k-1} \cdot f_n,n,z\} \right)$
  18662. \\ \\
  18663. \underline {Multiplication by $\lambda^n$}
  18664. \>${\cal Z} \{\lambda^n \cdot f_n\}=F \left(\frac{z}{\lambda}\right)$
  18665. \\ \\
  18666. \underline {Shift Equation}
  18667. \>${\cal Z} \{f_{n+k}\} =
  18668. z^k \left(F(z) - \sum\limits^{k-1}_{j=0} f_j z^{-j}\right)$
  18669. \\ \\
  18670. \underline {Symbolic Sums}
  18671. \> ${\cal Z} \left\{ \sum\limits_{k=0}^{n} f_k \right\} =
  18672. \frac{z}{z-1} \cdot {\cal Z} \{f_n\}$ \\ \\
  18673. \>${\cal Z} \left\{ \sum\limits_{k=p}^{n+q} f_k \right\}$
  18674. \ \ \ combination of the above \\ \\
  18675. where $k$,$\lambda \in$ {\bf N}$- \{0\}$; and $a$,$b$ are variables
  18676. or fractions; and $p$,$q \in$ {\bf Z} or \\
  18677. are functions of $n$; and $\alpha$, $\beta$ and $\phi$ are angles
  18678. in radians.
  18679. \end{tabbing}
  18680. The calculation of the Laurent coefficients of a regular function
  18681. results in the following inverse formula for the $Z$-Transform:
  18682. If $F(z)$ is a regular function in the region $|z|> \rho$ then
  18683. $\exists$ a sequence \{$f_n$\} with ${\cal Z} \{f_n\}=F(z)$
  18684. given by \[f_n = \frac{1}{2 \pi i}\oint F(z) z^{n-1} dz\]
  18685. \begin{tabbing}
  18686. {\bf SYNTAX:}\ \ {\tt invztrans($F(z)$, z, n)}\ \ \ \ \ \ \ \
  18687. \=where $F(z)$ is an expression, \\
  18688. \> and $z$,$n$ are identifiers.
  18689. \end{tabbing}
  18690. \ttindex{invztrans}
  18691. \begin{tabbing}
  18692. This \= package can compute the Inverse \= Z-Transforms of any
  18693. rational function, \\ whose denominator can be factored over
  18694. ${\bf Q}$, in addition to the following list \\ of $F(z)$.\\ \\
  18695. \> $\sin \left(\frac{\sin (\beta)}{z} \ \right)
  18696. e^{\left(\frac{\cos (\beta)}{z} \ \right)}$
  18697. \> $\cos \left(\frac{\sin (\beta)}{z} \ \right)
  18698. e^{\left(\frac{\cos (\beta)}{z} \ \right)}$ \\ \\
  18699. \> $\sqrt{\frac{z}{A}} \sin \left( \sqrt{\frac{z}{A}} \ \right)$
  18700. \> $\cos \left( \sqrt{\frac{z}{A}} \ \right)$ \\ \\
  18701. \> $\sqrt{\frac{z}{A}} \sinh \left( \sqrt{\frac{z}{A}} \ \right)$
  18702. \> $\cosh \left( \sqrt{\frac{z}{A}} \ \right)$ \\ \\
  18703. \> $z \ \log \left(\frac{z}{\sqrt{z^2-A z+B}} \ \right)$
  18704. \> $z \ \log \left(\frac{\sqrt{z^2+A z+B}}{z} \ \right)$ \\ \\
  18705. \> $\arctan \left(\frac{\sin (\beta)}{z+\cos (\beta)} \ \right)$
  18706. \\
  18707. \end{tabbing}
  18708. here $k$,$\lambda \in$ {\bf N}$ - \{0\}$ and $A$,$B$ are fractions
  18709. or variables ($B>0$) and $\alpha$,$\beta$, \& $\phi$ are angles
  18710. in radians.
  18711. Examples:
  18712. {\small\begin{verbatim}
  18713. ztrans(sum(1/factorial(k),k,0,n),n,z);
  18714. 1/z
  18715. e *z
  18716. --------
  18717. z - 1
  18718. invztrans(z/((z-a)*(z-b)),z,n);
  18719. n n
  18720. a - b
  18721. ---------
  18722. a - b
  18723. \end{verbatim}}
  18724. %\documentstyle[11pt,reduce]{article}
  18725. \part{Standard Lisp Report}
  18726. \setcounter{examplectr}{0}
  18727. \chapter{The Standard Lisp Report}
  18728. \label{SL}
  18729. \typeout{{The Standard Lisp Report}}
  18730. {\footnotesize
  18731. \begin{center}
  18732. Jed Marti \\ A. C. Hearn \\ M. L. Griss \\ C. Griss
  18733. \end{center}
  18734. }
  18735. \ttindex{Standard Lisp Report}
  18736. %%% Function/method definition.
  18737. %%% de{fname}{arglist}{type}{text} For short arg lists.
  18738. %%% DE{fname}{arglist}{type}{text} For long arg lists.
  18739. \newlength{\argwidth} % Width of argument box.
  18740. \setlength{\argwidth}{4in}
  18741. \newlength{\dewidth}
  18742. \setlength{\dewidth}{4.5in} % Width of text box.
  18743. \newcommand{\de}[4]
  18744. {\vspace{.25in} \noindent
  18745. \begin{minipage}[t]{\textwidth} \index{#1} {\f{#1}}{#2}\hfill{\em #3} \\
  18746. \hspace*{.25in}\begin{minipage}[t]{\dewidth} #4 \end{minipage}
  18747. \end{minipage} }
  18748. %%% Global/fluid variable description.
  18749. %%% variable{name}{initial value}{type}{text}
  18750. \newcommand{\variable}[4]
  18751. {\vspace{.25in} \noindent
  18752. \begin{minipage}[t]{\textwidth} \index{#1 (#3)} {\bf #1} = #2 \hfill {\em #3}
  18753. \\
  18754. \hspace*{.25in} \ \begin{minipage}[t]{\dewidth} #4 \end{minipage}
  18755. \end{minipage}}
  18756. %%% Command to display an error or warning message in teletype format. Also
  18757. %%% leaves blank vertical space around it.
  18758. \newcommand{\errormessage}[1]
  18759. {\vspace{.1in} \noindent {\tt #1} \\ \vspace{.1in}}
  18760. %%% \p is a parameter name (or argument). Just do this as bf.
  18761. \newcommand{\p}[1] {{\bf #1}}
  18762. %%% \ty is a type - do as italics.
  18763. \newcommand{\ty}[1] {{\em #1}}
  18764. %\begin{document}
  18765. %\maketitle
  18766. \section{Introduction}
  18767. Although the programming language LISP was first formulated in
  18768. 1960~\cite{LISP1.5}, a widely accepted standard has never appeared. As
  18769. a result, various dialects of LISP were
  18770. produced~\cite{CDC-LISP,LISP/360,MACLISP,Interlisp,LISPF1,LISP1.6} in
  18771. some cases several on the same machine! Consequently, a user often
  18772. faces considerable difficulty in moving programs from one system to
  18773. another. In addition, it is difficult to write and use programs which
  18774. depend on the structure of the source code such as translators,
  18775. editors and cross-reference programs.
  18776. In 1969, a model for such a standard was produced~\cite{Hearn:69} as
  18777. part of a general effort to make a large LISP based algebraic
  18778. manipulation program, REDUCE~\cite{REDUCE3.3}, as portable as
  18779. possible. The goal of this work was to define a uniform subset of
  18780. LISP 1.5 and its variants so that programs written in this subset
  18781. could run on any reasonable LISP system.
  18782. In the intervening years, two deficiencies in the approach taken in
  18783. Ref.~\cite{Hearn:69} have emerged. First in order to be as general as
  18784. possible, the specific semantics and values of several key functions
  18785. were left undefined. Consequently, programs built on this subset could
  18786. not make any assumptions about the form of the values of such
  18787. functions. The second deficiency related to the proposed method of
  18788. implementation of this language. The model considered in effect two
  18789. versions of LISP on any given machine, namely Standard LISP and the
  18790. LISP of the host machine (which we shall refer to as Target LISP).
  18791. This meant that if any definition was stored in interpretive form, it
  18792. would vary from implementation to implementation, and consequently one
  18793. could not write programs in Standard LISP which needed to assume any
  18794. knowledge about the structure of such forms. This deficiency became
  18795. apparent during recent work on the development of a portable compiler
  18796. for LISP~\cite{PLC}. Clearly a compiler has to know precisely the
  18797. structure of its source code; we concluded that the appropriate source
  18798. was Standard LISP and not Target LISP.
  18799. With these thoughts in mind we decided to attempt again a definition
  18800. of Standard LISP. However, our approach this time is more aggressive.
  18801. In this document we define a standard for a reasonably large subset of
  18802. LISP with as precise as possible a statement about the semantics of
  18803. each function. Secondly, we now require that the target machine
  18804. interpreter be modified or written to support this standard, rather
  18805. than mapping Standard LISP onto Target LISP as previously.
  18806. We have spent countless hours in discussion over many of the
  18807. definitions given in this report. We have also drawn on the help and
  18808. advice of a lot of friends whose names are given in the
  18809. Acknowledgements. Wherever possible, we have used the definition of a
  18810. function as given in the LISP 1.5 Programmer's Manual~\cite{LISP1.5}
  18811. and have only deviated where we felt it desirable in the light of LISP
  18812. programming experience since that time. In particular, we have given
  18813. considerable thought to the question of variable bindings and the
  18814. definition of the evaluator functions EVAL and APPLY. We have also
  18815. abandoned the previous definition of LISP arrays in favor of the more
  18816. accepted idea of a vector which most modern LISP systems support.
  18817. These are the places where we have strayed furthest from the
  18818. conventional definitions, but we feel that the consistency which
  18819. results from our approach is worth the redefinition.
  18820. We have avoided entirely in this report problems which arise from
  18821. environment passing, such as those represented by the FUNARG problem.
  18822. We do not necessarily exclude these considerations from our standard,
  18823. but in this report have decided to avoid the controversy which they
  18824. create. The semantic differences between compiled and interpreted
  18825. functions is the topic of another paper~\cite{PLC}. Only functions
  18826. which affect the compiler in a general way make reference to it.
  18827. This document is not intended as an introduction to LISP rather it is
  18828. assumed that the reader is already familiar with some version. The
  18829. document is thus intended as an arbiter of the syntax and semantics of
  18830. Standard LISP. However, since it is not intended as an implementation
  18831. description, we deliberately leave unspecified many of the details on
  18832. which an actual implementation depends. For example, while we assume
  18833. the existence of a symbol table for atoms (the "object list" in LISP
  18834. terminology), we do not specify its structure, since conventional LISP
  18835. programming does not require this information. Our ultimate goal,
  18836. however, is to remedy this by defining an interpreter for Standard
  18837. LISP which is sufficiently complete that its implementation on any
  18838. given computer will be straightforward and precise. At that time, we
  18839. shall produce an implementation level specification for Standard LISP
  18840. which will extend the description of the primitive functions defined
  18841. herein by introducing a new set of lower level primitive functions in
  18842. which the structure of the symbol table, heap and so on may be
  18843. defined.
  18844. The plan of this chapter is as follows. In Section~\ref{dtypes} we
  18845. describe the various data types used in Standard LISP. In
  18846. Section~\ref{slfns}, a description of all Standard LISP functions is
  18847. presented, organized by type. These functions are defined in an RLISP
  18848. syntax which is easier to read than LISP S-expressions.
  18849. Section~\ref{slglobals} describes global variables which control the
  18850. operation of Standard LISP.
  18851. \section{Preliminaries}
  18852. \label{dtypes}
  18853. \subsection{Primitive Data Types}
  18854. \label{pdat}
  18855. \begin{description}
  18856. \item[integer] Integers are also called "fixed" numbers. The magnitude of
  18857. an integer is unrestricted. Integers in the LISP input stream are
  18858. \index{integer ! input} \index{integer ! magnitude}
  18859. recognized by the grammar:
  18860. \begin{tabbing}
  18861. \s{digit} ::= 0$\mid$1$\mid$2$\mid$3$\mid$4$\mid$5$\mid$6$\mid$7$\mid$8$\mid$9
  18862. \\
  18863. \s{unsigned-integer} ::= \s{digit}$\mid$\s{unsigned-integer}\s{digit} \\
  18864. \s{integer} ::= \= \s{unsigned-integer} $\mid$ \\
  18865. \> +\s{unsigned-integer} $\mid$ \\
  18866. \> ---\s{unsigned-integer}
  18867. \end{tabbing}
  18868. \item[floating] - Any floating point number. The precision of floating point
  18869. \index{floating ! input}
  18870. numbers is determined solely by the implementation. In BNF floating
  18871. point numbers are recognized by the grammar:
  18872. \begin{tabbing}
  18873. \s{base} ::= \= \s{unsigned-integer}.$\mid$.\s{unsigned-integer}$\mid$ \\
  18874. \> \s{unsigned-integer}.\s{unsigned-integer} \\
  18875. \> \s{unsigned-floating} ::= \s{base}$\mid$ \\
  18876. \> \s{base}E\s{unsigned-integer}$\mid$ \\
  18877. \> \s{base}E-\s{unsigned-integer}$\mid$ \\
  18878. \> \s{base}E+\s{unsigned-integer} \\
  18879. \s{floating} ::= \= \s{unsigned-floating}$\mid$ \\
  18880. \> +\s{unsigned-floating}$\mid$-\s{unsigned-floating}
  18881. \end{tabbing}
  18882. \item[id] An identifier is a string of characters which may have the
  18883. \index{id ! input} \index{identifier (see id)}
  18884. following items associated with it.
  18885. \begin{description}
  18886. \item[print name] \index{print name} The characters of the identifier.
  18887. \item[flags] An identifier may be tagged with a flag. Access is by the
  18888. FLAG, REMFLAG, and FLAGP functions defined in section~\ref{plist} on
  18889. page~\pageref{plist}. \index{FLAG} \index{REMFLAG} \index{FLAGP}
  18890. \item[properties] \index{properties} An identifier may have an
  18891. indicator-value pair associated with it. Access is by the PUT, GET,
  18892. and REMPROP functions defined in section~\ref{plist} on
  18893. page~\pageref{plist}.
  18894. \index{PUT} \index{GET} \index{REMPROP}
  18895. \item[values/functions] An identifier may have a value associated with
  18896. \index{values} \index{functions} it. Access to values is by SET and SETQ
  18897. defined in \index{SET} \index{SETQ} section~\ref{varsandbinds} on
  18898. page~\pageref{varsandbinds}. The method by which the value is attached
  18899. to the identifier is known as the binding type, being one of LOCAL,
  18900. GLOBAL, or FLUID. Access to the binding type is by the GLOBAL,
  18901. GLOBALP, FLUID, FLUIDP, and UNFLUID functions.
  18902. \index{GLOBAL} \index{GLOBALP} \index{FLUID} \index{FUIDP} \index{UNFLUID}
  18903. An identifier may have a function or macro associated with it. Access
  18904. is by the PUTD, GETD, and REMD functions (see ``Function Definition'',
  18905. section~\ref{fdef}, on page~\pageref{fdef}). \index{PUTD} \index{GETD}
  18906. \index{REMD} An identifier may not have both a function and a value
  18907. associated with it.
  18908. \item[OBLIST entry] \index{OBLIST entry} An identifier may be entered and
  18909. removed from a structure called the OBLIST. Its presence on the OBLIST
  18910. does not directly affect the other properties. Access to the OBLIST is
  18911. by the INTERN, REMOB, and READ functions. \index{INTERN} \index{REMOB}
  18912. \index{READ}
  18913. \end{description}
  18914. The maximum length of a Standard LISP identifier is 24 characters
  18915. \index{id ! maximum length}
  18916. (excluding occurrences of the escape character !) but an
  18917. \index{id ! escape character}
  18918. implementation may allow more. Special characters (digits in the first
  18919. position and punctuation) must be prefixed with an escape character,
  18920. an ! in Standard LISP. In BNF identifiers are recognized by the
  18921. grammar:
  18922. \begin{tabbing}
  18923. \s{special-character} ::= !\s{any-character} \\
  18924. \s{alphabetic} ::= \\
  18925. \hspace*{.25in} \= A$\mid$B$\mid$C$\mid$D$\mid$E$\mid$F$\mid$G$\mid$H$
  18926. \mid$I$\mid$J$\mid$K$\mid$L$\mid$M$\mid$N$\mid$O$\mid$P$\mid$Q$\mid$R$
  18927. \mid$S$\mid$T$\mid$U$\mid$V$\mid$W$\mid$X$\mid$Y$\mid$Z$\mid$ \\
  18928. \> a$\mid$b$\mid$c$\mid$d$\mid$e$\mid$f$\mid$g$\mid$h$\mid$i$\mid$j$
  18929. \mid$k$\mid$l$\mid$m$\mid$n$\mid$o$\mid$p$\mid$q$\mid$r$\mid$s$\mid$t$
  18930. \mid$u$\mid$v$\mid$w$\mid$x$\mid$y$\mid$z \\
  18931. \s{lead-character} ::= \s{special-character}$\mid$\s{alphabetic} \\
  18932. \s{regular-character} ::= \s{lead-character}$\mid$\s{digit} \\
  18933. \s{last-part} ::= \= \s{regular-character} $\mid$ \\
  18934. \> \s{last-part}\s{regular-character} \\
  18935. \s{id} ::= \s{lead-character}$\mid$\s{lead-character}\s{last-part}
  18936. \end{tabbing}
  18937. Note: Using lower case letters in identifiers may cause portability
  18938. problems. Lower case letters are automatically converted to upper case
  18939. when the !*RAISE flag is T. \index{*RAISE (global)}
  18940. \item[string] \index{string} A set of characters enclosed in double quotes as
  18941. in "THIS IS A STRING". A quote is included by doubling it as in "HE
  18942. SAID, ""LISP""". The maximum size of strings is 80 characters but an
  18943. implementation may allow more. Strings are not part of the OBLIST and
  18944. are considered constants like numbers, vectors, and function-pointers.
  18945. \item[dotted-pair] A primitive structure which has a left and right part.
  18946. \index{dotted-pair} \index{dot-notation}
  18947. A notation called {\em dot-notation} is used for dotted pairs and
  18948. takes the form:
  18949. \begin{tabbing}
  18950. (\s{left-part} . \s{right-part})
  18951. \end{tabbing}
  18952. The \s{left-part} is known as the CAR portion and the \s{right-part}
  18953. as the CDR portion. The left and right parts may be of any type.
  18954. Spaces are used to resolve ambiguity with floating point numbers.
  18955. \item[vector] \index{vector} A primitive uniform structure in which
  18956. an integer index is used to access random values in the structure. The
  18957. individual elements of a vector may be of any type. Access to vectors
  18958. is restricted to functions defined in ``Vectors''
  18959. section~\ref{vectors} on page~\pageref{vectors}. A notation for
  18960. vectors, {\em vector-notation}, has the elements of a vector
  18961. surrounded
  18962. \index{vector-notation}
  18963. by square brackets\footnote{Vector elements are not separated by
  18964. commas as in the published version of this document.}
  18965. \begin{tabbing}
  18966. \s{elements} ::= \s{any}$\mid$\s{any} \s{elements} \\
  18967. \s{vector} ::= [\s{elements}]
  18968. \end{tabbing}
  18969. \item[function-pointer] \index{function-pointer} An implementation may have
  18970. functions which deal with specific data types other than those listed.
  18971. The use of these entities is to be avoided with the exception of a
  18972. restricted use of the function-pointer, an access method to compiled
  18973. EXPRs and FEXPRs. A particular function-pointer must remain valid
  18974. \index{EXPR} \index{FEXPR}
  18975. throughout execution. Systems which change the location of a function
  18976. must use either an indirect reference or change all occurrences of the
  18977. associated value. There are two classes of use of function-pointers,
  18978. those which are supported by Standard LISP but are not well defined,
  18979. and those which are well defined.
  18980. \begin{description}
  18981. \item[Not well defined] Function pointers may be displayed by the print
  18982. functions or expanded by EXPLODE. \index{EXPLODE} The value appears in
  18983. the convention of the implementation site. The value is not defined in
  18984. Standard LISP. Function pointers may be created by COMPRESS
  18985. \index{COMPRESS} in the format used for printing but the value used is
  18986. not defined in Standard LISP. Function pointers may be created by
  18987. functions which deal with compiled function loading. Again, the values
  18988. created are not well defined in Standard LISP.
  18989. \item[Well defined] The function pointer associated with an EXPR or
  18990. FEXPR may be retrieved by GETD \index{GETD} and is valid as long as
  18991. Standard LISP is in execution. Function pointers may be stored using
  18992. \index{PUTD} \index{PUT} \index{SETQ} PUTD, PUT, SETQ and the like or by
  18993. being bound to variables. Function pointers may be checked for
  18994. equivalence by EQ. \index{EQ ! of function-pointers} The value may be
  18995. checked for being a function pointer by the CODEP function.
  18996. \index{CODEP}
  18997. \end{description}
  18998. \end{description}
  18999. \subsection{Classes of Primitive Data Types}
  19000. \label{pclasses}
  19001. The classes of primitive types are a notational convenience for
  19002. describing the properties of functions.
  19003. \begin{description}
  19004. \item[boolean] \index{boolean} The set of global variables \{T,NIL\},
  19005. or their respective values, \{T, NIL\}. \index{T (global)} \index{NIL
  19006. (global)}
  19007. \item[extra-boolean] \index{extra-boolean} Any value in the system.
  19008. Anything that is not NIL \index{NIL (global)} has the boolean
  19009. interpretation T. \index{T (global)}
  19010. \item[ftype] \index{ftype} The class of definable function types. The
  19011. set of ids \{EXPR, FEXPR, MACRO\}. \index{EXPR} \index{FEXPR}
  19012. \index{MACRO}
  19013. \item[number] \index{number} The set of \{integer, floating\}.
  19014. \item[constant] \index{constant} The set of \{integer, floating,
  19015. string, vector, function-pointer\}. Constants evaluate to themselves
  19016. (see the definition of EVAL in ``The Interpreter'',
  19017. section~\ref{interpreter} on page~\pageref{interpreter}). \index{EVAL
  19018. ! of constants}
  19019. \item[any] \index{any} The set of \{integer, floating, string, id,
  19020. dotted-pair, vector, function-pointer\}. An S-expression is another
  19021. term for any. All Standard LISP entities have some value unless an
  19022. ERROR occurs during evaluation or the function causes transfer of
  19023. control (such as GO and RETURN).
  19024. \item[atom] \index{atom} The set \{any\}-\{dotted-pair\}.
  19025. \end{description}
  19026. \subsection{Structures}
  19027. \index{data structures} \index{structures}
  19028. Structures are entities created out of the primitive types by the use
  19029. of dotted-pairs. Lists are structures very commonly required as actual
  19030. parameters to functions. Where a list of homogeneous entities is
  19031. required by a function this class will be denoted by
  19032. \s{{\bf xxx}-list} where {\bf \em xxx} is the name of a class of primitives
  19033. or structures. Thus a list of ids is an {\em id-list}, a list of
  19034. integers an {\em integer-list} and so on. \index{id-list}
  19035. \index{integer-list}
  19036. \index{-list}
  19037. \begin{description}
  19038. \item[list] \index{list} A list is recursively defined as NIL or the
  19039. \index{list-notation} \index{NIL (global)}
  19040. dotted-pair (any~.~list). A special notation called {\em
  19041. list-notation} is used to represent lists. List-notation eliminates
  19042. extra parentheses and dots. The list (a . (b . (c . NIL))) in list
  19043. notation is (a b c).
  19044. \index{dot-notation}
  19045. List-notation and dot-notation may be mixed as in (a b . c) or (a (b .
  19046. c) d) which are (a . (b . c)) and (a . ((b . c) . (d . NIL))). In BNF
  19047. lists are recognized by the grammar:
  19048. \begin{tabbing}
  19049. \s{left-part} ::= ( $\mid$ \s{left-part} \s{any} \\
  19050. \s{list} ::= \s{left-part}) $\mid$ \s{left-part} . \s{any})
  19051. \end{tabbing}
  19052. Note: () is an alternate input representation of NIL. \index{()}
  19053. \item[alist] \index{alist} An association list; each element of the list
  19054. is a dotted-pair, the CAR part being a key associated with the value
  19055. in the CDR part. \index{association list}
  19056. \item[cond-form] \index{cond-form} A cond-form is a list of 2 element lists
  19057. of the form:
  19058. (\p{ANTECEDENT}:{\em any} \p{CONSEQUENT}:{\em any})
  19059. The first element will henceforth be known as the antecedent and
  19060. \index{antecedent (cond-form)} \index{consequent (cond-form)}
  19061. the second as the consequent. The antecedent must have a value. The
  19062. consequent may have a value or an occurrence of GO or RETURN
  19063. \index{GO} \index{RETURN}
  19064. as described in the ``Program Feature Functions'', section~\ref{prog}
  19065. on page~\pageref{prog}.
  19066. \item[lambda] \index{LAMBDA} A LAMBDA expression which must have the form
  19067. (in list notation): (LAMBDA parameters body). ``parameters'' is a list
  19068. of formal parameters for ``body'' an S-expression to be evaluated. The
  19069. semantics of the evaluation are defined with the EVAL function (see
  19070. ``The Interpreter'', section~\ref{interpreter} on \index{EVAL ! lambda
  19071. expressions} page~\pageref{interpreter}). \index{lambda expression}
  19072. \item[function] \index{function} A LAMBDA expression or a function-pointer
  19073. to a function. A function is always evaluated as an EVAL, SPREAD form.
  19074. \index{EVAL ! function}
  19075. \end{description}
  19076. \subsection{Function Descriptions}
  19077. Each function is provided with a prototypical header line. Each formal
  19078. parameter is given a name and suffixed with its allowed type. Lower
  19079. case, italic tokens are names of classes and upper case, bold face,
  19080. tokens are parameter names referred to in the definition. The type of
  19081. the value returned by the function (if any) is suffixed to the
  19082. parameter list. If it is not commonly used the parameter type may be
  19083. a specific set enclosed in brackets \{\ldots\}. \index{\{\ldots\} ! as
  19084. syntax} For example:
  19085. \vspace{.1in}
  19086. \noindent \f{PUTD}(\p{FNAME}:\ty{id}, \p{TYPE}:\ty{ftype},
  19087. \p{BODY}:\{\ty{lambda, function-pointer}\}):\ty{id}
  19088. \vspace{.1in}
  19089. PUTD is a function with three parameters. The parameter FNAME is an id
  19090. to be the name of the function being defined. TYPE is the type of the
  19091. function being defined and BODY is a lambda expression or a
  19092. function-pointer. PUTD returns the name of the function being defined.
  19093. Functions which accept formal parameter lists of arbitrary length have
  19094. the type class and parameter enclosed in square brackets indicating
  19095. that zero or more occurrences of that argument are permitted.
  19096. \index{[\ldots] syntax} For example:
  19097. \vspace{.1in}
  19098. \noindent \f{AND}([\p{U}:\ty{any}]):\ty{extra-boolean}
  19099. \vspace{.1in}
  19100. AND is a function which accepts zero or more arguments which may be of
  19101. any type.
  19102. \subsection{Function Types}
  19103. EVAL type functions are those which are invoked with evaluated
  19104. \index{EVAL ! function type}
  19105. arguments. NOEVAL functions are invoked with unevaluated arguments.
  19106. \index{NOEVAL ! function type}
  19107. SPREAD type functions have their arguments passed in one-to-one
  19108. \index{SPREAD ! function type}
  19109. correspondence with their formal parameters. NOSPREAD functions
  19110. \index{NOSPREAD ! function type}
  19111. receive their arguments as a single list. EVAL, SPREAD functions are
  19112. \index{FEXPR}
  19113. associated with EXPRs and NO\-EVAL, NO\-SPREAD functions with FEXPRs.
  19114. EVAL, NO\-SPREAD and NOEVAL, SPREAD functions can be simulated using
  19115. NOEVAL, NO\-SPREAD functions or MACROs. \index{MACRO}
  19116. EVAL, SPREAD type functions may have a maximum of 15 parameters.
  19117. \index{formal parameter limit}
  19118. There is no limit on the number of parameters a NOEVAL, NOSPREAD
  19119. function or MACRO may have.
  19120. In the context of the description of an EVAL, SPREAD function, then we
  19121. speak of the formal parameters we mean their actual values. However,
  19122. in a NOEVAL, NOSPREAD function it is the unevaluated actual
  19123. parameters.
  19124. A third function type, the MACRO, implements functions which
  19125. \index{MACRO}
  19126. create S-expressions based on actual parameters. When a macro
  19127. invocation is encountered, the body of the macro, a lambda expression,
  19128. is invoked as a NOEVAL, NOSPREAD function with the macro's invocation
  19129. bound as a list to the macros single formal parameter. When the macro
  19130. has been evaluated the resulting S-expression is reevaluated. The
  19131. description of the EVAL and EXPAND
  19132. \index{EVAL ! MACRO functions}
  19133. functions provide precise details.
  19134. \subsection{Error and Warning Messages}
  19135. \index{error messages}
  19136. Many functions detect errors. The description of such functions will
  19137. include these error conditions and suggested formats for display
  19138. \index{ERROR}
  19139. of the generated error messages. A call on the ERROR function is
  19140. implied but the error number is not specified by Standard LISP. In
  19141. some cases a warning message is sufficient. To distinguish between
  19142. \index{warning messages} \index{***** (error message)}
  19143. \index{*** (warning message)}
  19144. errors and warnings, errors are prefixed with five asterisks and
  19145. warnings with only three.
  19146. Primitive functions check arguments that must be of a certain
  19147. primitive type for being of that type and display an error message if
  19148. the argument is not correct. The type mismatch error always takes the
  19149. form:
  19150. \index{error ! type mismatch error}
  19151. \errormessage{***** PARAMETER not TYPE for FN}
  19152. Here PARAMETER is the unacceptable actual parameter, TYPE is the type
  19153. that PARAMETER was supposed to be. FN is the name of the function that
  19154. detected the error.
  19155. \subsection{Comments}
  19156. \index{comments} \index{\%}
  19157. The character \% signals the start of a comment, text to be ignored
  19158. during parsing. A comment is terminated by the end of the line it
  19159. \index{READCH} \index{READ}
  19160. is on. The function READCH must be able to read a comment one
  19161. character at a time. Comments are transparent to the function READ.
  19162. \% may occur as a character in identifiers by preceding it with the
  19163. \index{escape character}
  19164. escape character !.
  19165. \section{Functions}
  19166. \label{slfns}
  19167. \subsection{Elementary Predicates}
  19168. \label{elpreds}
  19169. \index{predicate !}
  19170. \index{T (global)} \index{NIL (global)}
  19171. Functions in this section return T when the condition defined is met
  19172. and NIL when it is not. Defined are type checking functions and
  19173. elementary comparisons.
  19174. \de{ATOM}{(\p{U}:\ty{any}):{\ty boolean}}{eval, spread}
  19175. {Returns T if U is not a pair.
  19176. {\tt \begin{tabbing} EXPR PROCEDURE ATOM(U); \\
  19177. \hspace*{1em} NULL PAIRP U;
  19178. \end{tabbing}}}
  19179. \de{CODEP}{(\p{U}:\f{any}):{\ty boolean}}{eval, spread}
  19180. {Returns T if U is a function-pointer.}
  19181. \de{CONSTANTP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19182. {Returns T if U is a constant (a number, string, function-pointer, or
  19183. vector).
  19184. {\tt \begin{tabbing} EXPR PROCEDURE CONSTANTP(U); \\
  19185. \hspace*{1em} NULL OR(PAIRP U, IDP U);
  19186. \end{tabbing}}
  19187. }
  19188. \de{EQ}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{boolean}}{eval, spread}
  19189. {Returns T if U points to the same object as V. EQ is \underline{not}
  19190. a reliable comparison between numeric arguments. }
  19191. \de{EQN}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{boolean}}{eval, spread}
  19192. {Returns T if U and V are EQ or if U and V are numbers and have the
  19193. same value and type. }
  19194. \de{EQUAL}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{boolean}}{eval, spread}
  19195. {Returns T if U and V are the same. Dotted-pairs are compared
  19196. recursively to the bottom levels of their trees. Vectors must have
  19197. identical dimensions and EQUAL values in all positions. Strings must
  19198. \index{EQ ! of function-pointers} \index{EQN} have identical characters.
  19199. Function pointers must have EQ values. Other atoms must be EQN equal. }
  19200. \de{FIXP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19201. {Returns T if U is an integer (a fixed number).}
  19202. \de{FLOATP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19203. {Returns T if U is a floating point number. }
  19204. \de{IDP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19205. {Returns T if U is an id.}
  19206. \de{MINUSP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19207. {Returns T if U is a number and less than 0. If U is not a number or
  19208. is a positive number, NIL is returned.
  19209. {\tt \begin{tabbing} EXPR PROCEDURE MINUSP(U); \\
  19210. \hspace*{1em} IF NUMBERP U THEN LESSP(U, 0) ELSE NIL;
  19211. \end{tabbing}}}
  19212. \de{NULL}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19213. {Returns T if U is NIL.
  19214. {\tt \begin{tabbing} EXPR PROCEDURE NULL(U); \\
  19215. \hspace*{1em} U EQ NIL;
  19216. \end{tabbing}}}
  19217. \de{NUMBERP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19218. {Returns T if U is a number (integer or floating).
  19219. {\tt \begin{tabbing} EXPR PROCEDURE NUMBERP(U); \\
  19220. \hspace*{1em} IF OR(FIXP U, FLOATP U) THEN T ELSE NIL;
  19221. \end{tabbing}}}
  19222. \de{ONEP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread.}
  19223. {Returns T if U is a number and has the value 1 or 1.0. Returns NIL
  19224. otherwise. \footnote{The definition in the published report is
  19225. incorrect as it does not return T for \p{U} of 1.0.}
  19226. {\tt \begin{tabbing} EXPR PROCEDURE ONEP(U); \\
  19227. \hspace*{1em} OR(EQN(U, 1), EQN(U, 1.0));
  19228. \end{tabbing}}}
  19229. \de{PAIRP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19230. {Returns T if U is a dotted-pair. }
  19231. \de{STRINGP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19232. {Returns T if U is a string. }
  19233. \de{VECTORP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19234. {Returns T if U is a vector. }
  19235. \de{ZEROP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread.}
  19236. {Returns T if U is a number and has the value 0 or 0.0. Returns NIL
  19237. otherwise.\footnote{The definition in the published report is
  19238. incorrect as it does not return T for \p{U} of 0.0.}
  19239. {\tt \begin{tabbing} EXPR PROCEDURE ZEROP(U); \\
  19240. \hspace*{1em} OR(EQN(U, 0), EQN(U, 0.0));
  19241. \end{tabbing}}}
  19242. \subsection{Functions on Dotted-Pairs}
  19243. \index{dotted-pair}
  19244. The following are elementary functions on dotted-pairs. All functions
  19245. in this section which require dotted-pairs as parameters detect a type
  19246. mismatch error if the actual parameter is not a dotted-pair.
  19247. \de{CAR}{(\p{U}:\ty{dotted-pair}):\ty{any}}{eval, spread}
  19248. {CAR(CONS(a, b)) $\rightarrow$ a. The left part of U is returned. The
  19249. type
  19250. \index{CONS}
  19251. mismatch error occurs if U is not a dotted-pair.}
  19252. \de{CDR}{(\p{U}:\ty{dotted-pair}):\ty{any}}{eval, spread}
  19253. {CDR(CONS(a, b)) $\rightarrow$ b. The right part of U is returned. The
  19254. type
  19255. \index{CONS}
  19256. mismatch error occurs if U is not a dotted-pair.}
  19257. The composites of CAR and CDR are supported up to 4 levels, namely:
  19258. \index{CAR ! composite forms} \index{CDR ! composite forms}
  19259. \hspace*{1in}\begin{tabular}{l l l}
  19260. CAAAAR & CAAAR & CAAR \\ CAAADR & CAADR & CADR \\ CAADAR & CADAR &
  19261. CDAR \\ CAADDR & CADDR & CDDR \\ CADAAR & CDAAR & \\ CADADR & CDADR &
  19262. \\ CADDAR & CDDAR & \\ CADDDR & CDDDR & \\ CDAAAR & & \\ CDAADR & & \\
  19263. CDADAR & & \\ CDADDR & & \\ CDDAAR & & \\ CDDADR & & \\ CDDDAR & & \\
  19264. CDDDDR & &
  19265. \end{tabular}
  19266. \de{CONS}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{dotted-pair}}{eval, spread}
  19267. {Returns a dotted-pair which is not EQ to anything and has U as its
  19268. \index{EQ ! of dotted-pairs} \index{dotted-pair}
  19269. CAR part and V as its CDR part.}
  19270. \de{LIST}{([\p{U}:\ty{any}]):\ty{list}}{noeval, nospread, or macro}
  19271. {A list of the evaluation of each element of U is returned. The order
  19272. of evaluation need not be first to last as the following definition
  19273. implies.\footnote{The published report's definition implies a specific
  19274. ordering.}
  19275. {\tt \begin{tabbing} FEXPR PROCEDURE LIST(U); \\
  19276. \hspace*{1em} EVLIS U;
  19277. \end{tabbing}}}
  19278. \de{RPLACA}{(\p{U}:\ty{dotted-pair},
  19279. \p{V}:\ty{any}):\ty{dotted-pair}}{eval, spread}
  19280. {The CAR portion of the dotted-pair U is replaced by V. If dotted-pair
  19281. U is (a . b) then (V . b) is returned. The type mismatch error occurs
  19282. if U is not a dotted-pair. }
  19283. \de{RPLACD}{(\p{U}:\ty{dotted-pair},
  19284. \p{V}:\ty{any}):\ty{dotted-pair}}{eval, spread}
  19285. {The CDR portion of the dotted-pair U is replaced by V. If dotted-pair
  19286. U is (a . b) then (a . V) is returned. The type mismatch error occurs
  19287. if U is not a dotted-pair.}
  19288. \subsection{Identifiers}
  19289. \label{identifiers}
  19290. The following functions deal with identifiers and the OBLIST,
  19291. \index{OBLIST}
  19292. the structure of which is not defined. The function of the OBLIST is
  19293. to provide a symbol table for identifiers created during input.
  19294. Identifiers created by READ which have the same characters will
  19295. \index{READ} \index{EQ ! of identifiers}
  19296. therefore refer to the same object (see the EQ function in
  19297. ``Elementary Predicates'', section~\ref{elpreds} on
  19298. page~\pageref{elpreds}).
  19299. \de{COMPRESS}{(\p{U}:\ty{id-list}):\{\ty{atom}-\ty{vector}\}}{eval, spread}
  19300. {U is a list of single character identifiers which is built into a
  19301. Standard LISP entity and returned. Recognized are numbers, strings,
  19302. and identifiers with the escape character prefixing special
  19303. characters. The formats of these items appear in ``Primitive Data
  19304. Types'' section~\ref{pdat} on page~\pageref{pdat}. Identifiers are not
  19305. interned on the OBLIST. Function pointers may be compressed but this
  19306. is an undefined use. If an entity cannot be parsed out of U or
  19307. characters are left over after parsing an error occurs:
  19308. \errormessage{***** Poorly formed atom in COMPRESS}
  19309. }
  19310. \de{EXPLODE}{(\p{U}:\{\ty{atom}\}-\{\ty{vector}\}):\ty{id-list}}{eval, spread}
  19311. {Returned is a list of interned characters representing the characters
  19312. to print of the value of U. The primitive data types have these
  19313. formats:
  19314. \begin{description}
  19315. \item[integer] \index{integer ! output} Leading zeroes are suppressed and
  19316. a minus sign prefixes the digits if the integer is negative.
  19317. \item[floating] \index{floating ! output} The value appears in the format
  19318. [-]0.nn...nnE[-]mm if the magnitude of the number is too large or
  19319. small to display in [-]nnnn.nnnn format. The crossover point is
  19320. determined by the implementation.
  19321. \item[id] \index{id ! output} The characters of the print name of the
  19322. identifier are produced with special characters prefixed with the
  19323. escape character.
  19324. \item[string] \index{string ! output} The characters of the string are
  19325. produced surrounded by double quotes "\ldots".
  19326. \item[function-pointer] \index{function-pointer ! output} The value of the
  19327. function-pointer is created as a list of characters conforming to the
  19328. conventions of the system site.
  19329. \end{description}
  19330. The type mismatch error occurs if U is not a number, identifier,
  19331. string, or function-pointer. }
  19332. \de{GENSYM}{():\ty{identifier}}{eval, spread}
  19333. {Creates an identifier which is not interned on the OBLIST and
  19334. consequently not EQ to anything else. \index{OBLIST entry} \index{EQ !
  19335. of GENSYMs}}
  19336. \de{INTERN}{(\p{U}:\{\ty{id,string}\}):\ty{id}}{eval, spread}
  19337. {INTERN searches the OBLIST for an identifier with the same print name
  19338. \index{OBLIST entry}
  19339. as U and returns the identifier on the OBLIST if a match is found.
  19340. Any properties and global values associated with U may be lost. If U
  19341. does not match any entry, a new one is created and returned. If U has
  19342. more than the maximum number of characters permitted by the
  19343. implementation (the minimum number is 24) an error occurs:
  19344. \index{id ! minimum size}
  19345. \errormessage{***** Too many characters to INTERN}
  19346. }
  19347. \de{REMOB}{(\p{U}:\ty{id}):\ty{id}}{eval, spread}
  19348. {If U is present on the OBLIST it is removed. This does not affect U
  19349. \index{OBLIST entry}
  19350. having properties, flags, functions and the like. U is returned.}
  19351. \subsection{Property List Functions}
  19352. \label{plist}
  19353. \index{property list}
  19354. With each id in the system is a ``property list'', a set of entities
  19355. which are associated with the id for fast access. These entities are
  19356. called ``flags'' if their use gives the id a single valued
  19357. \index{flags}
  19358. property, and ``properties'' if the id is to have a multivalued
  19359. \index{properties}
  19360. attribute: an indicator with a property.
  19361. Flags and indicators may clash, consequently care should be taken to
  19362. avoid this occurrence. Flagging X with an id which already is an
  19363. indicator for X may result in that indicator and associated property
  19364. being lost. Likewise, adding an indicator which is the same id as a
  19365. flag may result in the flag being destroyed.
  19366. \de{FLAG}{(\p{U}:\ty{id-list}, \p{V}:\ty{id}):\ty{NIL}}{eval, spread}
  19367. {U is a list of ids which are flagged with V. The effect of FLAG is
  19368. that FLAGP will have the value T for those ids of U which were
  19369. flagged. Both V and all the elements of U must be identifiers or the
  19370. type mismatch error occurs.}
  19371. \de{FLAGP}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{boolean}}{eval, spread}
  19372. {Returns T if U has been previously flagged with V, else NIL. Returns
  19373. NIL if either U or V is not an id.}
  19374. \de{GET}{(\p{U}:\ty{any}, \p{IND}:\ty{any}):\ty{any}}{eval, spread}
  19375. {Returns the property associated with indicator IND from the property
  19376. list of U. If U does not have indicator IND, NIL is returned. GET
  19377. cannot be used to access functions (use GETD instead).
  19378. \index{GET ! not for functions}}
  19379. \de{PUT}{(\p{U}:\ty{id}, \p{IND}:\ty{id},
  19380. \p{PROP}:\ty{any}):\ty{any}}{eval, spread}
  19381. {The indicator IND with the property PROP is placed on the property
  19382. list of the id U. If the action of PUT occurs, the value of PROP is
  19383. returned. If either of U and IND are not ids the type mismatch error
  19384. will occur and no property will be placed. PUT cannot be used to
  19385. define functions (use PUTD instead).
  19386. \index{PUT ! not for functions}}
  19387. \de{REMFLAG}{(\p{U}:\ty{any-list}, \p{V}:\ty{id}):\ty{NIL}}{eval, spread}
  19388. {Removes the flag V from the property list of each member of the list
  19389. U. Both V and all the elements of U must be ids or the type mismatch
  19390. error will occur.}
  19391. \de{REMPROP}{(\p{U}:\ty{any}, \p{IND}:\ty{any}):\ty{any}}{eval, spread}
  19392. {Removes the property with indicator IND from the property list of U.
  19393. Returns the removed property or NIL if there was no such indicator.}
  19394. \subsection{Function Definition}
  19395. \label{fdef}
  19396. Functions in Standard LISP are global entities. To avoid
  19397. function-variable naming clashes no variable may have the same name as
  19398. a function. \index{function ! as GLOBAL}
  19399. \de{DE}{(\p{FNAME}:\ty{id}, \p{PARAMS}:\ty{id-list},
  19400. \p{FN}:\ty{any}):\ty{id}}{noeval, nospread}
  19401. {The function FN with the formal parameter list PARAMS is added to the
  19402. set of defined functions with the name FNAME. Any previous definitions
  19403. of the function are lost. The function created is of type
  19404. \index{*COMP (fluid)}
  19405. EXPR. If the !*COMP variable is non-NIL, the EXPR is first
  19406. \index{EXPR}
  19407. compiled. The name of the defined function is returned.
  19408. {\tt \begin{tabbing} FEXPR PROCEDURE DE(U); \\
  19409. \hspace*{1em} PUTD(CAR U, 'EXPR, LIST('LAMBDA, CADR U, CADDR U));
  19410. \end{tabbing}}}
  19411. \de{DF}{(\p{FNAME}:\ty{id}, \p{PARAM}:\ty{id-list},
  19412. \p{FN}:\ty{any}):\ty{id}}{noeval, nospread}
  19413. {The function FN with formal parameter PARAM is added to the set of
  19414. defined functions with the name FNAME. Any previous definitions of the
  19415. function are lost. The function created is of type FEXPR.
  19416. \index{*COMP variable} \index{FEXPR}
  19417. If the !*COMP variable is T the FEXPR is first compiled. The name of
  19418. the defined function is returned.
  19419. {\tt \begin{tabbing} FEXPR PROCEDURE DF(U); \\
  19420. \hspace*{1em} PUTD(CAR U, 'FEXPR, LIST('LAMBDA, CADR U, CADDR U)); \\
  19421. \end{tabbing} }}
  19422. \de{DM}{(\p{MNAME}:\ty{id}, \p{PARAM}:\ty{id-list},
  19423. \p{FN}:\ty{any}):\ty{id}}{noeval, nospread}
  19424. {The macro FN with the formal parameter PARAM is added to the set of
  19425. defined functions with the name MNAME. Any previous definitions of the
  19426. function are overwritten. The function created is of type MACRO.
  19427. \index{MACRO}
  19428. The name of the macro is returned.
  19429. {\tt \begin{tabbing} FEXPR PROCEDURE DM(U); \\
  19430. \hspace*{1em} PUTD(CAR U, 'MACRO, LIST('LAMBDA, CADR U, CADDR U));
  19431. \end{tabbing} }
  19432. }
  19433. \de{GETD}{(\p{FNAME}:\ty{any}):\{NIL, \ty{dotted-pair}\}}{eval, spread}
  19434. {If FNAME is not the name of a defined function, NIL is returned. If
  19435. FNAME is a defined function then the dotted-pair
  19436. \vspace{.15in}
  19437. (\p{TYPE}:\ty{ftype} . \p{DEF}:\{\ty{function-pointer, lambda}\})
  19438. \vspace{.15in}
  19439. is returned.}
  19440. \de{PUTD}{(\p{FNAME}:\ty{id}, \p{TYPE}:\ty{ftype},
  19441. \p{BODY}:\ty{function}):\ty{id}}{eval, spread}
  19442. {Creates a function with name FNAME and definition BODY of type TYPE.
  19443. If PUTD succeeds the name of the defined function is returned. The
  19444. effect of PUTD is that GETD will return a dotted-pair with the
  19445. functions type and definition. Likewise the GLOBALP predicate will
  19446. \index{GLOBALP} \index{function ! as global}
  19447. return T when queried with the function name.
  19448. If the function FNAME has already been declared as a GLOBAL or FLUID
  19449. variable the error:
  19450. \errormessage{***** FNAME is a non-local variable}
  19451. occurs and the function will not be defined. If function FNAME already
  19452. exists a warning message will appear:
  19453. \errormessage{*** FNAME redefined}
  19454. The function defined by PUTD will be compiled before definition
  19455. \index{*COMP (fluid)} if the !*COMP global variable is non-NIL.}
  19456. \de{REMD}{(\p{FNAME}:\ty{id}):\{NIL, \ty{dotted-pair}\}}{eval, spread}
  19457. {Removes the function named FNAME from the set of defined functions.
  19458. Returns the (ftype . function) dotted-pair or NIL as does GETD. The
  19459. global/function attribute of FNAME is removed and the name may be used
  19460. subsequently as a variable.}
  19461. \subsection{Variables and Bindings}
  19462. \label{varsandbinds}
  19463. \index{variable scope} \index{scope}
  19464. A variable is a place holder for a Standard LISP entity which is said
  19465. to be bound to the variable. The scope of a variable is the range over
  19466. which the variable has a defined value. There are three different
  19467. binding mechanisms in Standard LISP.
  19468. \begin{description}
  19469. \item[Local Binding] \index{local binding} This type of binding occurs
  19470. \index{scope ! local}
  19471. only in compiled functions. Local variables occur as formal parameters
  19472. in lambda expressions and as PROG form variables. The binding occurs
  19473. when a lambda expression is evaluated or when a PROG form is executed.
  19474. The scope of a local variable is the body of the function in which it
  19475. is defined.
  19476. \item[Global Binding] \index{global binding} Only one binding of a
  19477. \index{scope ! global}
  19478. global variable exists at any time allowing direct access to the value
  19479. bound to the variable. The scope of a global variable is universal.
  19480. Variables declared GLOBAL may not appear as parameters in lambda
  19481. expressions or as PROG form variables. A variable must be declared
  19482. GLOBAL prior to its use as a global variable since the default type
  19483. for undeclared variables is FLUID.
  19484. \item[Fluid Binding] \index{fluid binding}
  19485. \index{fluid binding ! as default} Fluid variables are global
  19486. in scope but may occur as \index{scope ! fluid} formal parameters or
  19487. PROG form variables. In interpreted functions all formal parameters
  19488. and PROG form variables are considered to have fluid binding until
  19489. changed to local binding by compilation. When fluid variables are
  19490. used as parameters they are rebound in such a way that the previous
  19491. binding may be restored. All references to fluid variables are to the
  19492. currently active binding.
  19493. \end{description}
  19494. \de{FLUID}{(\p{IDLIST}:\ty{id-list}):\p{NIL}}{eval, spread}
  19495. {The ids in IDLIST are declared as FLUID type variables (ids not
  19496. previously declared are initialized to NIL). Variables in IDLIST
  19497. already declared FLUID are ignored. Changing a variable's type from
  19498. GLOBAL to FLUID is not permissible and results in the error:
  19499. \errormessage{***** ID cannot be changed to FLUID}
  19500. }
  19501. \de{FLUIDP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19502. {If U has been declared FLUID (by declaration only) T is returned,
  19503. otherwise NIL is returned.}
  19504. \de{GLOBAL}{(\p{IDLIST}:\ty{id-list}):\p{NIL}}{eval, spread}
  19505. {The ids of IDLIST are declared global type variables. If an id has
  19506. not been declared previously it is initialized to NIL. Variables
  19507. already declared GLOBAL are ignored. Changing a variables type from
  19508. FLUID to GLOBAL is not permissible and results in the error:
  19509. \errormessage{***** ID cannot be changed to GLOBAL}
  19510. }
  19511. \de{GLOBALP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19512. {If U has been declared GLOBAL or is the name of a defined function, T
  19513. is returned, else NIL is returned.}
  19514. \de{SET}{(\p{EXP}:\ty{id}, \p{VALUE}:\ty{any}):\ty{any}}{eval, spread}
  19515. {EXP must be an identifier or a type mismatch error occurs. The effect
  19516. of SET is replacement of the item bound to the identifier by VALUE.
  19517. If the identifier is not a local variable or has not been declared
  19518. GLOBAL it is automatically declared FLUID with the resulting warning
  19519. message:
  19520. \errormessage{*** EXP declared FLUID}
  19521. EXP must not evaluate to T or NIL or an error occurs:
  19522. \index{T ! cannot be changed} \index{NIL ! cannot be changed}
  19523. \errormessage{***** Cannot change T or NIL}
  19524. }
  19525. \de{SETQ}{(\p{VARIABLE}:\ty{id}, \p{VALUE}:\ty{any}):\ty{any}}{noeval,
  19526. nospread}
  19527. {If VARIABLE is not local or GLOBAL it is by default declared FLUID
  19528. and the warning message:
  19529. \errormessage{*** VARIABLE declared FLUID}
  19530. appears. The value of the current binding of VARIABLE is replaced by
  19531. the value of VALUE. VARIABLE must not be T or NIL or an error occurs:
  19532. \index{T ! cannot be changed} \index{NIL ! cannot be changed}
  19533. \errormessage{***** Cannot change T or NIL}
  19534. {\tt \begin{tabbing} MACRO PROCEDURE SETQ(X); \\
  19535. \hspace*{1em} LIST('SET, LIST('QUOTE, CADR X), CADDR X);
  19536. \end{tabbing}}
  19537. }
  19538. \de{UNFLUID}{(\p{IDLIST}:\ty{id-list}):\ty{NIL}}{eval, spread}
  19539. {The variables in IDLIST that have been declared as FLUID variables
  19540. are no longer considered as fluid variables. Others are ignored. This
  19541. affects only compiled functions as free variables in interpreted
  19542. functions are automatically considered fluid~\cite{PLC}.
  19543. \index{scope ! fluid and compiled}}
  19544. \subsection{Program Feature Functions}
  19545. \label{prog}
  19546. These functions provide for explicit control sequencing, and the
  19547. definition of blocks altering the scope of local variables.
  19548. \de{GO}{(\p{LABEL}:\ty{id})}{noeval, nospread}
  19549. {GO alters the normal flow of control within a PROG function. The next
  19550. statement of a PROG function to be evaluated is immediately preceded
  19551. by LABEL. A GO may only appear in the following situations:
  19552. \begin{enumerate}
  19553. \item At the top level of a PROG referencing a label which also
  19554. appears at the top level of the same PROG.
  19555. \item As the consequent of a COND item of a COND appearing on the top
  19556. level of a PROG.
  19557. \index{GO ! in COND}
  19558. \index{RETURN ! in COND}
  19559. \item As the consequent of a COND item which appears as the
  19560. consequent of a COND item to any level.
  19561. \item As the last statement of a PROGN which appears at the top level
  19562. of a PROG or in a PROGN appearing in the consequent of a COND to any
  19563. level subject to the restrictions of 2 and 3.
  19564. \item As the last statement of a PROGN within a PROGN or as the
  19565. consequent of a COND in a PROGN to any level subject to the
  19566. restrictions of 2, 3 and 4.
  19567. \end{enumerate}
  19568. If LABEL does not appear at the top level of the PROG in which the GO
  19569. appears, an error occurs:
  19570. \errormessage{***** LABEL is not a known label}
  19571. If the GO has been placed in a position not defined by rules 1-5,
  19572. another error is detected:
  19573. \errormessage{***** Illegal use of GO to LABEL}
  19574. }
  19575. \de{PROG}{(\p{VARS}:\ty{id-list},
  19576. [\p{PROGRAM}:\{\ty{id, any}\}]):\ty{any}}{noeval, nospread}
  19577. {VARS is a list of ids which are considered fluid when the PROG is
  19578. interpreted and local when compiled (see ``Variables and Bindings'',
  19579. section~\ref{varsandbinds} on page~\pageref{varsandbinds}). The PROGs
  19580. variables are allocated space when the PROG form is invoked and are
  19581. deallocated when the PROG is exited. PROG variables are initialized to
  19582. \index{PROG ! variables}
  19583. NIL. The PROGRAM is a set of expressions to be evaluated in order of
  19584. their appearance in the PROG function. Identifiers appearing in the
  19585. top level of the PROGRAM are labels which can be referenced by GO. The
  19586. value returned by the PROG function is determined by a RETURN function
  19587. \index{PROG ! default value}
  19588. or NIL if the PROG ``falls through''.}
  19589. \de{PROGN}{([\p{U}:\ty{any}]):\ty{any}}{noeval, nospread}
  19590. {U is a set of expressions which are executed sequentially. The value
  19591. returned is the value of the last expression.}
  19592. \de{PROG2}{(A:any, B:any)\ty{any}}{eval, spread}
  19593. {Returns the value of B.
  19594. {\tt \begin{tabbing} EXPR PROCEDURE PROG2(A, B);\\
  19595. \hspace*{1em} B;
  19596. \end{tabbing}}}
  19597. \de{RETURN}{(\p{U}:\ty{any})}{eval, spread}
  19598. {Within a PROG, RETURN terminates the evaluation of a PROG and returns
  19599. U as the value of the PROG. The restrictions on the placement of
  19600. RETURN are exactly those of GO. Improper placement of RETURN results
  19601. in the error:
  19602. \errormessage{***** Illegal use of RETURN}
  19603. }
  19604. \subsection{Error Handling}
  19605. \label{errors}
  19606. \de{ERROR}{(\p{NUMBER}:\ty{integer}, \p{MESSAGE}:\ty{any})}{eval, spread}
  19607. {NUMBER and MESSAGE are passed back to a surrounding ERRORSET (the
  19608. Standard LISP reader has an ERRORSET). MESSAGE is placed in the
  19609. \index{EMSG* (global)}
  19610. global variable EMSG!* and the error number becomes the value of the
  19611. surrounding ERRORSET. FLUID variables and local bindings are unbound
  19612. \index{fluid ! unbinding by ERROR}
  19613. to return to the environment of the ERRORSET. Global variables are not
  19614. affected by the process.}
  19615. \de{ERRORSET}{(\p{U}:\ty{any}, \p{MSGP}:\ty{boolean},
  19616. \p{TR}:\ty{boolean}):\ty{any}}{eval, spread}
  19617. {If an error occurs during the evaluation of U, the value of NUMBER
  19618. from the ERROR call is returned as the value of ERRORSET. In addition,
  19619. if the value of MSGP is non-NIL, the MESSAGE from the ERROR call is
  19620. displayed upon both the standard output device and the currently
  19621. selected output device unless the standard output device is not open.
  19622. The message appears prefixed with 5 asterisks. The MESSAGE
  19623. \index{***** (error message)}
  19624. list is displayed without top level parentheses. The MESSAGE from the
  19625. \index{EMSG* (global)}
  19626. ERROR call will be available in the global variable EMSG!*. The exact
  19627. format of error messages generated by Standard LISP functions
  19628. described in this document are not fixed and should not be relied upon
  19629. to be in any particular form. Likewise, error numbers generated by
  19630. Standard LISP functions are implementation dependent.
  19631. If no error occurs during the evaluation of U, the value of (LIST
  19632. (EVAL U)) is returned.
  19633. If an error has been signaled and the value of TR is non-NIL a
  19634. traceback sequence will be initiated on the selected output device.
  19635. The traceback will display information such as unbindings of FLUID
  19636. \index{fluid ! in traceback}
  19637. variables, argument lists and so on in an implementation dependent
  19638. format.}
  19639. \subsection{Vectors}
  19640. \label{vectors}
  19641. \index{vector}
  19642. Vectors are structured entities in which random elements may be
  19643. accessed with an integer index. A vector has a single dimension. Its
  19644. maximum size is determined by the implementation and available space.
  19645. A suggested input ``vector notation'' is defined in ``Classes of
  19646. Primitive Data Types'', section~\ref{pclasses} on
  19647. page~\pageref{pclasses} and output with EXPLODE, ``Identifiers''
  19648. section~\ref{identifiers} on page~\pageref{identifiers}.
  19649. \index{EXPLODE}
  19650. \de{GETV}{(\p{V}:\ty{vector}, \p{INDEX}:\ty{integer}):\ty{any}}{eval, spread}
  19651. {Returns the value stored at position INDEX of the vector V. The type
  19652. mismatch error may occur. An error occurs if the INDEX does not lie
  19653. within 0\ldots UPBV(V) inclusive:
  19654. \errormessage{***** INDEX subscript is out of range}
  19655. }
  19656. \de{MKVECT}{(\p{UPLIM}:\ty{integer}):\ty{vector}}{eval, spread}
  19657. {Defines and allocates space for a vector with UPLIM+1 elements
  19658. accessed as 0\ldots UPLIM. Each element is initialized to NIL. An
  19659. error will occur if UPLIM is $<$ 0 or there is not enough space for a
  19660. vector of this size:
  19661. \errormessage{***** A vector of size UPLIM cannot be allocated}
  19662. }
  19663. \de{PUTV}{(\p{V}:\ty{vector}, \p{INDEX}:\ty{integer},
  19664. \p{VALUE}:\ty{any}):\ty{any}}{eval, spread}
  19665. {Stores VALUE into the vector V at position INDEX. VALUE is returned.
  19666. The type mismatch error may occur. If INDEX does not lie in 0\ldots
  19667. UPBV(V) an error occurs:
  19668. \errormessage{***** INDEX subscript is out of range}
  19669. }
  19670. \de{UPBV}{(\p{U}:\ty{any}):{NIL,\ty{integer}}}{eval, spread}
  19671. {Returns the upper limit of U if U is a vector, or NIL if it is not.}
  19672. \subsection{Boolean Functions and Conditionals}
  19673. \de{AND}{([\p{U}:\ty{any}]):\ty{extra-boolean}}{noeval, nospread}
  19674. {AND evaluates each U until a value of NIL is found or the end of the
  19675. list is encountered. If a non-NIL value is the last value it is
  19676. returned, or NIL is returned.
  19677. {\tt \begin{tabbing} FEXPR PROCEDURE AND(U); \\ BEGIN \\
  19678. \hspace*{1em} IF NULL U THEN RETURN NIL; \\
  19679. LOOP: IF \= NULL CDR U THEN RETURN EVAL CAR U \\
  19680. \> ELSE IF NULL EVAL CAR U THEN RETURN NIL; \\
  19681. \hspace*{2em} \= U := CDR U; \\
  19682. \> GO LOOP \\
  19683. END;
  19684. \end{tabbing} }}
  19685. \de{COND}{([\p{U}:\ty{cond-form}]):\ty{any}}{noeval, nospread}
  19686. {The antecedents of all U's are evaluated in order of their appearance
  19687. until a non-NIL value is encountered. The consequent of the selected U
  19688. is evaluated and becomes the value of the COND. The consequent may
  19689. also contain the special functions GO and RETURN subject to the
  19690. restraints given for these functions in ``Program Feature Functions'',
  19691. section~\ref{prog} on page~\pageref{prog}.
  19692. \index{GO ! in COND} \index{RETUNR ! in CODE} In these cases COND does
  19693. not have a defined value, but rather an effect. If no antecedent is
  19694. non-NIL the value of COND is NIL. An error is detected if a U is
  19695. improperly formed:
  19696. \errormessage{***** Improper cond-form as argument of COND}
  19697. }
  19698. \de{NOT}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19699. {If U is NIL, return T else return NIL (same as function NULL).
  19700. {\tt \begin{tabbing} EXPR PROCEDURE NOT(U); \\
  19701. \hspace*{1em} U EQ NIL;
  19702. \end{tabbing}}
  19703. }
  19704. \de{OR}{([\p{U}:\ty{any}]):\ty{extra-boolean}}{noeval, nospread}
  19705. {U is any number of expressions which are evaluated in order of their
  19706. appearance. When one is found to be non-NIL it is returned as the
  19707. value of OR. If all are NIL, NIL is returned.
  19708. {\tt \begin{tabbing} FEXPR PROCEDURE OR(U); \\ BEGIN SCALAR X; \\
  19709. LOOP: IF \= NULL U THEN RETURN NIL \\
  19710. \> ELSE IF (X := EVAL CAR U) THEN RETURN X; \\
  19711. \hspace*{2em} \= U := CDR U; \\
  19712. \> GO LOOP \\
  19713. END;
  19714. \end{tabbing} }}
  19715. \subsection{Arithmetic Functions}
  19716. Conversions between numeric types are provided explicitly by the
  19717. \index{FIX} \index{FLOAT}
  19718. FIX and FLOAT functions and implicitly by any multi-parameter
  19719. \index{mixed-mode arithmetic}
  19720. arithmetic function which receives mixed types of arguments. A
  19721. conversion from fixed to floating point numbers may result in a loss
  19722. of precision without a warning message being generated. Since
  19723. \index{integer ! magnitude}
  19724. integers may have a greater magnitude that that permitted for floating
  19725. numbers, an error may be signaled when the attempted conversion cannot
  19726. be done. Because the magnitude of integers is unlimited the conversion
  19727. of a floating point number to a fixed number is always possible, the
  19728. only loss of precision being the digits to the right of the decimal
  19729. point which are truncated. If a function receives mixed types of
  19730. arguments the general rule will have the fixed numbers converted to
  19731. floating before arithmetic operations are performed. In all cases an
  19732. error occurs if the parameter to an arithmetic function is not a
  19733. number:
  19734. \errormessage{***** XXX parameter to FUNCTION is not a number}
  19735. XXX is the value of the parameter at fault and FUNCTION is the name of
  19736. the function that detected the error. Exceptions to the rule are noted
  19737. where they occur.
  19738. \de{ABS}{(\p{U}:\ty{number}):\ty{number}}{eval, spread}
  19739. {Returns the absolute value of its argument.
  19740. {\tt \begin{tabbing} EXPR PROCEDURE ABS(U); \\
  19741. \hspace*{1em} IF LESSP(U, 0) THEN MINUS(U) ELSE U;
  19742. \end{tabbing}}}
  19743. \de{ADD1}{(\p{U}:\ty{number}):\ty{number}}{eval, spread}
  19744. {Returns the value of U plus 1 of the same type as U (fixed or
  19745. floating).
  19746. {\tt \begin{tabbing} EXPR PROCEDURE ADD1(U); \\
  19747. % God knows why, but hspace* isn't accepted here.
  19748. \hspace{1em} PLUS2(U, 1);
  19749. \end{tabbing}}
  19750. }
  19751. \de{DIFFERENCE}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval,
  19752. spread}
  19753. {The value U - V is returned.}
  19754. \de{DIVIDE}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{dotted-pair}}{eval,
  19755. spread}
  19756. {The dotted-pair (quotient . remainder) is returned. The quotient part
  19757. is computed the same as by QUOTIENT and the remainder the same as by
  19758. REMAINDER. An error occurs if division by zero is attempted:
  19759. \index{division by zero}
  19760. \errormessage{***** Attempt to divide by 0 in DIVIDE}
  19761. {\tt \begin{tabbing} EXPR PROCEDURE DIVIDE(U, V); \\
  19762. \hspace*{1em} (QUOTIENT(U, V) . REMAINDER(U, V));
  19763. \end{tabbing}}}
  19764. \de{EXPT}{(\p{U}:\ty{number}, \p{V}:\ty{integer}):\ty{number}}{eval, spread}
  19765. {Returns U raised to the V power. A floating point U to an integer
  19766. power V does \underline{not} have V changed to a floating number
  19767. before exponentiation.}
  19768. \de{FIX}{(\p{U}:\ty{number}):\ty{integer}}{eval, spread}
  19769. {Returns an integer which corresponds to the truncated value of U. The
  19770. result of conversion must retain all significant portions of U. If U
  19771. is an integer it is returned unchanged. }
  19772. \de{FLOAT}{(\p{U}:\ty{number}):\ty{floating}}{eval, spread}
  19773. {The floating point number corresponding to the value of the argument
  19774. U is returned. Some of the least significant digits of an integer may
  19775. be lost do to the implementation of floating point numbers. FLOAT of a
  19776. floating point number returns the number unchanged. If U is too large
  19777. to represent in floating point an error occurs:
  19778. \errormessage{***** Argument to FLOAT is too large}
  19779. }
  19780. \de{GREATERP}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{boolean}}{eval,
  19781. spread}
  19782. {Returns T if U is strictly greater than V, otherwise returns NIL.}
  19783. \de{LESSP}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{boolean}}{eval, spread}
  19784. {Returns T if U is strictly less than V, otherwise returns NIL. }
  19785. \de{MAX}{([\p{U}:\ty{number}]):\ty{number}}{noeval, nospread, or macro}
  19786. {Returns the largest of the values in U. If two or more values are the
  19787. same the first is returned.
  19788. {\tt \begin{tabbing} MACRO PROCEDURE MAX(U); \\
  19789. \hspace*{1em} EXPAND(CDR U, 'MAX2);
  19790. \end{tabbing}}}
  19791. \de{MAX2}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19792. {Returns the larger of U and V. If U and V are the same value U is
  19793. returned (U and V might be of different types).
  19794. {\tt \begin{tabbing} EXPR PROCEDURE MAX2(U, V); \\
  19795. \hspace*{1em} IF LESSP(U, V) THEN V ELSE U;
  19796. \end{tabbing}}}
  19797. \de{MIN}{([\p{U}:\ty{number}]):\ty{number}}{noeval, nospread, or macro}
  19798. {Returns the smallest of the values in U. If two or more values are
  19799. the same the first of these is returned.
  19800. {\tt \begin{tabbing} MACRO PROCEDURE MIN(U); \\
  19801. \hspace*{1em} EXPAND(CDR U, 'MIN2);
  19802. \end{tabbing}}}
  19803. \de{MIN2}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19804. {Returns the smaller of its arguments. If U and V are the same value,
  19805. U is returned (U and V might be of different types).
  19806. {\tt \begin{tabbing} EXPR PROCEDURE MIN2(U, V); \\
  19807. \hspace*{1em} IF GREATERP(U, V) THEN V ELSE U;
  19808. \end{tabbing}}}
  19809. \de{MINUS}{(\p{U}:\ty{number}):\ty{number}}{eval, spread}
  19810. {Returns -U.
  19811. {\tt \begin{tabbing} EXPR PROCEDURE MINUS(U); \\
  19812. \hspace*{1em} DIFFERENCE(0, U);
  19813. \end{tabbing}}}
  19814. \de{PLUS}{([\p{U}:\ty{number}]):\ty{number}}{noeval, nospread, or macro}
  19815. {Forms the sum of all its arguments.
  19816. {\tt \begin{tabbing} MACRO PROCEDURE PLUS(U); \\
  19817. \hspace*{1em} EXPAND(CDR U, 'PLUS2);
  19818. \end{tabbing}}}
  19819. \de{PLUS2}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19820. {Returns the sum of U and V.}
  19821. \de{QUOTIENT}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19822. {The quotient of U divided by V is returned. Division of two positive
  19823. or two negative integers is conventional. When both U and V are
  19824. integers and exactly one of them is negative the value returned is the
  19825. negative truncation of the absolute value of U divided by the absolute
  19826. value of V. An error occurs if division by zero is attempted:
  19827. \index{division by zero}
  19828. \errormessage{***** Attempt to divide by 0 in QUOTIENT}
  19829. }
  19830. \de{REMAINDER}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval,
  19831. spread}
  19832. {If both U and V are integers the result is the integer remainder of U
  19833. divided by V. If either parameter is floating point, the result is the
  19834. difference between U and V*(U/V) all in floating point. If either
  19835. number is negative the remainder is negative. If both are positive or
  19836. both are negative the remainder is positive. An error occurs if V is
  19837. zero: \index{division by zero}
  19838. \errormessage{***** Attempt to divide by 0 in REMAINDER}
  19839. {\tt \begin{tabbing} EXPR PROCEDURE REMAINDER(U, V); \\
  19840. \hspace*{1em} DIFFERENCE(U, TIMES2(QUOTIENT(U, V), V));
  19841. \end{tabbing}}}
  19842. \de{SUB1}{(\p{U}:\ty{number}):\ty{number}}{eval, spread}
  19843. {Returns the value of U less 1. If U is a FLOAT type number, the
  19844. value returned is U less 1.0.
  19845. {\tt \begin{tabbing} EXPR PROCEDURE SUB1(U); \\
  19846. \hspace*{1em} DIFFERENCE(U, 1);
  19847. \end{tabbing}}}
  19848. \de{TIMES}{([\p{U}:\ty{number}]):\ty{number}}{noeval, nospread, or macro}
  19849. {Returns the product of all its arguments.
  19850. {\tt \begin{tabbing} MACRO PROCEDURE TIMES(U); \\
  19851. \hspace*{1em} EXPAND(CDR U, 'TIMES2);
  19852. \end{tabbing}}}
  19853. \de{TIMES2}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19854. {Returns the product of U and V.}
  19855. \subsection{MAP Composite Functions}
  19856. \de{MAP}{(\p{X}:\ty{list}, F\p{N}:\ty{function}):\ty{any}}{eval, spread}
  19857. {Applies FN to successive CDR segments of X. NIL is returned.
  19858. {\tt \begin{tabbing} EXPR PROCEDURE MAP(X, FN); \\
  19859. \hspace*{1em} WHILE X DO $<<$ FN X; X := CDR X $>>$;
  19860. \end{tabbing}}}
  19861. \de{MAPC}{(X:list, FN:function):\ty{any}}{eval, spread}
  19862. {FN is applied to successive CAR segments of list X. NIL is returned.
  19863. {\tt \begin{tabbing} EXPR PROCEDURE MAPC(X, FN); \\
  19864. \hspace*{1em} WHILE X DO $<<$ FN CAR X; X := CDR X $>>$;
  19865. \end{tabbing}}}
  19866. \de{MAPCAN}{(X:list, FN:function):\ty{any}}{eval, spread}
  19867. {A concatenated list of FN applied to successive CAR elements of X is
  19868. returned.
  19869. {\tt \begin{tabbing} EXPR PROCEDURE MAPCAN(X, FN); \\
  19870. \hspace*{1em} IF\= NULL X THEN NIL \\
  19871. \> ELSE NCONC(FN CAR X, MAPCAN(CDR X, FN));
  19872. \end{tabbing}}}
  19873. \de{MAPCAR}{(X:list, FN:function):\ty{any}}{eval, spread}
  19874. {Returned is a constructed list of FN applied to each CAR of list X.
  19875. {\tt \begin{tabbing} EXPR PROCEDURE MAPCAR(X, FN); \\
  19876. \hspace*{1em} IF\= NULL X THEN NIL \\
  19877. \> ELSE FN CAR X . MAPCAR(CDR X, FN);
  19878. \end{tabbing}}}
  19879. \de{MAPCON}{(X:list, FN:function):\ty{any}}{eval, spread}
  19880. {Returned is a concatenated list of FN applied to successive CDR
  19881. segments of X.
  19882. {\tt \begin{tabbing} EXPR PROCEDURE MAPCON(X, FN); \\
  19883. \hspace*{1em} IF\= NULL X THEN NIL \\
  19884. \> ELSE NCONC(FN X, MAPCON(CDR X, FN));
  19885. \end{tabbing}}}
  19886. \de{MAPLIST}{(X:list, FN:function):\ty{any}}{eval, spread}
  19887. {Returns a constructed list of FN applied to successive CDR segments
  19888. of X.
  19889. {\tt \begin{tabbing} EXPR PROCEDURE MAPLIST(X, FN); \\
  19890. \hspace*{1em} IF\= NULL X THEN NIL \\
  19891. \> ELSE FN X . MAPLIST(CDR X, FN);
  19892. \end{tabbing}}}
  19893. \subsection{Composite Functions}
  19894. \de{APPEND}{(\p{U}:\ty{list}, \p{V}:\ty{list}):\ty{list}}{eval, spread}
  19895. {Returns a constructed list in which the last element of U is followed
  19896. by the first element of V. The list U is copied, V is not.
  19897. {\tt \begin{tabbing} EXPR PROCEDURE APPEND(U, V); \\
  19898. \hspace*{1em} IF\= NULL U THEN V \\
  19899. \> ELSE CAR U . APPEND(CDR U, V);
  19900. \end{tabbing}}}
  19901. \de{ASSOC}{(\p{U}:\ty{any}, \p{V}:\ty{alist}):\{\ty{dotted-pair},
  19902. NIL\}}{eval, spread}
  19903. {If U occurs as the CAR portion of an element of the alist V, the
  19904. dotted-pair in which U occurred is returned, else NIL is returned.
  19905. ASSOC might not detect a poorly formed alist so an invalid
  19906. \index{EQUAL ! in ASSOC} \index{alist ! in ASSOC}
  19907. construction may be detected by CAR or CDR.
  19908. {\tt \begin{tabbing} EXPR PROCEDURE ASSOC(U, V); \\
  19909. \hspace*{1em} IF \= NULL V THEN NIL \\
  19910. \> ELSE \= IF ATOM CAR V THEN \\
  19911. \> \> ERROR(000, LIST(V, "is a poorly formed alist")) \\
  19912. \> ELSE IF U = CAAR V THEN CAR V \\
  19913. \> ELSE ASSOC(U, CDR V);
  19914. \end{tabbing}}
  19915. }
  19916. \de{DEFLIST}{(\p{U}:\ty{dlist}, \p{IND}:\ty{id}):\ty{list}}{eval, spread}
  19917. {A "dlist" is a list in which each element is a two element list:
  19918. \index{dlist}
  19919. (ID:id PROP:any). Each ID in U has the indicator IND with property
  19920. PROP placed on its property list by the PUT function. The value of
  19921. DEFLIST is a list of the first elements of each two element list.
  19922. Like PUT, DEFLIST may not be used to define functions.
  19923. {\tt \begin{tabbing} EXPR PROCEDURE DEFLIST(U, IND); \\
  19924. \hspace*{1em} IF NULL U THEN NIL \\
  19925. \hspace*{2em} ELSE $<<$ \= PUT(CAAR U, IND, CADAR U); \\
  19926. \> CAAR U $>>$ . DEFLIST(CDR U, IND);
  19927. \end{tabbing}}
  19928. }
  19929. \de{DELETE}{(\p{U}:\ty{any}, \p{V}:\ty{list}):\ty{list}}{eval, spread}
  19930. {Returns V with the first top level occurrence of U removed from it.
  19931. \index{EQUAL ! in DELETE}
  19932. {\tt \begin{tabbing} EXPR PROCEDURE DELETE(U, V); \\
  19933. \hspace*{1em} IF NULL V THEN NIL \\
  19934. \hspace*{2em} ELSE IF CAR V = U THEN CDR V \\
  19935. \hspace*{2em} ELSE CAR V . DELETE(U, CDR V);
  19936. \end{tabbing}}}
  19937. \de{DIGIT}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19938. {Returns T if U is a digit, otherwise NIL.
  19939. {\tt \begin{tabbing} EXPR PROCEDURE DIGIT(U); \\
  19940. \hspace*{1em} IF MEMQ(U, '(!0 !1 !2 !3 !4 !5 !6 !7 !8 !9)) \\
  19941. \hspace*{2em} THEN T ELSE NIL;
  19942. \end{tabbing}}}
  19943. \de{LENGTH}{(\p{X}:\ty{any}):\ty{integer}}{eval, spread}
  19944. {The top level length of the list X is returned.
  19945. {\tt \begin{tabbing} EXPR PROCEDURE LENGTH(X); \\
  19946. \hspace*{1em} IF ATOM X THEN 0 \\
  19947. \hspace*{2em} ELSE PLUS(1, LENGTH CDR X);
  19948. \end{tabbing}}}
  19949. \de{LITER}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19950. {Returns T if U is a character of the alphabet, NIL
  19951. otherwise.\footnote{The published report omits escape characters.
  19952. These are required for both upper and lower case as some systems
  19953. default to lower.}
  19954. {\tt \begin{tabbing} EXPR PROCEDURE LITER(U); \\
  19955. \hspace*{1em} IF \= MEMQ(U, '(\=!A !B !C !D !E !F !G !H !I !J !K !L !M \\
  19956. \> \> !N !O !P !Q !R !S !T !U !V !W !X !Y !Z \\
  19957. \> \> !a !b !c !d !e !f !g !h !i !j !k !l !m \\
  19958. \> \> !n !o !p !q !r !s !t !u !v !w !x !y !z)) \\
  19959. \> THEN T ELSE NIL;
  19960. \end{tabbing}}}
  19961. \de{MEMBER}{(\p{A}:\ty{any}, \p{B}:\ty{list}):\ty{extra-boolean}}{eval, spread}
  19962. {Returns NIL if A is not a member of list B, returns the remainder of
  19963. B whose first element is A. \index{EQUAL ! in MEMBER}
  19964. {\tt \begin{tabbing} EXPR PROCEDURE MEMBER(A, B); \\
  19965. \hspace*{1em} IF NULL B THEN NIL \\
  19966. \hspace*{2em} ELSE IF A = CAR B THEN B \\
  19967. \hspace*{2em} ELSE MEMBER(A, CDR B);
  19968. \end{tabbing}}}
  19969. \de{MEMQ}{(\p{A}:\ty{any}, \p{B}:\ty{list}):\ty{extra-boolean}}{eval, spread}
  19970. {Same as MEMBER but an EQ check is used for comparison. \index{EQ ! in
  19971. MEMQ}
  19972. {\tt \begin{tabbing} EXPR PROCEDURE MEMQ(A, B); \\
  19973. \hspace*{1em} IF \= NULL B THEN NIL \\
  19974. \> ELSE IF A EQ CAR B THEN B \\
  19975. \> ELSE MEMQ(A, CDR B);
  19976. \end{tabbing}}}
  19977. \de{NCONC}{(\p{U}:\ty{list}, \p{V}:\ty{list}):\ty{list}}{eval, spread}
  19978. {Concatenates V to U without copying U. The last CDR of U is modified
  19979. to point to V.
  19980. {\tt \begin{tabbing} EXPR PROCEDURE NCONC(U, V); \\ BEGIN SCALAR W; \\
  19981. \hspace*{2em} \= IF NULL U THEN RETURN V; \\
  19982. \> W := U; \\
  19983. \> WHILE CDR W DO W := CDR W; \\
  19984. \> RPLACD(W, V); \\
  19985. \> RETURN U \\
  19986. END;
  19987. \end{tabbing}}}
  19988. \de{PAIR}{(\p{U}:\ty{list}, \p{V}:\ty{list}):\ty{alist}}{eval, spread}
  19989. {U and V are lists which must have an identical number of elements. If
  19990. not, an error occurs (the 000 used in the ERROR call is arbitrary and
  19991. need not be adhered to). Returned is a list where each element is a
  19992. dotted-pair, the CAR of the pair being from U, and the CDR the
  19993. corresponding element from V.
  19994. {\tt \begin{tabbing} EXPR PROCEDURE PAIR(U, V); \\
  19995. \hspace*{1em} IF AND(U, V) THEN (CAR U . CAR V) . PAIR(CDR U, CDR V) \\
  19996. \hspace*{2em} \= ELSE IF OR(U, V) THEN ERROR(000, \\
  19997. \hspace*{4em} "Different length lists in PAIR") \\
  19998. \> ELSE NIL;
  19999. \end{tabbing}}}
  20000. \de{REVERSE}{(\p{U}:\ty{list}):\ty{list}}{eval, spread}
  20001. {Returns a copy of the top level of U in reverse order.
  20002. {\tt \begin{tabbing} EXPR PROCEDURE REVERSE(U); \\ BEGIN SCALAR W; \\
  20003. \hspace*{2em} \= WHILE U DO $<<$ \= W := CAR U . W; \\
  20004. \> \> U := CDR U $>>$; \\
  20005. \> RETURN W \\
  20006. END;
  20007. \end{tabbing}}}
  20008. \de{SASSOC}{(\p{U}:\ty{any}, \p{V}:\ty{alist},
  20009. \p{FN}:\ty{function}):\ty{any}}{eval, spread}
  20010. {Searches the alist V for an occurrence of U. If U is not in the alist
  20011. the evaluation of function FN is returned. \index{EQUAL ! in SASSOC}
  20012. \index{alist ! in SASSOC}
  20013. {\tt \begin{tabbing} EXPR PROCEDURE SASSOC(U, V, FN); \\
  20014. \hspace*{1em} IF NULL V THEN FN() \\
  20015. \hspace*{2em} \= ELSE IF U = CAAR V THEN CAR V \\
  20016. \> ELSE SASSOC(U, CDR V, FN);
  20017. \end{tabbing}}}
  20018. \de{SUBLIS}{(\p{X}:\ty{alist}, \p{Y}:\ty{any}):\ty{any}}{eval, spread}
  20019. {The value returned is the result of substituting the CDR of each
  20020. element of the alist X for every occurrence of the CAR part of that
  20021. element in Y. \index{alist ! in SUBLIS}
  20022. {\tt \begin{tabbing} EXPR PROCEDURE SUBLIS(X, Y); \\
  20023. \hspace*{1em}IF NULL X THEN Y \\
  20024. \hspace*{2em} ELSE BEGIN \= SCALAR U; \\
  20025. \> U := ASSOC(Y, X); \\
  20026. \> RETURN \= IF U THEN CDR U \\
  20027. \> \> ELSE IF ATOM Y THEN Y \\
  20028. \> \> ELSE \= SUBLIS(X, CAR Y) . \\
  20029. \> \> \> SUBLIS(X, CDR Y) \\
  20030. \> END;
  20031. \end{tabbing}}}
  20032. \de{SUBST}{(\p{U}:\ty{any}, \p{V}:\ty{any}, \p{W}:\ty{any}):\ty{any}}{eval,
  20033. spread}
  20034. {The value returned is the result of substituting U for all
  20035. occurrences of V in W. \index{EQUAL ! in SUBST}
  20036. {\tt \begin{tabbing} EXPR PROCEDURE SUBST(U, V, W); \\
  20037. \hspace*{1em} IF NULL W THEN NIL \\
  20038. \hspace*{2em} \= ELSE IF V = W THEN U \\
  20039. \> ELSE IF ATOM W THEN W \\
  20040. \> ELSE SUBST(U, V, CAR W) . SUBST(U, V, CDR W);
  20041. \end{tabbing}}}
  20042. \subsection{The Interpreter}
  20043. \label{interpreter}
  20044. \de{APPLY}{(\p{FN}:\{\ty{id,function}\},
  20045. \p{ARGS}:\ty{any-list}):\ty{any}}{eval, spread}
  20046. {APPLY returns the value of FN with actual parameters ARGS. The actual
  20047. parameters in ARGS are already in the form required for binding to the
  20048. formal parameters of FN. Implementation specific portions described in
  20049. English are enclosed in boxes.
  20050. {\tt \begin{tabbing} EXPR PROCEDURE APPLY(FN, ARGS); \\ BEGIN SCALAR
  20051. DEFN; \\
  20052. \hspace*{2em}\= IF CODEP FN THEN RETURN \\
  20053. \> \hspace{1em} \framebox[3.25in]{\parbox{3.25in}{Spread the actual
  20054. parameters in ARGS
  20055. following the conventions: for calling functions, transfer to the
  20056. entry point of the function, and return the value returned by the
  20057. function.}}; \\
  20058. \> IF \= IDP FN THEN RETURN \\
  20059. \> \> IF \= NULL(DEFN := GETD FN) THEN \\
  20060. \> \> \> ERROR(000, LIST(FN, "is an undefined function")) \\
  20061. \> \> ELSE IF CAR DEFN EQ 'EXPR THEN \\
  20062. \> \> \> APPLY(CDR DEFN, ARGS) \\
  20063. \> \> ELSE ERROR(000, \\
  20064. \> \> \> LIST(FN, "cannot be evaluated by APPLY")); \\
  20065. \> IF OR(ATOM FN, NOT(CAR FN EQ 'LAMBDA)) THEN \\
  20066. \> \> ERROR(000, \\
  20067. \> \> LIST(FN, "cannot be evaluated by APPLY")); \\
  20068. \> RETURN \\
  20069. \> \> \framebox[3.25in]{\parbox{3.25in}{Bind the actual parameters in ARGS to
  20070. the formal
  20071. parameters of the lambda expression. If the two lists are not of equal
  20072. length then ERROR(000, "Number of parameters do not match"); The value
  20073. returned is EVAL CADDR FN.}} \\ END;
  20074. \end{tabbing}}}
  20075. \de{EVAL}{(\p{U}:\ty{any}):\ty{any}}{eval, spread}
  20076. {The value of the expression U is computed. Error numbers are
  20077. arbitrary. Portions of EVAL involving machine specific coding are
  20078. expressed in English enclosed in boxes.
  20079. {\tt \begin{tabbing} EXPR PROCEDURE EVAL(U); \\ BEGIN SCALAR FN; \\
  20080. \hspace*{2em} \= IF CONSTANTP U THEN RETURN U; \\
  20081. \> IF IDP U THEN RETURN \\
  20082. \> \hspace{1em} \framebox[3.25in]{\parbox{3.25in}{U is an id. Return the
  20083. value most currently
  20084. bound to U or if there is no such binding: ERROR(000, LIST("Unbound:",
  20085. U));}} \\
  20086. \> IF \= PAIRP CAR U THEN RETURN \\
  20087. \> \> IF CAAR U EQ 'LAMBDA THEN APPLY(CAR U, EVLIS CDR U) \\
  20088. \> \> ELSE ERROR(\= 000, LIST(CAR U, \\
  20089. \> \> \> "improperly formed LAMBDA expression")) \\
  20090. \> \> ELSE IF CODEP CAR U THEN \\
  20091. \> \> \> RETURN APPLY(CAR U, EVLIS CDR U); \\
  20092. \> FN := GETD CAR U; \\
  20093. \> IF NULL FN THEN \\
  20094. \> \> ERROR(000, LIST(CAR U, "is an undefined function")) \\
  20095. \> ELSE IF CAR FN EQ 'EXPR THEN \\
  20096. \> \> RETURN APPLY(CDR FN, EVLIS CDR U) \\
  20097. \> ELSE IF CAR FN EQ 'FEXPR THEN \\
  20098. \> \> RETURN APPLY(CDR FN, LIST CDR U) \\
  20099. \> ELSE IF CAR FN EQ 'MACRO THEN \\
  20100. \> \> RETURN EVAL APPLY(CDR FN, LIST U) \\
  20101. END;
  20102. \end{tabbing}}}
  20103. \de{EVLIS}{(\p{U}:\ty{any-list}):\ty{any-list}}{eval, spread}
  20104. {EVLIS returns a list of the evaluation of each element of U.
  20105. {\tt \begin{tabbing} EXPR PROCEDURE EVLIS(U); \\
  20106. \hspace*{1em} IF NULL U THEN NIL \\
  20107. \hspace*{2em} ELSE EVAL CAR U . EVLIS CDR U;
  20108. \end{tabbing}}}
  20109. \de{EXPAND}{(\p{L}:\ty{list}, \p{FN}:\ty{function}):\ty{list}}{eval, spread}
  20110. {FN is a defined function of two arguments to be used in the expansion
  20111. of a MACRO. EXPAND returns a list in the form:
  20112. \vspace{.15in}
  20113. (FN L$_0$ (FN L$_1$ \ldots (FN L$_{n-1}$ L$_n$) \ldots ))
  20114. \vspace{.15in}
  20115. where $n$ is the number of elements in L, L$_i$ is the $i$th element
  20116. of L.
  20117. {\tt \begin{tabbing} EXPR PROCEDURE EXPAND(L,FN); \\
  20118. \hspace*{1em} IF NULL CDR L THEN CAR L \\
  20119. \hspace*{2em} ELSE LIST(FN, CAR L, EXPAND(CDR L, FN));
  20120. \end{tabbing}}}
  20121. \de{FUNCTION}{(\p{FN}:\ty{function}):\ty{function}}{noeval, nospread}
  20122. {The function FN is to be passed to another function. If FN is to have
  20123. side effects its free variables must be fluid or global. FUNCTION is
  20124. like QUOTE but its argument may be affected by compilation. We do not
  20125. \index{FUNARGs not supported}
  20126. consider FUNARGs in this report.}
  20127. \de{QUOTE}{(U:any):\ty{any}}{noeval, nospread}
  20128. {Stops evaluation and returns U unevaluated.
  20129. {\tt \begin{tabbing} FEXPR PROCEDURE QUOTE(U); \\
  20130. \hspace*{2em}CAR U;
  20131. \end{tabbing}}}
  20132. \subsection{Input and Output}
  20133. \label{IO}
  20134. The user normally communicates with Standard LISP through
  20135. \index{standard devices}
  20136. ``standard devices''. The default devices are selected in accordance
  20137. with the conventions of the implementation site. Other input and
  20138. output devices or files may be selected for reading and writing using
  20139. the functions described herein.
  20140. \de{CLOSE}{(\p{FILEHANDLE}:\ty{any}):\ty{any}}{eval, spread}
  20141. {Closes the file with the internal name FILEHANDLE writing any
  20142. necessary end of file marks and such. The value of FILEHANDLE is that
  20143. returned by the corresponding OPEN. \index{OPEN} The value returned is
  20144. the value of FILEHANDLE. An error occurs if the file can not be
  20145. \index{file handle} \index{files}
  20146. closed.
  20147. \errormessage{ ***** FILEHANDLE could not be closed}
  20148. }
  20149. \de{EJECT}{():NIL}{eval, spread}
  20150. {Skip to the top of the next output page. Automatic EJECTs are
  20151. executed by the print functions when the length set by the PAGELENGTH
  20152. \index{PAGELENGTH} function is exceeded.}
  20153. \de{LINELENGTH}{(\p{LEN}:\{\ty{integer}, NIL\}):\ty{integer}}{eval, spread}
  20154. {If LEN is an integer the maximum line length to be printed before the
  20155. print functions initiate an automatic TERPRI is set to the value LEN.
  20156. \index{TERPRI}
  20157. No initial Standard LISP line length is assumed. The previous line
  20158. length is returned except when LEN is NIL. This special case returns
  20159. the current line length and does not cause it to be reset. An error
  20160. occurs if the requested line length is too large for the currently
  20161. selected output file or LEN is negative or zero.
  20162. \errormessage{ ***** LEN is an invalid line length}
  20163. }
  20164. \de{LPOSN}{():\ty{integer}}{eval, spread}
  20165. {Returns the number of lines printed on the current page. At the top
  20166. of a page, 0 is returned. }
  20167. \de{OPEN}{(\p{FILE}:\ty{any}, \p{HOW}:\ty{id}):\ty{any}}{eval, spread}
  20168. {Open the file with the system dependent name FILE for output if HOW
  20169. is EQ to OUTPUT, or input if HOW is EQ to INPUT. If the file is
  20170. \index{file handle} \index{files} \index{OUTPUT} \index{INPUT}
  20171. opened successfully, a value which is internally associated with the
  20172. file is returned. This value must be saved for use by RDS and WRS. An
  20173. error occurs if HOW is something other than INPUT or OUTPUT or the
  20174. file can't be opened.
  20175. \errormessage{***** HOW is not option for OPEN}
  20176. \errormessage{***** FILE could not be opened}
  20177. }
  20178. \de{PAGELENGTH}{(\p{LEN}:\{\ty{integer}, NIL\}):\ty{integer}}{eval, spread}
  20179. {Sets the vertical length (in lines) of an output page. Automatic page
  20180. EJECTs are executed by the print functions when this length is
  20181. \index{EJECT}
  20182. reached. The initial vertical length is implementation specific. The
  20183. previous page length is returned. If LEN is 0, no automatic page
  20184. ejects will occur. }
  20185. \de{POSN}{():\ty{integer}}{eval, spread}
  20186. {Returns the number of characters in the output buffer. When the
  20187. buffer is empty, 0 is returned.}
  20188. \de{PRINC}{(\p{U}:\ty{id}):\ty{id}}{eval, spread}
  20189. {U must be a single character id such as produced by EXPLODE or read
  20190. by READCH or the value of !\$EOL!\$. The effect is the character U
  20191. \index{\$EOL\$ (global)}
  20192. displayed upon the currently selected output device. The value of
  20193. !\$EOL!\$ causes termination of the current line like a call to
  20194. TERPRI.}
  20195. \de{PRINT}{(\p{U}:\ty{any}):\ty{any}}{eval, spread}
  20196. {Displays U in READ readable format and terminates the print line. The
  20197. value of U is returned.
  20198. {\tt \begin{tabbing} EXPR PROCEDURE PRINT(U); \\
  20199. \hspace*{2em} $<<$ PRIN1 U; TERPRI(); U $>>$;
  20200. \end{tabbing}}}
  20201. \de{PRIN1}{(\p{U}:\ty{any}):\ty{any}}{eval, spread}
  20202. {U is displayed in a READ readable form. The format of display is the
  20203. result of EXPLODE expansion; special characters are prefixed with the
  20204. escape character !, and strings are enclosed in "\ldots ". Lists are
  20205. displayed in list-notation and vectors in vector-notation. }
  20206. \de{PRIN2}{(\p{U}:\ty{any}):\ty{any}}{eval, spread}
  20207. {U is displayed upon the currently selected print device but output is
  20208. not READ readable. The value of U is returned. Items are displayed as
  20209. described in the EXPLODE function with the exceptions that the escape
  20210. character does not prefix special characters and strings are not
  20211. enclosed in "\ldots ". Lists are displayed in list-notation and
  20212. vectors in vector-notation. The value of U is returned. }
  20213. \de{RDS}{(\p{FILEHANDLE}:\ty{any}):\ty{any}}{eval, spread}
  20214. {Input from the currently selected input file is suspended and further
  20215. input comes from the file named. FILEHANDLE is a system dependent
  20216. \index{file handle}
  20217. internal name which is a value returned by OPEN. If FILEHANDLE is NIL
  20218. the standard input device is selected. When end of file is reached on
  20219. a non-standard input device, the standard input device is reselected.
  20220. When end of file occurs on the standard input device the Standard LISP
  20221. reader terminates. RDS returns the internal name of the previously
  20222. selected input file.
  20223. \index{standard input}
  20224. \errormessage{***** FILEHANDLE could not be selected for input}
  20225. }
  20226. \de{READ}{():\ty{any}}{}
  20227. {The next expression from the file currently selected for input. Valid
  20228. input forms are: vector-notation, dot-notation, list-notation,
  20229. numbers, function-pointers, strings, and identifiers with escape
  20230. characters. Identifiers are interned onW the OBLIST (see
  20231. \index{INTERN} \index{OBLIST entry}
  20232. the INTERN function in "Identifiers", section~\ref{identifiers} on
  20233. page~\pageref{identifiers}). READ returns the
  20234. \index{\$EOF\$ (global)}
  20235. value of !\$EOF!\$ when the end of the currently selected input file
  20236. is reached. }
  20237. \de{READCH}{():\ty{id}}{}
  20238. {Returns the next interned character from the file currently selected
  20239. for input. Two special cases occur. If all the characters in an input
  20240. \index{\$EOL\$ (global)} \index{\$EOF\$ (global)} record have been read,
  20241. the value of !\$EOL!\$ is returned. If the file selected for input has
  20242. all been read the value of !\$EOF!\$ is returned. Comments delimited
  20243. by \% and end-of-line are not transparent to READCH. \index{\% ! read
  20244. by READCH} }
  20245. \de{TERPRI}{():\p{NIL}}{}
  20246. {The current print line is terminated.}
  20247. \de{WRS}{(\p{FILEHANDLE}:\ty{any}):\ty{any}}{eval, spread}
  20248. {Output to the currently active output file is suspended and further
  20249. output is directed to the file named. FILEHANDLE is an internal name
  20250. which is returned by OPEN. The file named must have been opened for
  20251. output. If FILEHANDLE is NIL the standard output device is selected.
  20252. \index{file handle} \index{standard output}
  20253. WRS returns the internal name of the previously selected output file.
  20254. \errormessage{***** FILEHANDLE could not be selected for output}
  20255. }
  20256. \subsection{LISP Reader}
  20257. An EVAL read loop has been chosen to drive a Standard LISP system to
  20258. provide a continuity in functional syntax. Choices of messages and the
  20259. amount of extra information displayed are decisions left to the
  20260. implementor.
  20261. \index{STANDARD-LISP}
  20262. {\tt \begin{tabbing} EXPR PROCEDURE STANDARD!-LISP(); \\ BEGIN SCALAR
  20263. VALUE; \\
  20264. \hspace*{2em} \= RDS NIL; WRS NIL; \\
  20265. \> PRIN2 "Standard LISP"; TERPRI(); \\
  20266. \> WHILE T DO \\
  20267. \> \hspace*{1em} $<<$ \= PRIN2 "EVAL:"; TERPRI(); \\
  20268. \> \> VALUE := ERRORSET(QUOTE EVAL READ(), T, T); \\
  20269. \> \> IF NOT ATOM VALUE THEN PRINT CAR VALUE; \\
  20270. \> \> TERPRI() $>>$; \\
  20271. END;
  20272. \end{tabbing}}
  20273. \de{QUIT}{()}{}
  20274. {Causes termination of the LISP reader and control to be transferred
  20275. to the operating system.}
  20276. \section{System GLOBAL Variables}
  20277. \label{slglobals}
  20278. These variables provide global control of the LISP system, or
  20279. implement values which are constant throughout execution.\footnote{The
  20280. published document does not specify that all these are GLOBAL.}
  20281. \variable{*COMP}{NIL}{global}
  20282. {The value of !*COMP controls whether or not PUTD compiles the
  20283. function defined in its arguments before defining it. If !*COMP is NIL
  20284. the function is defined as an xEXPR. If !*COMP is something else the
  20285. function is first compiled. Compilation will produce certain changes
  20286. in the semantics of functions particularly FLUID type access.}
  20287. \variable{EMSG*}{NIL}{global}
  20288. {Will contain the MESSAGE generated by the last ERROR call (see
  20289. \index{ERROR}
  20290. ``Error Handling'' section~\ref{errors} on page~\pageref{errors}).}
  20291. \variable{\$EOF\$}{\s{an uninterned identifier}}{global}
  20292. {The value of !\$EOF!\$ is returned by all input functions when the
  20293. end
  20294. \index{end of file}
  20295. of the currently selected input file is reached.}
  20296. \variable{\$EOL\$}{\s{an uninterned identifier}}{global}
  20297. {The value of !\$EOL!\$ is returned by READCH when it reaches the end
  20298. of
  20299. \index{READCH} \index{end of line} \index{PRINC}
  20300. a logical input record. Likewise PRINC will terminate its current line
  20301. (like a call to TERPRI) when !\$EOL!\$ is its argument.}
  20302. \variable{*GC}{NIL}{global}
  20303. {!*GC controls the printing of garbage collector messages. If NIL no
  20304. \index{garbage collector}
  20305. indication of garbage collection may occur. If non-NIL various system
  20306. dependent messages may be displayed.}
  20307. \variable{NIL}{NIL}{global}
  20308. {NIL is a special global variable. It is protected from being modified
  20309. by SET or SETQ.
  20310. \index{NIL ! cannot be changed}}
  20311. \variable{*RAISE}{NIL}{global}
  20312. {If !*RAISE is non-NIL all characters input through Standard LISP
  20313. input/output functions will be raised to upper case. If !*RAISE is NIL
  20314. characters will be input as is.}
  20315. \variable{T}{T}{global}
  20316. {T is a special global variable. It is protected from being modified
  20317. by SET or SETQ. \index{T ! cannot be changed}}
  20318. \section{The Extended Syntax}
  20319. Whenever it is possible to define Standard LISP functions in LISP the
  20320. text of the function will appear in an extended syntax. These
  20321. definitions are supplied as an aid to understanding the behavior of
  20322. functions and not as a strict implementation guide. A formal scheme
  20323. for the translation of extended syntax to Standard LISP is presented
  20324. to eliminate misinterpretation of the definitions.
  20325. \subsection{Definition}
  20326. The goal of the transformation scheme is to produce a PUTD invocation
  20327. which has the function translated from the extended syntax as its
  20328. actual parameter. A rule has a name in brackets
  20329. \s{\ldots} by which it is known and is defined by what follows the meta
  20330. symbol ::=. Each rule of the set consists of one or more
  20331. ``alternatives'' separated by the $\mid$ meta symbol, being the
  20332. different ways in which the rule will be matched by source text. Each
  20333. alternative is composed of a ``recognizer'' and a ``generator''
  20334. separated by the $\Longrightarrow$ meta symbol. The recognizer is a
  20335. concatenation of any of three different forms. 1) Terminals - Upper
  20336. case lexemes and punctuation which is not part of the meta syntax
  20337. represent items which must appear as is in the source text for the
  20338. rule to succeed. 2) Rules - Lower case lexemes enclosed in \s{\ldots}
  20339. are names of other rules. The source text is matched if the named
  20340. rule succeeds. 3) Primitives - Lower case singletons not in brackets
  20341. are names of primitives or primitive classes of Standard LISP. The
  20342. syntax and semantics of the primitives are given in Part I.
  20343. The recognizer portion of the following rule matches an extended
  20344. syntax procedure:
  20345. \s{function} ::= ftype PROCEDURE id (\s{id list}); \\
  20346. \hspace*{2em} \s{statement}; $\Longrightarrow$
  20347. A function is recognized as an ``ftype'' (one of the tokens EXPR,
  20348. FEXPR, etc.) followed by the keyword PROCEDURE, followed by an ``id''
  20349. (the name of the function), followed by an \s{id list} (the formal
  20350. parameter names) enclosed in parentheses. A semicolon terminates the
  20351. title line. The body of the function is a
  20352. \s{statement} followed by a semicolon. For example:
  20353. {\small\begin{verbatim}
  20354. EXPR PROCEDURE NULL(X); EQ(X, NIL);
  20355. \end{verbatim}}
  20356. \noindent satisfies the recognizer, causes the generator to be activated and
  20357. the rule to be matched successfully.
  20358. The generator is a template into which generated items are
  20359. substituted. The three syntactic entities have corresponding meanings
  20360. when they appear in the generator portion. 1) Terminals - These
  20361. lexemes are copied as is to the generated text. 2) Rules - If a rule
  20362. has succeeded in the recognizer section then the value of the rule is
  20363. the result of the generator portion of that rule. 3) Primitives -
  20364. When primitives are matched the primitive lexeme replaces its
  20365. occurrence in the generator.
  20366. If more than one occurrence of an item would cause ambiguity in the
  20367. generator portion this entity appears with a bracketed subscript.
  20368. Thus:
  20369. \begin{tabbing}
  20370. \s{conditional} ::= \\
  20371. \hspace*{2em} IF \s{expression} \= THEN \s{statement$_1$} \\
  20372. \> ELSE \s{statement$_2$} \ldots
  20373. \end{tabbing}
  20374. \noindent has occurrences of two different \s{statement}s. The generator
  20375. portion uses the subscripted entities to reference the proper
  20376. generated value.
  20377. The \s{function} rule appears in its entirety as:
  20378. \begin{tabbing}
  20379. \s{function} ::= ftype PROCEDURE id (\s{id list});\s{statement};
  20380. $\Longrightarrow$ \\
  20381. \hspace*{2em} \=(PUTD \= (QUOTE id) \\
  20382. \> \> (QUOTE ftype) \\
  20383. \> \>(QUOTE (LAMBDA (\s{id list}) \s{statement})))
  20384. \end{tabbing}
  20385. If the recognizer succeeds (as it would in the case of the NULL
  20386. procedure example) the generator returns:
  20387. {\small\begin{verbatim}
  20388. (PUTD (QUOTE NULL) (QUOTE EXPR) (QUOTE (LAMBDA (X) (EQ X NIL))))
  20389. \end{verbatim}}
  20390. The identifier in the template is replaced by the procedure name NULL,
  20391. \s{id list} by the single formal parameter X, the \s{statement} by (EQ
  20392. X NIL) which is the result of the \s{statement} generator. EXPR
  20393. replaces ftype, the type of the defined procedure.
  20394. \subsection{The Extended Syntax Rules}
  20395. \begin{tabbing}
  20396. \s{function} ::= ftype \k{PROCEDURE} id (\s{id list}); \s{statement};
  20397. $\Longrightarrow$ \\
  20398. \hspace*{2em} \= (PUTD \= (QUOTE id) \\
  20399. \> \> (QUOTE ftype) \\
  20400. \> \> (QUOTE (LAMBDA (\s{id list}) \s{statement}))) \\ \\
  20401. \s{id list} ::= id $\Longrightarrow$ id $\mid$ \\
  20402. \> id, \s{id list} $\Longrightarrow$ id \s{id list} $\mid$ \\
  20403. \> $\Longrightarrow$ NIL \\
  20404. \s{statement} ::= \s{expression} $\Longrightarrow$ \s{expression} $\mid$ \\
  20405. \> \s{proper statement} $\Longrightarrow$ \s{proper statement} \\ \\
  20406. \s{proper statement} ::= \\
  20407. \> \s{assignment statement} $\Longrightarrow$ \s{assignment statement}
  20408. $\mid$ \\
  20409. \> \s{conditional statement} $\Longrightarrow$ \s{conditional statement}
  20410. $\mid$ \\
  20411. \> \s{while statement} $\Longrightarrow$ \s{while statement} $\mid$ \\
  20412. \> \s{compound statement} $\Longrightarrow$ \s{compound statement} \\ \\
  20413. \s{assignment statement} ::= id := \s{expression} $\Longrightarrow$ \\
  20414. \> \> (SETQ id \s{expression}) \\ \\
  20415. \s{conditional statement} ::= \\
  20416. \> \k{IF} \s{expression} \k{THEN} \s{statement$_1$} \k{ELSE}
  20417. \s{statement$_2$} $\Longrightarrow$ \\
  20418. \> \hspace{2em} \= (COND (\s{expression} \s{statement$_1$})(T
  20419. \s{statement$_2$})) $\mid$ \\
  20420. \> \k{IF} \s{expression} \k{THEN} \s{statement} $\Longrightarrow$ \\
  20421. \> \> (COND (\s{expression} \s{statement})) \\ \\
  20422. \s{while statement} ::= \k{WHILE} \s{expression} \k{DO} \s{statement}
  20423. $\Longrightarrow$ \\
  20424. \> \> (PROG NIL \\
  20425. \> \> LBL \= (COND ((NULL \s{expression}) (RETURN NIL))) \\
  20426. \> \> \> \s{statement} \\
  20427. \> \> \> (GO LBL)) \\ \\
  20428. \s{compound statement} ::= \\
  20429. \> \k{BEGIN} \k{SCALAR} \s{id list}; \s{program list} \k{END}
  20430. $\Longrightarrow$ \\
  20431. \> \> (PROG (\s{id list}) \s{program list}) $\mid$ \\
  20432. \> \k{BEGIN} \s{program list} \k{END} $\Longrightarrow$ \\
  20433. \> \> (PROG NIL \s{program list}) $\mid$ \\
  20434. \> \k{$<<$} \s{statement list} \k{$>>$} $\Longrightarrow$ (PROGN
  20435. \s{statement list}) \\ \\
  20436. \s{program list} ::= \s{full statement} $\Longrightarrow$ \s{full statement}
  20437. $\mid$ \\
  20438. \> \s{full statement} \s{program list} $\Longrightarrow$ \\
  20439. \> \> \s{full statement} \s{program list} \\ \\
  20440. \s{full statement} ::= \s{statement} $\Longrightarrow$ \s{statement} $\mid$
  20441. id: $\Longrightarrow$ id \\ \\
  20442. \s{statement list} ::= \s{statement} $\Longrightarrow$ \s{statement} $\mid$ \\
  20443. \> \s{statement}; \s{statement list} $\Longrightarrow$ \\
  20444. \> \> \s{statement} \s{statement list} \\ \\
  20445. \s{expression} ::= \\
  20446. \> \s{expression$_1$} \k{.} \s{expression$_2$} $\Longrightarrow$ \\
  20447. \> \> (CONS \s{expression$_1$} \s{expression$_2$} $\mid$ \\
  20448. \> \s{expression$_1$} \k{=} \s{expression$_2$} $\Longrightarrow$ \\
  20449. \> \> (EQUAL \s{expression$_1$} \s{expression$_2$}) $\mid$ \\
  20450. \> \s{expression$_1$} \k{EQ} \s{expression$_2$} $\Longrightarrow$ \\
  20451. \> \> (EQ \s{expression$_1$} \s{expression$_2$}) $\mid$ \\
  20452. \> '\s{expression} $\Longrightarrow$ (QUOTE \s{expression}) $\mid$ \\
  20453. \> function \s{expression} $\Longrightarrow$ (function \s{expression})
  20454. $\mid$ \\
  20455. \> function(\s{argument list}) $\Longrightarrow$ (function \s{argument list})
  20456. $\mid$ \\
  20457. \> number $\Longrightarrow$ number $\mid$ \\
  20458. \> id $\Longrightarrow$ id \\ \\
  20459. \s{argument list} ::= () $\Longrightarrow$ $\mid$ \\
  20460. \> \s{expression} $\Longrightarrow$ \s{expression} $\mid$ \\
  20461. \> \s{expression}, \s{argument list} $\Longrightarrow$ \s{expression}
  20462. \s{argument list}
  20463. \end{tabbing}
  20464. Notice the three infix operators . EQ and = which are translated into
  20465. calls on CONS, EQ, and EQUAL respectively. Note also that a call on a
  20466. function which has no formal parameters must have () as an argument
  20467. list. The QUOTE function is abbreviated by '.
  20468. %\bibliography{sl}
  20469. %\bibliographystyle{plain}
  20470. %\end{document}
  20471. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  20472. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EndCodemist
  20473. \part{Appendix}
  20474. \appendix
  20475. \chapter{Reserved Identifiers}
  20476. We list here all identifiers that are normally reserved in \REDUCE{}
  20477. including names of commands, operators and switches initially in the system.
  20478. Excluded are words that are reserved in specific implementations of the
  20479. system.
  20480. \vspace{13pt}
  20481. \begin{list}{}{\renewcommand{\makelabel}[1]{#1\hspace{\fill}}%
  20482. \settowidth{\labelwidth}{Numerical Operators}%
  20483. \setlength{\labelsep}{1em}%
  20484. \settowidth{\leftmargin}{Numerical Operators\hspace*{\labelsep}}%
  20485. \sloppy}
  20486. \item[Commands] {\tt ALGEBRAIC} {\tt ANTISYMMETRIC}
  20487. {\tt ARRAY} {\tt BYE} {\tt CLEAR} \linebreak
  20488. {\tt CLEARRULES} {\tt COMMENT} {\tt
  20489. CONT} {\tt DECOMPOSE} {\tt DEFINE} {\tt DEPEND} {\tt DISPLAY} {\tt ED}
  20490. {\tt EDITDEF} {\tt END} {\tt EVEN} {\tt FACTOR} {\tt FOR} {\tt FORALL}
  20491. {\tt FOREACH} {\tt GO} {\tt GOTO} {\tt IF} {\tt IN} {\tt INDEX} {\tt INFIX}
  20492. {\tt INPUT} {\tt INTEGER} {\tt KORDER} {\tt LET} {\tt LINEAR} {\tt LISP}
  20493. {\tt LISTARGP} {\tt LOAD} {\tt LOAD\_PACKAGE} {\tt MASS} {\tt MATCH} {\tt
  20494. MATRIX} {\tt MSHELL} {\tt NODEPEND} {\tt NONCOM} {\tt NONZERO} {\tt NOSPUR}
  20495. {\tt ODD} {\tt OFF}
  20496. {\tt ON} {\tt OPERATOR} {\tt ORDER} {\tt OUT} {\tt PAUSE} {\tt PRECEDENCE}
  20497. {\tt PRINT\_PRECISION} {\tt PROCEDURE} {\tt QUIT} {\tt REAL} {\tt REMFAC}
  20498. {\tt REMIND} {\tt RETRY} {\tt RETURN} {\tt SAVEAS} {\tt SCALAR} {\tt
  20499. SETMOD} {\tt SHARE} {\tt SHOWTIME} {\tt SHUT} {\tt SPUR} {\tt SYMBOLIC}
  20500. {\tt SYMMETRIC} {\tt VECDIM} {\tt VECTOR} {\tt WEIGHT} {\tt WRITE} {\tt
  20501. WTLEVEL}
  20502. \item[Boolean Operators] {\tt EVENP} {\tt FIXP}
  20503. {\tt FREEOF} {\tt NUMBERP} {\tt ORDP} {\tt PRIMEP}
  20504. \item[Infix Operators]
  20505. \verb|:=| \verb|=| \verb|>=| \verb|>| \verb|<=| \verb|<| \verb|=>|
  20506. \verb|+| \verb|*| \verb|/| \verb|^| \verb|**| \verb|.| {\tt WHERE}
  20507. {\tt SETQ} {\tt OR} {\tt AND} {\tt MEMBER} {\tt MEMQ} {\tt
  20508. EQUAL} {\tt NEQ} {\tt EQ} {\tt GEQ} {\tt GREATERP} {\tt LEQ} {\tt LESSP}
  20509. {\tt PLUS} {\tt DIFFERENCE} {\tt MINUS} {\tt TIMES} {\tt QUOTIENT} {\tt
  20510. EXPT} {\tt CONS}
  20511. \item[Numerical Operators] {\tt ABS} {\tt ACOS}
  20512. {\tt ACOSH} {\tt ACOT} {\tt ACOTH} {\tt ACSC} {\tt ACSCH} {\tt ASEC} {\tt
  20513. ASECH} {\tt ASIN} {\tt ASINH} {\tt ATAN} {\tt ATANH} {\tt ATAN2} {\tt COS}
  20514. {\tt COSH} {\tt COT} {\tt COTH} {\tt CSC} {\tt CSCH} {\tt EXP} {\tt
  20515. FACTORIAL} {\tt FIX} {\tt FLOOR} {\tt HYPOT} {\tt LN} {\tt LOG} {\tt LOGB}
  20516. {\tt LOG10} {\tt NEXTPRIME} {\tt ROUND} {\tt SEC} {\tt SECH} {\tt SIN}
  20517. {\tt SINH} {\tt SQRT} {\tt TAN} {\tt TANH}
  20518. \item[Prefix Operators] {\tt APPEND} {\tt
  20519. ARGLENGTH} {\tt CEILING} {\tt COEFF} {\tt COEFFN} {\tt COFACTOR} {\tt
  20520. CONJ} {\tt DEG} {\tt DEN} {\tt DET} {\tt DF} {\tt DILOG} {\tt EI}
  20521. {\tt EPS} {\tt ERF} {\tt FACTORIZE} {\tt FIRST} {\tt GCD} {\tt G} {\tt
  20522. IMPART} {\tt INT} {\tt INTERPOL} {\tt LCM} {\tt LCOF} {\tt LENGTH} {\tt
  20523. LHS} {\tt LINELENGTH} {\tt LTERM} {\tt MAINVAR} {\tt MAT} {\tt MATEIGEN}
  20524. {\tt MAX} {\tt MIN} {\tt MKID} {\tt NULLSPACE} {\tt NUM} {\tt PART} {\tt
  20525. PF} {\tt PRECISION} {\tt RANDOM} {\tt RANDOM\_NEW\_SEED} {\tt RANK} {\tt
  20526. REDERR} {\tt REDUCT} {\tt REMAINDER} {\tt REPART} {\tt REST} {\tt
  20527. RESULTANT} {\tt REVERSE} {\tt RHS} {\tt SECOND} {\tt SET} {\tt SHOWRULES}
  20528. {\tt SIGN} {\tt SOLVE} {\tt STRUCTR} {\tt SUB} {\tt SUM} {\tt THIRD} {\tt
  20529. TP} {\tt TRACE} {\tt VARNAME}
  20530. \item[Reserved Variables] {\tt CARD\_NO} {\tt E} {\tt EVAL\_MODE}
  20531. {\tt FORT\_WIDTH} {\tt HIGH\_POW} {\tt I} {\tt INFINITY} {\tt K!*} {\tt
  20532. LOW\_POW} {\tt NIL} {\tt PI} {\tt ROOT\_MULTIPLICITY} {\tt T}
  20533. \item[Switches] {\tt ADJPREC} {\tt ALGINT} {\tt ALLBRANCH} {\tt ALLFAC}
  20534. {\tt BFSPACE} {\tt COMBINEEXPT} {\tt COMBINELOGS}
  20535. {\tt COMP} {\tt COMPLEX} {\tt CRAMER} {\tt CREF} {\tt DEFN} {\tt DEMO}
  20536. {\tt DIV} {\tt ECHO} {\tt ERRCONT} {\tt EVALLHSEQP} {\tt EXP} {\tt
  20537. EXPANDLOGS} {\tt EZGCD} {\tt FACTOR} {\tt FORT} {\tt FULLROOTS} {\tt GCD}
  20538. {\tt IFACTOR} {\tt INT} {\tt INTSTR} {\tt LCM} {\tt LIST} {\tt LISTARGS}
  20539. {\tt MCD} {\tt MODULAR} {\tt MSG} {\tt MULTIPLICITIES} {\tt NAT} {\tt
  20540. NERO} {\tt NOSPLIT} {\tt OUTPUT} {\tt PERIOD} {\tt PRECISE} {\tt PRET}
  20541. {\tt PRI} {\tt RAT} {\tt RATARG} {\tt RATIONAL} {\tt RATIONALIZE} {\tt
  20542. RATPRI} {\tt REVPRI} {\tt RLISP88} {\tt ROUNDALL} {\tt ROUNDBF} {\tt
  20543. ROUNDED} {\tt SAVESTRUCTR} {\tt SOLVESINGULAR} {\tt TIME} {\tt TRA} {\tt
  20544. TRFAC} {\tt TRIGFORM} {\tt TRINT}
  20545. \item[Other Reserved Ids] {\tt BEGIN} {\tt DO} {\tt
  20546. EXPR} {\tt FEXPR} {\tt INPUT} {\tt LAMBDA} {\tt
  20547. LISP} {\tt MACRO} {\tt PRODUCT} {\tt REPEAT} {\tt SMACRO} {\tt
  20548. SUM} {\tt UNTIL} {\tt WHEN} {\tt WHILE} {\tt WS}
  20549. \end{list}
  20550. \newpage
  20551. \addcontentsline{toc}{chapter}{Index}{}
  20552. \appendix
  20553. \bibliographystyle{plain}
  20554. \bibliography{bibl,sl}
  20555. \printindex
  20556. \end{document}