r38.tex 918 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917
  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 r38
  5. % bibtex r38
  6. % latex r38
  7. % latex r38
  8. % makeindex r38
  9. % latex r38
  10. % dvipdfm r38
  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.8}
  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 July 2003
  100. \end{center}
  101. \newpage
  102. \vspace*{3.0in}
  103. \noindent Copyright \copyright 2004 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.8. 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 2004} \\
  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.8}
  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 July 2003
  201. \end{center}
  202. %%\end{titlepage}
  203. \newpage
  204. \vspace*{3.0in}
  205. \noindent Copyright \copyright 2003 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.8, 15-Jul-2003 ...
  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, i.e., any object
  844. other than 0 and plus or minus 1 which is only exactly divisible
  845. by itself or a unit.
  846. \\
  847. \end{tabular}}
  848. {\it Examples:}
  849. {\small\begin{verbatim}
  850. j<1
  851. x>0 or x=-2
  852. numberp x
  853. fixp x and evenp x
  854. numberp x and x neq 0
  855. \end{verbatim}}
  856. Boolean expressions can only appear directly within {\tt IF}, {\tt FOR},
  857. {\tt WHILE}, and {\tt UNTIL} statements, as described in other sections.
  858. Such expressions cannot be used in place of ordinary algebraic expressions,
  859. or assigned to a variable.
  860. NB: For those familiar with symbolic mode, the meaning of some of
  861. these operators is different in that mode. For example, {\tt NUMBERP} is
  862. true only for integers and reals in symbolic mode.
  863. When two or more boolean expressions are combined with {\tt AND}, they are
  864. evaluated one by one until a {\em false\/} expression is found. The rest are
  865. not evaluated. Thus
  866. {\small\begin{verbatim}
  867. numberp x and numberp y and x>y
  868. \end{verbatim}}
  869. does not attempt to make the {\tt x>y} comparison unless {\tt X} and {\tt Y}
  870. are both verified to be numbers.
  871. Similarly, evaluation of a sequence of boolean expressions connected by
  872. {\tt OR} stops as soon as a {\em true\/} expression is found.
  873. NB: In a boolean expression, and in a place where a boolean expression is
  874. expected, the algebraic value 0 is interpreted as {\em false}, while all
  875. other algebraic values are converted to {\em true}. So in algebraic mode
  876. a procedure can be written for direct usage in boolean expressions,
  877. returning say 1 or 0 as its value as in
  878. {\small\begin{verbatim}
  879. procedure polynomialp(u,x);
  880. if den(u)=1 and deg(u,x)>=1 then 1 else 0;
  881. \end{verbatim}}
  882. One can then use this in a boolean construct, such as
  883. {\small\begin{verbatim}
  884. if polynomialp(q,z) and not polynomialp(q,y) then ...
  885. \end{verbatim}}
  886. In addition, any procedure that does not have a defined return value
  887. (for example, a block without a {\tt RETURN} statement in it)
  888. has the boolean value {\em false}.
  889. \section{Equations}
  890. Equations\index{Equation} are a particular type of expression with the syntax
  891. {\small\begin{verbatim}
  892. <expression> = <expression>.
  893. \end{verbatim}}
  894. In addition to their role as boolean expressions, they can also be used as
  895. arguments to several operators (e.g., {\tt SOLVE}), and can be
  896. returned as values.
  897. Under normal circumstances, the right-hand-side of the equation is
  898. evaluated but not the left-hand-side. This also applies to any substitutions
  899. made by the {\tt SUB}\ttindex{SUB} operator. If both sides are to be
  900. evaluated, the switch {\tt EVALLHSEQP}\ttindex{EVALLHSEQP} should be
  901. turned on.
  902. To facilitate the handling of equations, two selectors, {\tt LHS}
  903. \ttindex{LHS} and {\tt RHS},\ttindex{RHS} which return the left- and
  904. right-hand sides of a equation\index{Equation} respectively, are provided.
  905. For example,
  906. {\small\begin{verbatim}
  907. lhs(a+b=c) -> a+b
  908. and
  909. rhs(a+b=c) -> c.
  910. \end{verbatim}}
  911. \section{Proper Statements as Expressions}
  912. Several kinds of proper statements\index{Proper statement} deliver
  913. an algebraic or numerical result of some kind, which can in turn be used as
  914. an expression or part of an expression. For example, an assignment
  915. statement itself has a value, namely the value assigned. So
  916. {\small\begin{verbatim}
  917. 2 * (x := a+b)
  918. \end{verbatim}}
  919. is equal to {\tt 2*(a+b)}, as well as having the ``side-effect''\index{Side
  920. effect} of assigning the value {\tt a+b} to {\tt X}. In context,
  921. {\small\begin{verbatim}
  922. y := 2 * (x := a+b);
  923. \end{verbatim}}
  924. sets {\tt X} to {\tt a+b} and {\tt Y} to {\tt 2*(a+b)}.
  925. The sections on the various proper statement\index{Proper statement} types
  926. indicate which of these statements are also useful as expressions.
  927. \chapter{Lists}
  928. A list\index{List} is an object consisting of a sequence of other objects
  929. (including lists themselves), separated by commas and surrounded by
  930. braces. Examples of lists are:
  931. {\small\begin{verbatim}
  932. {a,b,c}
  933. {1,a-b,c=d}
  934. {{a},{{b,c},d},e}.
  935. \end{verbatim}}
  936. The empty list is represented as
  937. {\small\begin{verbatim}
  938. {}.
  939. \end{verbatim}}
  940. \section{Operations on Lists}\index{List operation}
  941. Several operators in the system return their results as lists, and a user
  942. can create new lists using braces and commas. Alternatively, one can use
  943. the operator LIST to construct a list. An important class of operations
  944. on lists are MAP and SELECT operations. For details, please refer to the
  945. chapters on MAP, SELECT and the FOR command. See also the documentation
  946. on the ASSIST package.
  947. To facilitate the use of
  948. lists, a number of operators are also available for manipulating
  949. them. {\tt PART(<list>,n)}\ttindex{PART} for example will return the
  950. $n^{th}$ element of a list. {\tt LENGTH}\ttindex{LENGTH} will return the
  951. length of a list. Several operators are also defined uniquely for lists.
  952. For those familiar with them, these operators in fact mirror the
  953. operations defined for Lisp lists. These operators are as follows:
  954. \subsection{LIST}
  955. The operator LIST is an alternative to the usage of curly brackets. LIST
  956. accepts an arbitrary number of arguments and returns a list
  957. of its arguments. This operator is useful in cases where operators
  958. have to be passed as arguments. E.g.,
  959. {\small\begin{verbatim}
  960. list(a,list(list(b,c),d),e); -> {{a},{{b,c},d},e}
  961. \end{verbatim}}
  962. \subsection{FIRST}
  963. This operator\ttindex{FIRST} returns the first member of a list. An error
  964. occurs if the argument is not a list, or the list is empty.
  965. \subsection{SECOND}
  966. {\tt SECOND}\ttindex{SECOND} returns the second member of a list. An error
  967. occurs if the argument is not a list or has no second element.
  968. \subsection{THIRD}
  969. This operator\ttindex{THIRD} returns the third member of a list. An error
  970. occurs if the argument is not a list or has no third element.
  971. \subsection{REST}
  972. {\tt REST}\ttindex{REST} returns its argument with the first element
  973. removed. An error occurs if the argument is not a list, or is empty.
  974. \subsection{$.$ (Cons) Operator}
  975. This operator\ttindex{. (CONS)} adds (``conses'') an expression to the
  976. front of a list. For example:
  977. {\small\begin{verbatim}
  978. a . {b,c} -> {a,b,c}.
  979. \end{verbatim}}
  980. \subsection{APPEND}
  981. This operator\ttindex{APPEND} appends its first argument to its second to
  982. form a new list.
  983. {\it Examples:}
  984. {\small\begin{verbatim}
  985. append({a,b},{c,d}) -> {a,b,c,d}
  986. append({{a,b}},{c,d}) -> {{a,b},c,d}.
  987. \end{verbatim}}
  988. \subsection{REVERSE}
  989. The operator {\tt REVERSE}\ttindex{REVERSE} returns its argument with the
  990. elements in the reverse order. It only applies to the top level list, not
  991. any lower level lists that may occur. Examples are:\index{List operation}
  992. {\small\begin{verbatim}
  993. reverse({a,b,c}) -> {c,b,a}
  994. reverse({{a,b,c},d}) -> {d,{a,b,c}}.
  995. \end{verbatim}}
  996. \subsection{List Arguments of Other Operators}
  997. If an operator other than those specifically defined for lists is given a
  998. single argument that is a list, then the result of this operation will be
  999. a list in which that operator is applied to each element of the list. For
  1000. example, the result of evaluating {\tt log\{a,b,c\}} is the expression
  1001. {\tt \{LOG(A),LOG(B),LOG(C)\}}.
  1002. There are two ways to inhibit this operator distribution. Firstly, the
  1003. switch {\tt LISTARGS},\ttindex{LISTARGS} if on, will globally inhibit
  1004. such distribution. Secondly, one can inhibit this distribution for a
  1005. specific operator by the declaration {\tt LISTARGP}.\ttindex{LISTARGP} For
  1006. example, with the declaration {\tt listargp log}, {\tt log\{a,b,c\}} would
  1007. evaluate to {\tt LOG(\{A,B,C\})}.
  1008. If an operator has more than one argument, no such distribution occurs.
  1009. \subsection{Caveats and Examples}
  1010. Some of the natural list operations such as {\it member} or {\it delete}
  1011. are available only after loading the package {\it ASSIST}.
  1012. Please note that a non-list as second argument to CONS
  1013. (a "dotted pair" in LISP terms) is not allowed
  1014. and causes an "invalid as list" error.
  1015. {\small\begin{verbatim}
  1016. a := 17 . 4;
  1017. ***** 17 4 invalid as list
  1018. \end{verbatim}}
  1019. Also, the initialization of a scalar variable is not the empty list --
  1020. one has to set list type variables explicitly, as in the following
  1021. example:
  1022. {\small\begin{verbatim}
  1023. load_package assist;
  1024. procedure lotto (n,m);
  1025. begin scalar list_1_n, luckies, hit;
  1026. list_1_n := {};
  1027. luckies := {};
  1028. for k:=1:n do list_1_n := k . list_1_n;
  1029. for k:=1:m do
  1030. << hit := part(list_1_n,random(n-k+1) + 1);
  1031. list_1_n := delete(hit,list_1_n);
  1032. luckies := hit . luckies >>;
  1033. return luckies;
  1034. end; % In Germany, try lotto (49,6);
  1035. \end{verbatim}}
  1036. {\it Another example:} Find all coefficients of a multivariate
  1037. polynomial with respect to a list of variables:
  1038. {\small\begin{verbatim}
  1039. procedure allcoeffs(q,lis); % q : polynomial, lis: list of vars
  1040. allcoeffs1 (list q,lis);
  1041. procedure allcoeffs1(q,lis);
  1042. if lis={} then q else
  1043. allcoeffs1(foreach qq in q join coeff(qq,first lis),rest lis);
  1044. \end{verbatim}}
  1045. \chapter{Statements}
  1046. A statement\index{Statement} is any combination of reserved words and
  1047. expressions, and has the syntax \index{Proper statement}
  1048. {\small\begin{verbatim}
  1049. <statement> ::= <expression>|<proper statement>
  1050. \end{verbatim}}
  1051. A {\REDUCE} program consists of a series of commands which are statements
  1052. followed by a terminator:\index{Terminator}\index{Semicolon}
  1053. \index{Dollar sign}
  1054. {\small\begin{verbatim}
  1055. <terminator> ::= ;|$
  1056. \end{verbatim}}
  1057. The division of the program into lines is arbitrary. Several statements
  1058. can be on one line, or one statement can be freely broken onto several
  1059. lines. If the program is run interactively, statements ending with ; or \$
  1060. are not processed until an end-of-line character is encountered. This
  1061. character can vary from system to system, but is normally the \key{Return}
  1062. key on an ASCII terminal. Specific systems may also use additional keys
  1063. as statement terminators.
  1064. If a statement is a proper statement\index{Proper statement}, the
  1065. appropriate action takes place.
  1066. Depending on the nature of the proper statement some result or response may
  1067. or may not be printed out, and the response may or may not depend on the
  1068. terminator used.
  1069. If a statement is an expression, it is evaluated. If the terminator is a
  1070. semicolon, the result is printed. If the terminator is a dollar sign, the
  1071. result is not printed. Because it is not usually possible to know in
  1072. advance how large an expression will be, no explicit format statements are
  1073. offered to the user. However, a variety of output declarations are
  1074. available so that the output can be produced in different forms. These
  1075. output declarations are explained in Section~\ref{sec-output}.
  1076. The following sub-sections describe the types of proper statements
  1077. \index{Proper statement} in {\REDUCE}.
  1078. \section{Assignment Statements}
  1079. These statements\index{Assignment} have the syntax
  1080. {\small\begin{verbatim}
  1081. <assignment statement> ::= <expression> := <expression>
  1082. \end{verbatim}}
  1083. The {\tt <expression>} on the left side is normally the name of a variable, an
  1084. operator symbol with its list of arguments filled in, or an array name with
  1085. the proper number of integer subscript values within the array bounds. For
  1086. example:
  1087. \begin{quote}
  1088. \begin{tabbing}
  1089. {\tt a1 := b + c} \\
  1090. {\tt h(l,m) := x-2*y} \hspace{1in} \= (where {\tt h} is an operator) \\
  1091. {\tt k(3,5) := x-2*y} \> (where {\tt k} is a 2-dim. array)
  1092. \end{tabbing}
  1093. \end{quote}
  1094. More general assignments\index{Assignment} such as {\tt a+b := c} are also
  1095. allowed. The effect of these is explained in Section~\ref{sec-gensubs}.
  1096. An assignment statement causes the expression on the right-hand-side to be
  1097. evaluated. If the left-hand-side is a variable, the value of the
  1098. right-hand-side is assigned to that unevaluated variable. If the
  1099. left-hand-side is an operator or array expression, the arguments of that
  1100. operator or array are evaluated, but no other simplification done. The
  1101. evaluated right-hand-side is then assigned to the resulting expression.
  1102. For example, if {\tt A} is a single-dimensional array, {\tt a(1+1) := b}
  1103. assigns the value {\tt B} to the array element {\tt a(2)}.
  1104. If a semicolon is used as the terminator when an assignment
  1105. \index{Assignment} is issued as a command (i.e. not as a part of a group
  1106. statement or procedure or other similar construct), the left-hand side
  1107. symbol of the assignment statement is printed out, followed by a
  1108. ``{\tt :=}'', followed by the value of the expression on the right.
  1109. It is also possible to write a multiple assignment statement:
  1110. \index{Multiple assignment statement}
  1111. {\small\begin{verbatim}
  1112. <expression> := ... := <expression> := <expression>
  1113. \end{verbatim}}
  1114. In this form, each {\tt <expression>} but the last is set to the value of
  1115. the last {\tt <expression>}. If a semicolon is used as a terminator, each
  1116. expression except the last is printed followed by a ``{\tt :=}'' ending
  1117. with the value of the last expression.
  1118. \subsection{Set Statement}
  1119. In some cases, it is desirable to perform an assignment in which {\em both\/}
  1120. the left- and right-hand sides of an assignment\index{Assignment} are
  1121. evaluated. In this case, the {\tt SET}\ttindex{SET} statement can be used
  1122. with the syntax:
  1123. {\small\begin{verbatim}
  1124. SET(<expression>,<expression>);
  1125. \end{verbatim}}
  1126. For example, the statements
  1127. {\small\begin{verbatim}
  1128. j := 23;
  1129. set(mkid(a,j),x);
  1130. \end{verbatim}}
  1131. assigns the value {\tt X} to {\tt A23}.
  1132. \section{Group Statements}
  1133. The group statement\index{Group statement} is a construct used where
  1134. {\REDUCE} expects a single statement, but a series of actions needs to be
  1135. performed. It is formed by enclosing one or more statements (of any kind)
  1136. between the symbols {\tt $<<$} and {\tt $>>$}, separated by semicolons or
  1137. dollar signs -- it doesn't matter which. The statements are executed one
  1138. after another.
  1139. Examples will be given in the sections on {\tt IF}\ttindex{IF} and other
  1140. types of statements in which the {\tt $<<$} \ldots {\tt $>>$} construct is
  1141. useful.
  1142. If the last statement in the enclosed group has a value, then that is also
  1143. the value of the group statement. Care must be taken not to have a
  1144. semicolon or dollar sign after the last grouped statement, if the value of
  1145. the group is relevant: such an extra terminator causes the group to have
  1146. the value NIL or zero.
  1147. \section{Conditional Statements}
  1148. The conditional statement\index{Conditional statement} has the following
  1149. syntax:
  1150. {\small\begin{verbatim}
  1151. <conditional statement> ::=
  1152. IF <boolean expression> THEN <statement> [ELSE <statement>]
  1153. \end{verbatim}}
  1154. The boolean expression is evaluated. If this is {\em true}, the first
  1155. {\tt <statement>} is executed. If it is {\em false}, the second is.
  1156. {\it Examples:}
  1157. {\small\begin{verbatim}
  1158. if x=5 then a:=b+c else d:=e+f
  1159. if x=5 and numberp y
  1160. then <<ff:=q1; a:=b+c>>
  1161. else <<ff:=q2; d:=e+f>>
  1162. \end{verbatim}}
  1163. Note the use of the group statement\index{Group statement}.
  1164. \\
  1165. Conditional statements associate to the right; i.e.,\ttindex{IF}
  1166. {\small\begin{verbatim}
  1167. IF <a> THEN <b> ELSE IF <c> THEN <d> ELSE <e>
  1168. \end{verbatim}}
  1169. is equivalent to:
  1170. {\small\begin{verbatim}
  1171. IF <a> THEN <b> ELSE (IF <c> THEN <d> ELSE <e>)
  1172. \end{verbatim}}
  1173. In addition, the construction
  1174. {\small\begin{verbatim}
  1175. IF <a> THEN IF <b> THEN <c> ELSE <d>
  1176. \end{verbatim}}
  1177. parses as
  1178. {\small\begin{verbatim}
  1179. IF <a> THEN (IF <b> THEN <c> ELSE <d>).
  1180. \end{verbatim}}
  1181. If the value of the conditional statement\index{Conditional
  1182. statement} is of primary interest, it is often called a conditional
  1183. expression instead. Its value is the value of whichever statement was
  1184. executed. (If the executed statement has no value, the conditional
  1185. expression has no value or the value 0, depending on how it is used.)
  1186. {\it Examples:}
  1187. {\small\begin{verbatim}
  1188. a:=if x<5 then 123 else 456;
  1189. b:=u + v^(if numberp z then 10*z else 1) + w;
  1190. \end{verbatim}}
  1191. If the value is of no concern, the {\tt ELSE} clause may be omitted if no
  1192. action is required in the {\em false\/} case.
  1193. {\small\begin{verbatim}
  1194. if x=5 then a:=b+c;
  1195. \end{verbatim}}
  1196. Note: As explained in Section~\ref{sec-boolean},a
  1197. if a scalar or numerical expression is used in place of
  1198. the boolean expression -- for example, a variable is written there -- the
  1199. {\em true\/} alternative is followed unless the expression has the value 0.
  1200. \section{FOR Statements}
  1201. The {\tt FOR} statement is used to define a variety of program
  1202. loops\index{Loop}. Its general syntax is as follows:\ttindex{UNTIL}
  1203. \ttindex{DO}\ttindex{PRODUCT}\ttindex{SUM}\ttindex{COLLECT}\ttindex{JOIN}
  1204. \begin{small}
  1205. \[ \mbox{\tt FOR} \left\{ \begin{array}{@{}ccc@{}}
  1206. \mbox{\tt \meta{var} := \meta{number} } \left\{ \begin{array}{@{}c@{}}
  1207. \mbox{\tt STEP \meta{number} UNTIL} \\
  1208. \mbox{\tt :}
  1209. \end{array}
  1210. \right\} \mbox{\tt \meta{number}} \\[3mm]
  1211. \multicolumn{1}{c}{\mbox{\tt EACH \meta{var}
  1212. \(\left\{
  1213. \begin{tabular}{@{}c@{}}
  1214. IN \\ ON
  1215. \end{tabular}
  1216. \right\}\)
  1217. \meta{list}}}
  1218. \end{array}
  1219. \right\} \mbox{\tt \meta{action} \meta{exprn}} \]
  1220. \end{small}%
  1221. %
  1222. where
  1223. \begin{center}
  1224. \tt \meta{action} ::= do|product|sum|collect|join.
  1225. \end{center}
  1226. The assignment\index{Assignment} form of the {\tt FOR} statement defines an
  1227. iteration over the indicated numerical range. If expressions that do not
  1228. evaluate to numbers are used in the designated places, an error will
  1229. result.
  1230. The {\tt FOR EACH}\ttindex{FOR EACH} form of the {\tt FOR} statement is
  1231. designed to iterate down a list. Again, an error will occur if a list is
  1232. not used.
  1233. The action {\tt DO}\ttindex{DO} means that {\tt <exprn>} is simply
  1234. evaluated and no value kept; the statement returning 0 in this case (or no
  1235. value at the top level). {\tt COLLECT} means that the results of
  1236. evaluating {\tt <exprn>} each time are linked together to make a list,
  1237. and {\tt JOIN} means that the values of {\tt <exprn>} are themselves
  1238. lists that are joined to make one list (similar to {\tt CONC} in Lisp).
  1239. Finally, {\tt PRODUCT}\ttindex{PRODUCT} and {\tt SUM}\ttindex{SUM}
  1240. form the respective combined value out of the values of {\tt <exprn>}.
  1241. In all cases, {\tt <exprn>} is evaluated algebraically within the
  1242. scope of the current value of {\tt <var>}. If {\tt <action>} is
  1243. {\tt DO}\ttindex{DO}, then nothing else happens. In other cases, {\tt
  1244. <action>} is a binary operator that causes a result to be built up and
  1245. returned by {\tt FOR}. In those cases, the loop\index{Loop} is
  1246. initialized to a default value ({\tt 0} for {\tt SUM},\ttindex{SUM} {\tt
  1247. 1} for {\tt PRODUCT},\ttindex{PRODUCT} and an empty list for the other
  1248. actions). The test for the end condition is made before any action is
  1249. taken. As in Pascal, if the variable is out of range in the assignment
  1250. case, or the {\tt <list>} is empty in the {\tt FOR EACH}\ttindex{FOR EACH}
  1251. case, {\tt <exprn>} is not evaluated at all.
  1252. {\it Examples:}
  1253. \begin{enumerate}
  1254. \item If {\tt A}, {\tt B} have been declared to be arrays, the following
  1255. stores $5^{2}$ through $10^{2}$ in {\tt A(5)} through {\tt A(10)}, and at
  1256. the same time stores the cubes in the {\tt B} array:
  1257. {\small\begin{verbatim}
  1258. for i := 5 step 1 until 10 do <<a(i):=i^2; b(i):=i^3>>
  1259. \end{verbatim}}
  1260. \item As a convenience, the common construction
  1261. {\small\begin{verbatim}
  1262. STEP 1 UNTIL
  1263. \end{verbatim}}
  1264. may be abbreviated to a colon. Thus, instead of the above we could write:
  1265. {\small\begin{verbatim}
  1266. for i := 5:10 do <<a(i):=i^2; b(i):=i^3>>
  1267. \end{verbatim}}
  1268. \item The following sets {\tt C} to the sum of the squares of 1,3,5,7,9;
  1269. and {\tt D} to the expression {\tt x*(x+1)*(x+2)*(x+3)*(x+4):}
  1270. {\small\begin{verbatim}
  1271. c := for j:=1 step 2 until 9 sum j^2;
  1272. d := for k:=0 step 1 until 4 product (x+k);
  1273. \end{verbatim}}
  1274. \item The following forms a list of the squares of the elements of the list
  1275. {\tt \{a,b,c\}:}\ttindex{FOR EACH}
  1276. {\small\begin{verbatim}
  1277. for each x in {a,b,c} collect x^2;
  1278. \end{verbatim}}
  1279. \item The following forms a list of the listed squares of the elements of the
  1280. list {\tt \{a,b,c\}}
  1281. (i.e., {\tt \{\{A\verb|^|2\},\{B\verb|^|2\},\{C\verb|^|2\}\}):}
  1282. {\small\begin{verbatim}
  1283. for each x in {a,b,c} collect {x^2};
  1284. \end{verbatim}}
  1285. \item The following also forms a list of the squares of the elements of
  1286. the list {\tt \{a,b,c\},} since the {\tt JOIN} operation joins the
  1287. individual lists into one list:\ttindex{FOR EACH}
  1288. {\small\begin{verbatim}
  1289. for each x in {a,b,c} join {x^2};
  1290. \end{verbatim}}
  1291. \end{enumerate}
  1292. The control variable used in the {\tt FOR} statement is actually a new
  1293. variable, not related to the variable of the same name outside the {\tt
  1294. FOR} statement. In other words, executing a statement {\tt for i:=} \ldots
  1295. doesn't change the system's assumption that $i^{2} = -1$.
  1296. Furthermore, in algebraic mode, the value of the control variable is
  1297. substituted in {\tt <exprn>} only if it occurs explicitly in that
  1298. expression. It will not replace a variable of the same name in the value
  1299. of that expression. For example:
  1300. {\small\begin{verbatim}
  1301. b := a; for a := 1:2 do write b;
  1302. \end{verbatim}}
  1303. prints {\tt A} twice, not 1 followed by 2.
  1304. \section{WHILE \ldots DO}
  1305. The\ttindex{WHILE} {\tt FOR \ldots DO}\ttindex{DO} feature allows easy
  1306. coding of a repeated operation in which the number of repetitions is known
  1307. in advance. If the criterion for repetition is more complicated, {\tt
  1308. WHILE \ldots DO} can often be used. Its syntax is:
  1309. {\small\begin{verbatim}
  1310. WHILE <boolean expression> DO <statement>
  1311. \end{verbatim}}
  1312. The {\tt WHILE \ldots DO} controls the single statement following {\tt DO}.
  1313. If several statements are to be repeated, as is almost always the case,
  1314. they must be grouped using the $<<$ \ldots $>>$ or {\tt BEGIN \ldots END}
  1315. as in the example below.
  1316. The {\tt WHILE} condition is tested each time {\em before\/} the action
  1317. following the {\tt DO} is attempted. If the condition is false to begin
  1318. with, the action is not performed at all. Make sure that what is to be
  1319. tested has an appropriate value initially.
  1320. {\it Example:}
  1321. Suppose we want to add up a series of terms, generated one by one, until
  1322. we reach a term which is less than 1/1000 in value. For our simple
  1323. example, let us suppose the first term equals 1 and each term is obtained
  1324. from the one before by taking one third of it and adding one third its
  1325. square. We would write:
  1326. {\small\begin{verbatim}
  1327. ex:=0; term:=1;
  1328. while num(term - 1/1000) >= 0 do
  1329. <<ex := ex+term; term:=(term + term^2)/3>>;
  1330. ex;
  1331. \end{verbatim}}
  1332. As long as {\tt TERM} is greater than or equal to ({\tt >=}) 1/1000 it will
  1333. be added to {\tt EX} and the next {\tt TERM} calculated. As soon as {\tt
  1334. TERM} becomes less than 1/1000 the {\tt WHILE} test fails and the {\tt
  1335. TERM} will not be added.
  1336. \section{REPEAT \ldots UNTIL}
  1337. \ttindex{REPEAT} {\tt REPEAT \ldots UNTIL} is very similar in purpose to
  1338. {\tt WHILE \ldots DO}. Its syntax is:
  1339. {\small\begin{verbatim}
  1340. REPEAT <statement> UNTIL <boolean expression>
  1341. \end{verbatim}}
  1342. (PASCAL users note: Only a single statement -- usually a group statement
  1343. -- is allowed between the {\tt REPEAT} and the {\tt UNTIL.)}
  1344. There are two essential differences:
  1345. \begin{enumerate}
  1346. \item The test is performed {\em after\/} the controlled statement (or group of
  1347. statements) is executed, so the controlled statement is always executed at
  1348. least once.
  1349. \item The test is a test for when to stop rather than when to continue, so its
  1350. ``polarity'' is the opposite of that in {\tt WHILE \ldots DO.}
  1351. \end{enumerate}
  1352. As an example, we rewrite the example from the {\tt WHILE \ldots DO} section:
  1353. \begin{samepage}
  1354. {\small\begin{verbatim}
  1355. ex:=0; term:=1;
  1356. repeat <<ex := ex+term; term := (term + term^2)/3>>
  1357. until num(term - 1/1000) < 0;
  1358. ex;
  1359. \end{verbatim}}
  1360. \end{samepage}
  1361. In this case, the answer will be the same as before, because in neither
  1362. case is a term added to {\tt EX} which is less than 1/1000.
  1363. \section{Compound Statements}
  1364. \index{Compound statement}Often the desired process can best (or only) be
  1365. described as a series of steps to be carried out one after the other. In
  1366. many cases, this can be achieved by use of the group statement\index{Group
  1367. statement}. However, each step often provides some intermediate
  1368. result, until at the end we have the final result wanted. Alternatively,
  1369. iterations on the steps are needed that are not possible with constructs
  1370. such as {\tt WHILE}\ttindex{WHILE} or {\tt REPEAT}\ttindex{REPEAT}
  1371. statements. In such cases the steps of the process must be
  1372. enclosed between the words {\tt BEGIN} and {\tt END}\ttindex{BEGIN \ldots
  1373. END} forming what is technically called a {\em block\/}\index{Block} or
  1374. {\em compound\/} statement. Such a compound statement can in fact be used
  1375. wherever a group statement appears. The converse is not true: {\tt BEGIN
  1376. \ldots END} can be used in ways that {\tt $<<$} \ldots {\tt $>>$} cannot.
  1377. If intermediate results must be formed, local variables must be provided
  1378. in which to store them. {\em Local\/} means that their values are deleted as
  1379. soon as the block's operations are complete, and there is no conflict with
  1380. variables outside the block that happen to have the same name. Local
  1381. variables are created by a {\tt SCALAR}\ttindex{SCALAR} declaration
  1382. immediately after the {\tt BEGIN}:
  1383. {\small\begin{verbatim}
  1384. scalar a,b,c,z;
  1385. \end{verbatim}}
  1386. If more convenient, several {\tt SCALAR} declarations can be given one after
  1387. another:
  1388. {\small\begin{verbatim}
  1389. scalar a,b,c;
  1390. scalar z;
  1391. \end{verbatim}}
  1392. In place of {\tt SCALAR} one can also use the declarations
  1393. {\tt INTEGER}\ttindex{INTEGER} or {\tt REAL}\ttindex{REAL}. In the present
  1394. version of {\REDUCE} variables declared {\tt INTEGER} are expected to have
  1395. only integer values, and are initialized to 0. {\tt REAL}
  1396. variables on the other hand are currently treated as algebraic mode {\tt
  1397. SCALAR}s.
  1398. {\it CAUTION:} {\tt INTEGER}, {\tt REAL} and {\tt SCALAR} declarations can
  1399. only be given immediately after a {\tt BEGIN}. An error will result if
  1400. they are used after other statements in a block (including {\tt ARRAY} and
  1401. {\tt OPERATOR} declarations, which are global in scope), or outside the
  1402. top-most block (e.g., at the top level). All variables declared {\tt
  1403. SCALAR} are automatically initialized to zero in algebraic mode ({\tt NIL}
  1404. in symbolic mode).
  1405. Any symbols not declared as local variables in a block refer to the
  1406. variables of the same name in the current calling environment. In
  1407. particular, if they are not so declared at a higher level (e.g., in a
  1408. surrounding block or as parameters in a calling procedure), their values can
  1409. be permanently changed.
  1410. Following the {\tt SCALAR}\ttindex{SCALAR} declaration(s), if any, write the
  1411. statements to be executed, one after the other, separated by delimiters
  1412. (e.g., {\tt ;} or {\tt \$}) (it doesn't matter which). However, from a
  1413. stylistic point of view, {\tt ;} is preferred.
  1414. The last statement in the body, just before {\tt END}, need not have a
  1415. terminator (since the {\tt BEGIN \ldots END} are in a sense brackets
  1416. confining the block statements). The last statement must also be the
  1417. command {\tt RETURN}\ttindex{RETURN} followed by the variable or
  1418. expression whose value is to be the value returned by the procedure. If
  1419. the {\tt RETURN} is omitted (or nothing is written after the word
  1420. {\tt RETURN}) the procedure will have no value or the value zero, depending
  1421. on how it is used (and {\tt NIL} in symbolic mode). Remember to put a
  1422. terminator after the {\tt END}.
  1423. {\it Example:}
  1424. Given a previously assigned integer value for {\tt N}, the following block
  1425. will compute the Legendre polynomial of degree {\tt N} in the variable
  1426. {\tt X}:
  1427. {\small\begin{verbatim}
  1428. begin scalar seed,deriv,top,fact;
  1429. seed:=1/(y^2 - 2*x*y +1)^(1/2);
  1430. deriv:=df(seed,y,n);
  1431. top:=sub(y=0,deriv);
  1432. fact:=for i:=1:n product i;
  1433. return top/fact
  1434. end;
  1435. \end{verbatim}}
  1436. \subsection{Compound Statements with GO TO}
  1437. It is possible to have more complicated structures inside the {\tt BEGIN
  1438. \ldots END}\ttindex{BEGIN \ldots END} brackets than indicated in the
  1439. previous example. That the individual lines of the program need not be
  1440. assignment\index{Assignment} statements, but could be almost any other
  1441. kind of statement or command, needs no explanation. For example,
  1442. conditional statements, and {\tt WHILE}\ttindex{WHILE} and {\tt REPEAT}
  1443. \ttindex{REPEAT} constructions, have an obvious role in defining more
  1444. intricate blocks.
  1445. If these structured constructs don't suffice, it is possible to use labels
  1446. \index{Label} and {\tt GO} {\tt TO}s\ttindex{GO TO} within a compound
  1447. statement,\index{Compound statement} and also to use {\tt RETURN}
  1448. \ttindex{RETURN} in places within the block other than just before the
  1449. {\tt END}. The following subsections discuss these matters in detail.
  1450. For many readers the following example, presenting one possible definition
  1451. of a process to calculate the factorial of {\tt N} for preassigned {\tt N}
  1452. will suffice:
  1453. {\it Example:}
  1454. {\small\begin{verbatim}
  1455. begin scalar m;
  1456. m:=1;
  1457. l: if n=0 then return m;
  1458. m:=m*n;
  1459. n:=n-1;
  1460. go to l
  1461. end;
  1462. \end{verbatim}}
  1463. \subsection{Labels and GO TO Statements}
  1464. \index{Label}\ttindex{GO TO}Within a {\tt BEGIN \ldots END} compound
  1465. statement it is possible to label statements, and transfer to them out of
  1466. sequence using {\tt GO} {\tt TO} statements. Only statements on the top
  1467. level inside compound statements can be labeled, not ones inside
  1468. subsidiary constructions like {\tt $<<$} \ldots {\tt $>>$}, {\tt IF} \ldots
  1469. {\tt THEN} \ldots , {\tt WHILE} \ldots {\tt DO} \ldots , etc.
  1470. Labels and {\tt GO TO} statements have the syntax:
  1471. {\small\begin{verbatim}
  1472. <go to statement> ::= GO TO <label> | GOTO <label>
  1473. <label> ::= <identifier>
  1474. <labeled statement> ::= <label>:<statement>
  1475. \end{verbatim}}
  1476. Note that statement names cannot be used as labels.
  1477. While {\tt GO TO} is an unconditional transfer, it is frequently used
  1478. in conditional statements such as
  1479. {\small\begin{verbatim}
  1480. if x>5 then go to abcd;
  1481. \end{verbatim}}
  1482. giving the effect of a conditional transfer.
  1483. Transfers using {\tt GO TO}s can only occur within the block in which the
  1484. {\tt GO TO} is used. In other words, you cannot transfer from an inner
  1485. block to an outer block using a {\tt GO TO}. However, if a group statement
  1486. occurs within a compound statement, it is possible to jump out of that group
  1487. statement to a point within the compound statement using a {\tt GO TO}.
  1488. \subsection{RETURN Statements}
  1489. The value corresponding to a {\tt BEGIN \ldots END} compound statement,
  1490. \ttindex{BEGIN \ldots END} such as a procedure body, is normally 0 ({\tt
  1491. NIL} in symbolic mode). By executing a {\tt RETURN}\ttindex{RETURN}
  1492. statement in the compound statement a different value can be returned.
  1493. After a {\tt RETURN} statement is executed, no further statements within
  1494. the compound statement are executed.
  1495. {\tt Examples:}
  1496. {\small\begin{verbatim}
  1497. return x+y;
  1498. return m;
  1499. return;
  1500. \end{verbatim}}
  1501. Note that parentheses are not required around the {\tt x+y}, although they
  1502. are permitted. The last example is equivalent to {\tt return 0} or {\tt
  1503. return nil}, depending on whether the block is used as part of an
  1504. expression or not.
  1505. Since {\tt RETURN}\ttindex{RETURN} actually moves up only one
  1506. block\index{Block} level, in a sense the casual user is not expected to
  1507. understand, we tabulate some cautions concerning its use.
  1508. \begin{enumerate}
  1509. \item {\tt RETURN} can be used on the top level inside the compound
  1510. statement, i.e. as one of the statements bracketed together by the {\tt
  1511. BEGIN \ldots END}\ttindex{BEGIN \ldots END}
  1512. \item {\tt RETURN} can be used within a top level {\tt $<<$} \ldots {\tt
  1513. $>>$} construction within the compound statement. In this case, the {\tt
  1514. RETURN} transfers control out of both the group statement and the compound
  1515. statement.
  1516. \item {\tt RETURN} can be used within an {\tt IF} \ldots {\tt THEN} \ldots
  1517. {\tt ELSE} \ldots on the top level within the compound statement.
  1518. \end{enumerate}
  1519. NOTE: At present, there is no construct provided to permit early
  1520. termination of a {\tt FOR}\ttindex{FOR}, {\tt WHILE}\ttindex{WHILE},
  1521. or {\tt REPEAT}\ttindex{REPEAT} statement. In particular, the use of
  1522. {\tt RETURN} in such cases results in a syntax error. For example,
  1523. {\small\begin{verbatim}
  1524. begin scalar y;
  1525. y := for i:=0:99 do if a(i)=x then return b(i);
  1526. ...
  1527. \end{verbatim}}
  1528. will lead to an error.
  1529. \chapter{Commands and Declarations}
  1530. A command\index{Command} is an order to the system to do something. Some
  1531. commands cause visible results (such as calling for input or output);
  1532. others, usually called declarations\index{Declaration}, set options,
  1533. define properties of variables, or define procedures. Commands are
  1534. formally defined as a statement followed by a terminator
  1535. {\small\begin{verbatim}
  1536. <command> ::= <statement> <terminator>
  1537. <terminator> ::= ;|$
  1538. \end{verbatim}}
  1539. Some {\REDUCE} commands and declarations are described in the following
  1540. sub-sections.
  1541. \section{Array Declarations}
  1542. Array\ttindex{ARRAY} declarations in {\REDUCE} are similar to FORTRAN
  1543. dimension statements. For example:
  1544. {\small\begin{verbatim}
  1545. array a(10),b(2,3,4);
  1546. \end{verbatim}}
  1547. Array indices each range from 0 to the value declared. An element of an
  1548. array is referred to in standard FORTRAN notation, e.g. {\tt A(2)}.
  1549. We can also use an expression for defining an array bound, provided the
  1550. value of the expression is a positive integer. For example, if {\tt X} has the
  1551. value 10 and {\tt Y} the value 7 then
  1552. {\tt array c(5*x+y)} is the same as {\tt array c(57)}.
  1553. If an array is referenced by an index outside its range, an error occurs.
  1554. If the array is to be one-dimensional, and the bound a number or a variable
  1555. (not a more general expression) the parentheses may be omitted:
  1556. {\small\begin{verbatim}
  1557. array a 10, c 57;
  1558. \end{verbatim}}
  1559. The operator {\tt LENGTH}\ttindex{LENGTH} applied to an array name
  1560. returns a list of its dimensions.
  1561. All array elements are initialized to 0 at declaration time. In other words,
  1562. an array element has an {\em instant evaluation\/}\index{Instant evaluation}
  1563. property and cannot stand for itself. If this is required, then an
  1564. operator should be used instead.
  1565. Array declarations can appear anywhere in a program. Once a symbol is
  1566. declared to name an array, it can not also be used as a variable, or to
  1567. name an operator or a procedure. It can however be re-declared to be an
  1568. array, and its size may be changed at that time. An array name can also
  1569. continue to be used as a parameter in a procedure, or a local variable in
  1570. a compound statement, although this use is not recommended, since it can
  1571. lead to user confusion over the type of the variable.
  1572. Arrays once declared are global in scope, and so can then be referenced
  1573. anywhere in the program. In other words, unlike arrays in most other
  1574. languages, a declaration within a block (or a procedure) does not limit
  1575. the scope of the array to that block, nor does the array go away on
  1576. exiting the block (use {\tt CLEAR} instead for this purpose).
  1577. \section{Mode Handling Declarations}\index{Mode}
  1578. The {\tt ON}\ttindex{ON} and {\tt OFF}\ttindex{OFF} declarations are
  1579. available to the user for controlling various system options. Each option
  1580. is represented by a {\em switch\/}\index{Switch} name. {\tt ON} and {\tt OFF}
  1581. take a list of switch names as argument and turn them on and off
  1582. respectively, e.g.,
  1583. {\small\begin{verbatim}
  1584. on time;
  1585. \end{verbatim}}
  1586. causes the system to print a message after each command giving the elapsed
  1587. CPU time since the last command, or since {\tt TIME}\ttindex{TIME} was
  1588. last turned off, or the session began. Another useful switch with
  1589. interactive use is {\tt DEMO},\ttindex{DEMO} which causes the system to
  1590. pause after each command in a file (with the exception of comments)
  1591. until a \key{Return} is typed on the terminal. This
  1592. enables a user to set up a demonstration file and step through it command
  1593. by command.
  1594. As with most declarations, arguments to {\tt ON} and {\tt OFF} may be
  1595. strung together separated by commas. For example,
  1596. {\small\begin{verbatim}
  1597. off time,demo;
  1598. \end{verbatim}}
  1599. will turn off both the time messages and the demonstration switch.
  1600. We note here that while most {\tt ON} and {\tt OFF} commands are obeyed
  1601. almost instantaneously, some trigger time-consuming actions such as
  1602. reading in necessary modules from secondary storage.
  1603. A diagnostic message is printed if {\tt ON}\ttindex{ON} or {\tt OFF}
  1604. \ttindex{OFF} are used with a switch that is not known to the system. For
  1605. example, if you misspell {\tt DEMO} and type
  1606. {\small\begin{verbatim}
  1607. on demq;
  1608. \end{verbatim}}
  1609. you will get the message\index{Switch}
  1610. {\small\begin{verbatim}
  1611. ***** DEMQ not defined as switch.
  1612. \end{verbatim}}
  1613. \section{END}
  1614. The identifier {\tt END}\ttindex{END} has two separate uses.
  1615. 1) Its use in a {\tt BEGIN \ldots END} bracket has been discussed in
  1616. connection with compound statements.
  1617. 2) Files to be read using {\tt IN} should end with an extra {\tt END};
  1618. command. The reason for this is explained in the section on the {\tt IN}
  1619. command. This use of {\tt END} does not allow an immediately
  1620. preceding {\tt END} (such as the {\tt END} of a procedure definition), so
  1621. we advise using {\tt ;END;} there.
  1622. %3) A command {\tt END}; entered at the top level transfers control to the
  1623. %Lisp system\index{Lisp} which is the host of the {\REDUCE} system. All
  1624. %files opened by {\tt IN} or {\tt OUT} statements are closed in the
  1625. %process. {\tt END;} does not stop {\REDUCE}. Those familiar with Lisp can
  1626. %experiment with typing identifiers and ({\tt <function name> <argument
  1627. %list>}) lists to see the value returned by Lisp. (No terminators, other
  1628. %than the RETURN key, should be used.) The data structures created during
  1629. %the {\REDUCE} run are accessible.
  1630. %You remain in this Lisp mode until you explicitly re-enter {\REDUCE} by
  1631. %saying {\tt (BEGIN)} at the Lisp top level. In most systems, a Lisp error
  1632. %also returns you to {\REDUCE} (exceptions are noted in the operating
  1633. %instructions for your particular {\REDUCE} implementation). In either
  1634. %case, you will return to {\REDUCE} in the same mode, algebraic or
  1635. %symbolic, that you were in before the {\tt END};. If you are in
  1636. %Lisp mode\index{Lisp mode} by mistake -- which is usually the case,
  1637. %the result of typing more {\tt END}s\ttindex{END} than {\tt BEGIN}s --
  1638. %type {\tt (BEGIN)} in parentheses and hit the RETURN key.
  1639. \section{BYE Command}\ttindex{BYE}
  1640. The command {\tt BYE}; (or alternatively {\tt QUIT};)\ttindex{QUIT}
  1641. stops the execution
  1642. of {\REDUCE}, closes all open output files, and returns you to the calling
  1643. program (usually the operating system). Your {\REDUCE} session is
  1644. normally destroyed.
  1645. \section{SHOWTIME Command}\ttindex{SHOWTIME}
  1646. {\tt SHOWTIME}; prints the elapsed time since the last call of this
  1647. command or, on its first call, since the current {\REDUCE} session began.
  1648. The time is normally given in milliseconds and gives the time as measured
  1649. by a system clock. The operations covered by this measure are system
  1650. dependent.
  1651. \section{DEFINE Command}
  1652. The command {\tt DEFINE}\ttindex{DEFINE} allows a user to supply a new name for
  1653. any identifier or replace it by any well-formed expression. Its argument
  1654. is a list of expressions of the form
  1655. {\small\begin{verbatim}
  1656. <identifier> = <number>|<identifier>|<operator>|
  1657. <reserved word>|<expression>
  1658. \end{verbatim}}
  1659. {\it Example:}
  1660. {\small\begin{verbatim}
  1661. define be==,x=y+z;
  1662. \end{verbatim}}
  1663. means that {\tt BE} will be interpreted as an equal sign, and {\tt X}
  1664. as the expression {\tt y+z} from then on. This renaming is done at parse
  1665. time, and therefore takes precedence over any other replacement declared
  1666. for the same identifier. It stays in effect until the end of the
  1667. {\REDUCE} run.
  1668. The identifiers {\tt ALGEBRAIC} and {\tt SYMBOLIC} have properties which
  1669. prevent {\tt DEFINE}\ttindex{DEFINE} from being used on them. To define
  1670. {\tt ALG} to be a synonym for {\tt ALGEBRAIC}, use the more complicated
  1671. construction
  1672. {\small\begin{verbatim}
  1673. put('alg,'newnam,'algebraic);
  1674. \end{verbatim}}
  1675. \chapter{Built-in Prefix Operators}
  1676. In the following subsections are descriptions of the most useful prefix
  1677. \index{Prefix}
  1678. operators built into {\REDUCE} that are not defined in other sections (such
  1679. as substitution operators). Some are fully defined internally as
  1680. procedures; others are more nearly abstract operators, with only some of
  1681. their properties known to the system.
  1682. In many cases, an operator is described by a prototypical header line as
  1683. follows. Each formal parameter is given a name and followed by its allowed
  1684. type. The names of classes referred to in the definition are printed in
  1685. lower case, and parameter names in upper case. If a parameter type is not
  1686. commonly used, it may be a specific set enclosed in brackets {\tt \{} \ldots
  1687. {\tt \}}.
  1688. Operators that accept formal parameter lists of arbitrary length have the
  1689. parameter and type class enclosed in square brackets indicating that zero
  1690. or more occurrences of that argument are permitted. Optional parameters
  1691. and their type classes are enclosed in angle brackets.
  1692. \section{Numerical Operators}\index{Numerical operator}
  1693. {\REDUCE} includes a number of functions that are analogs of those found
  1694. in most numerical systems. With numerical arguments, such functions
  1695. return the expected result. However, they may also be called with
  1696. non-numerical arguments. In such cases, except where noted, the system
  1697. attempts to simplify the expression as far as it can. In such cases, a
  1698. residual expression involving the original operator usually remains.
  1699. These operators are as follows:
  1700. \subsection{ABS}
  1701. {\tt ABS}\ttindex{ABS} returns the absolute value
  1702. of its single argument, if that argument has a numerical value.
  1703. A non-numerical argument is returned as an absolute value, with an overall
  1704. numerical coefficient taken outside the absolute value operator. For example:
  1705. {\small\begin{verbatim}
  1706. abs(-3/4) -> 3/4
  1707. abs(2a) -> 2*ABS(A)
  1708. abs(i) -> 1
  1709. abs(-x) -> ABS(X)
  1710. \end{verbatim}}
  1711. \subsection{CEILING}\ttindex{CEILING}
  1712. This operator returns the ceiling (i.e., the least integer greater than
  1713. the given argument) if its single argument has a numerical value. A
  1714. non-numerical argument is returned as an expression in the original
  1715. operator. For example:
  1716. {\small\begin{verbatim}
  1717. ceiling(-5/4) -> -1
  1718. ceiling(-a) -> CEILING(-A)
  1719. \end{verbatim}}
  1720. \subsection{CONJ}\ttindex{CONJ}
  1721. This returns the complex conjugate
  1722. of an expression, if that argument has an numerical value. A
  1723. non-numerical argument is returned as an expression in the operators
  1724. {\tt REPART}\ttindex{REPART} and {\tt IMPART}\ttindex{IMPART}. For example:
  1725. {\small\begin{verbatim}
  1726. conj(1+i) -> 1-I
  1727. conj(a+i*b) -> REPART(A) - REPART(B)*I - IMPART(A)*I
  1728. - IMPART(B)
  1729. \end{verbatim}}
  1730. \subsection{FACTORIAL}\ttindex{FACTORIAL}
  1731. If the single argument of {\tt FACTORIAL} evaluates to a non-negative
  1732. integer, its factorial is returned. Otherwise an expression involving
  1733. {\tt FACTORIAL} is returned. For example:
  1734. {\small\begin{verbatim}
  1735. factorial(5) -> 120
  1736. factorial(a) -> FACTORIAL(A)
  1737. \end{verbatim}}
  1738. \subsection{FIX}\ttindex{FIX}
  1739. This operator returns the fixed value (i.e., the integer part of
  1740. the given argument) if its single argument has a numerical value. A
  1741. non-numerical argument is returned as an expression in the original
  1742. operator. For example:
  1743. {\small\begin{verbatim}
  1744. fix(-5/4) -> -1
  1745. fix(a) -> FIX(A)
  1746. \end{verbatim}}
  1747. \subsection{FLOOR}\ttindex{FLOOR}
  1748. This operator returns the floor (i.e., the greatest integer less than
  1749. the given argument) if its single argument has a numerical value. A
  1750. non-numerical argument is returned as an expression in the original
  1751. operator. For example:
  1752. {\small\begin{verbatim}
  1753. floor(-5/4) -> -2
  1754. floor(a) -> FLOOR(A)
  1755. \end{verbatim}}
  1756. \subsection{IMPART}\ttindex{IMPART}
  1757. This operator returns the imaginary part of an expression, if that argument
  1758. has an numerical value. A non-numerical argument is returned as an expression
  1759. in the operators {\tt REPART}\ttindex{REPART} and {\tt IMPART}. For example:
  1760. {\small\begin{verbatim}
  1761. impart(1+i) -> 1
  1762. impart(a+i*b) -> REPART(B) + IMPART(A)
  1763. \end{verbatim}}
  1764. \subsection{MAX/MIN}
  1765. {\tt MAX} and {\tt MIN}\ttindex{MAX}\ttindex{MIN} can take an arbitrary
  1766. number of expressions as their arguments. If all arguments evaluate to
  1767. numerical values, the maximum or minimum of the argument list is returned.
  1768. If any argument is non-numeric, an appropriately reduced expression is
  1769. returned. For example:
  1770. {\small\begin{verbatim}
  1771. max(2,-3,4,5) -> 5
  1772. min(2,-2) -> -2.
  1773. max(a,2,3) -> MAX(A,3)
  1774. min(x) -> X
  1775. \end{verbatim}}
  1776. {\tt MAX} or {\tt MIN} of an empty list returns 0.
  1777. \subsection{NEXTPRIME}\ttindex{NEXTPRIME}
  1778. {\tt NEXTPRIME} returns the next prime greater than its integer argument,
  1779. using a probabilistic algorithm. A type error occurs if the value of the
  1780. argument is not an integer. For example:
  1781. {\small\begin{verbatim}
  1782. nextprime(5) -> 7
  1783. nextprime(-2) -> 2
  1784. nextprime(-7) -> -5
  1785. nextprime 1000000 -> 1000003
  1786. \end{verbatim}}
  1787. whereas {\tt nextprime(a)} gives a type error.
  1788. \subsection{RANDOM}\ttindex{RANDOM}
  1789. {\tt random(}{\em n\/}{\tt)} returns a random number $r$ in the range $0
  1790. \leq r < n$. A type error occurs if the value of the argument is not a
  1791. positive integer in algebraic mode, or positive number in symbolic mode.
  1792. For example:
  1793. {\small\begin{verbatim}
  1794. random(5) -> 3
  1795. random(1000) -> 191
  1796. \end{verbatim}}
  1797. whereas {\tt random(a)} gives a type error.
  1798. \subsection{RANDOM\_NEW\_SEED}\ttindex{RANDOM\_NEW\_SEED}
  1799. {\tt random\_new\_seed(}{\em n\/}{\tt)} reseeds the random number generator
  1800. to a sequence determined by the integer argument $n$. It can be used to
  1801. ensure that a repeatable pseudo-random sequence will be delivered
  1802. regardless of any previous use of {\tt RANDOM}, or can be called early in
  1803. a run with an argument derived from something variable (such as the time
  1804. of day) to arrange that different runs of a REDUCE program will use
  1805. different random sequences. When a fresh copy of REDUCE is first created
  1806. it is as if {\tt random\_new\_seed(1)} has been obeyed.
  1807. A type error occurs if the value of the argument is not a positive integer.
  1808. \subsection{REPART}\ttindex{REPART}
  1809. This returns the real part of an expression, if that argument has an
  1810. numerical value. A non-numerical argument is returned as an expression in
  1811. the operators {\tt REPART} and {\tt IMPART}\ttindex{IMPART}. For example:
  1812. {\small\begin{verbatim}
  1813. repart(1+i) -> 1
  1814. repart(a+i*b) -> REPART(A) - IMPART(B)
  1815. \end{verbatim}}
  1816. \subsection{ROUND}\ttindex{ROUND}
  1817. This operator returns the rounded value (i.e, the nearest integer) of its
  1818. single argument if that argument has a numerical value. A non-numeric
  1819. argument is returned as an expression in the original operator. For
  1820. example:
  1821. {\small\begin{verbatim}
  1822. round(-5/4) -> -1
  1823. round(a) -> ROUND(A)
  1824. \end{verbatim}}
  1825. \subsection{SIGN}\ttindex{SIGN}
  1826. {\tt SIGN} tries to evaluate the sign of its argument. If this
  1827. is possible {\tt SIGN} returns one of 1, 0 or -1. Otherwise, the result
  1828. is the original form or a simplified variant. For example:
  1829. {\small\begin{verbatim}
  1830. sign(-5) -> -1
  1831. sign(-a^2*b) -> -SIGN(B)
  1832. \end{verbatim}}
  1833. Note that even powers of formal expressions are assumed to be
  1834. positive only as long as the switch {\tt COMPLEX} is off.
  1835. \section{Mathematical Functions}
  1836. {\REDUCE} knows that the following represent mathematical functions
  1837. \index{Mathematical function} that can
  1838. take arbitrary scalar expressions as their single argument:
  1839. {\small\begin{verbatim}
  1840. ACOS ACOSH ACOT ACOTH ACSC ACSCH ASEC ASECH ASIN ASINH
  1841. ATAN ATANH ATAN2 COS COSH COT COTH CSC CSCH DILOG EI EXP
  1842. HYPOT LN LOG LOGB LOG10 SEC SECH SIN SINH SQRT TAN TANH
  1843. \end{verbatim}}
  1844. \ttindex{ACOS}\ttindex{ACOSH}\ttindex{ACOT}
  1845. \ttindex{ACOTH}\ttindex{ACSC}\ttindex{ACSCH}\ttindex{ASEC}
  1846. \ttindex{ASECH}\ttindex{ASIN}
  1847. \ttindex{ASINH}\ttindex{ATAN}\ttindex{ATANH}
  1848. \ttindex{ATAN2}\ttindex{COS}
  1849. \ttindex{COSH}\ttindex{COT}\ttindex{COTH}\ttindex{CSC}
  1850. \ttindex{CSCH}\ttindex{DILOG}\ttindex{Ei}\ttindex{EXP}
  1851. \ttindex{HYPOT}\ttindex{LN}\ttindex{LOG}\ttindex{LOGB}\ttindex{LOG10}
  1852. \ttindex{SEC}\ttindex{SECH}\ttindex{SIN}
  1853. \ttindex{SINH}\ttindex{SQRT}\ttindex{TAN}\ttindex{TANH}
  1854. where {\tt LOG} is the natural logarithm (and equivalent to {\tt LN}),
  1855. and {\tt LOGB} has two arguments of which the second is the logarithmic base.
  1856. The derivatives of all these functions are also known to the system.
  1857. {\REDUCE} knows various elementary identities and properties
  1858. of these functions. For example:
  1859. {\small\begin{verbatim}
  1860. cos(-x) = cos(x) sin(-x) = - sin (x)
  1861. cos(n*pi) = (-1)^n sin(n*pi) = 0
  1862. log(e) = 1 e^(i*pi/2) = i
  1863. log(1) = 0 e^(i*pi) = -1
  1864. log(e^x) = x e^(3*i*pi/2) = -i
  1865. \end{verbatim}}
  1866. Beside these identities, there are a lot of simplifications
  1867. for elementary functions
  1868. defined in the {\REDUCE} system as rulelists. In order to
  1869. view these, the SHOWRULES operator can be used, e.g.
  1870. {\small\begin{verbatim}
  1871. SHOWRULES tan;
  1872. {tan(~n*arbint(~i)*pi + ~(~ x)) => tan(x) when fixp(n),
  1873. tan(~x)
  1874. => trigquot(sin(x),cos(x)) when knowledge_about(sin,x,tan)
  1875. ,
  1876. ~x + ~(~ k)*pi
  1877. tan(----------------)
  1878. ~d
  1879. x k 1
  1880. => - cot(---) when x freeof pi and abs(---)=---,
  1881. d d 2
  1882. ~(~ w) + ~(~ k)*pi w + remainder(k,d)*pi
  1883. tan(--------------------) => tan(-----------------------)
  1884. ~(~ d) d
  1885. k
  1886. when w freeof pi and ratnump(---) and fixp(k)
  1887. d
  1888. k
  1889. and abs(---)>=1,
  1890. d
  1891. tan(atan(~x)) => x,
  1892. 2
  1893. df(tan(~x),~x) => 1 + tan(x) }
  1894. \end{verbatim}}
  1895. For further simplification, especially of expressions involving
  1896. trigonometric functions, see the TRIGSIMP\ttindex{TRIGSIMP} package
  1897. documentation.
  1898. Functions not listed above may be defined in the special functions
  1899. package SPECFN\ttindex{SPECFN}.
  1900. The user can add further rules for the reduction of expressions involving
  1901. these operators by using the {\tt LET}\ttindex{LET} command.
  1902. % The square root function can be input using the name {\tt SQRT}, or the
  1903. % power operation {\tt \verb|^|(1/2)}. On output, unsimplified square roots
  1904. % are normally represented by the operator {\tt SQRT} rather than a
  1905. % fractional power.
  1906. In many cases it is desirable to expand product arguments of logarithms,
  1907. or collect a sum of logarithms into a single logarithm. Since these are
  1908. inverse operations, it is not possible to provide rules for doing both at
  1909. the same time and preserve the {\REDUCE} concept of idempotent evaluation.
  1910. As an alternative, REDUCE provides two switches {\tt EXPANDLOGS}
  1911. \ttindex{EXPANDLOGS} and {\tt COMBINELOGS}\ttindex{COMBINELOGS} to carry
  1912. out these operations. Both are off by default. Thus to expand {\tt
  1913. LOG(X*Y)} into a sum of logs, one can say
  1914. {\small\begin{verbatim}
  1915. ON EXPANDLOGS; LOG(X*Y);
  1916. \end{verbatim}}
  1917. and to combine this sum into a single log:
  1918. {\small\begin{verbatim}
  1919. ON COMBINELOGS; LOG(X) + LOG(Y);
  1920. \end{verbatim}}
  1921. At the present time, it is possible to have both switches on at once,
  1922. which could lead to infinite recursion. However, an expression is
  1923. switched from one form to the other in this case. Users should not rely
  1924. on this behavior, since it may change in the next release.
  1925. The current version of {\REDUCE} does a poor job of simplifying surds. In
  1926. particular, expressions involving the product of variables raised to
  1927. non-integer powers do not usually have their powers combined internally,
  1928. even though they are printed as if those powers were combined. For
  1929. example, the expression
  1930. {\small\begin{verbatim}
  1931. x^(1/3)*x^(1/6);
  1932. \end{verbatim}}
  1933. will print as
  1934. {\small\begin{verbatim}
  1935. SQRT(X)
  1936. \end{verbatim}}
  1937. but will have an internal form containing the two exponentiated terms.
  1938. If you now subtract {\tt sqrt(x)} from this expression, you will {\em not\/}
  1939. get zero. Instead, the confusing form
  1940. {\small\begin{verbatim}
  1941. SQRT(X) - SQRT(X)
  1942. \end{verbatim}}
  1943. will result. To combine such exponentiated terms, the switch
  1944. {\tt COMBINEEXPT}\ttindex{COMBINEEXPT} should be turned on.
  1945. The square root function can be input using the name {\tt SQRT}, or the
  1946. power operation {\tt \verb|^|(1/2)}. On output, unsimplified square roots
  1947. are normally represented by the operator {\tt SQRT} rather than a
  1948. fractional power. With the default system switch settings, the argument
  1949. of a square root is first simplified, and any divisors of the expression
  1950. that are perfect squares taken outside the square root argument. The
  1951. remaining expression is left under the square root.
  1952. % However, if the switch {\tt REDUCED}\ttindex{REDUCED} is on,
  1953. % multiplicative factors in the argument of the square root are also
  1954. % separated, becoming individual square roots. Thus with {\tt REDUCED} off,
  1955. Thus the expression
  1956. {\small\begin{verbatim}
  1957. sqrt(-8a^2*b)
  1958. \end{verbatim}}
  1959. becomes
  1960. {\small\begin{verbatim}
  1961. 2*a*sqrt(-2*b).
  1962. \end{verbatim}}
  1963. % whereas with {\tt REDUCED} on, it would become
  1964. % {\small\begin{verbatim}
  1965. % 2*a*i*sqrt(2)*sqrt(b) .
  1966. % \end{verbatim}}
  1967. % The switch {\tt REDUCED}\ttindex{REDUCED} also applies to other rational
  1968. % powers in addition to square roots.
  1969. Note that such simplifications can cause trouble if {\tt A} is eventually
  1970. given a value that is a negative number. If it is important that the
  1971. positive property of the square root and higher even roots always be
  1972. preserved, the switch {\tt PRECISE}\ttindex{PRECISE} should be set on
  1973. (the default value).
  1974. This causes any non-numerical factors taken out of surds to be represented
  1975. by their absolute value form.
  1976. With % both {\tt REDUCED} and
  1977. {\tt PRECISE} on then, the above example would become
  1978. {\small\begin{verbatim}
  1979. 2*abs(a)*sqrt(-2*b).
  1980. \end{verbatim}}
  1981. The statement that {\REDUCE} knows very little about these functions
  1982. applies only in the mathematically exact {\tt off rounded} mode. If
  1983. {\tt ROUNDED}\ttindex{ROUNDED} is on, any of the functions
  1984. {\small\begin{verbatim}
  1985. ACOS ACOSH ACOT ACOTH ACSC ACSCH ASEC ASECH ASIN ASINH
  1986. ATAN ATANH ATAN2 COS COSH COT COTH CSC CSCH EXP HYPOT
  1987. LN LOG LOGB LOG10 SEC SECH SIN SINH SQRT TAN TANH
  1988. \end{verbatim}}
  1989. \ttindex{ACOS}\ttindex{ACOSH}\ttindex{ACOT}\ttindex{ACOTH}
  1990. \ttindex{ACSC}\ttindex{ACSCH}\ttindex{ASEC}\ttindex{ASECH}
  1991. \ttindex{ASIN}\ttindex{ASINH}\ttindex{ATAN}\ttindex{ATANH}
  1992. \ttindex{ATAN2}\ttindex{COS}\ttindex{COSH}\ttindex{COT}
  1993. \ttindex{COTH}\ttindex{CSC}\ttindex{CSCH}\ttindex{EXP}\ttindex{HYPOT}
  1994. \ttindex{LN}\ttindex{LOG}\ttindex{LOGB}\ttindex{LOG10}\ttindex{SEC}
  1995. \ttindex{SECH}\ttindex{SIN}\ttindex{SINH}\ttindex{SQRT}\ttindex{TAN}
  1996. \ttindex{TANH}
  1997. when given a numerical argument has its value calculated to the current
  1998. degree of floating point precision. In addition, real (non-integer
  1999. valued) powers of numbers will also be evaluated.
  2000. If the {\tt COMPLEX} switch is turned on in addition to {\tt ROUNDED},
  2001. these functions will also calculate a real or complex result, again to
  2002. the current degree of floating point precision,
  2003. if given complex arguments. For example, with {\tt on rounded,complex;}
  2004. {\small\begin{verbatim}
  2005. 2.3^(5.6i) -> -0.0480793490914 - 0.998843519372*I
  2006. cos(2+3i) -> -4.18962569097 - 9.10922789376*I
  2007. \end{verbatim}}
  2008. \section{DF Operator}
  2009. The operator {\tt DF}\ttindex{DF} is used to represent partial
  2010. differentiation\index{Differentiation} with respect
  2011. to one or more variables. It is used with the syntax:
  2012. {\small\begin{verbatim}
  2013. DF(EXPRN:algebraic[,VAR:kernel<,NUM:integer>]):algebraic.
  2014. \end{verbatim}}
  2015. The first argument is the expression to be differentiated. The remaining
  2016. arguments specify the differentiation variables and the number of times
  2017. they are applied.
  2018. The number {\tt NUM} may be omitted if it is 1. For example,
  2019. \begin{quote}
  2020. \begin{tabbing}
  2021. {\tt df(y,x1,2,x2,x3,2)} \= = $\partial^{5}y/\partial x_{1}^{2} \
  2022. \partial x_{2}\partial x_{3}^{2}.$\kill
  2023. {\tt df(y,x)} \> = $\partial y/\partial x$ \\
  2024. {\tt df(y,x,2)} \> = $\partial^{2}y/\partial x^{2}$ \\
  2025. {\tt df(y,x1,2,x2,x3,2)} \> = $\partial^{5}y/\partial x_{1}^{2} \
  2026. \partial x_{2}\partial x_{3}^{2}.$
  2027. \end{tabbing}
  2028. \end{quote}
  2029. The evaluation of {\tt df(y,x)} proceeds as follows: first, the values of
  2030. {\tt Y} and {\tt X} are found. Let us assume that {\tt X} has no assigned
  2031. value, so its value is {\tt X}. Each term or other part of the value of
  2032. {\tt Y} that contains the variable {\tt X} is differentiated by the
  2033. standard rules. If {\tt Z} is another variable, not {\tt X} itself, then
  2034. its derivative with respect to {\tt X} is taken to be 0, unless {\tt Z}
  2035. has previously been declared to {\tt DEPEND} on {\tt X}, in which
  2036. case the derivative is reported as the symbol {\tt df(z,x)}.
  2037. \subsection{Adding Differentiation Rules}
  2038. The {\tt LET}\ttindex{LET} statement can be used to introduce
  2039. rules for differentiation of user-defined operators. Its general form is
  2040. {\small\begin{verbatim}
  2041. FOR ALL <var1>,...,<varn>
  2042. LET DF(<operator><varlist>,<vari>)=<expression>
  2043. \end{verbatim}}
  2044. where {\tt <varlist>} ::= ({\tt <var1>},\dots,{\tt <varn>}), and
  2045. {\tt <var1>},...,{\tt <varn>} are the dummy variable arguments of
  2046. {\tt <operator>}.
  2047. An analogous form applies to infix operators.
  2048. {\it Examples:}
  2049. {\small\begin{verbatim}
  2050. for all x let df(tan x,x)= 1 + tan(x)^2;
  2051. \end{verbatim}}
  2052. (This is how the tan differentiation rule appears in the {\REDUCE}
  2053. source.)
  2054. {\small\begin{verbatim}
  2055. for all x,y let df(f(x,y),x)=2*f(x,y),
  2056. df(f(x,y),y)=x*f(x,y);
  2057. \end{verbatim}}
  2058. Notice that all dummy arguments of the relevant operator must be declared
  2059. arbitrary by the {\tt FOR ALL} command, and that rules may be supplied for
  2060. operators with any number of arguments. If no differentiation rule
  2061. appears for an argument in an operator, the differentiation routines will
  2062. return as result an expression in terms of {\tt DF}\ttindex{DF}. For
  2063. example, if the rule for the differentiation with respect to the second
  2064. argument of {\tt F} is not supplied, the evaluation of {\tt df(f(x,z),z)}
  2065. would leave this expression unchanged. (No {\tt DEPEND} declaration
  2066. is needed here, since {\tt f(x,z)} obviously ``depends on'' {\tt Z}.)
  2067. Once such a rule has been defined for a given operator, any future
  2068. differentiation\index{Differentiation} rules for that operator must be
  2069. defined with the same number of arguments for that operator, otherwise we
  2070. get the error message
  2071. {\small\begin{verbatim}
  2072. Incompatible DF rule argument length for <operator>
  2073. \end{verbatim}}
  2074. \section{INT Operator}
  2075. {\tt INT}\ttindex{INT} is an operator in {\REDUCE} for indefinite
  2076. integration\index{Integration}\index{Indefinite integration} using a
  2077. combination of the Risch-Norman algorithm and pattern matching. It is
  2078. used with the syntax:
  2079. {\small\begin{verbatim}
  2080. INT(EXPRN:algebraic,VAR:kernel):algebraic.
  2081. \end{verbatim}}
  2082. This will return correctly the indefinite integral for expressions comprising
  2083. polynomials, log functions, exponential functions and tan and atan. The
  2084. arbitrary constant is not represented. If the integral cannot be done in
  2085. closed terms, it returns a formal integral for the answer in one of two ways:
  2086. \begin{enumerate}
  2087. \item It returns the input, {\tt INT(\ldots,\ldots)} unchanged.
  2088. \item It returns an expression involving {\tt INT}s of some
  2089. other functions (sometimes more complicated than
  2090. the original one, unfortunately).
  2091. \end{enumerate}
  2092. Rational functions can be integrated when the denominator is factorizable
  2093. by the program. In addition it will attempt to integrate expressions
  2094. involving error functions, dilogarithms and other trigonometric
  2095. expressions. In these cases it might not always succeed in finding the
  2096. solution, even if one exists.
  2097. {\it Examples:}
  2098. {\small\begin{verbatim}
  2099. int(log(x),x) -> X*(LOG(X) - 1),
  2100. int(e^x,x) -> E**X.
  2101. \end{verbatim}}
  2102. The program checks that the second argument is a variable and gives an
  2103. error if it is not.
  2104. {\it Note:} If the {\tt int} operator is called with 4 arguments,
  2105. {\REDUCE} will implicitly call the definite integration package (DEFINT)
  2106. and this package will interpret the third and fourth arguments as the lower
  2107. and upper limit of integration, respectively. For details, consult
  2108. the documentation on the DEFINT package.
  2109. \subsection{Options}
  2110. The switch {\tt TRINT} when on will trace the operation of the algorithm. It
  2111. produces a great deal of output in a somewhat illegible form, and is not
  2112. of much interest to the general user. It is normally off.
  2113. If the switch {\tt FAILHARD} is on the algorithm will terminate with an
  2114. error if the integral cannot be done in closed terms, rather than return a
  2115. formal integration form. {\tt FAILHARD} is normally off.
  2116. The switch {\tt NOLNR} suppresses the use of the linear properties of
  2117. integration in cases when the integral cannot be found in closed terms.
  2118. It is normally off.
  2119. \subsection{Advanced Use}
  2120. If a function appears in the integrand that is not one of the functions
  2121. {\tt EXP, ERF, TAN, ATAN, LOG, DILOG}\ttindex{EXP}\ttindex{ERF}
  2122. \ttindex{TAN}\ttindex{ATAN}\ttindex{LOG}\ttindex{DILOG}
  2123. then the algorithm will make an
  2124. attempt to integrate the argument if it can, differentiate it and reach a
  2125. known function. However the answer cannot be guaranteed in this case. If
  2126. a function is known to be algebraically independent of this set it can be
  2127. flagged transcendental by
  2128. {\small\begin{verbatim}
  2129. flag('(trilog),'transcendental);
  2130. \end{verbatim}}
  2131. in which case this function will be added to the permitted field
  2132. descriptors for a genuine decision procedure. If this is done the user is
  2133. responsible for the mathematical correctness of his actions.
  2134. The standard version does not deal with algebraic extensions. Thus
  2135. integration of expressions involving square roots and other like things
  2136. can lead to trouble. A contributed package that supports integration of
  2137. functions involving square roots is available, however
  2138. (ALGINT\extendedmanual{, chapter~\ref{ALGINT}}).
  2139. In addition there is a definite integration
  2140. package, DEFINT\extendedmanual{( chapter~\ref{DEFINT})}.
  2141. \subsection{References}
  2142. A. C. Norman \& P. M. A. Moore, ``Implementing the New Risch
  2143. Algorithm'', Proc. 4th International Symposium on Advanced
  2144. Comp. Methods in Theor. Phys., CNRS, Marseilles, 1977.
  2145. S. J. Harrington, ``A New Symbolic Integration System in Reduce'',
  2146. Comp. Journ. 22 (1979) 2.
  2147. A. C. Norman \& J. H. Davenport, ``Symbolic Integration --- The Dust
  2148. Settles?'', Proc. EUROSAM 79, Lecture Notes in Computer
  2149. Science 72, Springer-Verlag, Berlin Heidelberg New York
  2150. (1979) 398-407.
  2151. %\subsection{Definite Integration} \index{Definite integration}
  2152. %
  2153. %If {\tt INT} is used with the syntax
  2154. %
  2155. %{\small\begin{verbatim}
  2156. % INT(EXPRN:algebraic,VAR:kernel,LOWER:algebraic,UPPER:algebraic):algebraic.
  2157. %\end{verbatim}}
  2158. %
  2159. %The definite integral of {\tt EXPRN} with respect to {\tt VAR} is
  2160. %calculated between the limits {\tt LOWER} and {\tt UPPER}. In the present
  2161. %system, this is calculated either by pattern matching, or by first finding
  2162. %the indefinite integral, and then substituting the limits into this.
  2163. \section{LENGTH Operator}
  2164. {\tt LENGTH}\ttindex{LENGTH} is a generic operator for finding the
  2165. length of various objects in the system. The meaning depends on the type
  2166. of the object. In particular, the length of an algebraic expression is
  2167. the number of additive top-level terms its expanded representation.
  2168. {\it Examples:}
  2169. {\small\begin{verbatim}
  2170. length(a+b) -> 2
  2171. length(2) -> 1.
  2172. \end{verbatim}}
  2173. Other objects that support a length operator include arrays, lists and
  2174. matrices. The explicit meaning in these cases is included in the description
  2175. of these objects.
  2176. \section{MAP Operator}\ttindex{MAP}
  2177. The {\tt MAP} operator applies a uniform evaluation pattern to all members
  2178. of a composite structure: a matrix, a list, or the arguments of an
  2179. operator expression. The evaluation pattern can be a unary procedure, an
  2180. operator, or an algebraic expression with one free variable.
  2181. It is used with the syntax:
  2182. {\small\begin{verbatim}
  2183. MAP(U:function,V:object)
  2184. \end{verbatim}}
  2185. Here {\tt object} is a list, a matrix or an operator expression.
  2186. {\tt Function} can be one of the following:
  2187. \begin{enumerate}
  2188. \item the name of an operator for a single argument: the operator
  2189. is evaluated once with each element of {\tt object} as its single argument;
  2190. \item an algebraic expression with exactly one free variable, that is
  2191. a variable preceded by the tilde symbol. The expression
  2192. is evaluated for each element of {\tt object}, where the element is
  2193. substituted for the free variable;
  2194. \item a replacement rule of the form {\tt var => rep}
  2195. where {\tt var} is a variable (a kernel without a subscript)
  2196. and {\tt rep} is an expression that contains {\tt var}.
  2197. {\tt Rep} is evaluated for each element of {\tt object} where
  2198. the element is substituted for {\tt var}. {\tt Var} may be
  2199. optionally preceded by a tilde.
  2200. \end{enumerate}
  2201. The rule form for {\tt function} is needed when more than
  2202. one free variable occurs.
  2203. Examples:
  2204. {\small\begin{verbatim}
  2205. map(abs,{1,-2,a,-a}) -> {1,2,ABS(A),ABS(A)}
  2206. map(int(~w,x), mat((x^2,x^5),(x^4,x^5))) ->
  2207. [ 3 6 ]
  2208. [ x x ]
  2209. [---- ----]
  2210. [ 3 6 ]
  2211. [ ]
  2212. [ 5 6 ]
  2213. [ x x ]
  2214. [---- ----]
  2215. [ 5 6 ]
  2216. map(~w*6, x^2/3 = y^3/2 -1) -> 2*X^2=3*(Y^3-2)
  2217. \end{verbatim}}
  2218. You can use {\tt MAP} in nested expressions. However, you cannot
  2219. apply {\tt MAP} to a non-composed object, e.g. an identifier or a number.
  2220. \section{MKID Operator}\ttindex{MKID}
  2221. In many applications, it is useful to create a set of identifiers for
  2222. naming objects in a consistent manner. In most cases, it is sufficient to
  2223. create such names from two components. The operator {\tt MKID} is provided
  2224. for this purpose. Its syntax is:
  2225. {\small\begin{verbatim}
  2226. MKID(U:id,V:id|non-negative integer):id
  2227. \end{verbatim}}
  2228. for example
  2229. {\small\begin{verbatim}
  2230. mkid(a,3) -> A3
  2231. mkid(apple,s) -> APPLES
  2232. \end{verbatim}}
  2233. while {\tt mkid(a+b,2)} gives an error.
  2234. The {\tt SET}\ttindex{SET} operator can be used to give a value to the
  2235. identifiers created by {\tt MKID}, for example
  2236. {\small\begin{verbatim}
  2237. set(mkid(a,3),3);
  2238. \end{verbatim}}
  2239. will give {\tt A3} the value 2.
  2240. \section{PF Operator}\ttindex{PF}
  2241. {\tt PF(<exp>,<var>)} transforms the expression {\tt <exp>} into a list of
  2242. partial fractions with respect to the main variable, {\tt <var>}. {\tt PF}
  2243. does a complete partial fraction decomposition, and as the algorithms used
  2244. are fairly unsophisticated (factorization and the extended Euclidean
  2245. algorithm), the code may be unacceptably slow in complicated cases.
  2246. {\it Example:}
  2247. Given {\tt 2/((x+1)\verb|^|2*(x+2))} in the workspace,
  2248. {\tt pf(ws,x);} gives the result
  2249. {\small\begin{verbatim}
  2250. 2 - 2 2
  2251. {-------,-------,--------------} .
  2252. X + 2 X + 1 2
  2253. X + 2*X + 1
  2254. \end{verbatim}}
  2255. If you want the denominators in factored form, use {\tt off exp;}.
  2256. Thus, with {\tt 2/((x+1)\verb|^|2*(x+2))} in the workspace, the commands
  2257. {\tt off exp; pf(ws,x);} give the result
  2258. {\small\begin{verbatim}
  2259. 2 - 2 2
  2260. {-------,-------,----------} .
  2261. X + 2 X + 1 2
  2262. (X + 1)
  2263. \end{verbatim}}
  2264. To recombine the terms, {\tt FOR EACH \ldots SUM} can be used. So with
  2265. the above list in the workspace, {\tt for each j in ws sum j;} returns the
  2266. result
  2267. {\small\begin{verbatim}
  2268. 2
  2269. ------------------
  2270. 2
  2271. (X + 2)*(X + 1)
  2272. \end{verbatim}}
  2273. Alternatively, one can use the operations on lists to extract any desired
  2274. term.
  2275. \section{SELECT Operator}\ttindex{SELECT}
  2276. \ttindex{map}\ttindex{list}
  2277. The {\tt SELECT} operator extracts from a list,
  2278. or from the arguments of an n--ary operator, elements corresponding
  2279. to a boolean predicate. It is used with the syntax:
  2280. {\small\begin{verbatim}
  2281. SELECT(U:function,V:list)
  2282. \end{verbatim}}
  2283. {\tt Function} can be one of the following forms:
  2284. \begin{enumerate}
  2285. \item the name of an operator for a single argument: the operator
  2286. is evaluated once with each element of {\tt object} as its single argument;
  2287. \item an algebraic expression with exactly one free variable, that is
  2288. a variable preceded by the tilde symbol. The expression
  2289. is evaluated for each element of \meta{object}, where the element is
  2290. substituted for the free variable;
  2291. \item a replacement rule of the form \meta{var $=>$ rep}
  2292. where {\tt var} is a variable (a kernel without subscript)
  2293. and {\tt rep} is an expression that contains {\tt var}.
  2294. {\tt Rep} is evaluated for each element of {\tt object} where
  2295. the element is substituted for {\tt var}. {\tt var} may be
  2296. optionally preceded by a tilde.
  2297. \end{enumerate}
  2298. The rule form for {\tt function} is needed when more than
  2299. one free variable occurs.
  2300. The result of evaluating {\tt function} is
  2301. interpreted as a boolean value corresponding to the conventions of
  2302. {\REDUCE}. These values are composed with the leading operator of the
  2303. input expression.
  2304. {\it Examples:}
  2305. {\small\begin{verbatim}
  2306. select( ~w>0 , {1,-1,2,-3,3}) -> {1,2,3}
  2307. select(evenp deg(~w,y),part((x+y)^5,0):=list)
  2308. -> {X^5 ,10*X^3*Y^2 ,5*X*Y^4}
  2309. select(evenp deg(~w,x),2x^2+3x^3+4x^4) -> 4X^4 + 2X^2
  2310. \end{verbatim}}
  2311. \section{SOLVE Operator}\ttindex{SOLVE}
  2312. SOLVE is an operator for solving one or more simultaneous algebraic
  2313. equations. It is used with the syntax:
  2314. {\small\begin{verbatim}
  2315. SOLVE(EXPRN:algebraic[,VAR:kernel|,VARLIST:list of kernels])
  2316. :list.
  2317. \end{verbatim}}
  2318. {\tt EXPRN} is of the form {\tt <expression>} or
  2319. \{ {\tt <expression1>},{\tt <expression2>}, \dots \}. Each expression is an
  2320. algebraic equation, or is the difference of the two sides of the equation.
  2321. The second argument is either a kernel or a list of kernels representing
  2322. the unknowns in the system. This argument may be omitted if the number of
  2323. distinct, non-constant, top-level kernels equals the number of unknowns,
  2324. in which case these kernels are presumed to be the unknowns.
  2325. For one equation, {\tt SOLVE}\ttindex{SOLVE} recursively uses
  2326. factorization and decomposition, together with the known inverses of
  2327. {\tt LOG}, {\tt SIN}, {\tt COS}, {\tt \verb|^|}, {\tt ACOS}, {\tt ASIN}, and
  2328. linear, quadratic, cubic, quartic, or binomial factors. Solutions
  2329. of equations built with exponentials or logarithms are often
  2330. expressed in terms of Lambert's {\tt W} function.\index{Lambert's W}
  2331. This function is (partially) implemented in the special functions package.
  2332. Linear equations are solved by the multi-step elimination method due to
  2333. Bareiss, unless the switch {\tt CRAMER}\ttindex{CRAMER} is on, in which
  2334. case Cramer's method is used. The Bareiss method is usually more
  2335. efficient unless the system is large and dense.
  2336. Non-linear equations are solved using the Groebner basis package.
  2337. \index{Groebner} Users should note that this can be quite a
  2338. time consuming process.
  2339. {\it Examples:}
  2340. {\small\begin{verbatim}
  2341. solve(log(sin(x+3))^5 = 8,x);
  2342. solve(a*log(sin(x+3))^5 - b, sin(x+3));
  2343. solve({a*x+y=3,y=-2},{x,y});
  2344. \end{verbatim}}
  2345. {\tt SOLVE} returns a list of solutions. If there is one unknown, each
  2346. solution is an equation for the unknown. If a complete solution was
  2347. found, the unknown will appear by itself on the left-hand side of the
  2348. equation. On the other hand, if the solve package could not find a
  2349. solution, the ``solution'' will be an equation for the unknown in terms
  2350. of the operator {\tt ROOT\_OF}\ttindex{ROOT\_OF}. If there
  2351. are several unknowns, each solution will be a list of equations for the
  2352. unknowns. For example,
  2353. {\small\begin{verbatim}
  2354. solve(x^2=1,x); -> {X=-1,X=1}
  2355. solve(x^7-x^6+x^2=1,x)
  2356. 6
  2357. -> {X=ROOT_OF(X_ + X_ + 1,X_,TAG_1),X=1}
  2358. solve({x+3y=7,y-x=1},{x,y}) -> {{X=1,Y=2}}.
  2359. \end{verbatim}}
  2360. The TAG argument is used to uniquely identify those particular solutions.
  2361. Solution multiplicities are stored in the global variable {\tt
  2362. ROOT\_MULTIPLICITIES} rather than the solution list. The value of this
  2363. variable is a list of the multiplicities of the solutions for the last
  2364. call of {\tt SOLVE}. \ttindex{SOLVE} For example,
  2365. {\small\begin{verbatim}
  2366. solve(x^2=2x-1,x); root_multiplicities;
  2367. \end{verbatim}}
  2368. gives the results
  2369. {\small\begin{verbatim}
  2370. {X=1}
  2371. {2}
  2372. \end{verbatim}}
  2373. If you want the multiplicities explicitly displayed, the switch
  2374. {\tt MULTIPLICITIES}\ttindex{MULTIPLICITIES} can be turned on. For example
  2375. {\small\begin{verbatim}
  2376. on multiplicities; solve(x^2=2x-1,x);
  2377. \end{verbatim}}
  2378. yields the result
  2379. {\small\begin{verbatim}
  2380. {X=1,X=1}
  2381. \end{verbatim}}
  2382. \subsection{Handling of Undetermined Solutions}
  2383. When {\tt SOLVE} cannot find a solution to an equation, it normally
  2384. returns an equation for the relevant indeterminates in terms of the
  2385. operator {\tt ROOT\_OF}.\ttindex{ROOT\_OF} For example, the expression
  2386. {\small\begin{verbatim}
  2387. solve(cos(x) + log(x),x);
  2388. \end{verbatim}}
  2389. returns the result
  2390. {\small\begin{verbatim}
  2391. {X=ROOT_OF(COS(X_) + LOG(X_),X_,TAG_1)} .
  2392. \end{verbatim}}
  2393. An expression with a top-level {\tt ROOT\_OF} operator is implicitly a
  2394. list with an unknown number of elements (since we don't always know how
  2395. many solutions an equation has). If a substitution is made into such an
  2396. expression, closed form solutions can emerge. If this occurs, the {\tt
  2397. ROOT\_OF} construct is replaced by an operator {\tt ONE\_OF}.\ttindex{ONE\_OF}
  2398. At this point it is of course possible to transform the result of the
  2399. original {\tt SOLVE} operator expression into a standard {\tt SOLVE}
  2400. solution. To effect this, the operator {\tt EXPAND\_CASES}
  2401. \ttindex{EXPAND\_CASES} can be used.
  2402. The following example shows the use of these facilities:
  2403. \extendedmanual{\newpage}
  2404. {\small\begin{verbatim}
  2405. solve(-a*x^3+a*x^2+x^4-x^3-4*x^2+4,x);
  2406. 2 3
  2407. {X=ROOT_OF(A*X_ - X_ + 4*X_ + 4,X_,TAG_2),X=1}
  2408. sub(a=-1,ws);
  2409. {X=ONE_OF({2,-1,-2},TAG_2),X=1}
  2410. expand_cases ws;
  2411. {X=2,X=-1,X=-2,X=1}
  2412. \end{verbatim}}
  2413. \subsection{Solutions of Equations Involving Cubics and Quartics}
  2414. Since roots of cubics and quartics can often be very messy, a switch
  2415. {\tt FULLROOTS}\ttindex{FULLROOTS} is available, that, when off (the
  2416. default), will prevent the production of a result in closed form. The
  2417. {\tt ROOT\_OF} construct will be used in this case instead.
  2418. In constructing the solutions of cubics and quartics, trigonometrical
  2419. forms are used where appropriate. This option is under the control of a
  2420. switch {\tt TRIGFORM},\ttindex{TRIGFORM} which is normally on.
  2421. The following example illustrates the use of these facilities:
  2422. {\small\begin{verbatim}
  2423. let xx = solve(x^3+x+1,x);
  2424. xx;
  2425. 3
  2426. {X=ROOT_OF(X_ + X_ + 1,X_)}
  2427. on fullroots;
  2428. xx;
  2429. - SQRT(31)*I
  2430. ATAN(---------------)
  2431. 3*SQRT(3)
  2432. {X=(I*(SQRT(3)*SIN(-----------------------)
  2433. 3
  2434. \end{verbatim}}
  2435. \newpage
  2436. {\small\begin{verbatim}
  2437. - SQRT(31)*I
  2438. ATAN(---------------)
  2439. 3*SQRT(3)
  2440. - COS(-----------------------)))/SQRT(3),
  2441. 3
  2442. - SQRT(31)*I
  2443. ATAN(---------------)
  2444. 3*SQRT(3)
  2445. X=( - I*(SQRT(3)*SIN(-----------------------)
  2446. 3
  2447. - SQRT(31)*I
  2448. ATAN(---------------)
  2449. 3*SQRT(3)
  2450. + COS(-----------------------)))/SQRT(
  2451. 3
  2452. 3),
  2453. - SQRT(31)*I
  2454. ATAN(---------------)
  2455. 3*SQRT(3)
  2456. 2*COS(-----------------------)*I
  2457. 3
  2458. X=----------------------------------}
  2459. SQRT(3)
  2460. off trigform;
  2461. xx;
  2462. 2/3
  2463. {X=( - (SQRT(31) - 3*SQRT(3)) *SQRT(3)*I
  2464. 2/3 2/3
  2465. - (SQRT(31) - 3*SQRT(3)) - 2 *SQRT(3)*I
  2466. 2/3 1/3 1/3
  2467. + 2 )/(2*(SQRT(31) - 3*SQRT(3)) *6
  2468. 1/6
  2469. *3 ),
  2470. 2/3
  2471. X=((SQRT(31) - 3*SQRT(3)) *SQRT(3)*I
  2472. 2/3 2/3
  2473. - (SQRT(31) - 3*SQRT(3)) + 2 *SQRT(3)*I
  2474. 2/3 1/3 1/3
  2475. + 2 )/(2*(SQRT(31) - 3*SQRT(3)) *6
  2476. 1/6
  2477. *3 ),
  2478. 2/3 2/3
  2479. (SQRT(31) - 3*SQRT(3)) - 2
  2480. X=-------------------------------------}
  2481. 1/3 1/3 1/6
  2482. (SQRT(31) - 3*SQRT(3)) *6 *3
  2483. \end{verbatim}}
  2484. \subsection{Other Options}
  2485. If {\tt SOLVESINGULAR}\ttindex{SOLVESINGULAR} is on (the default setting),
  2486. degenerate systems such as {\tt x+y=0}, {\tt 2x+2y=0} will be solved by
  2487. introducing appropriate arbitrary constants.
  2488. The consistent singular equation 0=0 or equations involving functions with
  2489. multiple inverses may introduce unique new indeterminant kernels
  2490. {\tt ARBCOMPLEX(j)}, or {\tt ARBINT(j)}, ($j$=1,2,...), % {\tt ARBREAL(j)},
  2491. representing arbitrary complex or integer numbers respectively. To
  2492. automatically select the principal branches, do {\tt off allbranch;} .
  2493. \ttindex{ALLBRANCH} To avoid the introduction of new indeterminant kernels
  2494. do {\tt OFF ARBVARS}\ttindex{ARBVARS} -- then no equations are generated for the free
  2495. variables and their original names are used to express the solution forms.
  2496. To suppress solutions of consistent singular equations do
  2497. {\tt OFF SOLVESINGULAR}.
  2498. To incorporate additional inverse functions do, for example:
  2499. {\small\begin{verbatim}
  2500. put('sinh,'inverse,'asinh);
  2501. put('asinh,'inverse,'sinh);
  2502. \end{verbatim}}
  2503. together with any desired simplification rules such as
  2504. {\small\begin{verbatim}
  2505. for all x let sinh(asinh(x))=x, asinh(sinh(x))=x;
  2506. \end{verbatim}}
  2507. For completeness, functions with non-unique inverses should be treated as
  2508. {\tt \verb|^|}, {\tt SIN}, and {\tt COS} are in the {\tt SOLVE}
  2509. \ttindex{SOLVE} module source.
  2510. Arguments of {\tt ASIN} and {\tt ACOS} are not checked to ensure that the
  2511. absolute value of the real part does not exceed 1; and arguments of
  2512. {\tt LOG} are not checked to ensure that the absolute value of the imaginary
  2513. part does not exceed $\pi$; but checks (perhaps involving user response
  2514. for non-numerical arguments) could be introduced using
  2515. {\tt LET}\ttindex{LET} statements for these operators.
  2516. \subsection{Parameters and Variable Dependency}
  2517. The proper design of a variable sequence
  2518. supplied as a second argument to {\tt SOLVE} is important
  2519. for the structure of the solution of an equation system.
  2520. Any unknown in the system
  2521. not in this list is considered totally free. E.g.\ the call
  2522. {\small\begin{verbatim}
  2523. solve({x=2*z,z=2*y},{z});
  2524. \end{verbatim}}
  2525. produces an empty list as a result because there is no function
  2526. $z=z(x,y)$ which fulfills both equations for arbitrary $x$ and $y$ values.
  2527. In such a case the share variable {\tt requirements}\ttindex{requirements}
  2528. displays a set of restrictions for the parameters of the system:
  2529. {\small\begin{verbatim}
  2530. requirements;
  2531. {x - 4*y}
  2532. \end{verbatim}}
  2533. The non-existence of a formal solution is caused by a
  2534. contradiction which disappears only if the parameters
  2535. of the initial system are set such that all members
  2536. of the requirements list take the value zero.
  2537. For a linear system the set is complete: a solution
  2538. of the requirements list makes the initial
  2539. system solvable. E.g.\ in the above case a substitution
  2540. $x=4y$ makes the equation set consistent. For a non-linear
  2541. system only one inconsistency is detected. If such a system
  2542. has more than one inconsistency, you must reduce them
  2543. one after the other.
  2544. \footnote{
  2545. The difference between linear and non--linear
  2546. inconsistent systems is based on the algorithms which
  2547. produce this information as a side effect when attempting
  2548. to find a formal solution; example:
  2549. $solve(\{x=a,x=b,y=c,y=d\},\{x,y\}$ gives a set $\{a-b,c-d\}$
  2550. while $solve(\{x^2=a,x^2=b,y^2=c,y^2=d\},\{x,y\}$ leads to $\{a-b\}$.
  2551. }
  2552. The set shows you also the dependency among the parameters: here
  2553. one of $x$ and $y$ is free and a formal solution of the system can be
  2554. computed by adding it to the variable list of {\tt solve}.
  2555. The requirement set is not unique -- there may be other such sets.
  2556. A system with parameters may have a formal solution, e.g.\
  2557. {\small\begin{verbatim}
  2558. solve({x=a*z+1,0=b*z-y},{z,x});
  2559. y a*y + b
  2560. {{z=---,x=---------}}
  2561. b b
  2562. \end{verbatim}}
  2563. which is not valid for all possible values of the parameters.
  2564. The variable {\tt assumptions}\ttindex{assumptions} contains then a list of
  2565. restrictions: the solutions are valid only as long
  2566. as none of these expressions vanishes. Any zero of one of them
  2567. represents a special case that is not covered by the
  2568. formal solution. In the above case the value is
  2569. \extendedmanual{\newpage}
  2570. {\small\begin{verbatim}
  2571. assumptions;
  2572. {b}
  2573. \end{verbatim}}
  2574. which excludes formally the case $b=0$; obviously this special
  2575. parameter value makes the system singular. The set of assumptions
  2576. is complete for both, linear and non--linear systems.
  2577. {\tt SOLVE} rearranges the variable sequence
  2578. to reduce the (expected) computing time. This behavior is controlled
  2579. by the switch {\tt varopt}\ttindex{varopt}, which is on by default.
  2580. If it is turned off, the supplied variable sequence is used
  2581. or the system kernel ordering is taken if the variable
  2582. list is omitted. The effect is demonstrated by an example:
  2583. {\small\begin{verbatim}
  2584. s:= {y^3+3x=0,x^2+y^2=1};
  2585. solve(s,{y,x});
  2586. 6 2
  2587. {{y=root_of(y_ + 9*y_ - 9,y_),
  2588. 3
  2589. - y
  2590. x=-------}}
  2591. 3
  2592. off varopt; solve(s,{y,x});
  2593. 6 4 2
  2594. {{x=root_of(x_ - 3*x_ + 12*x_ - 1,x_),
  2595. 4 2
  2596. x*( - x + 2*x - 10)
  2597. y=-----------------------}}
  2598. 3
  2599. \end{verbatim}}
  2600. In the first case, {\tt solve} forms the solution as a set of
  2601. pairs $(y_i,x(y_i))$ because the degree of $x$ is higher --
  2602. such a rearrangement makes the internal computation of the Gr\"obner basis
  2603. generally faster. For the second case the explicitly given variable sequence
  2604. is used such that the solution has now the form $(x_i,y(x_i))$.
  2605. Controlling the variable sequence is especially important if
  2606. the system has one or more free variables.
  2607. As an alternative to turning off {\tt varopt}, a partial dependency among
  2608. the variables can be declared using the {\tt depend}\index{depend}
  2609. statement: {\tt solve} then rearranges the variable sequence but keeps any
  2610. variable ahead of those on which it depends.
  2611. \extendedmanual{\newpage}
  2612. {\small\begin{verbatim}
  2613. on varopt;
  2614. s:={a^3+b,b^2+c}$
  2615. solve(s,{a,b,c});
  2616. 3 6
  2617. {{a=arbcomplex(1),b= - a ,c= - a }}
  2618. depend a,c; depend b,c; solve(s,{a,b,c});
  2619. {{c=arbcomplex(2),
  2620. 6
  2621. a=root_of(a_ + c,a_),
  2622. 3
  2623. b= - a }}
  2624. \end{verbatim}}
  2625. Here {\tt solve} is forced to put $c$ after $a$ and after $b$, but
  2626. there is no obstacle to interchanging $a$ and $b$.
  2627. \section{Even and Odd Operators}\index{Even operator}\index{Odd operator}
  2628. An operator can be declared to be {\em even\/} or {\em odd\/} in its first
  2629. argument by the declarations {\tt EVEN}\ttindex{EVEN} and
  2630. {\tt ODD}\ttindex{ODD} respectively. Expressions involving an operator
  2631. declared in this manner are transformed if the first argument contains a
  2632. minus sign. Any other arguments are not affected. In addition, if say
  2633. {\tt F} is declared odd, then {\tt f(0)} is replaced by zero unless
  2634. {\tt F} is also declared {\em non zero\/} by the declaration
  2635. {\tt NONZERO}\ttindex{NONZERO}. For example, the declarations
  2636. {\small\begin{verbatim}
  2637. even f1; odd f2;
  2638. \end{verbatim}}
  2639. mean that
  2640. {\small\begin{verbatim}
  2641. f1(-a) -> F1(A)
  2642. f2(-a) -> -F2(A)
  2643. f1(-a,-b) -> F1(A,-B)
  2644. f2(0) -> 0.
  2645. \end{verbatim}}
  2646. To inhibit the last transformation, say {\tt nonzero f2;}.
  2647. \section{Linear Operators}\index{Linear operator}
  2648. An operator can be declared to be linear in its first argument over powers
  2649. of its second argument. If an operator {\tt F} is so declared, {\tt F} of
  2650. any sum is broken up into sums of {\tt F}s, and any factors that are not
  2651. powers of the variable are taken outside. This means that {\tt F} must
  2652. have (at least) two arguments. In addition, the second argument must be
  2653. an identifier (or more generally a kernel), not an expression.
  2654. {\it Example:}
  2655. If {\tt F} were declared linear, then
  2656. {\small\begin{verbatim}
  2657. 5
  2658. f(a*x^5+b*x+c,x) -> F(X ,X)*A + F(X,X)*B + F(1,X)*C
  2659. \end{verbatim}}
  2660. More precisely, not only will the variable and its powers remain within the
  2661. scope of the {\tt F} operator, but so will any variable and its powers that
  2662. had been declared to {\tt DEPEND} on the prescribed variable; and so would
  2663. any expression that contains that variable or a dependent variable on any
  2664. level, e.g. {\tt cos(sin(x))}.
  2665. To declare operators {\tt F} and {\tt G} to be linear operators,
  2666. use:\ttindex{LINEAR}
  2667. {\small\begin{verbatim}
  2668. linear f,g;
  2669. \end{verbatim}}
  2670. The analysis is done of the first argument with respect to the second; any
  2671. other arguments are ignored. It uses the following rules of evaluation:
  2672. \begin{quote}
  2673. \begin{tabbing}
  2674. {\tt f(0) -> 0} \\
  2675. {\tt f(-y,x) -> -F(Y,X)} \\
  2676. {\tt f(y+z,x) -> F(Y,X)+F(Z,X)} \\
  2677. {\tt f(y*z,x) -> Z*F(Y,X)} \hspace{0.5in}\= if Z does not depend on X \\
  2678. {\tt f(y/z,x) -> F(Y,X)/Z} \> if Z does not depend on X
  2679. \end{tabbing}
  2680. \end{quote}
  2681. To summarize, {\tt Y} ``depends'' on the indeterminate {\tt X} in the above
  2682. if either of the following hold:
  2683. \begin{enumerate}
  2684. \item {\tt Y} is an expression that contains {\tt X} at any level as a
  2685. variable, e.g.: {\tt cos(sin(x))}
  2686. \item Any variable in the expression {\tt Y} has been declared dependent on
  2687. {\tt X} by use of the declaration {\tt DEPEND}.
  2688. \end{enumerate}
  2689. The use of such linear operators\index{Linear operator} can be seen in the
  2690. paper Fox, J.A. and A. C. Hearn, ``Analytic Computation of Some Integrals
  2691. in Fourth Order Quantum Electrodynamics'' Journ. Comp. Phys. 14 (1974)
  2692. 301-317, which contains a complete listing of a program for definite
  2693. integration\index{Integration} of some expressions that arise in fourth
  2694. order quantum electrodynamics.
  2695. \section{Non-Commuting Operators}\index{Non-commuting operator}
  2696. An operator can be declared to be non-commutative under multiplication by
  2697. the declaration {\tt NONCOM}.\ttindex{NONCOM}
  2698. {\it Example:}
  2699. After the declaration \\
  2700. {\tt noncom u,v;}\\
  2701. the expressions {\tt
  2702. u(x)*u(y)-u(y)*u(x)} and {\tt u(x)*v(y)-v(y)*u(x)} will remain unchanged
  2703. on simplification, and in particular will not simplify to zero.
  2704. Note that it is the operator ({\tt U} and {\tt V} in the above example)
  2705. and not the variable that has the non-commutative property.
  2706. The {\tt LET}\ttindex{LET} statement may be used to introduce rules of
  2707. evaluation for such operators. In particular, the boolean operator
  2708. {\tt ORDP}\ttindex{ORDP} is useful for introducing an ordering on such
  2709. expressions.
  2710. {\it Example:}
  2711. The rule
  2712. {\small\begin{verbatim}
  2713. for all x,y such that x neq y and ordp(x,y)
  2714. let u(x)*u(y)= u(y)*u(x)+comm(x,y);
  2715. \end{verbatim}}
  2716. would introduce the commutator of {\tt u(x)} and {\tt u(y)} for all
  2717. {\tt X} and {\tt Y}. Note that since {\tt ordp(x,x)} is {\em true}, the
  2718. equality check is necessary in the degenerate case to avoid a circular
  2719. loop in the rule.
  2720. \section{Symmetric and Antisymmetric Operators}
  2721. An operator can be declared to be symmetric with respect to its arguments
  2722. by the declaration {\tt SYMMETRIC}.\ttindex{SYMMETRIC} For example
  2723. {\small\begin{verbatim}
  2724. symmetric u,v;
  2725. \end{verbatim}}
  2726. means that any expression involving the top level operators {\tt U} or
  2727. {\tt V} will have its arguments reordered to conform to the internal order
  2728. used by {\REDUCE}. The user can change this order for kernels by the
  2729. command {\tt KORDER}.
  2730. For example, {\tt u(x,v(1,2))} would become {\tt u(v(2,1),x)}, since
  2731. numbers are ordered in decreasing order, and expressions are ordered in
  2732. decreasing order of complexity.
  2733. Similarly the declaration {\tt ANTISYMMETRIC}\ttindex{ANTISYMMETRIC}
  2734. declares an operator antisymmetric. For example,
  2735. {\small\begin{verbatim}
  2736. antisymmetric l,m;
  2737. \end{verbatim}}
  2738. means that any expression involving the top level operators {\tt L} or
  2739. {\tt M} will have its arguments reordered to conform to the internal order
  2740. of the system, and the sign of the expression changed if there are an odd
  2741. number of argument interchanges necessary to bring about the new order.
  2742. For example, {\tt l(x,m(1,2))} would become {\tt -l(-m(2,1),x)} since one
  2743. interchange occurs with each operator. An expression like {\tt l(x,x)}
  2744. would also be replaced by 0.
  2745. \section{Declaring New Prefix Operators}
  2746. The user may add new prefix\index{Prefix} operators to the system by
  2747. using the declaration {\tt OPERATOR}. For example:
  2748. {\small\begin{verbatim}
  2749. operator h,g1,arctan;
  2750. \end{verbatim}}
  2751. adds the prefix operators {\tt H}, {\tt G1} and {\tt ARCTAN} to the system.
  2752. This allows symbols like {\tt h(w), h(x,y,z), g1(p+q), arctan(u/v)} to be
  2753. used in expressions, but no meaning or properties of the operator are
  2754. implied. The same operator symbol can be used equally well as a 0-, 1-, 2-,
  2755. 3-, etc.-place operator.
  2756. To give a meaning to an operator symbol, or express some of its
  2757. properties, {\tt LET}\ttindex{LET} statements can be used, or the operator
  2758. can be given a definition as a procedure.
  2759. If the user forgets to declare an identifier as an operator, the system
  2760. will prompt the user to do so in interactive mode, or do it automatically
  2761. in non-interactive mode. A diagnostic message will also be printed if an
  2762. identifier is declared {\tt OPERATOR} more than once.
  2763. Operators once declared are global in scope, and so can then be referenced
  2764. anywhere in the program. In other words, a declaration within a block (or
  2765. a procedure) does not limit the scope of the operator to that block, nor
  2766. does the operator go away on exiting the block (use {\tt CLEAR} instead
  2767. for this purpose).
  2768. \section{Declaring New Infix Operators}
  2769. Users can add new infix operators by using the declarations
  2770. {\tt INFIX}\ttindex{INFIX} and {\tt PRECEDENCE}.\ttindex{PRECEDENCE}
  2771. For example,
  2772. {\small\begin{verbatim}
  2773. infix mm;
  2774. precedence mm,-;
  2775. \end{verbatim}}
  2776. The declaration {\tt infix mm;} would allow one to use the symbol
  2777. {\tt MM} as an infix operator:
  2778. \begin{quote}
  2779. \hspace{0.2in} {\tt a mm b} \hspace{0.3in} instead of \hspace{0.3in}
  2780. {\tt mm(a,b)}.
  2781. \end{quote}
  2782. The declaration {\tt precedence mm,-;} says that {\tt MM} should be
  2783. inserted into the infix operator precedence list just {\em after\/}
  2784. the $-$ operator. This gives it higher precedence than $-$ and lower
  2785. precedence than * . Thus
  2786. \begin{quote}
  2787. \hspace{0.2in}{\tt a - b mm c - d}\hspace{.3in} means \hspace{.3in}
  2788. {\tt a - (b mm c) - d},
  2789. \end{quote}
  2790. while
  2791. \begin{quote}
  2792. \hspace{0.2in}{\tt a * b mm c * d}\hspace{.3in} means \hspace{.3in}
  2793. {\tt (a * b) mm (c * d)}.
  2794. \end{quote}
  2795. Both infix and prefix\index{Prefix} operators have no transformation
  2796. properties unless {\tt LET}\ttindex{LET} statements or procedure
  2797. declarations are used to assign a meaning.
  2798. We should note here that infix operators so defined are always binary:
  2799. \begin{quote}
  2800. \hspace{0.2in}{\tt a mm b mm c}\hspace{.3in} means \hspace{.3in}
  2801. {\tt (a mm b) mm c}.
  2802. \end{quote}
  2803. \section{Creating/Removing Variable Dependency}
  2804. There are several facilities in {\REDUCE}, such as the differentiation
  2805. \index{Differentiation}
  2806. operator and the linear operator\index{Linear operator} facility, that
  2807. can utilize knowledge of the dependency between various variables, or
  2808. kernels. Such dependency may be expressed by the command {\tt
  2809. DEPEND}.\ttindex{DEPEND} This takes an arbitrary number of arguments and
  2810. sets up a dependency of the first argument on the remaining arguments.
  2811. For example,
  2812. {\small\begin{verbatim}
  2813. depend x,y,z;
  2814. \end{verbatim}}
  2815. says that {\tt X} is dependent on both {\tt Y} and {\tt Z}.
  2816. {\small\begin{verbatim}
  2817. depend z,cos(x),y;
  2818. \end{verbatim}}
  2819. says that {\tt Z} is dependent on {\tt COS(X)} and {\tt Y}.
  2820. Dependencies introduced by {\tt DEPEND} can be removed by {\tt NODEPEND}.
  2821. \ttindex{NODEPEND} The arguments of this are the same as for {\tt DEPEND}.
  2822. For example, given the above dependencies,
  2823. {\small\begin{verbatim}
  2824. nodepend z,cos(x);
  2825. \end{verbatim}}
  2826. says that {\tt Z} is no longer dependent on {\tt COS(X)}, although it remains
  2827. dependent on {\tt Y}.
  2828. \chapter{Display and Structuring of Expressions}\index{Display}
  2829. \index{Structuring}
  2830. In this section, we consider a variety of commands and operators that
  2831. permit the user to obtain various parts of algebraic expressions and also
  2832. display their structure in a variety of forms. Also presented are some
  2833. additional concepts in the {\REDUCE} design that help the user gain a better
  2834. understanding of the structure of the system.
  2835. \section{Kernels}\index{Kernel}
  2836. {\REDUCE} is designed so that each operator in the system has an
  2837. evaluation (or simplification)\index{Simplification} function associated
  2838. with it that transforms the expression into an internal canonical form.
  2839. \index{Canonical form} This form, which bears little resemblance to the
  2840. original expression, is described in detail in Hearn, A. C., ``{\REDUCE} 2:
  2841. A System and Language for Algebraic Manipulation,'' Proc. of the Second
  2842. Symposium on Symbolic and Algebraic Manipulation, ACM, New York (1971)
  2843. 128-133.
  2844. The evaluation function may transform its arguments in one of two
  2845. alternative ways. First, it may convert the expression into other
  2846. operators in the system, leaving no functions of the original operator for
  2847. further manipulation. This is in a sense true of the evaluation functions
  2848. associated with the operators {\tt +}, {\tt *} and {\tt /} , for example,
  2849. because the canonical form\index{Canonical form} does not include these
  2850. operators explicitly. It is also true of an operator such as the
  2851. determinant operator {\tt DET}\ttindex{DET} because the relevant
  2852. evaluation function calculates the appropriate determinant, and the
  2853. operator {\tt DET} no longer appears. On the other hand, the evaluation
  2854. process may leave some residual functions of the relevant operator. For
  2855. example, with the operator {\tt COS}, a residual expression like {\tt
  2856. COS(X)} may remain after evaluation unless a rule for the reduction of
  2857. cosines into exponentials, for example, were introduced. These residual
  2858. functions of an operator are termed {\em kernels\/}\index{Kernel} and are
  2859. stored uniquely like variables. Subsequently, the kernel is carried
  2860. through the calculation as a variable unless transformations are
  2861. introduced for the operator at a later stage.
  2862. In those cases where the evaluation process leaves an operator expression
  2863. with non-trivial arguments, the form of the argument can vary depending on
  2864. the state of the system at the point of evaluation. Such arguments are
  2865. normally produced in expanded form with no terms factored or grouped in
  2866. any way. For example, the expression {\tt cos(2*x+2*y)} will normally be
  2867. returned in the same form. If the argument {\tt 2*x+2*y} were evaluated
  2868. at the top level, however, it would be printed as {\tt 2*(X+Y)}. If it is
  2869. desirable to have the arguments themselves in a similar form, the switch
  2870. {\tt INTSTR}\ttindex{INTSTR} (for ``internal structure''), if on, will
  2871. cause this to happen.
  2872. In cases where the arguments of the kernel operators may be reordered, the
  2873. system puts them in a canonical order, based on an internal intrinsic
  2874. ordering of the variables. However, some commands allow arguments in the
  2875. form of kernels, and the user has no way of telling what internal order the
  2876. system will assign to these arguments. To resolve this difficulty, we
  2877. introduce the notion of a {\em kernel form\/}\index{kernel form} as an
  2878. expression that transforms to a kernel on evaluation.
  2879. Examples of kernel forms are:
  2880. {\small\begin{verbatim}
  2881. a
  2882. cos(x*y)
  2883. log(sin(x))
  2884. \end{verbatim}}
  2885. whereas
  2886. {\small\begin{verbatim}
  2887. a*b
  2888. (a+b)^4
  2889. \end{verbatim}}
  2890. are not.
  2891. We see that kernel forms can usually be used as generalized variables, and
  2892. most algebraic properties associated with variables may also be associated
  2893. with kernels.
  2894. \section{The Expression Workspace}\index{Workspace}
  2895. Several mechanisms are available for saving and retrieving previously
  2896. evaluated expressions. The simplest of these refers to the last algebraic
  2897. expression simplified. When an assignment of an algebraic expression is
  2898. made, or an expression is evaluated at the top level, (i.e., not inside a
  2899. compound statement or procedure) the results of the evaluation are
  2900. automatically saved in a variable {\tt WS} that we shall refer to as the
  2901. workspace. (More precisely, the expression is assigned to the variable
  2902. {\tt WS} that is then available for further manipulation.)
  2903. {\it Example:}
  2904. If we evaluate the expression {\tt (x+y)\verb|^|2} at the top level and next
  2905. wish to differentiate it with respect to {\tt Y}, we can simply say
  2906. {\small\begin{verbatim}
  2907. df(ws,y);
  2908. \end{verbatim}}
  2909. to get the desired answer.
  2910. If the user wishes to assign the workspace to a variable or expression for
  2911. later use, the {\tt SAVEAS}\ttindex{SAVEAS} statement can be used. It
  2912. has the syntax
  2913. {\small\begin{verbatim}
  2914. SAVEAS <expression>
  2915. \end{verbatim}}
  2916. For example, after the differentiation in the last example, the workspace
  2917. holds the expression {\tt 2*x+2*y}. If we wish to assign this to the
  2918. variable {\tt Z} we can now say
  2919. {\small\begin{verbatim}
  2920. saveas z;
  2921. \end{verbatim}}
  2922. If the user wishes to save the expression in a form that allows him to use
  2923. some of its variables as arbitrary parameters, the {\tt FOR ALL}
  2924. command can be used.
  2925. {\it Example:}
  2926. {\small\begin{verbatim}
  2927. for all x saveas h(x);
  2928. \end{verbatim}}
  2929. with the above expression would mean that {\tt h(z)} evaluates to {\tt
  2930. 2*Y+2*Z}.
  2931. A further method for referencing more than the last expression is described
  2932. in the section on interactive use of {\REDUCE}.
  2933. \section{Output of Expressions}
  2934. A considerable degree of flexibility is available in {\REDUCE} in the
  2935. printing of expressions generated during calculations. No explicit format
  2936. statements are supplied, as these are in most cases of little use in
  2937. algebraic calculations, where the size of output or its composition is not
  2938. generally known in advance. Instead, {\REDUCE} provides a series of mode
  2939. options to the user that should enable him to produce his output in a
  2940. comprehensible and possibly pleasing form.
  2941. The most extreme option offered is to suppress the output entirely from
  2942. any top level evaluation. This is accomplished by turning off the switch
  2943. {\tt OUTPUT}\ttindex{OUTPUT} which is normally on. It is useful for
  2944. limiting output when loading large files or producing ``clean'' output from
  2945. the prettyprint programs.
  2946. In most circumstances, however, we wish to view the output, so we need to
  2947. know how to format it appropriately. As we mentioned earlier, an
  2948. algebraic expression is normally printed in an expanded form, filling the
  2949. whole output line with terms. Certain output declarations,\index{Output
  2950. declaration} however, can be used to affect this format. To begin with,
  2951. we look at an operator for changing the length of the output line.
  2952. \subsection{LINELENGTH Operator}\ttindex{LINELENGTH}
  2953. This operator is used with the syntax
  2954. {\small\begin{verbatim}
  2955. LINELENGTH(NUM:integer):integer
  2956. \end{verbatim}}
  2957. and sets the output line length to the integer {\tt NUM}. It returns the
  2958. previous output line length (so that it can be stored for later resetting
  2959. of the output line if needed).
  2960. \subsection{Output Declarations}
  2961. We now describe a number of switches and declarations that are available
  2962. for controlling output formats. It should be noted, however, that the
  2963. transformation of large expressions to produce these varied output formats
  2964. can take a lot of computing time and space. If a user wishes to speed up
  2965. the printing of the output in such cases, he can turn off the switch {\tt
  2966. PRI}.\ttindex{PRI} If this is done, then output is produced in one fixed
  2967. format, which basically reflects the internal form of the expression, and
  2968. none of the options below apply. {\tt PRI} is normally on.
  2969. With {\tt PRI} on, the output declarations\index{Output declaration}
  2970. and switches available are as follows:
  2971. \subsubsection{ORDER Declaration}
  2972. The declaration {\tt ORDER}\ttindex{ORDER} may be used to order variables
  2973. on output. The syntax is:
  2974. {\small\begin{verbatim}
  2975. order v1,...vn;
  2976. \end{verbatim}}
  2977. where the {\tt vi} are kernels. Thus,
  2978. {\small\begin{verbatim}
  2979. order x,y,z;
  2980. \end{verbatim}}
  2981. orders {\tt X} ahead of {\tt Y}, {\tt Y} ahead of {\tt Z} and all three
  2982. ahead of other variables not given an order. {\tt order nil;} resets the
  2983. output order to the system default. The order of variables may be changed
  2984. by further calls of {\tt ORDER}, but then the reordered variables would
  2985. have an order lower than those in earlier {\tt ORDER}\ttindex{ORDER} calls.
  2986. Thus,
  2987. {\small\begin{verbatim}
  2988. order x,y,z;
  2989. order y,x;
  2990. \end{verbatim}}
  2991. would order {\tt Z} ahead of {\tt Y} and {\tt X}. The default ordering is
  2992. usually alphabetic.
  2993. \subsubsection{FACTOR Declaration}
  2994. This declaration takes a list of identifiers or kernels\index{Kernel}
  2995. as argument. {\tt FACTOR}\ttindex{FACTOR} is not a factoring command
  2996. (use {\tt FACTORIZE} or the {\tt FACTOR} switch for this purpose); rather it
  2997. is a separation command. All terms involving fixed powers of the declared
  2998. expressions are printed as a product of the fixed powers and a sum of the
  2999. rest of the terms.
  3000. All expressions involving a given prefix operator may also be factored by
  3001. putting the operator name in the list of factored identifiers. For example:
  3002. {\small\begin{verbatim}
  3003. factor x,cos,sin(x);
  3004. \end{verbatim}}
  3005. causes all powers of {\tt X} and {\tt SIN(X)} and all functions of
  3006. {\tt COS} to be factored.
  3007. Note that {\tt FACTOR} does not affect the order of its arguments. You
  3008. should also use {\tt ORDER} if this is important.
  3009. The declaration {\tt remfac v1,...,vn;}\ttindex{REMFAC} removes the
  3010. factoring flag from the expressions {\tt v1} through {\tt vn}.
  3011. \subsection{Output Control Switches}
  3012. \label{sec-output}
  3013. In addition to these declarations, the form of the output can be modified
  3014. by switching various output control switches using the declarations
  3015. {\tt ON} and {\tt OFF}. We shall illustrate the use of these switches by an
  3016. example, namely the printing of the expression
  3017. {\small\begin{verbatim}
  3018. x^2*(y^2+2*y)+x*(y^2+z)/(2*a) .
  3019. \end{verbatim}}
  3020. The relevant switches are as follows:
  3021. \subsubsection{ALLFAC Switch}
  3022. This switch will cause the system to search the whole expression, or any
  3023. sub-expression enclosed in parentheses, for simple multiplicative factors
  3024. and print them outside the parentheses. Thus our expression with {\tt ALLFAC}
  3025. \ttindex{ALLFAC}
  3026. off will print as
  3027. {\small\begin{verbatim}
  3028. 2 2 2 2
  3029. (2*X *Y *A + 4*X *Y*A + X*Y + X*Z)/(2*A)
  3030. \end{verbatim}}
  3031. and with {\tt ALLFAC} on as
  3032. {\small\begin{verbatim}
  3033. 2 2
  3034. X*(2*X*Y *A + 4*X*Y*A + Y + Z)/(2*A) .
  3035. \end{verbatim}}
  3036. {\tt ALLFAC} is normally on, and is on in the following examples, except
  3037. where otherwise stated.
  3038. \subsubsection{DIV Switch}\ttindex{DIV}
  3039. This switch makes the system search the denominator of an expression for
  3040. simple factors that it divides into the numerator, so that rational
  3041. fractions and negative powers appear in the output. With {\tt DIV} on, our
  3042. expression would print as
  3043. {\small\begin{verbatim}
  3044. 2 2 (-1) (-1)
  3045. X*(X*Y + 2*X*Y + 1/2*Y *A + 1/2*A *Z) .
  3046. \end{verbatim}}
  3047. {\tt DIV} is normally off.
  3048. \subsubsection{LIST Switch}\ttindex{LIST}
  3049. This switch causes the system to print each term in any sum on a separate
  3050. line. With {\tt LIST} on, our expression prints as
  3051. {\small\begin{verbatim}
  3052. 2
  3053. X*(2*X*Y *A
  3054. + 4*X*Y*A
  3055. 2
  3056. + Y
  3057. + Z)/(2*A) .
  3058. \end{verbatim}}
  3059. {\tt LIST} is normally off.
  3060. \subsubsection{NOSPLIT Switch}\ttindex{NOSPLIT}
  3061. Under normal circumstances, the printing routines try to break an expression
  3062. across lines at a natural point. This is a fairly expensive process. If
  3063. you are not overly concerned about where the end-of-line breaks come, you
  3064. can speed up the printing of expressions by turning off the switch
  3065. {\tt NOSPLIT}. This switch is normally on.
  3066. \subsubsection{RAT Switch}\ttindex{RAT}
  3067. This switch is only useful with expressions in which variables are
  3068. factored with {\tt FACTOR}. With this mode, the overall denominator of the
  3069. expression is printed with each factored sub-expression. We assume a prior
  3070. declaration {\tt factor x;} in the following output. We first print the
  3071. expression with {\tt RAT off}:
  3072. {\small\begin{verbatim}
  3073. 2 2
  3074. (2*X *Y*A*(Y + 2) + X*(Y + Z))/(2*A) .
  3075. \end{verbatim}}
  3076. With {\tt RAT} on the output becomes:
  3077. \extendedmanual{\newpage}
  3078. {\small\begin{verbatim}
  3079. 2 2
  3080. X *Y*(Y + 2) + X*(Y + Z)/(2*A) .
  3081. \end{verbatim}}
  3082. {\tt RAT} is normally off.
  3083. Next, if we leave {\tt X} factored, and turn on both {\tt DIV} and
  3084. {\tt RAT}, the result becomes
  3085. {\small\begin{verbatim}
  3086. 2 (-1) 2
  3087. X *Y*(Y + 2) + 1/2*X*A *(Y + Z) .
  3088. \end{verbatim}}
  3089. Finally, with {\tt X} factored, {\tt RAT} on and {\tt ALLFAC}\ttindex{ALLFAC}
  3090. off we retrieve the original structure
  3091. {\small\begin{verbatim}
  3092. 2 2 2
  3093. X *(Y + 2*Y) + X*(Y + Z)/(2*A) .
  3094. \end{verbatim}}
  3095. \subsubsection{RATPRI Switch}\ttindex{RATPRI}
  3096. If the numerator and denominator of an expression can each be printed in
  3097. one line, the output routines will print them in a two dimensional
  3098. notation, with numerator and denominator on separate lines and a line of
  3099. dashes in between. For example, {\tt (a+b)/2} will print as
  3100. {\small\begin{verbatim}
  3101. A + B
  3102. -----
  3103. 2
  3104. \end{verbatim}}
  3105. Turning this switch off causes such expressions to be output in a linear
  3106. form.
  3107. \subsubsection{REVPRI Switch}\ttindex{REVPRI}
  3108. The normal ordering of terms in output is from highest to lowest power.
  3109. In some situations (e.g., when a power series is output), the opposite
  3110. ordering is more convenient. The switch {\tt REVPRI} if on causes such a
  3111. reverse ordering of terms. For example, the expression
  3112. {\tt y*(x+1)\verb|^|2+(y+3)\verb|^|2} will normally print as
  3113. {\small\begin{verbatim}
  3114. 2 2
  3115. X *Y + 2*X*Y + Y + 7*Y + 9
  3116. \end{verbatim}}
  3117. whereas with {\tt REVPRI} on, it will print as
  3118. {\small\begin{verbatim}
  3119. 2 2
  3120. 9 + 7*Y + Y + 2*X*Y + X *Y.
  3121. \end{verbatim}}
  3122. \subsection{WRITE Command}\ttindex{WRITE}
  3123. In simple cases no explicit output\index{Output} command is necessary in
  3124. {\REDUCE}, since the value of any expression is automatically printed if a
  3125. semicolon is used as a delimiter. There are, however, several situations
  3126. in which such a command is useful.
  3127. In a {\tt FOR}, {\tt WHILE}, or {\tt REPEAT} statement it may be desired
  3128. to output something each time the statement within the loop construct is
  3129. repeated.
  3130. It may be desired for a procedure to output intermediate results or other
  3131. information while it is running. It may be desired to have results labeled
  3132. in special ways, especially if the output is directed to a file or device
  3133. other than the terminal.
  3134. The {\tt WRITE} command consists of the word {\tt WRITE} followed by one
  3135. or more items separated by commas, and followed by a terminator. There
  3136. are three kinds of items that can be used:
  3137. \begin{enumerate}
  3138. \item Expressions (including variables and constants). The expression is
  3139. evaluated, and the result is printed out.
  3140. \item Assignments. The expression on the right side of the {\tt :=}
  3141. operator is evaluated, and is assigned to the variable on the left; then
  3142. the symbol on the left is printed, followed by a ``{\tt :=}'', followed by
  3143. the value of the expression on the right -- almost exactly the way an
  3144. assignment followed by a semicolon prints out normally. (The difference is
  3145. that if the {\tt WRITE} is in a {\tt FOR} statement and the left-hand side
  3146. of the assignment is an array position or something similar containing the
  3147. variable of the {\tt FOR} iteration, then the value of that variable is
  3148. inserted in the printout.)
  3149. \item Arbitrary strings of characters, preceded and followed by double-quote
  3150. marks (e.g., {\tt "string"}).
  3151. \end{enumerate}
  3152. The items specified by a single {\tt WRITE} statement print side by side
  3153. on one line. (The line is broken automatically if it is too long.) Strings
  3154. print exactly as quoted. The {\tt WRITE} command itself however does not
  3155. return a value.
  3156. The print line is closed at the end of a {\tt WRITE} command evaluation.
  3157. Therefore the command {\tt WRITE "";} (specifying nothing to be printed
  3158. except the empty string) causes a line to be skipped.
  3159. {\it Examples:}
  3160. \begin{enumerate}
  3161. \item If {\tt A} is {\tt X+5}, {\tt B} is itself, {\tt C} is 123, {\tt M} is
  3162. an array, and {\tt Q}=3, then
  3163. {\small\begin{verbatim}
  3164. write m(q):=a," ",b/c," THANK YOU";
  3165. \end{verbatim}}
  3166. will set {\tt M(3)} to {\tt x+5} and print
  3167. {\small\begin{verbatim}
  3168. M(Q) := X + 5 B/123 THANK YOU
  3169. \end{verbatim}}
  3170. The blanks between the {\tt 5} and {\tt B}, and the
  3171. {\tt 3} and {\tt T}, come from the blanks in the quoted strings.
  3172. \item To print a table of the squares of the integers from 1 to 20:
  3173. {\small\begin{verbatim}
  3174. for i:=1:20 do write i," ",i^2;
  3175. \end{verbatim}}
  3176. \item To print a table of the squares of the integers from 1 to 20, and at
  3177. the same time store them in positions 1 to 20 of an array {\tt A:}
  3178. {\small\begin{verbatim}
  3179. for i:=1:20 do <<a(i):=i^2; write i," ",a(i)>>;
  3180. \end{verbatim}}
  3181. This will give us two columns of numbers. If we had used
  3182. {\small\begin{verbatim}
  3183. for i:=1:20 do write i," ",a(i):=i^2;
  3184. \end{verbatim}}
  3185. we would also get {\tt A(}i{\tt ) := } repeated on each line.
  3186. \item The following more complete example calculates the famous f and g
  3187. series, first reported in Sconzo, P., LeSchack, A. R., and Tobey, R.,
  3188. ``Symbolic Computation of f and g Series by Computer'', Astronomical Journal
  3189. 70 (May 1965).
  3190. {\small\begin{verbatim}
  3191. x1:= -sig*(mu+2*eps)$
  3192. x2:= eps - 2*sig^2$
  3193. x3:= -3*mu*sig$
  3194. f:= 1$
  3195. g:= 0$
  3196. for i:= 1 step 1 until 10 do begin
  3197. f1:= -mu*g+x1*df(f,eps)+x2*df(f,sig)+x3*df(f,mu);
  3198. write "f(",i,") := ",f1;
  3199. g1:= f+x1*df(g,eps)+x2*df(g,sig)+x3*df(g,mu);
  3200. write "g(",i,") := ",g1;
  3201. f:=f1$
  3202. g:=g1$
  3203. end;
  3204. \end{verbatim}}
  3205. A portion of the output, to illustrate the printout from the {\tt WRITE}
  3206. command, is as follows:
  3207. {\small\begin{verbatim}
  3208. ... <prior output> ...
  3209. 2
  3210. F(4) := MU*(3*EPS - 15*SIG + MU)
  3211. G(4) := 6*SIG*MU
  3212. 2
  3213. F(5) := 15*SIG*MU*( - 3*EPS + 7*SIG - MU)
  3214. 2
  3215. G(5) := MU*(9*EPS - 45*SIG + MU)
  3216. ... <more output> ...
  3217. \end{verbatim}}
  3218. \end{enumerate}
  3219. \subsection{Suppression of Zeros}
  3220. It is sometimes annoying to have zero assignments (i.e. assignments of the
  3221. form {\tt <expression> := 0}) printed, especially in printing large arrays
  3222. with many zero elements. The output from such assignments can be
  3223. suppressed by turning on the switch {\tt NERO}.\ttindex{NERO}
  3224. \subsection{{FORTRAN} Style Output Of Expressions}
  3225. It is naturally possible to evaluate expressions numerically in {\REDUCE} by
  3226. giving all variables and sub-expressions numerical values. However, as we
  3227. pointed out elsewhere the user must declare real arithmetical operation by
  3228. turning on the switch {\tt ROUNDED}\ttindex{ROUNDED}. However, it should be
  3229. remembered that arithmetic in {\REDUCE} is not particularly fast, since
  3230. results are interpreted rather than evaluated in a compiled form. The user
  3231. with a large amount of numerical computation after all necessary algebraic
  3232. manipulations have been performed is therefore well advised to perform
  3233. these calculations in a FORTRAN\index{FORTRAN} or similar system. For
  3234. this purpose, {\REDUCE} offers facilities for users to produce FORTRAN
  3235. compatible files for numerical processing.
  3236. First, when the switch {\tt FORT}\ttindex{FORT} is on, the system will
  3237. print expressions in a FORTRAN notation. Expressions begin in column
  3238. seven. If an expression extends over one line, a continuation mark (.)
  3239. followed by a blank appears on subsequent cards. After a certain number
  3240. of lines have been produced (according to the value of the variable {\tt
  3241. CARD\_NO}),\ttindex{CARD\_NO} a new expression is started. If the
  3242. expression printed arises from an assignment to a variable, the variable
  3243. is printed as the name of the expression. Otherwise the expression is
  3244. given the default name {\tt ANS}. An error occurs if identifiers or
  3245. numbers are outside the bounds permitted by FORTRAN.
  3246. A second option is to use the {\tt WRITE} command to produce other programs.
  3247. {\it Example:}
  3248. The following {\REDUCE} statements
  3249. {\small\begin{verbatim}
  3250. on fort;
  3251. out "forfil";
  3252. write "C this is a fortran program";
  3253. write " 1 format(e13.5)";
  3254. write " u=1.23";
  3255. write " v=2.17";
  3256. write " w=5.2";
  3257. x:=(u+v+w)^11;
  3258. write "C it was foolish to expand this expression";
  3259. write " print 1,x";
  3260. write " end";
  3261. shut "forfil";
  3262. off fort;
  3263. \end{verbatim}}
  3264. will generate a file {\tt forfil} that contains:
  3265. {\small
  3266. {\small\begin{verbatim}
  3267. c this is a fortran program
  3268. 1 format(e13.5)
  3269. u=1.23
  3270. v=2.17
  3271. w=5.2
  3272. ans1=1320.*u**3*v*w**7+165.*u**3*w**8+55.*u**2*v**9+495.*u
  3273. . **2*v**8*w+1980.*u**2*v**7*w**2+4620.*u**2*v**6*w**3+
  3274. . 6930.*u**2*v**5*w**4+6930.*u**2*v**4*w**5+4620.*u**2*v**3*
  3275. . w**6+1980.*u**2*v**2*w**7+495.*u**2*v*w**8+55.*u**2*w**9+
  3276. . 11.*u*v**10+110.*u*v**9*w+495.*u*v**8*w**2+1320.*u*v**7*w
  3277. . **3+2310.*u*v**6*w**4+2772.*u*v**5*w**5+2310.*u*v**4*w**6
  3278. . +1320.*u*v**3*w**7+495.*u*v**2*w**8+110.*u*v*w**9+11.*u*w
  3279. . **10+v**11+11.*v**10*w+55.*v**9*w**2+165.*v**8*w**3+330.*
  3280. . v**7*w**4+462.*v**6*w**5+462.*v**5*w**6+330.*v**4*w**7+
  3281. . 165.*v**3*w**8+55.*v**2*w**9+11.*v*w**10+w**11
  3282. x=u**11+11.*u**10*v+11.*u**10*w+55.*u**9*v**2+110.*u**9*v*
  3283. . w+55.*u**9*w**2+165.*u**8*v**3+495.*u**8*v**2*w+495.*u**8
  3284. . *v*w**2+165.*u**8*w**3+330.*u**7*v**4+1320.*u**7*v**3*w+
  3285. . 1980.*u**7*v**2*w**2+1320.*u**7*v*w**3+330.*u**7*w**4+462.
  3286. . *u**6*v**5+2310.*u**6*v**4*w+4620.*u**6*v**3*w**2+4620.*u
  3287. . **6*v**2*w**3+2310.*u**6*v*w**4+462.*u**6*w**5+462.*u**5*
  3288. . v**6+2772.*u**5*v**5*w+6930.*u**5*v**4*w**2+9240.*u**5*v
  3289. . **3*w**3+6930.*u**5*v**2*w**4+2772.*u**5*v*w**5+462.*u**5
  3290. . *w**6+330.*u**4*v**7+2310.*u**4*v**6*w+6930.*u**4*v**5*w
  3291. . **2+11550.*u**4*v**4*w**3+11550.*u**4*v**3*w**4+6930.*u**
  3292. . 4*v**2*w**5+2310.*u**4*v*w**6+330.*u**4*w**7+165.*u**3*v
  3293. . **8+1320.*u**3*v**7*w+4620.*u**3*v**6*w**2+9240.*u**3*v**
  3294. . 5*w**3+11550.*u**3*v**4*w**4+9240.*u**3*v**3*w**5+4620.*u
  3295. . **3*v**2*w**6+ans1
  3296. c it was foolish to expand this expression
  3297. print 1,x
  3298. end
  3299. \end{verbatim}}
  3300. }
  3301. If the arguments of a {\tt WRITE} statement include an expression that
  3302. requires continuation records, the output will need editing, since the
  3303. output routine prints the arguments of {\tt WRITE} sequentially, and the
  3304. continuation mechanism therefore generates its auxiliary variables after
  3305. the preceding expression has been printed.
  3306. Finally, since there is no direct analog of {\em list\/} in FORTRAN,
  3307. a comment line of the form
  3308. {\small\begin{verbatim}
  3309. c ***** invalid fortran construct (list) not printed
  3310. \end{verbatim}}
  3311. will be printed if you try to print a list with {\tt FORT} on.
  3312. \subsubsection{{FORTRAN} Output Options}\index{Output}\index{FORTRAN}
  3313. There are a number of methods available to change the default format of the
  3314. FORTRAN output.
  3315. The breakup of the expression into subparts is such that the number of
  3316. continuation lines produced is less than a given number. This number can
  3317. be modified by the assignment
  3318. {\small\begin{verbatim}
  3319. card_no := <number>;
  3320. \end{verbatim}}
  3321. where {\tt <number>} is the {\em total\/} number of cards allowed in a
  3322. statement. The default value of {\tt CARD\_NO} is 20.
  3323. The width of the output expression is also adjustable by the assignment
  3324. {\small\begin{verbatim}
  3325. fort_width := <integer>;
  3326. \end{verbatim}}
  3327. \ttindex{FORT\_WIDTH} which sets the total width of a given line to
  3328. {\tt <integer>}. The initial FORTRAN output width is 70.
  3329. {\REDUCE} automatically inserts a decimal point after each isolated integer
  3330. coefficient in a FORTRAN expression (so that, for example, 4 becomes
  3331. {\tt 4.} ). To prevent this, set the {\tt PERIOD}\ttindex{PERIOD}
  3332. mode switch to {\tt OFF}.
  3333. FORTRAN output is normally produced in lower case. If upper case is desired,
  3334. the switch {\tt FORTUPPER}\ttindex{FORTUPPER} should be turned on.
  3335. Finally, the default name {\tt ANS} assigned to an unnamed expression and
  3336. its subparts can be changed by the operator {\tt VARNAME}.
  3337. \ttindex{VARNAME} This takes a single identifier as argument, which then
  3338. replaces {\tt ANS} as the expression name. The value of {\tt VARNAME} is
  3339. its argument.
  3340. Further facilities for the production of FORTRAN and other language output
  3341. are provided by the SCOPE and GENTRAN
  3342. packages\extendedmanual{described in chapters~\ref{GENTRAN} and \ref{SCOPE}}.
  3343. \subsection{Saving Expressions for Later Use as Input}
  3344. \index{Saving an expression}
  3345. It is often useful to save an expression on an external file for use later
  3346. as input in further calculations. The commands for opening and closing
  3347. output files are explained elsewhere. However, we see in the examples on
  3348. output of expressions that the standard ``natural'' method of printing
  3349. expressions is not compatible with the input syntax. So to print the
  3350. expression in an input compatible form we must inhibit this natural style
  3351. by turning off the switch {\tt NAT}.\ttindex{NAT} If this is done, a
  3352. dollar sign will also be printed at the end of the expression.
  3353. {\it Example:}
  3354. The following sequence of commands
  3355. {\small\begin{verbatim}
  3356. off nat; out "out"; x := (y+z)^2; write "end";
  3357. shut "out"; on nat;
  3358. \end{verbatim}}
  3359. will generate a file {\tt out} that contains
  3360. {\small\begin{verbatim}
  3361. X := Y**2 + 2*Y*Z + Z**2$
  3362. END$
  3363. \end{verbatim}}
  3364. \subsection{Displaying Expression Structure}\index{Displaying structure}
  3365. In those cases where the final result has a complicated form, it is often
  3366. convenient to display the skeletal structure of the answer. The operator
  3367. {\tt STRUCTR},\ttindex{STRUCTR} that takes a single expression as argument,
  3368. will do this for you. Its syntax is:
  3369. {\small\begin{verbatim}
  3370. STRUCTR(EXPRN:algebraic[,ID1:identifier[,ID2:identifier]]);
  3371. \end{verbatim}}
  3372. The structure is printed effectively as a tree, in which the subparts are
  3373. laid out with auxiliary names. If the optional {\tt ID1} is absent, the
  3374. auxiliary names are prefixed by the root {\tt ANS}. This root may be
  3375. changed by the operator {\tt VARNAME}\ttindex{VARNAME}. If the
  3376. optional {\tt ID1} is present, and is an array name, the subparts are
  3377. named as elements of that array, otherwise {\tt ID1} is used as the root
  3378. prefix. (The second optional argument {\tt ID2} is explained later.)
  3379. The {\tt EXPRN} can be either a scalar or a matrix expression. Use of any
  3380. other will result in an error.
  3381. {\it Example:}
  3382. Let us suppose that the workspace contains
  3383. {\tt ((A+B)\verb|^|2+C)\verb|^|3+D}.
  3384. Then the input {\tt STRUCTR WS;} will (with {\tt EXP} off) result in the
  3385. output:\newpage
  3386. {\small\begin{verbatim}
  3387. ANS3
  3388. where
  3389. 3
  3390. ANS3 := ANS2 + D
  3391. 2
  3392. ANS2 := ANS1 + C
  3393. ANS1 := A + B
  3394. \end{verbatim}}
  3395. The workspace remains unchanged after this operation, since {\tt STRUCTR}
  3396. \ttindex{STRUCTR} in the default situation returns
  3397. no value (if {\tt STRUCTR} is used as a sub-expression, its value is taken
  3398. to be 0). In addition, the sub-expressions are normally only displayed
  3399. and not retained. If you wish to access the sub-expressions with their
  3400. displayed names, the switch {\tt SAVESTRUCTR}\ttindex{SAVESTRUCTR} should be
  3401. turned on. In this case, {\tt STRUCTR} returns a list whose first element
  3402. is a representation for the expression, and subsequent elements are the
  3403. sub-expression relations. Thus, with {\tt SAVESTRUCTR} on, {\tt STRUCTR WS}
  3404. in the above example would return
  3405. \vspace{-11pt}
  3406. {\small\begin{verbatim}
  3407. 3 2
  3408. {ANS3,ANS3=ANS2 + D,ANS2=ANS1 + C,ANS1=A + B}
  3409. \end{verbatim}}
  3410. The {\tt PART}\ttindex{PART} operator can
  3411. be used to retrieve the required parts of the expression. For example, to
  3412. get the value of {\tt ANS2} in the above, one could say:
  3413. {\small\begin{verbatim}
  3414. part(ws,3,2);
  3415. \end{verbatim}}
  3416. If {\tt FORT} is on, then the results are printed in the reverse order; the
  3417. algorithm in fact guaranteeing that no sub-expression will be referenced
  3418. before it is defined. The second optional argument {\tt ID2} may also be
  3419. used in this case to name the actual expression (or expressions in the
  3420. case of a matrix argument).
  3421. {\it Example:}
  3422. Let us suppose that {\tt M}, a 2 by 1 matrix, contains the elements {\tt
  3423. ((a+b)\verb|^|2 + c)\verb|^|3 + d} and {\tt (a + b)*(c + d)} respectively,
  3424. and that {\tt V} has been declared to be an array. With {\tt EXP} off and
  3425. {\tt FORT} on, the statement {\tt structr(2*m,v,k);} will result in the output
  3426. {\small\begin{verbatim}
  3427. V(1)=A+B
  3428. V(2)=V(1)**2+C
  3429. V(3)=V(2)**3+D
  3430. V(4)=C+D
  3431. K(1,1)=2.*V(3)
  3432. K(2,1)=2.*V(1)*V(4)
  3433. \end{verbatim}}
  3434. \section{Changing the Internal Order of Variables}
  3435. The internal ordering of variables (more specifically kernels) can have
  3436. a significant effect on the space and time associated with a calculation.
  3437. In its default state, {\REDUCE} uses a specific order for this which may
  3438. vary between sessions. However, it is possible for the user to change
  3439. this internal order by means of the declaration
  3440. {\tt KORDER}\ttindex{KORDER}. The syntax for this is:
  3441. {\small\begin{verbatim}
  3442. korder v1,...,vn;
  3443. \end{verbatim}}
  3444. where the {\tt Vi} are kernels\index{Kernel}. With this declaration, the
  3445. {\tt Vi} are ordered internally ahead of any other kernels in the system.
  3446. {\tt V1} has the highest order, {\tt V2} the next highest, and so on. A
  3447. further call of {\tt KORDER} replaces a previous one. {\tt KORDER NIL;}
  3448. resets the internal order to the system default.
  3449. Unlike the {\tt ORDER}\ttindex{ORDER} declaration, that has a purely
  3450. cosmetic effect on the way results are printed, the use of {\tt KORDER}
  3451. can have a significant effect on computation time. In critical cases
  3452. then, the user can experiment with the ordering of the variables used to
  3453. determine the optimum set for a given problem.
  3454. \section{Obtaining Parts of Algebraic Expressions}
  3455. There are many occasions where it is desirable to obtain a specific part
  3456. of an expression, or even change such a part to another expression. A
  3457. number of operators are available in {\REDUCE} for this purpose, and will be
  3458. described in this section. In addition, operators for obtaining specific
  3459. parts of polynomials and rational functions (such as a denominator) are
  3460. described in another section.
  3461. \subsection{COEFF Operator}\ttindex{COEFF}
  3462. Syntax:
  3463. {\small\begin{verbatim}
  3464. COEFF(EXPRN:polynomial,VAR:kernel)
  3465. \end{verbatim}}
  3466. {\tt COEFF} is an operator that partitions {\tt EXPRN} into its various
  3467. coefficients with respect to {\tt VAR} and returns them as a list, with
  3468. the coefficient independent of {\tt VAR} first.
  3469. Under normal circumstances, an error results if {\tt EXPRN} is not a
  3470. polynomial in {\tt VAR}, although the coefficients themselves can be
  3471. rational as long as they do not depend on {\tt VAR}. However, if the
  3472. switch {\tt RATARG}\ttindex{RATARG} is on, denominators are not checked for
  3473. dependence on {\tt VAR}, and are taken to be part of the coefficients.
  3474. {\it Example:}
  3475. {\small\begin{verbatim}
  3476. coeff((y^2+z)^3/z,y);
  3477. \end{verbatim}}
  3478. returns the result
  3479. {\small\begin{verbatim}
  3480. 2
  3481. {Z ,0,3*Z,0,3,0,1/Z}.
  3482. \end{verbatim}}
  3483. whereas
  3484. {\small\begin{verbatim}
  3485. coeff((y^2+z)^3/y,y);
  3486. \end{verbatim}}
  3487. gives an error if {\tt RATARG} is off, and the result
  3488. {\small\begin{verbatim}
  3489. 3 2
  3490. {Z /Y,0,3*Z /Y,0,3*Z/Y,0,1/Y}
  3491. \end{verbatim}}
  3492. if {\tt RATARG} is on.
  3493. The length of the result of {\tt COEFF} is the highest power of {\tt VAR}
  3494. encountered plus 1. In the above examples it is 7. In addition, the
  3495. variable {\tt HIGH\_POW}\ttindex{HIGH\_POW} is set to the highest non-zero
  3496. power found in {\tt EXPRN} during the evaluation, and {\tt LOW\_POW}
  3497. \ttindex{LOW\_POW} to the lowest non-zero power, or zero if there is a
  3498. constant term. If {\tt EXPRN} is a constant, then {\tt HIGH\_POW} and
  3499. {\tt LOW\_POW} are both set to zero.
  3500. \subsection{COEFFN Operator}\ttindex{COEFFN}
  3501. The {\tt COEFFN} operator is designed to give the user a particular
  3502. coefficient of a variable in a polynomial, as opposed to {\tt COEFF} that
  3503. returns all coefficients. {\tt COEFFN} is used with the syntax
  3504. {\small\begin{verbatim}
  3505. COEFFN(EXPRN:polynomial,VAR:kernel,N:integer)
  3506. \end{verbatim}}
  3507. It returns the $n^{th}$ coefficient of {\tt VAR} in the polynomial
  3508. {\tt EXPRN}.
  3509. \subsection{PART Operator}\ttindex{PART}
  3510. Syntax:
  3511. {\small\begin{verbatim}
  3512. PART(EXPRN:algebraic[,INTEXP:integer])
  3513. \end{verbatim}}
  3514. This operator works on the form of the expression as printed {\em or as it
  3515. would have been printed at that point in the calculation\/} bearing in mind
  3516. all the relevant switch settings at that point. The reader therefore
  3517. needs some familiarity with the way that expressions are represented in
  3518. prefix form in {\REDUCE} to use these operators effectively. Furthermore,
  3519. it is assumed that {\tt PRI} is {\tt ON} at that point in the calculation.
  3520. The reason for this is that with {\tt PRI} off, an expression is printed
  3521. by walking the tree representing the expression internally. To save
  3522. space, it is never actually transformed into the equivalent prefix
  3523. expression as occurs when {\tt PRI} is on. However, the operations on
  3524. polynomials described elsewhere can be equally well used in this case to
  3525. obtain the relevant parts.
  3526. The evaluation proceeds recursively down the integer expression list. In
  3527. other words,
  3528. {\small\begin{verbatim}
  3529. PART(<expression>,<integer1>,<integer2>)
  3530. -> PART(PART(<expression>,<integer1>),<integer2>)
  3531. \end{verbatim}}
  3532. and so on, and
  3533. {\small\begin{verbatim}
  3534. PART(<expression>) -> <expression>.
  3535. \end{verbatim}}
  3536. {\tt INTEXP} can be any expression that evaluates to an integer. If the
  3537. integer is positive, then that term of the expression is found. If the
  3538. integer is 0, the operator is returned. Finally, if the integer is
  3539. negative, the counting is from the tail of the expression rather than the
  3540. head.
  3541. For example, if the expression {\tt a+b} is printed as {\tt A+B} (i.e.,
  3542. the ordering of the variables is alphabetical), then
  3543. {\small\begin{verbatim}
  3544. part(a+b,2) -> B
  3545. part(a+b,-1) -> B
  3546. and
  3547. part(a+b,0) -> PLUS
  3548. \end{verbatim}}
  3549. An operator {\tt ARGLENGTH}\ttindex{ARGLENGTH} is available to determine
  3550. the number of arguments of the top level operator in an expression. If
  3551. the expression does not contain a top level operator, then $-1$ is returned.
  3552. For example,
  3553. {\small\begin{verbatim}
  3554. arglength(a+b+c) -> 3
  3555. arglength(f()) -> 0
  3556. arglength(a) -> -1
  3557. \end{verbatim}}
  3558. \subsection{Substituting for Parts of Expressions}
  3559. {\tt PART} may also be used to substitute for a given part of an
  3560. expression. In this case, the {\tt PART} construct appears on the
  3561. left-hand side of an assignment statement, and the expression to replace
  3562. the given part on the right-hand side.
  3563. For example, with the normal settings of the {\REDUCE} switches:
  3564. {\small\begin{verbatim}
  3565. xx := a+b;
  3566. part(xx,2) := c; -> A+C
  3567. part(c+d,0) := -; -> C-D
  3568. \end{verbatim}}
  3569. Note that {\tt xx} in the above is not changed by this substitution. In
  3570. addition, unlike expressions such as array and matrix elements that have
  3571. an {\em instant evaluation\/}\index{Instant evaluation} property, the values
  3572. of {\tt part(xx,2)} and {\tt part(c+d,0)} are also not changed.
  3573. \chapter{Polynomials and Rationals}
  3574. Many operations in computer algebra are concerned with polynomials
  3575. \index{Polynomial} and rational functions\index{Rational function}. In
  3576. this section, we review some of the switches and operators available for
  3577. this purpose. These are in addition to those that work on general
  3578. expressions (such as {\tt DF} and {\tt INT}) described elsewhere. In the
  3579. case of operators, the arguments are first simplified before the
  3580. operations are applied. In addition, they operate only on arguments of
  3581. prescribed types, and produce a type mismatch error if given arguments
  3582. which cannot be interpreted in the required mode with the current switch
  3583. settings. For example, if an argument is required to be a kernel and
  3584. {\tt a/2} is used (with no other rules for {\tt A}), an error
  3585. {\small\begin{verbatim}
  3586. A/2 invalid as kernel
  3587. \end{verbatim}}
  3588. will result.
  3589. With the exception of those that select various parts of a polynomial or
  3590. rational function, these operations have potentially significant effects on
  3591. the space and time associated with a given calculation. The user should
  3592. therefore experiment with their use in a given calculation in order to
  3593. determine the optimum set for a given problem.
  3594. One such operation provided by the system is an operator {\tt LENGTH}
  3595. \ttindex{LENGTH} which returns the number of top level terms in the
  3596. numerator of its argument. For example,
  3597. {\small\begin{verbatim}
  3598. length ((a+b+c)^3/(c+d));
  3599. \end{verbatim}}
  3600. has the value 10. To get the number of terms in the denominator, one
  3601. would first select the denominator by the operator {\tt DEN}\ttindex{DEN}
  3602. and then call {\tt LENGTH}, as in
  3603. {\small\begin{verbatim}
  3604. length den ((a+b+c)^3/(c+d));
  3605. \end{verbatim}}
  3606. Other operations currently supported, the relevant switches and operators,
  3607. and the required argument and value modes of the latter, follow.
  3608. \section{Controlling the Expansion of Expressions}
  3609. The switch {\tt EXP}\ttindex{EXP} controls the expansion of expressions. If
  3610. it is off, no expansion of powers or products of expressions occurs.
  3611. Users should note however that in this case results come out in a normal
  3612. but not necessarily canonical form. This means that zero expressions
  3613. simplify to zero, but that two equivalent expressions need not necessarily
  3614. simplify to the same form.
  3615. {\it Example:} With {\tt EXP} on, the two expressions
  3616. {\small\begin{verbatim}
  3617. (a+b)*(a+2*b)
  3618. \end{verbatim}}
  3619. and
  3620. {\small\begin{verbatim}
  3621. a^2+3*a*b+2*b^2
  3622. \end{verbatim}}
  3623. will both simplify to the latter form. With {\tt EXP}
  3624. off, they would remain unchanged, unless the complete factoring {\tt
  3625. (ALLFAC)} option were in force. {\tt EXP} is normally on.
  3626. Several operators that expect a polynomial as an argument behave
  3627. differently when {\tt EXP} is off, since there is often only one term at
  3628. the top level. For example, with {\tt EXP} off
  3629. {\small\begin{verbatim}
  3630. length((a+b+c)^3/(c+d));
  3631. \end{verbatim}}
  3632. returns the value 1.
  3633. \section{Factorization of Polynomials}\index{Factorization}
  3634. {\REDUCE} is capable of factorizing univariate and multivariate polynomials
  3635. that have integer coefficients, finding all factors that also have integer
  3636. coefficients. The package for doing this was written by Dr. Arthur C.
  3637. Norman and Ms. P. Mary Ann Moore at The University of Cambridge. It is
  3638. described in P. M. A. Moore and A. C. Norman, ``Implementing a Polynomial
  3639. Factorization and GCD Package'', Proc. SYMSAC '81, ACM (New York) (1981),
  3640. 109-116.
  3641. The easiest way to use this facility is to turn on the switch
  3642. {\tt FACTOR},\ttindex{FACTOR} which causes all expressions to be output in
  3643. a factored form. For example, with {\tt FACTOR} on, the expression
  3644. {\tt A\verb|^|2-B\verb|^|2} is returned as {\tt (A+B)*(A-B)}.
  3645. It is also possible to factorize a given expression explicitly. The
  3646. operator {\tt FACTORIZE}\ttindex{FACTORIZE} that invokes this facility is
  3647. used with the syntax
  3648. {\small\begin{verbatim}
  3649. FACTORIZE(EXPRN:polynomial[,INTEXP:prime integer]):list,
  3650. \end{verbatim}}
  3651. the optional argument of which will be described later. Thus to find and
  3652. display all factors of the cyclotomic polynomial $x^{105}-1$, one could
  3653. write:
  3654. {\small\begin{verbatim}
  3655. factorize(x^105-1);
  3656. \end{verbatim}}
  3657. The result is a list of factor,exponent pairs.
  3658. In the above example, there is no overall numerical factor in the result,
  3659. so the results will consist only of polynomials in x. The number of such
  3660. polynomials can be found by using the operator {\tt LENGTH}.\ttindex{LENGTH}
  3661. If there is a numerical factor, as in factorizing $12x^{2}-12$,
  3662. that factor will appear as the first member of the result.
  3663. It will however not be factored further. Prime factors of such numbers
  3664. can be found, using a probabilistic algorithm, by turning on the switch
  3665. {\tt IFACTOR}.\ttindex{IFACTOR} For example,
  3666. {\small\begin{verbatim}
  3667. on ifactor; factorize(12x^2-12);
  3668. \end{verbatim}}
  3669. would result in the output
  3670. {\small\begin{verbatim}
  3671. {{2,2},{3,1},{X + 1,1},{X - 1,1}}.
  3672. \end{verbatim}}
  3673. If the first argument of {\tt FACTORIZE} is an integer, it will be
  3674. decomposed into its prime components, whether or not {\tt IFACTOR} is on.
  3675. Note that the {\tt IFACTOR} switch only affects the result of {\tt FACTORIZE}.
  3676. It has no effect if the {\tt FACTOR}\ttindex{FACTOR} switch is also on.
  3677. The order in which the factors occur in the result (with the exception of
  3678. a possible overall numerical coefficient which comes first) can be system
  3679. dependent and should not be relied on. Similarly it should be noted that
  3680. any pair of individual factors can be negated without altering their
  3681. product, and that {\REDUCE} may sometimes do that.
  3682. The factorizer works by first reducing multivariate problems to univariate
  3683. ones and then solving the univariate ones modulo small primes. It normally
  3684. selects both evaluation points and primes using a random number generator
  3685. that should lead to different detailed behavior each time any particular
  3686. problem is tackled. If, for some reason, it is known that a certain
  3687. (probably univariate) factorization can be performed effectively with a
  3688. known prime, {\tt P} say, this value of {\tt P} can be handed to
  3689. {\tt FACTORIZE}\ttindex{FACTORIZE} as a second
  3690. argument. An error will occur if a non-prime is provided to {\tt FACTORIZE} in
  3691. this manner. It is also an error to specify a prime that divides the
  3692. discriminant of the polynomial being factored, but users should note that
  3693. this condition is not checked by the program, so this capability should be
  3694. used with care.
  3695. Factorization can be performed over a number of polynomial coefficient
  3696. domains in addition to integers. The particular description of the relevant
  3697. domain should be consulted to see if factorization is supported. For
  3698. example, the following statements will factorize $x^{4}+1$ modulo 7:
  3699. {\small\begin{verbatim}
  3700. setmod 7;
  3701. on modular;
  3702. factorize(x^4+1);
  3703. \end{verbatim}}
  3704. The factorization module is provided with a trace facility that may be useful
  3705. as a way of monitoring progress on large problems, and of satisfying
  3706. curiosity about the internal workings of the package. The most simple use
  3707. of this is enabled by issuing the {\REDUCE} command\ttindex{TRFAC}
  3708. {\tt on trfac;} .
  3709. Following this, all calls to the factorizer will generate informative
  3710. messages reporting on such things as the reduction of multivariate to
  3711. univariate cases, the choice of a prime and the reconstruction of full
  3712. factors from their images. Further levels of detail in the trace are
  3713. intended mainly for system tuners and for the investigation of suspected
  3714. bugs. For example, {\tt TRALLFAC} gives tracing information at all levels
  3715. of detail. The switch that can be set by {\tt on timings;} makes it
  3716. possible for one who is familiar with the algorithms used to determine
  3717. what part of the factorization code is consuming the most resources.
  3718. {\tt on overview}; reduces the amount of detail presented in other forms of
  3719. trace. Other forms of trace output are enabled by directives of the form
  3720. {\small\begin{verbatim}
  3721. symbolic set!-trace!-factor(<number>,<filename>);
  3722. \end{verbatim}}
  3723. where useful numbers are 1, 2, 3 and 100, 101, ... . This facility is
  3724. intended to make it possible to discover in fairly great detail what just
  3725. some small part of the code has been doing --- the numbers refer mainly to
  3726. depths of recursion when the factorizer calls itself, and to the split
  3727. between its work forming and factorizing images and reconstructing full
  3728. factors from these. If {\tt NIL} is used in place of a filename the trace
  3729. output requested is directed to the standard output stream. After use of
  3730. this trace facility the generated trace files should be closed by calling
  3731. {\small\begin{verbatim}
  3732. symbolic close!-trace!-files();
  3733. \end{verbatim}}
  3734. {\it NOTE:} Using the factorizer with {\tt MCD}\ttindex{MCD} off will
  3735. result in an error.
  3736. \section{Cancellation of Common Factors}
  3737. Facilities are available in {\REDUCE} for cancelling common factors in the
  3738. numerators and denominators of expressions, at the option of the user. The
  3739. system will perform this greatest common divisor computation if the switch
  3740. {\tt GCD}\ttindex{GCD} is on. ({\tt GCD} is normally off.)
  3741. A check is automatically made, however, for common variable and numerical
  3742. products in the numerators and denominators of expressions, and the
  3743. appropriate cancellations made.
  3744. When {\tt GCD} is on, and {\tt EXP} is off, a check is made for square
  3745. free factors in an expression. This includes separating out and
  3746. independently checking the content of a given polynomial where
  3747. appropriate. (For an explanation of these terms, see Anthony C. Hearn,
  3748. ``Non-Modular Computation of Polynomial GCDs Using Trial Division'', Proc.
  3749. EUROSAM 79, published as Lecture Notes on Comp. Science, Springer-Verlag,
  3750. Berlin, No 72 (1979) 227-239.)
  3751. {\it Example:} With {\tt EXP}\ttindex{EXP} off and {\tt GCD}\ttindex{GCD}
  3752. on,
  3753. the polynomial {\tt a*c+a*d+b*c+b*d} would be returned as {\tt (A+B)*(C+D)}.
  3754. Under normal circumstances, GCDs are computed using an algorithm described
  3755. in the above paper. It is also possible in {\REDUCE} to compute GCDs using
  3756. an alternative algorithm, called the EZGCD Algorithm, which uses modular
  3757. arithmetic. The switch {\tt EZGCD}\ttindex{EZGCD}, if on in addition to
  3758. {\tt GCD}, makes this happen.
  3759. In non-trivial cases, the EZGCD algorithm is almost always better
  3760. than the basic algorithm, often by orders of magnitude. We therefore
  3761. {\em strongly\/} advise users to use the {\tt EZGCD} switch where they have the
  3762. resources available for supporting the package.
  3763. For a description of the EZGCD algorithm, see J. Moses and D.Y.Y. Yun,
  3764. ``The EZ GCD Algorithm'', Proc. ACM 1973, ACM, New York (1973) 159-166.
  3765. {\it NOTE:}
  3766. This package shares code with the factorizer, so a certain amount of trace
  3767. information can be produced using the factorizer trace switches.
  3768. \subsection{Determining the GCD of Two Polynomials}
  3769. This operator, used with the syntax
  3770. {\small\begin{verbatim}
  3771. GCD(EXPRN1:polynomial,EXPRN2:polynomial):polynomial,
  3772. \end{verbatim}}
  3773. returns the greatest common divisor of the two polynomials {\tt EXPRN1} and
  3774. {\tt EXPRN2}.
  3775. {\it Examples:}
  3776. {\small\begin{verbatim}
  3777. gcd(x^2+2*x+1,x^2+3*x+2) -> X+1
  3778. gcd(2*x^2-2*y^2,4*x+4*y) -> 2*X+2*Y
  3779. gcd(x^2+y^2,x-y) -> 1.
  3780. \end{verbatim}}
  3781. \section{Working with Least Common Multiples}
  3782. Greatest common divisor calculations can often become expensive if
  3783. extensive work with large rational expressions is required. However, in
  3784. many cases, the only significant cancellations arise from the fact that
  3785. there are often common factors in the various denominators which are
  3786. combined when two rationals are added. Since these denominators tend to be
  3787. smaller and more regular in structure than the numerators, considerable
  3788. savings in both time and space can occur if a full GCD check is made when
  3789. the denominators are combined and only a partial check when numerators are
  3790. constructed. In other words, the true least common multiple of the
  3791. denominators is computed at each step. The switch {\tt LCM}\ttindex{LCM}
  3792. is available for this purpose, and is normally on.
  3793. In addition, the operator {\tt LCM},\ttindex{LCM} used with the syntax
  3794. {\small\begin{verbatim}
  3795. LCM(EXPRN1:polynomial,EXPRN2:polynomial):polynomial,
  3796. \end{verbatim}}
  3797. returns the least common multiple of the two polynomials {\tt EXPRN1} and
  3798. {\tt EXPRN2}.
  3799. {\it Examples:}
  3800. {\small\begin{verbatim}
  3801. lcm(x^2+2*x+1,x^2+3*x+2) -> X**3 + 4*X**2 + 5*X + 2
  3802. lcm(2*x^2-2*y^2,4*x+4*y) -> 4*(X**2 - Y**2)
  3803. \end{verbatim}}
  3804. \section{Controlling Use of Common Denominators}
  3805. When two rational functions are added, {\REDUCE} normally produces an
  3806. expression over a common denominator. However, if the user does not want
  3807. denominators combined, he or she can turn off the switch {\tt MCD}
  3808. \ttindex{MCD} which controls this process. The latter switch is
  3809. particularly useful if no greatest common divisor calculations are
  3810. desired, or excessive differentiation of rational functions is required.
  3811. {\it CAUTION:} With {\tt MCD} off, results are not guaranteed to come out in
  3812. either normal or canonical form. In other words, an expression equivalent
  3813. to zero may in fact not be simplified to zero. This option is therefore
  3814. most useful for avoiding expression swell during intermediate parts of a
  3815. calculation.
  3816. {\tt MCD}\ttindex{MCD} is normally on.
  3817. \section{REMAINDER Operator}\ttindex{REMAINDER}
  3818. This operator is used with the syntax
  3819. {\small\begin{verbatim}
  3820. REMAINDER(EXPRN1:polynomial,EXPRN2:polynomial):polynomial.
  3821. \end{verbatim}}
  3822. It returns the remainder when {\tt EXPRN1} is divided by {\tt EXPRN2}. This
  3823. is the true remainder based on the internal ordering of the variables, and
  3824. not the pseudo-remainder. The pseudo-remainder \ttindex{PSEUDO\_REMAINDER}
  3825. and in general pseudo-division \ttindex{PSEUDO\_DIVIDE} of polynomials
  3826. can be calculated after loading the {\tt polydiv} package.
  3827. Please refer to the documentation of this package for details.
  3828. {\it Examples:}
  3829. {\small\begin{verbatim}
  3830. remainder((x+y)*(x+2*y),x+3*y) -> 2*Y**2
  3831. remainder(2*x+y,2) -> Y.
  3832. \end{verbatim}}
  3833. {\it CAUTION:} In the default case, remainders are calculated over the
  3834. integers. If you need the remainder with respect to another domain, it
  3835. must be declared explicitly.
  3836. {\it Example:}
  3837. {\small\begin{verbatim}
  3838. remainder(x^2-2,x+sqrt(2)); -> X^2 - 2
  3839. load_package arnum;
  3840. defpoly sqrt2**2-2;
  3841. remainder(x^2-2,x+sqrt2); -> 0
  3842. \end{verbatim}}
  3843. \section{RESULTANT Operator}\ttindex{RESULTANT}
  3844. This is used with the syntax
  3845. {\small\begin{verbatim}
  3846. RESULTANT(EXPRN1:polynomial,EXPRN2:polynomial,VAR:kernel):
  3847. polynomial.
  3848. \end{verbatim}}
  3849. It computes the resultant of the two given polynomials with respect to the
  3850. given variable, the coefficients of the polynomials can be taken from any
  3851. domain. The result can be identified as the determinant of a
  3852. Sylvester matrix, but can often also be thought of informally as the
  3853. result obtained when the given variable is eliminated between the two input
  3854. polynomials. If the two input polynomials have a non-trivial GCD their
  3855. resultant vanishes.
  3856. The switch {\tt Bezout}\ttindex{Bezout} controls the computation of the
  3857. resultants. It is off by default. In this case a subresultant algorithm
  3858. is used. If the switch Bezout is turned on, the resultant is computed via
  3859. the Bezout Matrix. However, in the latter case, only polynomial coefficients
  3860. are permitted.
  3861. \begin{samepage}
  3862. The sign conventions used by the resultant function follow those in R.
  3863. Loos, ``Computing in Algebraic Extensions'' in ``Computer Algebra --- Symbolic
  3864. and Algebraic Computation'', Second Ed., Edited by B. Buchberger, G.E.
  3865. Collins and R. Loos, Springer-Verlag, 1983. Namely, with {\tt A} and {\tt B}
  3866. not dependent on {\tt X}:
  3867. {\small\begin{verbatim}
  3868. deg(p)*deg(q)
  3869. resultant(p(x),q(x),x)= (-1) *resultant(q,p,x)
  3870. deg(p)
  3871. resultant(a,p(x),x) = a
  3872. resultant(a,b,x) = 1
  3873. \end{verbatim}}
  3874. \end{samepage}
  3875. {\it Examples:}
  3876. \begin{samepage}
  3877. {\small\begin{verbatim}
  3878. 2
  3879. resultant(x/r*u+y,u*y,u) -> - y
  3880. \end{verbatim}}
  3881. \end{samepage}
  3882. {\it calculation in an algebraic extension:}
  3883. \begin{samepage}
  3884. {\small\begin{verbatim}
  3885. load arnum;
  3886. defpoly sqrt2**2 - 2;
  3887. resultant(x + sqrt2,sqrt2 * x +1,x) -> -1
  3888. \end{verbatim}}
  3889. \end{samepage}
  3890. {\it or in a modular domain:}
  3891. \begin{samepage}
  3892. {\small\begin{verbatim}
  3893. setmod 17;
  3894. on modular;
  3895. resultant(2x+1,3x+4,x) -> 5
  3896. \end{verbatim}}
  3897. \end{samepage}
  3898. \section{DECOMPOSE Operator}\ttindex{DECOMPOSE}
  3899. The {\tt DECOMPOSE} operator takes a multivariate polynomial as argument,
  3900. and returns an expression and a list of equations from which the
  3901. original polynomial can be found by composition. Its syntax is:
  3902. {\small\begin{verbatim}
  3903. DECOMPOSE(EXPRN:polynomial):list.
  3904. \end{verbatim}}
  3905. For example:
  3906. {\small\begin{verbatim}
  3907. decompose(x^8-88*x^7+2924*x^6-43912*x^5+263431*x^4-
  3908. 218900*x^3+65690*x^2-7700*x+234)
  3909. 2 2 2
  3910. -> {U + 35*U + 234, U=V + 10*V, V=X - 22*X}
  3911. 2
  3912. decompose(u^2+v^2+2u*v+1) -> {W + 1, W=U + V}
  3913. \end{verbatim}}
  3914. Users should note however that, unlike factorization, this decomposition
  3915. is not unique.
  3916. \section{INTERPOL operator}\ttindex{INTERPOL}
  3917. Syntax:
  3918. {\small\begin{verbatim}
  3919. INTERPOL(<values>,<variable>,<points>);
  3920. \end{verbatim}}
  3921. where {\tt <values>} and {\tt <points>} are lists of equal length and
  3922. {\tt <variable>} is an algebraic expression (preferably a kernel).
  3923. {\tt INTERPOL} generates an interpolation polynomial {\em f\/} in the given
  3924. variable of degree length({\tt <values>})-1. The unique polynomial {\em f\/}
  3925. is defined by the property that for corresponding elements {\em v\/} of
  3926. {\tt <values>} and {\em p\/} of {\tt <points>} the relation $f(p)=v$ holds.
  3927. The Aitken-Neville interpolation algorithm is used which guarantees a
  3928. stable result even with rounded numbers and an ill-conditioned problem.
  3929. \section{Obtaining Parts of Polynomials and Rationals}
  3930. These operators select various parts of a polynomial or rational function
  3931. structure. Except for the cost of rearrangement of the structure, these
  3932. operations take very little time to perform.
  3933. For those operators in this section that take a kernel {\tt VAR} as their
  3934. second argument, an error results if the first expression is not a
  3935. polynomial in {\tt VAR}, although the coefficients themselves can be
  3936. rational as long as they do not depend on {\tt VAR}. However, if the
  3937. switch {\tt RATARG}\ttindex{RATARG} is on, denominators are not checked
  3938. for dependence on {\tt VAR}, and are taken to be part of the coefficients.
  3939. \subsection{DEG Operator}\ttindex{DEG}
  3940. This operator is used with the syntax
  3941. {\small\begin{verbatim}
  3942. DEG(EXPRN:polynomial,VAR:kernel):integer.
  3943. \end{verbatim}}
  3944. It returns the leading degree\index{Degree} of the polynomial {\tt EXPRN}
  3945. in the variable {\tt VAR}. If {\tt VAR} does not occur as a variable in
  3946. {\tt EXPRN}, 0 is returned.
  3947. {\it Examples:}
  3948. {\small\begin{verbatim}
  3949. deg((a+b)*(c+2*d)^2,a) -> 1
  3950. deg((a+b)*(c+2*d)^2,d) -> 2
  3951. deg((a+b)*(c+2*d)^2,e) -> 0.
  3952. \end{verbatim}}
  3953. Note also that if {\tt RATARG} is on,
  3954. {\small\begin{verbatim}
  3955. deg((a+b)^3/a,a) -> 3
  3956. \end{verbatim}}
  3957. since in this case, the denominator {\tt A} is considered part of the
  3958. coefficients of the numerator in {\tt A}. With {\tt RATARG} off, however,
  3959. an error would result in this case.
  3960. \subsection{DEN Operator}\ttindex{DEN}
  3961. This is used with the syntax:
  3962. {\small\begin{verbatim}
  3963. DEN(EXPRN:rational):polynomial.
  3964. \end{verbatim}}
  3965. It returns the denominator of the rational expression {\tt EXPRN}. If
  3966. {\tt EXPRN} is a polynomial, 1 is returned.
  3967. {\it Examples:}
  3968. {\small\begin{verbatim}
  3969. den(x/y^2) -> Y**2
  3970. den(100/6) -> 3
  3971. [since 100/6 is first simplified to 50/3]
  3972. den(a/4+b/6) -> 12
  3973. den(a+b) -> 1
  3974. \end{verbatim}}
  3975. \subsection{LCOF Operator}\ttindex{LCOF}
  3976. LCOF is used with the syntax
  3977. {\small\begin{verbatim}
  3978. LCOF(EXPRN:polynomial,VAR:kernel):polynomial.
  3979. \end{verbatim}}
  3980. It returns the leading coefficient\index{Leading coefficient} of the
  3981. polynomial {\tt EXPRN} in the variable {\tt VAR}. If {\tt VAR} does not
  3982. occur as a variable in {\tt EXPRN}, {\tt EXPRN} is returned.
  3983. \extendedmanual{\newpage}
  3984. {\it Examples:}
  3985. {\small\begin{verbatim}
  3986. lcof((a+b)*(c+2*d)^2,a) -> C**2+4*C*D+4*D**2
  3987. lcof((a+b)*(c+2*d)^2,d) -> 4*(A+B)
  3988. lcof((a+b)*(c+2*d),e) -> A*C+2*A*D+B*C+2*B*D
  3989. \end{verbatim}}
  3990. \subsection{LPOWER Operator}\ttindex{LPOWER}
  3991. \begin{samepage}
  3992. Syntax:
  3993. {\small\begin{verbatim}
  3994. LPOWER(EXPRN:polynomial,VAR:kernel):polynomial.
  3995. \end{verbatim}}
  3996. LPOWER returns the leading power of {\tt EXPRN} with respect to {\tt VAR}.
  3997. If {\tt EXPRN} does not depend on {\tt VAR}, 1 is returned.
  3998. \end{samepage}
  3999. {\it Examples:}
  4000. {\small\begin{verbatim}
  4001. lpower((a+b)*(c+2*d)^2,a) -> A
  4002. lpower((a+b)*(c+2*d)^2,d) -> D**2
  4003. lpower((a+b)*(c+2*d),e) -> 1
  4004. \end{verbatim}}
  4005. \subsection{LTERM Operator}\ttindex{LTERM}
  4006. \begin{samepage}
  4007. Syntax:
  4008. {\small\begin{verbatim}
  4009. LTERM(EXPRN:polynomial,VAR:kernel):polynomial.
  4010. \end{verbatim}}
  4011. LTERM returns the leading term of {\tt EXPRN} with respect to {\tt VAR}.
  4012. If {\tt EXPRN} does not depend on {\tt VAR}, {\tt EXPRN} is returned.
  4013. \end{samepage}
  4014. {\it Examples:}
  4015. {\small\begin{verbatim}
  4016. lterm((a+b)*(c+2*d)^2,a) -> A*(C**2+4*C*D+4*D**2)
  4017. lterm((a+b)*(c+2*d)^2,d) -> 4*D**2*(A+B)
  4018. lterm((a+b)*(c+2*d),e) -> A*C+2*A*D+B*C+2*B*D
  4019. \end{verbatim}}
  4020. {\COMPATNOTE} In some earlier versions of REDUCE, {\tt LTERM} returned
  4021. {\tt 0} if the {\tt EXPRN} did not depend on {\tt VAR}. In the present
  4022. version, {\tt EXPRN} is always equal to {\tt LTERM(EXPRN,VAR)} $+$ {\tt
  4023. REDUCT(EXPRN,VAR)}.
  4024. \subsection{MAINVAR Operator}\ttindex{MAINVAR}
  4025. Syntax:
  4026. {\small\begin{verbatim}
  4027. MAINVAR(EXPRN:polynomial):expression.
  4028. \end{verbatim}}
  4029. Returns the main variable (based on the internal polynomial representation)
  4030. of {\tt EXPRN}. If {\tt EXPRN} is a domain element, 0 is returned.
  4031. {\it Examples:}
  4032. Assuming {\tt A} has higher kernel order than {\tt B}, {\tt C}, or {\tt D}:
  4033. {\small\begin{verbatim}
  4034. mainvar((a+b)*(c+2*d)^2) -> A
  4035. mainvar(2) -> 0
  4036. \end{verbatim}}
  4037. \subsection{NUM Operator}\ttindex{NUM}
  4038. Syntax:
  4039. {\small\begin{verbatim}
  4040. NUM(EXPRN:rational):polynomial.
  4041. \end{verbatim}}
  4042. Returns the numerator of the rational expression {\tt EXPRN}. If {\tt EXPRN}
  4043. is a polynomial, that polynomial is returned.
  4044. {\it Examples:}
  4045. {\small\begin{verbatim}
  4046. num(x/y^2) -> X
  4047. num(100/6) -> 50
  4048. num(a/4+b/6) -> 3*A+2*B
  4049. num(a+b) -> A+B
  4050. \end{verbatim}}
  4051. \subsection{REDUCT Operator}\ttindex{REDUCT}
  4052. Syntax:
  4053. {\small\begin{verbatim}
  4054. REDUCT(EXPRN:polynomial,VAR:kernel):polynomial.
  4055. \end{verbatim}}
  4056. Returns the reductum of {\tt EXPRN} with respect to {\tt VAR} (i.e., the
  4057. part of {\tt EXPRN} left after the leading term is removed). If {\tt
  4058. EXPRN} does not depend on the variable {\tt VAR}, 0 is returned.
  4059. {\it Examples:}
  4060. {\small\begin{verbatim}
  4061. reduct((a+b)*(c+2*d),a) -> B*(C + 2*D)
  4062. reduct((a+b)*(c+2*d),d) -> C*(A + B)
  4063. reduct((a+b)*(c+2*d),e) -> 0
  4064. \end{verbatim}}
  4065. {\COMPATNOTE} In some earlier versions of REDUCE, {\tt REDUCT} returned
  4066. {\tt EXPRN} if it did not depend on {\tt VAR}. In the present version, {\tt
  4067. EXPRN} is always equal to {\tt LTERM(EXPRN,VAR)} $+$ {\tt
  4068. REDUCT(EXPRN,VAR)}.
  4069. \section{Polynomial Coefficient Arithmetic}\index{Coefficient}
  4070. {\REDUCE} allows for a variety of numerical domains for the numerical
  4071. coefficients of polynomials used in calculations. The default mode is
  4072. integer arithmetic, although the possibility of using real coefficients
  4073. \index{Real coefficient} has been discussed elsewhere. Rational
  4074. coefficients have also been available by using integer coefficients in
  4075. both the numerator and denominator of an expression, using the {\tt ON
  4076. DIV}\ttindex{DIV} option to print the coefficients as rationals.
  4077. However, {\REDUCE} includes several other coefficient options in its basic
  4078. version which we shall describe in this section. All such coefficient
  4079. modes are supported in a table-driven manner so that it is
  4080. straightforward to extend the range of possibilities. A description of
  4081. how to do this is given in R.J. Bradford, A.C. Hearn, J.A. Padget and
  4082. E. Schr\"ufer, ``Enlarging the {\REDUCE} Domain of Computation,'' Proc. of
  4083. SYMSAC '86, ACM, New York (1986), 100--106.
  4084. \subsection{Rational Coefficients in Polynomials}\index{Coefficient}
  4085. \index{Rational coefficient}
  4086. Instead of treating rational numbers as the numerator and denominator of a
  4087. rational expression, it is also possible to use them as polynomial
  4088. coefficients directly. This is accomplished by turning on the switch
  4089. {\tt RATIONAL}.\ttindex{RATIONAL}
  4090. {\it Example:} With {\tt RATIONAL} off, the input expression {\tt a/2}
  4091. would be converted into a rational expression, whose numerator was {\tt A}
  4092. and denominator 2. With {\tt RATIONAL} on, the same input would become a
  4093. rational expression with numerator {\tt 1/2*A} and denominator {\tt 1}.
  4094. Thus the latter can be used in operations that require polynomial input
  4095. whereas the former could not.
  4096. \subsection{Real Coefficients in Polynomials}\index{Coefficient}
  4097. \index{Real coefficient}
  4098. The switch {\tt ROUNDED}\ttindex{ROUNDED} permits the use of arbitrary
  4099. sized real coefficients in polynomial expressions. The actual precision
  4100. of these coefficients can be set by the operator {\tt PRECISION}.
  4101. \ttindex{PRECISION} For example, {\tt precision 50;} sets the precision to
  4102. fifty decimal digits. The default precision is system dependent and can
  4103. be found by {\tt precision 0;}. In this mode, denominators are
  4104. automatically made monic, and an appropriate adjustment is made to the
  4105. numerator.
  4106. {\it Example:} With {\tt ROUNDED} on, the input expression {\tt a/2} would
  4107. be converted into a rational expression whose numerator is {\tt 0.5*A} and
  4108. denominator {\tt 1}.
  4109. Internally, {\REDUCE} uses floating point numbers up to the precision
  4110. supported by the underlying machine hardware, and so-called {\em
  4111. bigfloats} for higher precision or whenever necessary to represent numbers
  4112. whose value cannot be represented in floating point. The internal
  4113. precision is two decimal digits greater than the external precision to
  4114. guard against roundoff inaccuracies. Bigfloats represent the fraction and
  4115. exponent parts of a floating-point number by means of (arbitrary
  4116. precision) integers, which is a more precise representation in many cases
  4117. than the machine floating point arithmetic, but not as efficient. If a
  4118. case arises where use of the machine arithmetic leads to problems, a user
  4119. can force {\REDUCE} to use the bigfloat representation at all precisions by
  4120. turning on the switch {\tt ROUNDBF}.\ttindex{ROUNDBF} In rare cases,
  4121. this switch is turned on by the system, and the user informed by the
  4122. message
  4123. {\small\begin{verbatim}
  4124. ROUNDBF turned on to increase accuracy
  4125. \end{verbatim}}
  4126. Rounded numbers are normally printed to the specified precision. However,
  4127. if the user wishes to print such numbers with less precision, the printing
  4128. precision can be set by the command {\tt PRINT\_PRECISION}.
  4129. \ttindex{PRINT\_PRECISION} For example, {\tt print\_precision 5;} will
  4130. cause such numbers to be printed with five digits maximum.
  4131. Under normal circumstances when {\tt ROUNDED} is on, {\REDUCE} converts the
  4132. number 1.0 to the integer 1. If this is not desired, the switch
  4133. {\tt NOCONVERT}\ttindex{NOCONVERT} can be turned on.
  4134. Numbers that are stored internally as bigfloats are normally printed with
  4135. a space between every five digits to improve readability. If this
  4136. feature is not required, it can be suppressed by turning off the switch
  4137. {\tt BFSPACE}.\ttindex{BFSPACE}
  4138. Further information on the bigfloat arithmetic may be found in T. Sasaki,
  4139. ``Manual for Arbitrary Precision Real Arithmetic System in {\REDUCE}'',
  4140. Department of Computer Science, University of Utah, Technical Note No.
  4141. TR-8 (1979).
  4142. When a real number is input, it is normally truncated to the precision in
  4143. effect at the time the number is read. If it is desired to keep the full
  4144. precision of all numbers input, the switch {\tt ADJPREC}\ttindex{ADJPREC}
  4145. (for {\em adjust precision\/}) can be turned on. While on, {\tt ADJPREC}
  4146. will automatically increase the precision, when necessary, to match that
  4147. of any integer or real input, and a message printed to inform the user of
  4148. the precision increase.
  4149. When {\tt ROUNDED} is on, rational numbers are normally converted to
  4150. rounded representation. However, if a user wishes to keep such numbers in
  4151. a rational form until used in an operation that returns a real number,
  4152. the switch {\tt ROUNDALL}\ttindex{ROUNDALL} can be turned off. This
  4153. switch is normally on.
  4154. Results from rounded calculations are returned in rounded form with two
  4155. exceptions: if the result is recognized as {\tt 0} or {\tt 1} to the
  4156. current precision, the integer result is returned.
  4157. \subsection{Modular Number Coefficients in Polynomials}\index{Coefficient}
  4158. \index{Modular coefficient}
  4159. {\REDUCE} includes facilities for manipulating polynomials whose
  4160. coefficients are computed modulo a given base. To use this option, two
  4161. commands must be used; {\tt SETMOD} {\tt <integer>},\ttindex{SETMOD} to set
  4162. the prime modulus, and {\tt ON MODULAR}\ttindex{MODULAR} to cause the
  4163. actual modular calculations to occur.
  4164. For example, with {\tt setmod 3;} and {\tt on modular;}, the polynomial
  4165. {\tt (a+2*b)\verb|^|3} would become {\tt A\verb|^|3+2*B\verb|^|3}.
  4166. The argument of {\tt SETMOD} is evaluated algebraically, except that
  4167. non-modular (integer) arithmetic is used. Thus the sequence
  4168. {\small\begin{verbatim}
  4169. setmod 3; on modular; setmod 7;
  4170. \end{verbatim}}
  4171. will correctly set the modulus to 7.
  4172. Modular numbers are by default represented by integers in the interval
  4173. [0,p-1] where p is the current modulus. Sometimes it is more convenient
  4174. to use an equivalent symmetric representation in the interval
  4175. [-p/2+1,p/2], or more precisely
  4176. [-floor((p-1)/2), ceiling((p-1)/2)],
  4177. especially if the modular numbers map objects that include
  4178. negative quantities. The switch {\tt BALANCED\_MOD}\ttindex{BALANCED\_MOD}
  4179. allows you to select the symmetric representation for output.
  4180. Users should note that the modular calculations are on the polynomial
  4181. coefficients only. It is not currently possible to reduce the exponents
  4182. since no check for a prime modulus is made (which would allow
  4183. $x^{p-1}$ to be reduced to 1 mod p). Note also that any division by a
  4184. number not co-prime with the modulus will result in the error ``Invalid
  4185. modular division''.
  4186. \subsection{Complex Number Coefficients in Polynomials}\index{Coefficient}
  4187. \index{Complex coefficient}
  4188. Although {\REDUCE} routinely treats the square of the variable {\em i\/} as
  4189. equivalent to $-1$, this is not sufficient to reduce expressions involving
  4190. {\em i\/} to lowest terms, or to factor such expressions over the complex
  4191. numbers. For example, in the default case,
  4192. {\small\begin{verbatim}
  4193. factorize(a^2+1);
  4194. \end{verbatim}}
  4195. gives the result
  4196. {\small\begin{verbatim}
  4197. {{A**2+1,1}}
  4198. \end{verbatim}}
  4199. and
  4200. {\small\begin{verbatim}
  4201. (a^2+b^2)/(a+i*b)
  4202. \end{verbatim}}
  4203. is not reduced further. However, if the switch
  4204. {\tt COMPLEX}\ttindex{COMPLEX} is turned on, full complex arithmetic is then
  4205. carried out. In other words, the above factorization will give the result
  4206. {\small\begin{verbatim}
  4207. {{A + I,1},{A - I,1}}
  4208. \end{verbatim}}
  4209. and the quotient will be reduced to {\tt A-I*B}.
  4210. The switch {\tt COMPLEX} may be combined with {\tt ROUNDED} to give complex
  4211. real numbers; the appropriate arithmetic is performed in this case.
  4212. Complex conjugation is used to remove complex numbers from denominators of
  4213. expressions. To do this if {\tt COMPLEX} is off, you must turn the switch
  4214. {\tt RATIONALIZE}\ttindex{RATIONALIZE} on.
  4215. \chapter{Substitution Commands}\index{Substitution}
  4216. An important class of commands in {\REDUCE} define
  4217. substitutions for variables and expressions to be made during the
  4218. evaluation of expressions. Such substitutions use the prefix operator
  4219. {\tt SUB}, various forms of the command {\tt LET}, and rule sets.
  4220. \section{SUB Operator}\ttindex{SUB}
  4221. Syntax:
  4222. {\small\begin{verbatim}
  4223. SUB(<substitution_list>,EXPRN1:algebraic):algebraic
  4224. \end{verbatim}}
  4225. where {\tt <substitution\_list>} is a list of one or more equations of the
  4226. form
  4227. {\small\begin{verbatim}
  4228. VAR:kernel=EXPRN:algebraic
  4229. \end{verbatim}}
  4230. or a kernel that evaluates to such a list.
  4231. The {\tt SUB} operator gives the algebraic result of replacing every
  4232. occurrence of the variable {\tt VAR} in the expression {\tt EXPRN1} by the
  4233. expression {\tt EXPRN}. Specifically, {\tt EXPRN1} is first evaluated
  4234. using all available rules. Next the substitutions are made, and finally
  4235. the substituted expression is reevaluated. When more than one variable
  4236. occurs in the substitution list, the substitution is performed by
  4237. recursively walking down the tree representing {\tt EXPRN1}, and replacing
  4238. every {\tt VAR} found by the appropriate {\tt EXPRN}. The {\tt EXPRN} are
  4239. not themselves searched for any occurrences of the various {\tt VAR}s.
  4240. The trivial case {\tt SUB(EXPRN1)} returns the algebraic value of
  4241. {\tt EXPRN1}.
  4242. {\it Examples:}
  4243. {\small\begin{verbatim}
  4244. 2 2
  4245. sub({x=a+y,y=y+1},x^2+y^2) -> A + 2*A*Y + 2*Y + 2*Y + 1
  4246. \end{verbatim}}
  4247. and with {\tt s := \{x=a+y,y=y+1\}},
  4248. {\small\begin{verbatim}
  4249. 2 2
  4250. sub(s,x^2+y^2) -> A + 2*A*Y + 2*Y + 2*Y + 1
  4251. \end{verbatim}}
  4252. Note that the global assignments {\tt x:=a+y}, etc., do not take place.
  4253. {\tt EXPRN1} can be any valid algebraic expression whose type is such that
  4254. a substitution process is defined for it (e.g., scalar expressions, lists
  4255. and matrices). An error will occur if an expression of an invalid type
  4256. for substitution occurs either in {\tt EXPRN} or {\tt EXPRN1}.
  4257. The braces around the substitution list may also be omitted, as in:
  4258. {\small\begin{verbatim}
  4259. 2 2
  4260. sub(x=a+y,y=y+1,x^2+y^2) -> A + 2*A*Y + 2*Y + 2*Y + 1
  4261. \end{verbatim}}
  4262. \section{LET Rules}\ttindex{LET}
  4263. Unlike substitutions introduced via {\tt SUB}, {\tt LET}
  4264. rules are global in scope and stay in effect until replaced or {\tt CLEAR}ed.
  4265. The simplest use of the {\tt LET} statement is in the form
  4266. {\small\begin{verbatim}
  4267. LET <substitution list>
  4268. \end{verbatim}}
  4269. where {\tt <substitution list>} is a list of rules separated by commas, each
  4270. of the form:
  4271. {\small\begin{verbatim}
  4272. <variable> = <expression>
  4273. \end{verbatim}}
  4274. or
  4275. {\small\begin{verbatim}
  4276. <prefix operator>(<argument>,...,<argument>) = <expression>
  4277. \end{verbatim}}
  4278. or
  4279. {\small\begin{verbatim}
  4280. <argument> <infix operator>,..., <argument> = <expression>
  4281. \end{verbatim}}
  4282. For example,
  4283. {\small\begin{verbatim}
  4284. let {x => y^2,
  4285. h(u,v) => u - v,
  4286. cos(pi/3) => 1/2,
  4287. a*b => c,
  4288. l+m => n,
  4289. w^3 => 2*z - 3,
  4290. z^10 => 0}
  4291. \end{verbatim}}
  4292. The list brackets can be left out if preferred. The above rules could
  4293. also have been entered as seven separate {\tt LET} statements.
  4294. After such {\tt LET} rules have been input, {\tt X} will always be
  4295. evaluated as the square of {\tt Y}, and so on. This is so even if at the
  4296. time the {\tt LET} rule was input, the variable {\tt Y} had a value other
  4297. than {\tt Y}. (In contrast, the assignment {\tt x:=y\verb|^|2} will set {\tt X}
  4298. equal to the square of the current value of {\tt Y}, which could be quite
  4299. different.)
  4300. The rule {\tt let a*b=c} means that whenever {\tt A} and {\tt B} are both
  4301. factors in an expression their product will be replaced by {\tt C}. For
  4302. example, {\tt a\verb|^|5*b\verb|^|7*w} would be replaced by
  4303. {\tt c\verb|^|5*b\verb|^|2*w}.
  4304. The rule for {\tt l+m} will not only replace all occurrences of {\tt l+m}
  4305. by {\tt N}, but will also normally replace {\tt L} by {\tt n-m}, but not
  4306. {\tt M} by {\tt n-l}. A more complete description of this case is given
  4307. in Section~\ref{sec-gensubs}.
  4308. The rule pertaining to {\tt w\verb|^|3} will apply to any power of {\tt W}
  4309. greater than or equal to the third.
  4310. Note especially the last example, {\tt let z\verb|^|10=0}. This declaration
  4311. means, in effect: ignore the tenth or any higher power of {\tt Z}. Such
  4312. declarations, when appropriate, often speed up a computation to a
  4313. considerable degree. (See\index{Asymptotic command}
  4314. Section~\ref{sec-asymp} for more details.)
  4315. Any new operators occurring in such {\tt LET} rules will be automatically
  4316. declared {\tt OPERATOR} by the system, if the rules are being read from a
  4317. file. If they are being entered interactively, the system will ask
  4318. {\tt DECLARE} ... {\tt OPERATOR?} . Answer {\tt Y} or {\tt N} and hit
  4319. \key{Return}.
  4320. In each of these examples, substitutions are only made for the explicit
  4321. expressions given; i.e., none of the variables may be considered arbitrary
  4322. in any sense. For example, the command
  4323. {\small\begin{verbatim}
  4324. let h(u,v) = u - v;
  4325. \end{verbatim}}
  4326. will cause {\tt h(u,v)} to evaluate to {\tt U - V}, but will not affect
  4327. {\tt h(u,z)} or {\tt H} with any arguments other than precisely the
  4328. symbols {\tt U,V}.
  4329. These simple {\tt LET} rules are on the same logical level as assignments
  4330. made with the := operator. An assignment {\tt x := p+q} cancels a rule
  4331. {\tt let x = y\verb|^|2} made earlier, and vice versa.
  4332. {\it CAUTION:} A recursive rule such as
  4333. {\small\begin{verbatim}
  4334. let x = x + 1;
  4335. \end{verbatim}}
  4336. is erroneous, since any subsequent evaluation of {\tt X} would lead to a
  4337. non-terminating chain of substitutions:
  4338. {\small\begin{verbatim}
  4339. x -> x + 1 -> (x + 1) + 1 -> ((x + 1) + 1) + 1 -> ...
  4340. \end{verbatim}}
  4341. Similarly, coupled substitutions such as
  4342. {\small\begin{verbatim}
  4343. let l = m + n, n = l + r;
  4344. \end{verbatim}}
  4345. would lead to the same error. As a result, if you try to evaluate an {\tt X},
  4346. {\tt L} or {\tt N} defined as above, you will get an error such as
  4347. {\small\begin{verbatim}
  4348. X improperly defined in terms of itself
  4349. \end{verbatim}}
  4350. Array and matrix elements can appear on the left-hand side of a {\tt LET}
  4351. statement. However, because of their {\em instant evaluation\/}
  4352. \index{Instant evaluation} property, it is the value of the element that
  4353. is substituted for, rather than the element itself. E.g.,
  4354. {\small\begin{verbatim}
  4355. array a(5);
  4356. a(2) := b;
  4357. let a(2) = c;
  4358. \end{verbatim}}
  4359. results in {\tt B} being substituted by {\tt C}; the assignment for
  4360. {\tt a(2)} does not change.
  4361. Finally, if an error occurs in any equation in a {\tt LET} statement
  4362. (including generalized statements involving {\tt FOR ALL} and {\tt SUCH
  4363. THAT)}, the remaining rules are not evaluated.
  4364. \subsection{FOR ALL \ldots LET}\ttindex{FOR ALL}
  4365. If a substitution for all possible values of a given argument of an
  4366. operator is required, the declaration {\tt FOR ALL} may be used. The
  4367. syntax of such a command is
  4368. {\small\begin{verbatim}
  4369. FOR ALL <variable>,...,<variable>
  4370. <LET statement> <terminator>
  4371. \end{verbatim}}
  4372. e.g.,
  4373. {\small\begin{verbatim}
  4374. for all x,y let h(x,y) = x-y;
  4375. for all x let k(x,y) = x^y;
  4376. \end{verbatim}}
  4377. The first of these declarations would cause {\tt h(a,b)} to be evaluated
  4378. as {\tt A-B}, {\tt h(u+v,u+w)} to be {\tt V-W}, etc. If the operator
  4379. symbol {\tt H} is used with more or fewer argument places, not two, the
  4380. {\tt LET} would have no effect, and no error would result.
  4381. The second declaration would cause {\tt k(a,y)} to be evaluated as
  4382. {\tt a\verb|^|y}, but would have no effect on {\tt k(a,z)} since the rule
  4383. didn't say {\tt FOR ALL Y} ... .
  4384. Where we used {\tt X} and {\tt Y} in the examples, any variables could
  4385. have been used. This use of a variable doesn't affect the value it may
  4386. have outside the {\tt LET} statement. However, you should remember what
  4387. variables you actually used. If you want to delete the rule subsequently,
  4388. you must use the same variables in the {\tt CLEAR} command.
  4389. It is possible to use more complicated expressions as a template for a
  4390. {\tt LET} statement, as explained in the section on substitutions for
  4391. general expressions. In nearly all cases, the rule will be accepted, and
  4392. a consistent application made by the system. However, if there is a sole
  4393. constant or a sole free variable on the left-hand side of a rule (e.g.,
  4394. {\tt let 2=3} or {\tt for all x let x=2)}, then the system is unable to
  4395. handle the rule, and the error message
  4396. {\small\begin{verbatim}
  4397. Substitution for ... not allowed
  4398. \end{verbatim}}
  4399. will be issued. Any variable listed in the {\tt FOR ALL} part will have
  4400. its symbol preceded by an equal sign: {\tt X} in the above example will
  4401. appear as {\tt =X}. An error will also occur if a variable in the
  4402. {\tt FOR ALL} part is not properly matched on both sides of the {\tt LET}
  4403. equation.
  4404. \subsection{FOR ALL \ldots SUCH THAT \ldots LET}
  4405. \ttindex{FOR ALL}\ttindex{SUCH THAT}
  4406. If a substitution is desired for more than a single value of a variable in
  4407. an operator or other expression, but not all values, a conditional form of
  4408. the {\tt FOR ALL \ldots LET} declaration can be used.
  4409. {\it Example:}
  4410. {\small\begin{verbatim}
  4411. for all x such that numberp x and x<0 let h(x)=0;
  4412. \end{verbatim}}
  4413. will cause {\tt h(-5)} to be evaluated as 0, but {\tt H} of a positive
  4414. integer, or of an argument that is not an integer at all, would not be
  4415. affected. Any boolean expression can follow the {\tt SUCH THAT} keywords.
  4416. \subsection{Removing Assignments and Substitution Rules}\ttindex{CLEAR}
  4417. The user may remove all assignments and substitution rules from any
  4418. expression by the command {\tt CLEAR}, in the form
  4419. {\small\begin{verbatim}
  4420. CLEAR <expression>,...,<expression><terminator>
  4421. \end{verbatim}}
  4422. e.g.
  4423. {\small\begin{verbatim}
  4424. clear x, h(x,y);
  4425. \end{verbatim}}
  4426. Because of their {\em instant evaluation\/} property, array and matrix elements
  4427. cannot be cleared with {\tt CLEAR}. For example, if {\tt A} is an array,
  4428. you must say
  4429. {\small\begin{verbatim}
  4430. a(3) := 0;
  4431. \end{verbatim}}
  4432. rather than
  4433. {\small\begin{verbatim}
  4434. clear a(3);
  4435. \end{verbatim}}
  4436. to ``clear'' element {\tt a(3)}.
  4437. On the other hand, a whole array (or matrix) {\tt A} can be cleared by the
  4438. command {\tt clear a}; This means much more than resetting to 0 all the
  4439. elements of {\tt A}. The fact that {\tt A} is an array, and what its
  4440. dimensions are, are forgotten, so {\tt A} can be redefined as another type
  4441. of object, for example an operator.
  4442. The more general types of {\tt LET} declarations can also be deleted by
  4443. using {\tt CLEAR}. Simply repeat the {\tt LET} rule to be deleted, using
  4444. {\tt CLEAR} in place of {\tt LET}, and omitting the equal sign and
  4445. right-hand part. The same dummy variables must be used in the {\tt FOR
  4446. ALL} part, and the boolean expression in the {\tt SUCH THAT} part must be
  4447. written the same way. (The placing of blanks doesn't have to be
  4448. identical.)
  4449. {\it Example:} The {\tt LET} rule
  4450. {\small\begin{verbatim}
  4451. for all x such that numberp x and x<0 let h(x)=0;
  4452. \end{verbatim}}
  4453. can be erased by the command
  4454. {\small\begin{verbatim}
  4455. for all x such that numberp x and x<0 clear h(x);
  4456. \end{verbatim}}
  4457. \subsection{Overlapping LET Rules}
  4458. {\tt CLEAR} is not the only way to delete a {\tt LET} rule. A new {\tt
  4459. LET} rule identical to the first, but with a different expression after
  4460. the equal sign, replaces the first. Replacements are also made in other
  4461. cases where the existing rule would be in conflict with the new rule. For
  4462. example, a rule for {\tt x\verb|^|4} would replace a rule for {\tt x\verb|^|5}.
  4463. The user should however be cautioned against having several {\tt LET}
  4464. rules in effect that relate to the same expression. No guarantee can be
  4465. given as to which rules will be applied by {\REDUCE} or in what order. It
  4466. is best to {\tt CLEAR} an old rule before entering a new related {\tt LET}
  4467. rule.
  4468. \subsection{Substitutions for General Expressions}
  4469. \label{sec-gensubs}
  4470. The examples of substitutions discussed in other sections have involved
  4471. very simple rules. However, the substitution mechanism used in {\REDUCE} is
  4472. very general, and can handle arbitrarily complicated rules without
  4473. difficulty.
  4474. The general substitution mechanism used in {\REDUCE} is discussed in Hearn, A.
  4475. C., ``{\REDUCE}, A User-Oriented Interactive System for Algebraic
  4476. Simplification,'' Interactive Systems for Experimental Applied Mathematics,
  4477. (edited by M. Klerer and J. Reinfelds), Academic Press, New York (1968),
  4478. 79-90, and Hearn. A. C., ``The Problem of Substitution,'' Proc. 1968 Summer
  4479. Institute on Symbolic Mathematical Computation, IBM Programming Laboratory
  4480. Report FSC 69-0312 (1969). For the reasons given in these
  4481. references, {\REDUCE} does not attempt to implement a general pattern
  4482. matching algorithm. However, the present system uses far more sophisticated
  4483. techniques than those discussed in the above papers. It is now possible for
  4484. the rules appearing in arguments of {\tt LET} to have the form
  4485. {\small\begin{verbatim}
  4486. <substitution expression> = <expression>
  4487. \end{verbatim}}
  4488. where any rule to which a sensible meaning can be assigned is permitted.
  4489. However, this meaning can vary according to the form of {\tt <substitution
  4490. expression>}. The semantic rules associated with the application of the
  4491. substitution are completely consistent, but somewhat complicated by the
  4492. pragmatic need to perform such substitutions as efficiently as possible.
  4493. The following rules explain how the majority of the cases are handled.
  4494. To begin with, the {\tt <substitution expression>} is first partly
  4495. simplified by collecting like terms and putting identifiers (and kernels)
  4496. in the system order. However, no substitutions are performed on any part
  4497. of the expression with the exception of expressions with the {\em instant
  4498. evaluation\/} property, such as array and matrix elements, whose actual
  4499. values are used. It should also be noted that the system order used is
  4500. not changeable by the user, even with the {\tt KORDER} command. Specific
  4501. cases are then handled as follows:
  4502. \begin{enumerate}
  4503. \item If the resulting simplified rule has a left-hand side that is an
  4504. identifier, an expression with a top-level algebraic operator or a power,
  4505. then the rule is added without further change to the appropriate table.
  4506. \item If the operator * appears at the top level of the simplified left-hand
  4507. side, then any constant arguments in that expression are moved to the
  4508. right-hand side of the rule. The remaining left-hand side is then added
  4509. to the appropriate table. For example,
  4510. {\small\begin{verbatim}
  4511. let 2*x*y=3
  4512. \end{verbatim}}
  4513. becomes
  4514. {\small\begin{verbatim}
  4515. let x*y=3/2
  4516. \end{verbatim}}
  4517. so that {\tt x*y} is added to the product substitution table, and when
  4518. this rule is applied, the expression {\tt x*y} becomes 3/2, but {\tt X} or
  4519. {\tt Y} by themselves are not replaced.
  4520. \item If the operators {\tt +}, {\tt -} or {\tt /} appear at the top level
  4521. of the simplified left-hand side, all but the first term is moved to the
  4522. right-hand side of the rule. Thus the rules
  4523. {\small\begin{verbatim}
  4524. let l+m=n, x/2=y, a-b=c
  4525. \end{verbatim}}
  4526. become
  4527. {\small\begin{verbatim}
  4528. let l=n-m, x=2*y, a=c+b.
  4529. \end{verbatim}}
  4530. \end{enumerate}
  4531. One problem that can occur in this case is that if a quantified expression
  4532. is moved to the right-hand side, a given free variable might no longer
  4533. appear on the left-hand side, resulting in an error because of the
  4534. unmatched free variable. E.g.,
  4535. {\small\begin{verbatim}
  4536. for all x,y let f(x)+f(y)=x*y
  4537. \end{verbatim}}
  4538. would become
  4539. {\small\begin{verbatim}
  4540. for all x,y let f(x)=x*y-f(y)
  4541. \end{verbatim}}
  4542. which no longer has {\tt Y} on both sides.
  4543. The fact that array and matrix elements are evaluated in the left-hand side
  4544. of rules can lead to confusion at times. Consider for example the
  4545. statements
  4546. {\small\begin{verbatim}
  4547. array a(5); let x+a(2)=3; let a(3)=4;
  4548. \end{verbatim}}
  4549. The left-hand side of the first rule will become {\tt X}, and the second
  4550. 0. Thus the first rule will be instantiated as a substitution for
  4551. {\tt X}, and the second will result in an error.
  4552. The order in which a list of rules is applied is not easily understandable
  4553. without a detailed knowledge of the system simplification protocol. It is
  4554. also possible for this order to change from release to release, as improved
  4555. substitution techniques are implemented. Users should therefore assume
  4556. that the order of application of rules is arbitrary, and program
  4557. accordingly.
  4558. After a substitution has been made, the expression being evaluated is
  4559. reexamined in case a new allowed substitution has been generated. This
  4560. process is continued until no more substitutions can be made.
  4561. As mentioned elsewhere, when a substitution expression appears in a
  4562. product, the substitution is made if that expression divides the product.
  4563. For example, the rule
  4564. {\small\begin{verbatim}
  4565. let a^2*c = 3*z;
  4566. \end{verbatim}}
  4567. would cause {\tt a\verb|^|2*c*x} to be replaced by {\tt 3*Z*X} and
  4568. {\tt a\verb|^|2*c\verb|^|2} by {\tt 3*Z*C}. If the substitution is desired only
  4569. when the substitution expression appears in a product with the explicit
  4570. powers supplied in the rule, the command {\tt MATCH} should be used
  4571. instead.\ttindex{MATCH}
  4572. For example,
  4573. {\small\begin{verbatim}
  4574. match a^2*c = 3*z;
  4575. \end{verbatim}}
  4576. would cause {\tt a\verb|^|2*c*x} to be replaced by {\tt 3*Z*X}, but
  4577. {\tt a\verb|^|2*c\verb|^|2} would not be replaced. {\tt MATCH} can also be used
  4578. with the {\tt FOR ALL} constructions described above.
  4579. To remove substitution rules of the type discussed in this section, the
  4580. {\tt CLEAR}\ttindex{CLEAR} command can be used, combined, if necessary,
  4581. with the same {\tt FOR ALL} clause with which the rule was defined, for
  4582. example:
  4583. {\small\begin{verbatim}
  4584. for all x clear log(e^x),e^log(x),cos(w*t+theta(x));
  4585. \end{verbatim}}
  4586. Note, however, that the arbitrary variable names in this case {\em must\/}
  4587. be the same as those used in defining the substitution.
  4588. \section{Rule Lists} \index{Rule lists}
  4589. Rule lists offer an alternative approach to defining substitutions that is
  4590. different from either {\tt SUB} or {\tt LET}. In fact, they provide the
  4591. best features of both, since they have all the capabilities of {\tt LET},
  4592. but the rules can also be applied locally as is possible with {\tt SUB}.
  4593. In time, they will be used more and more in {\REDUCE}. However, since they
  4594. are relatively new, much of the {\REDUCE} code you see uses the older
  4595. constructs.
  4596. A rule list is a list of {\em rules\/} that have the syntax
  4597. {\small\begin{verbatim}
  4598. <expression> => <expression> (WHEN <boolean expression>)
  4599. \end{verbatim}}
  4600. For example,
  4601. {\small\begin{verbatim}
  4602. {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
  4603. cos(~n*pi) => (-1)^n when remainder(n,2)=0}
  4604. \end{verbatim}}
  4605. The tilde preceding a variable marks that variable as {\em free\/} for that
  4606. rule, much as a variable in a {\tt FOR ALL} clause in a {\tt LET}
  4607. statement. The first occurrence of that variable in each relevant rule
  4608. must be so marked on input, otherwise inconsistent results can occur.
  4609. For example, the rule list
  4610. {\small\begin{verbatim}
  4611. {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
  4612. cos(x)^2 => (1+cos(2x))/2}
  4613. \end{verbatim}}
  4614. designed to replace products of cosines, would not be correct, since the
  4615. second rule would only apply to the explicit argument {\tt X}. Later
  4616. occurrences in the same rule may also be marked, but this is optional
  4617. (internally, all such rules are stored with each relevant variable
  4618. explicitly marked). The optional {\tt WHEN}\ttindex{WHEN} clause allows
  4619. constraints to be placed on the application of the rule, much as the {\tt
  4620. SUCH THAT} clause in a {\tt LET} statement.
  4621. A rule list may be named, for example
  4622. {\small\begin{verbatim}
  4623. trig1 := {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2,
  4624. cos(~x)*sin(~y) => (sin(x+y)-sin(x-y))/2,
  4625. sin(~x)*sin(~y) => (cos(x-y)-cos(x+y))/2,
  4626. cos(~x)^2 => (1+cos(2*x))/2,
  4627. sin(~x)^2 => (1-cos(2*x))/2};
  4628. \end{verbatim}}
  4629. Such named rule lists may be inspected as needed. E.g., the command
  4630. {\tt trig1;} would cause the above list to be printed.
  4631. Rule lists may be used in two ways. They can be globally instantiated by
  4632. means of the command {\tt LET}.\ttindex{LET} For example,
  4633. {\small\begin{verbatim}
  4634. let trig1;
  4635. \end{verbatim}}
  4636. would cause the above list of rules to be globally active from then on until
  4637. cancelled by the command {\tt CLEARRULES},\ttindex{CLEARRULES} as in
  4638. {\small\begin{verbatim}
  4639. clearrules trig1;
  4640. \end{verbatim}}
  4641. {\tt CLEARRULES} has the syntax
  4642. {\small\begin{verbatim}
  4643. CLEARRULES <rule list>|<name of rule list>(,...) .
  4644. \end{verbatim}}
  4645. The second way to use rule lists is to invoke them locally by means of a
  4646. {\tt WHERE}\ttindex{WHERE} clause. For example
  4647. {\small\begin{verbatim}
  4648. cos(a)*cos(b+c)
  4649. where {cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2};
  4650. \end{verbatim}}
  4651. or
  4652. {\small\begin{verbatim}
  4653. cos(a)*sin(b) where trigrules;
  4654. \end{verbatim}}
  4655. The syntax of an expression with a {\tt WHERE} clause is:
  4656. {\small\begin{verbatim}
  4657. <expression>
  4658. WHERE <rule>|<rule list>(,<rule>|<rule list> ...)
  4659. \end{verbatim}}
  4660. so the first example above could also be written
  4661. {\small\begin{verbatim}
  4662. cos(a)*cos(b+c)
  4663. where cos(~x)*cos(~y) => (cos(x+y)+cos(x-y))/2;
  4664. \end{verbatim}}
  4665. The effect of this construct is that the rule list(s) in the {\tt WHERE}
  4666. clause only apply to the expression on the left of {\tt WHERE}. They have
  4667. no effect outside the expression. In particular, they do not affect
  4668. previously defined {\tt WHERE} clauses or {\tt LET} statements. For
  4669. example, the sequence
  4670. {\small\begin{verbatim}
  4671. let a=2;
  4672. a where a=>4;
  4673. a;
  4674. \end{verbatim}}
  4675. would result in the output
  4676. {\small\begin{verbatim}
  4677. 4
  4678. 2
  4679. \end{verbatim}}
  4680. Although {\tt WHERE} has a precedence less than any other infix operator,
  4681. it still binds higher than keywords such as {\tt ELSE}, {\tt THEN},
  4682. {\tt DO}, {\tt REPEAT} and so on. Thus the expression
  4683. {\small\begin{verbatim}
  4684. if a=2 then 3 else a+2 where a=3
  4685. \end{verbatim}}
  4686. will parse as
  4687. {\small\begin{verbatim}
  4688. if a=2 then 3 else (a+2 where a=3)
  4689. \end{verbatim}}
  4690. {\tt WHERE} may be used to introduce auxiliary variables in symbolic mode
  4691. expressions, as described in Section~\ref{sec-lambda}. However, the
  4692. symbolic mode use has different semantics, so expressions do not carry
  4693. from one mode to the other.
  4694. \COMPATNOTE In order to provide compatibility with older versions of rule
  4695. lists released through the Network Library, it is currently possible to use
  4696. an equal sign interchangeably with the replacement sign {\tt =>} in rules
  4697. and {\tt LET} statements. However, since this will change in future
  4698. versions, the replacement sign is preferable in rules and the equal sign
  4699. in non-rule-based {\tt LET} statements.
  4700. \subsection*{Advanced Use of Rule Lists}
  4701. Some advanced features of the rule list mechanism make it possible to
  4702. write more complicated rules than those discussed so far, and in many
  4703. cases to write more compact rule lists. These features are:
  4704. \begin{itemize}
  4705. \item Free operators
  4706. \item Double slash operator
  4707. \item Double tilde variables.
  4708. \end{itemize}
  4709. A {\bf free operator} in the left hand side of a pattern will match any
  4710. operator with the same number of arguments. The free operator is written
  4711. in the same style as a variable. For example, the implementation of the
  4712. product rule of differentiation can be written as:
  4713. {\small\begin{verbatim}
  4714. operator diff, !~f, !~g;
  4715. prule := {diff(~f(~x) * ~g(~x),x) =>
  4716. diff(f(x),x) * g(x) + diff(g(x),x) * f(x)};
  4717. let prule;
  4718. diff(sin(z)*cos(z),z);
  4719. cos(z)*diff(sin(z),z) + diff(cos(z),z)*sin(z)
  4720. \end{verbatim}}
  4721. The {\bf double slash operator} may be used as an alternative to a single
  4722. slash (quotient) in order to match quotients properly. E.g., in the
  4723. example of the Gamma function above, one can use:
  4724. {\small\begin{verbatim}
  4725. gammarule :=
  4726. {gamma(~z)//(~c*gamma(~zz)) => gamma(z)/(c*gamma(zz-1)*zz)
  4727. when fixp(zz -z) and (zz -z) >0,
  4728. gamma(~z)//gamma(~zz) => gamma(z)/(gamma(zz-1)*zz)
  4729. when fixp(zz -z) and (zz -z) >0};
  4730. let gammarule;
  4731. gamma(z)/gamma(z+3);
  4732. 1
  4733. ----------------------
  4734. 3 2
  4735. z + 6*z + 11*z + 6
  4736. \end{verbatim}}
  4737. The above example suffers from the fact that two rules had to be
  4738. written in order to perform the required operation. This can be simplified
  4739. by the use of {\bf double tilde variables}. E.g. the rule list
  4740. {\small\begin{verbatim}
  4741. GGrule := {
  4742. gamma(~z)//(~~c*gamma(~zz)) => gamma(z)/(c*gamma(zz-1)*zz)
  4743. when fixp(zz -z) and (zz -z) >0};
  4744. \end{verbatim}}
  4745. will implement the same operation in a much more compact way.
  4746. In general, double tilde variables are bound to the neutral element
  4747. with respect to the operation in which they are used.
  4748. \begin{tabular}{lll}
  4749. Pattern given & Argument used & Binding \\
  4750. \\
  4751. \symbol{126}z + \symbol{126}\symbol{126}y & x & z=x; y=0 \\
  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 or z=3; y=x\\
  4756. \\
  4757. \symbol{126}z / \symbol{126}\symbol{126}y & x & z=x; y=1\\
  4758. \symbol{126}z / \symbol{126}\symbol{126}y & x/3 & z=x; y=3 \\
  4759. \\
  4760. \end{tabular}
  4761. Remarks: A double tilde variable as the numerator of a pattern is not allowed.
  4762. Also, using double tilde variables may lead to recursion errors when the
  4763. zero case is not handled properly.
  4764. {\small\begin{verbatim}
  4765. let f(~~a * ~x,x) => a * f(x,x) when freeof (a,x);
  4766. f(z,z);
  4767. ***** f(z,z) improperly defined in terms of itself
  4768. % BUT:
  4769. let ff(~~a * ~x,x)
  4770. => a * ff(x,x) when freeof (a,x) and a neq 1;
  4771. ff(z,z);
  4772. ff(z,z)
  4773. ff(3*z,z);
  4774. 3*ff(z,z)
  4775. \end{verbatim}}
  4776. \subsection*{Displaying Rules Associated with an Operator}
  4777. The operator {\tt SHOWRULES}\ttindex{SHOWRULES} takes a single identifier
  4778. as argument, and returns in rule-list form the operator rules associated
  4779. with that argument. For example:
  4780. {\small\begin{verbatim}
  4781. showrules log;
  4782. {LOG(E) => 1,
  4783. LOG(1) => 0,
  4784. ~X
  4785. LOG(E ) => ~X,
  4786. 1
  4787. DF(LOG(~X),~X) => ----}
  4788. ~X
  4789. \end{verbatim}}
  4790. Such rules can then be manipulated further as with any list. For example
  4791. {\tt rhs first ws;} has the value {\tt 1}. Note that an operator may
  4792. have other properties that cannot be displayed in such a form, such as the
  4793. fact it is an odd function, or has a definition defined as a procedure.
  4794. \subsection*{Order of Application of Rules}
  4795. If rules have overlapping domains, their order of application is
  4796. important. In general, it is very difficult to specify this order
  4797. precisely, so that it is best to assume that the order is arbitrary.
  4798. However, if only one operator is involved, the order of application of the
  4799. rules for this operator can be determined from the following:
  4800. \begin{enumerate}
  4801. \item Rules containing at least one free variable apply before all rules
  4802. without free variables.
  4803. \item Rules activated in the most recent {\tt LET}
  4804. command are applied first.
  4805. \item {\tt LET} with several entries generate
  4806. the same order of application as a corresponding sequence of commands with
  4807. one rule or rule set each.
  4808. \item Within a rule set, the rules containing at least
  4809. one free variable are applied in their given order.
  4810. In other words, the first member of the list is applied first.
  4811. \item Consistent with the first item, any rule in a rule list that
  4812. contains no free variables is applied after all rules containing free
  4813. variables.
  4814. \end{enumerate}
  4815. {\it Example:} The following rule set enables the computation of exact
  4816. values of the Gamma function:
  4817. {\small\begin{verbatim}
  4818. operator gamma,gamma_error;
  4819. gamma_rules :=
  4820. {gamma(~x)=>sqrt(pi)/2 when x=1/2,
  4821. gamma(~n)=>factorial(n-1) when fixp n and n>0,
  4822. gamma(~n)=>gamma_error(n) when fixp n,
  4823. gamma(~x)=>(x-1)*gamma(x-1) when fixp(2*x) and x>1,
  4824. gamma(~x)=>gamma(x+1)/x when fixp(2*x)};
  4825. \end{verbatim}}
  4826. Here, rule by rule, cases of known or definitely uncomputable values
  4827. are sorted out; e.g. the rule leading to the error expression
  4828. will be applied for negative integers only, since the positive
  4829. integers are caught by the preceding rule, and the
  4830. last rule will apply for negative odd multiples of $1/2$ only.
  4831. Alternatively the first rule could have been written as
  4832. {\small\begin{verbatim}
  4833. gamma(1/2) => sqrt(pi)/2,
  4834. \end{verbatim}}
  4835. but then the case $x=1/2$ should be excluded in the {\tt WHEN} part of the
  4836. last rule explicitly because a rule without free variables cannot take
  4837. precedence over the other rules.
  4838. \section{Asymptotic Commands} \index{Asymptotic command}
  4839. \label{sec-asymp}
  4840. In expansions of polynomials involving variables that are known to be
  4841. small, it is often desirable to throw away all powers of these variables
  4842. beyond a certain point to avoid unnecessary computation. The command {\tt
  4843. LET} may be used to do this. For example, if only powers of {\tt X} up to
  4844. {\tt x\verb|^|7} are needed, the command
  4845. {\small\begin{verbatim}
  4846. let x^8 = 0;
  4847. \end{verbatim}}
  4848. will cause the system to delete all powers of {\tt X} higher than 7.
  4849. {\it CAUTION:} This particular simplification works differently from most
  4850. substitution mechanisms in {\REDUCE} in that it is applied during
  4851. polynomial manipulation rather than to the whole evaluated expression.
  4852. Thus, with the above rule in effect, {\tt x\verb|^|10/x\verb|^|5} would give the
  4853. result zero, since the numerator would simplify to zero. Similarly
  4854. {\tt x\verb|^|20/x\verb|^|10} would give a {\tt Zero divisor} error message,
  4855. since both numerator and denominator would first simplify to zero.
  4856. The method just described is not adequate when expressions involve several
  4857. variables having different degrees of smallness. In this case, it is
  4858. necessary to supply an asymptotic weight to each variable and count up the
  4859. total weight of each product in an expanded expression before deciding
  4860. whether to keep the term or not. There are two associated commands in the
  4861. system to permit this type of asymptotic constraint. The command {\tt WEIGHT}
  4862. \ttindex{WEIGHT}
  4863. takes a list of equations of the form
  4864. {\small\begin{verbatim}
  4865. <kernel form> = <number>
  4866. \end{verbatim}}
  4867. where {\tt <number>} must be a positive integer (not just evaluate to a
  4868. positive integer). This command assigns the weight {\tt <number>} to the
  4869. relevant kernel form. A check is then made in all algebraic evaluations
  4870. to see if the total weight of the term is greater than the weight level
  4871. assigned to the calculation. If it is, the term is deleted. To compute
  4872. the total weight of a product, the individual weights of each kernel form
  4873. are multiplied by their corresponding powers and then added.
  4874. The weight level of the system is initially set to 1. The user may change
  4875. this setting by the command\ttindex{WTLEVEL}
  4876. {\small\begin{verbatim}
  4877. wtlevel <number>;
  4878. \end{verbatim}}
  4879. which sets {\tt <number>} as the new weight level of the system.
  4880. {\tt <number>} must evaluate to a positive integer. WTLEVEL will also
  4881. allow NIL as an argument, in which case the current weight level is returned.
  4882. \chapter{File Handling Commands}\index{File handling}
  4883. In many applications, it is desirable to load previously prepared {\REDUCE}
  4884. files into the system, or to write output on other files. {\REDUCE} offers
  4885. four commands for this purpose, namely, {\tt IN}, {\tt OUT}, {\tt SHUT},
  4886. {\tt LOAD}, and {\tt LOAD\_PACKAGE}. The first\ttindex{IN}\ttindex{OUT}
  4887. \ttindex{SHUT} three operators are described here; {\tt LOAD} and {\tt
  4888. LOAD\_PACKAGE} are discussed in Section~\ref{sec-load}.
  4889. \section{IN Command}\ttindex{IN}
  4890. This command takes a list of file names as argument and directs the system
  4891. to input\index{Input} each file (that should contain {\REDUCE} statements
  4892. and commands) into the system. File names can either be an identifier or
  4893. a string. The explicit format of these will be system dependent and, in
  4894. many cases, site dependent. The explicit instructions for the
  4895. implementation being used should therefore be consulted for further
  4896. details. For example:
  4897. {\small\begin{verbatim}
  4898. in f1,"ggg.rr.s";
  4899. \end{verbatim}}
  4900. will first load file {\tt F1}, then {\tt ggg.rr.s}. When a semicolon is
  4901. used as the terminator of the IN statement, the statements in the file are
  4902. echoed on the terminal or written on the current output file. If \$
  4903. \index{Command terminator} is used as the terminator, the input is not
  4904. shown. Echoing of all or part of the input file can be prevented, even if
  4905. a semicolon was used, by placing an {\tt off echo;}\ttindex{ECHO} command
  4906. in the input file.
  4907. Files to be read using {\tt IN} should end with {\tt ;END;}. Note the two
  4908. semicolons! First of all, this is protection against obscure difficulties
  4909. the user will have if there are, by mistake, more {\tt BEGIN}s than
  4910. {\tt END}s on the file. Secondly, it triggers some file control book-keeping
  4911. which may improve system efficiency. If {\tt END} is omitted, an error
  4912. message {\tt "End-of-file read"} will occur.
  4913. \section{OUT Command}\ttindex{OUT}
  4914. This command takes a single file name as argument, and directs output to
  4915. that file from then on, until another {\tt OUT} changes the output file,
  4916. or {\tt SHUT} closes it. Output can go to only one file at a time,
  4917. although many can be open. If the file has previously been used for
  4918. output during the current job, and not {\tt SHUT},\ttindex{SHUT} the new
  4919. output is appended to the end of the file. Any existing file is erased
  4920. before its first use for output in a job, or if it had been {\tt SHUT}
  4921. before the new {\tt OUT}.
  4922. To output on the terminal without closing the output file, the reserved
  4923. file name T (for terminal) may be used. For example,
  4924. {\tt out ofile;} will direct output to the file {\tt OFILE} and
  4925. {\tt out t;} will direct output to the user's terminal.
  4926. The output sent to the file will be in the same form that it would have on
  4927. the terminal. In particular {\tt x\verb|^|2} would appear on two lines, an
  4928. {\tt X} on the lower line and a 2 on the line above. If the purpose of the
  4929. output file is to save results to be read in later, this is not an
  4930. appropriate form. We first must turn off the {\tt NAT} switch that
  4931. specifies that output should be in standard mathematical notation.
  4932. {\it Example:} To create a file {\tt ABCD} from which it will be possible
  4933. to read -- using {\tt IN} -- the value of the expression {\tt XYZ}:
  4934. {\small\begin{verbatim}
  4935. off echo$ % needed if your input is from a file.
  4936. off nat$ % output in IN-readable form. Each expression
  4937. % printed will end with a $ .
  4938. out abcd$ % output to new file
  4939. linelength 72$ % for systems with fixed input line length.
  4940. xyz:=xyz; % will output "XYZ := " followed by the value
  4941. % of XYZ
  4942. write ";end"$ % standard for ending files for IN
  4943. shut abcd$ % save ABCD, return to terminal output
  4944. on nat$ % restore usual output form
  4945. \end{verbatim}}
  4946. \section{SHUT Command}\ttindex{SHUT}
  4947. This command takes a list of names of files that have been previously
  4948. opened via an {\tt OUT} statement and closes them. Most systems require this
  4949. action by the user before he ends the {\REDUCE} job (if not sooner),
  4950. otherwise the output may be lost. If a file is shut and a further {\tt OUT}
  4951. command issued for the same file, the file is erased before the new output
  4952. is written.
  4953. If it is the current output file that is shut, output will switch to the
  4954. terminal. Attempts to shut files that have not been opened by {\tt OUT},
  4955. or an input file, will lead to errors.
  4956. \chapter{Commands for Interactive Use}\index{Interactive use}
  4957. {\REDUCE} is designed as an interactive system, but naturally it can also
  4958. operate in a batch processing or background mode by taking its input
  4959. command by command from the relevant input stream. There is a basic
  4960. difference, however, between interactive and batch use of the system. In
  4961. the former case, whenever the system discovers an ambiguity at some point
  4962. in a calculation, such as a forgotten type assignment for instance, it asks
  4963. the user for the correct interpretation. In batch operation, it is not
  4964. practical to terminate the calculation at such points and require
  4965. resubmission of the job, so the system makes the most obvious guess of the
  4966. user's intentions and continues the calculation.
  4967. There is also a difference in the handling of errors. In the former case,
  4968. the computation can continue since the user has the opportunity to correct
  4969. the mistake. In batch mode, the error may lead to consequent erroneous
  4970. (and possibly time consuming) computations. So in the default case, no
  4971. further evaluation occurs, although the remainder of the input is checked
  4972. for syntax errors. A message {\tt "Continuing with parsing only"}
  4973. informs the user that this is happening. On the other hand, the switch
  4974. {\tt ERRCONT},\ttindex{ERRCONT} if on, will cause the system to continue
  4975. evaluating expressions after such errors occur.
  4976. When a syntactical error occurs, the place where the system detected the
  4977. error is marked with three dollar signs (\$\$\$). In interactive mode, the
  4978. user can then use {\tt ED}\ttindex{ED} to correct the error, or retype the
  4979. command. When a non-syntactical error occurs in interactive mode, the
  4980. command being evaluated at the time the last error occurred is saved, and
  4981. may later be reevaluated by the command {\tt RETRY}.\ttindex{RETRY}
  4982. \section{Referencing Previous Results}
  4983. It is often useful to be able to reference results of previous
  4984. computations during a {\REDUCE} session. For this purpose, {\REDUCE}
  4985. maintains a history\index{History} of all interactive inputs and the
  4986. results of all interactive computations during a given session. These
  4987. results are referenced by the command number that {\REDUCE} prints
  4988. automatically in interactive mode. To use an input expression in a new
  4989. computation, one writes {\tt input(}$n${\tt )},\ttindex{INPUT} where
  4990. $n$ is the command number. To use an output expression, one writes {\tt
  4991. WS(}$n${\tt )}.\ttindex{WS} {\tt WS} references the previous command.
  4992. E.g., if command number 1 was {\tt INT(X-1,X)}; and the result of command
  4993. number 7 was {\tt X-1}, then
  4994. {\small\begin{verbatim}
  4995. 2*input(1)-ws(7)^2;
  4996. \end{verbatim}}
  4997. would give the result {\tt -1}, whereas
  4998. {\small\begin{verbatim}
  4999. 2*ws(1)-ws(7)^2;
  5000. \end{verbatim}}
  5001. would yield the same result, but {\em without\/} a recomputation of the
  5002. integral.
  5003. The operator {\tt DISPLAY}\ttindex{DISPLAY} is available to display previous
  5004. inputs. If its argument is a positive integer, {\it n} say, then the
  5005. previous n inputs are displayed. If its argument is {\tt ALL} (or in fact
  5006. any non-numerical expression), then all previous inputs are displayed.
  5007. \section{Interactive Editing}
  5008. It is possible when working interactively to edit any {\REDUCE} input that
  5009. comes from the user's terminal, and also some user-defined procedure
  5010. definitions. At the top level, one can access any previous command string
  5011. by the command {\tt ed(}$n${\tt )},\ttindex{ED} where n is the desired
  5012. command number as prompted by the system in interactive mode. {\tt ED};
  5013. (i.e. no argument) accesses the previous command.
  5014. After {\tt ED} has been called, you can now edit the displayed string using a
  5015. string editor with the following commands:
  5016. \begin{tabular}{lp{\rboxwidth}}
  5017. {\tt~~~~~ B} & move pointer to beginning \\
  5018. {\tt~~~~~ C<character>} & replace next character by
  5019. {\em character} \\
  5020. {\tt~~~~~ D} & delete next character \\
  5021. {\tt~~~~~ E} & end editing and reread text \\
  5022. {\tt~~~~~ F<character>} & move pointer to next
  5023. occurrence of {\em character} \\[1.7pt]
  5024. {\tt~~~~~ I<string><escape>} &
  5025. insert {\em string\/} in front of pointer \\
  5026. {\tt~~~~~ K<character>} & delete all characters
  5027. until {\em character} \\
  5028. {\tt~~~~~ P} & print string from current pointer \\
  5029. {\tt~~~~~ Q} & give up with error exit \\
  5030. {\tt~~~~~ S<string><escape>} &
  5031. search for first occurrence of {\em string},
  5032. positioning pointer just before it \\
  5033. {\tt~~~~~ space} or {\tt X} & move pointer right
  5034. one character.
  5035. \end{tabular}
  5036. The above table can be displayed online by typing a question mark followed
  5037. by a carriage return to the editor. The editor prompts with an angle
  5038. bracket. Commands can be combined on a single line, and all command
  5039. sequences must be followed by a carriage return to become effective.
  5040. Thus, to change the command {\tt x := a+1;} to {\tt x := a+2}; and cause
  5041. it to be executed, the following edit command sequence could be used:
  5042. {\small\begin{verbatim}
  5043. f1c2e<return>.
  5044. \end{verbatim}}
  5045. The interactive editor may also be used to edit a user-defined procedure that
  5046. has not been compiled. To do this, one says:
  5047. \ttindex{EDITDEF}
  5048. {\small\begin{verbatim}
  5049. editdef <id>;
  5050. \end{verbatim}}
  5051. where {\tt <id>} is the name of the procedure. The procedure definition
  5052. will then be displayed in editing mode, and may then be edited and
  5053. redefined on exiting from the editor.
  5054. Some versions of {\REDUCE} now include input editing that uses the
  5055. capabilities of modern window systems. Please consult your system
  5056. dependent documentation to see if this is possible. Such editing
  5057. techniques are usually much easier to use then {\tt ED} or {\tt EDITDEF}.
  5058. \section{Interactive File Control}
  5059. If input is coming from an external file, the system treats it as a batch
  5060. processed calculation. If the user desires interactive
  5061. \index{Interactive use} response in this case, he can include the command
  5062. {\tt on int};\ttindex{INT} in the file. Likewise, he can issue the
  5063. command {\tt off int}; in the main program if he does not desire continual
  5064. questioning from the system. Regardless of the setting of {\tt INT},
  5065. input commands from a file are not kept in the system, and so cannot be
  5066. edited using {\tt ED}. However, many implementations of {\REDUCE} provide
  5067. a link to an external system editor that can be used for such editing.
  5068. The specific instructions for the particular implementation should be
  5069. consulted for information on this.
  5070. Two commands are available in {\REDUCE} for interactive use of files. {\tt
  5071. PAUSE};\ttindex{PAUSE} may be inserted at any point in an input file. When
  5072. this command is encountered on input, the system prints the message {\tt
  5073. CONT?} on the user's terminal and halts. If the user responds {\tt Y}
  5074. (for yes), the calculation continues from that point in the file. If the
  5075. user responds {\tt N} (for no), control is returned to the terminal, and
  5076. the user can input further statements and commands. Later on he can use
  5077. the command {\tt cont;}\ttindex{CONT} to transfer control back to the
  5078. point in the file following the last {\tt PAUSE} encountered. A top-level
  5079. {\tt pause;}\ttindex{PAUSE} from the user's terminal has no effect.
  5080. \chapter{Matrix Calculations} \index{Matrix calculations}
  5081. A very powerful feature of {\REDUCE} is the ease with which matrix
  5082. calculations can be performed. To extend our syntax to this class of
  5083. calculations we need to add another prefix operator, {\tt MAT},
  5084. \ttindex{MAT} and a further
  5085. variable and expression type as follows:
  5086. \section{MAT Operator}\ttindex{MAT}
  5087. This prefix operator is used to represent $n\times m$ matrices. {\tt
  5088. MAT} has {\em n} arguments interpreted as rows of the matrix, each of
  5089. which is a list of {\em m} expressions representing elements in that row.
  5090. For example, the matrix
  5091. \[ \left( \begin{array}{lcr} a & b & c \\ d & e & f \end{array} \right) \]
  5092. would be written as {\tt mat((a,b,c),(d,e,f))}.
  5093. Note that the single column matrix
  5094. \[ \left( \begin{array}{c} x \\ y \end{array} \right) \]
  5095. becomes {\tt mat((x),(y))}. The inside parentheses are required to
  5096. distinguish it from the single row matrix
  5097. \[ \left( \begin{array}{lr} x & y \end{array} \right) \]
  5098. that would be written as {\tt mat((x,y))}.
  5099. \section{Matrix Variables}
  5100. An identifier may be declared a matrix variable by the declaration {\tt
  5101. MATRIX}.\ttindex{MATRIX}
  5102. The size of the matrix may be declared explicitly in the matrix
  5103. declaration, or by default in assigning such a variable to a matrix
  5104. expression. For example,
  5105. {\small\begin{verbatim}
  5106. matrix x(2,1),y(3,4),z;
  5107. \end{verbatim}}
  5108. declares {\tt X} to be a 2 x 1 (column) matrix, {\tt Y} to be a 3 x 4
  5109. matrix and {\tt Z} a matrix whose size is to be declared later.
  5110. Matrix declarations can appear anywhere in a program. Once a symbol is
  5111. declared to name a matrix, it can not also be used to name an array,
  5112. operator or a procedure, or used as an ordinary variable. It can however
  5113. be redeclared to be a matrix, and its size may be changed at that time.
  5114. Note however that matrices once declared are {\em global\/} in scope, and so
  5115. can then be referenced anywhere in the program. In other words, a
  5116. declaration within a block (or a procedure) does not limit the scope of
  5117. the matrix to that block, nor does the matrix go away on exiting the block
  5118. (use {\tt CLEAR} instead for this purpose). An element of a matrix is
  5119. referred to in the expected manner; thus {\tt x(1,1)} gives the first
  5120. element of the matrix {\tt X} defined above. References to elements of a
  5121. matrix whose size has not yet been declared leads to an error. All
  5122. elements of a matrix whose size is declared are initialized to 0. As a
  5123. result, a matrix element has an {\em instant evaluation\/}\index{Instant
  5124. evaluation} property and cannot stand for itself. If this is required,
  5125. then an operator should be used to name the matrix elements as in:
  5126. {\small\begin{verbatim}
  5127. matrix m; operator x; m := mat((x(1,1),x(1,2));
  5128. \end{verbatim}}
  5129. \section{Matrix Expressions}
  5130. These follow the normal rules of matrix algebra as defined by the
  5131. following syntax:\ttindex{MAT}
  5132. {\small\begin{verbatim}
  5133. <matrix expression> ::=
  5134. MAT<matrix description>|<matrix variable>|
  5135. <scalar expression>*<matrix expression>|
  5136. <matrix expression>*<matrix expression>
  5137. <matrix expression>+<matrix expression>|
  5138. <matrix expression>^<integer>|
  5139. <matrix expression>/<matrix expression>
  5140. \end{verbatim}}
  5141. Sums and products of matrix expressions must be of compatible size;
  5142. otherwise an error will result during their evaluation. Similarly, only
  5143. square matrices may be raised to a power. A negative power is computed as
  5144. the inverse of the matrix raised to the corresponding positive power.
  5145. {\tt a/b} is interpreted as {\tt a*b\verb|^|(-1)}.
  5146. {\it Examples:}
  5147. Assuming {\tt X} and {\tt Y} have been declared as matrices, the following
  5148. are matrix expressions
  5149. {\small\begin{verbatim}
  5150. y
  5151. y^2*x-3*y^(-2)*x
  5152. y + mat((1,a),(b,c))/2
  5153. \end{verbatim}}
  5154. The computation of the quotient of two matrices normally uses a two-step
  5155. elimination method due to Bareiss. An alternative method using Cramer's
  5156. method is also available. This is usually less efficient than the Bareiss
  5157. method unless the matrices are large and dense, although we have no solid
  5158. statistics on this as yet. To use Cramer's method instead, the switch
  5159. {\tt CRAMER}\ttindex{CRAMER} should be turned on.
  5160. \section{Operators with Matrix Arguments}
  5161. The operator {\tt LENGTH}\ttindex{LENGTH} applied to a matrix returns a
  5162. list of the number of rows and columns in the matrix. Other operators
  5163. useful in matrix calculations are defined in the following subsections.
  5164. Attention is also drawn to the LINALG
  5165. \extendedmanual{(chapter~\ref{LINALG})} and NORMFORM
  5166. \extendedmanual{(chapter~\ref{NORMFORM})} packages.
  5167. \subsection{DET Operator}\ttindex{DET}
  5168. Syntax:
  5169. {\small\begin{verbatim}
  5170. DET(EXPRN:matrix_expression):algebraic.
  5171. \end{verbatim}}
  5172. The operator {\tt DET} is used to represent the determinant of a square
  5173. matrix expression. E.g.,
  5174. {\small\begin{verbatim}
  5175. det(y^2)
  5176. \end{verbatim}}
  5177. is a scalar expression whose value is the determinant of the square of the
  5178. matrix {\tt Y}, and
  5179. {\small\begin{verbatim}
  5180. det mat((a,b,c),(d,e,f),(g,h,j));
  5181. \end{verbatim}}
  5182. is a scalar expression whose value is the determinant of the matrix
  5183. \[ \left( \begin{array}{lcr} a & b & c \\ d & e & f \\ g & h & j
  5184. \end{array} \right) \]
  5185. Determinant expressions have the {\em instant evaluation\/} property.
  5186. \index{Instant evaluation} In other words, the statement
  5187. {\small\begin{verbatim}
  5188. let det mat((a,b),(c,d)) = 2;
  5189. \end{verbatim}}
  5190. sets the {\em value\/} of the determinant to 2, and does not set up a rule
  5191. for the determinant itself.
  5192. \subsection{MATEIGEN Operator}\ttindex{MATEIGEN}
  5193. Syntax:
  5194. {\small\begin{verbatim}
  5195. MATEIGEN(EXPRN:matrix_expression,ID):list.
  5196. \end{verbatim}}
  5197. {\tt MATEIGEN} calculates the eigenvalue equation and the corresponding
  5198. eigenvectors of a matrix, using the variable {\tt ID} to denote the
  5199. eigenvalue. A square free decomposition of the characteristic polynomial
  5200. is carried out. The result is a list of lists of 3 elements, where the
  5201. first element is a square free factor of the characteristic polynomial,
  5202. the second its multiplicity and the third the corresponding eigenvector
  5203. (as an {\em n} by 1 matrix). If the square free decomposition was
  5204. successful, the product of the first elements in the lists is the minimal
  5205. polynomial. In the case of degeneracy, several eigenvectors can exist for
  5206. the same eigenvalue, which manifests itself in the appearance of more than
  5207. one arbitrary variable in the eigenvector. To extract the various parts
  5208. of the result use the operations defined on lists.
  5209. {\it Example:}
  5210. The command
  5211. {\small\begin{verbatim}
  5212. mateigen(mat((2,-1,1),(0,1,1),(-1,1,1)),eta);
  5213. \end{verbatim}}
  5214. gives the output
  5215. {\small\begin{verbatim}
  5216. {{ETA - 1,2,
  5217. [ARBCOMPLEX(1)]
  5218. [ ]
  5219. [ARBCOMPLEX(1)]
  5220. [ ]
  5221. [ 0 ]
  5222. },
  5223. {ETA - 2,1,
  5224. [ 0 ]
  5225. [ ]
  5226. [ARBCOMPLEX(2)]
  5227. [ ]
  5228. [ARBCOMPLEX(2)]
  5229. }}
  5230. \end{verbatim}}
  5231. \subsection{TP Operator}\ttindex{TP}
  5232. Syntax:
  5233. {\small\begin{verbatim}
  5234. TP(EXPRN:matrix_expression):matrix.
  5235. \end{verbatim}}
  5236. This operator takes a single matrix argument and returns its transpose.
  5237. \subsection{Trace Operator}\ttindex{TRACE}
  5238. Syntax:
  5239. {\small\begin{verbatim}
  5240. TRACE(EXPRN:matrix_expression):algebraic.
  5241. \end{verbatim}}
  5242. The operator {\tt TRACE} is used to represent the trace of a square matrix.
  5243. \subsection{Matrix Cofactors}\ttindex{COFACTOR}
  5244. Syntax:
  5245. {\small\begin{verbatim}
  5246. COFACTOR(EXPRN:matrix_expression,ROW:integer,COLUMN:integer):
  5247. algebraic
  5248. \end{verbatim}}
  5249. The operator {\tt COFACTOR} returns the cofactor of the element in row
  5250. {\tt ROW} and column {\tt COLUMN} of the matrix {\tt MATRIX}. Errors occur
  5251. if {\tt ROW} or {\tt COLUMN} do not simplify to integer expressions or if
  5252. {\tt MATRIX} is not square.
  5253. \subsection{NULLSPACE Operator}\ttindex{NULLSPACE}
  5254. Syntax:
  5255. {\small\begin{verbatim}
  5256. NULLSPACE(EXPRN:matrix_expression):list
  5257. \end{verbatim}}
  5258. {\tt NULLSPACE} calculates for a matrix {\tt A} a list of linear
  5259. independent vectors (a basis) whose linear combinations satisfy the
  5260. equation $A x = 0$. The basis is provided in a form such that as many
  5261. upper components as possible are isolated.
  5262. Note that with {\tt b := nullspace a} the expression {\tt length b} is the
  5263. {\em nullity\/} of A, and that {\tt second length a - length b} calculates the
  5264. {\em rank\/} of A. The rank of a matrix expression can also be found more
  5265. directly by the {\tt RANK} operator described below.
  5266. {\it Example:} The command
  5267. {\small\begin{verbatim}
  5268. nullspace mat((1,2,3,4),(5,6,7,8));
  5269. \end{verbatim}}
  5270. gives the output
  5271. {\small\begin{verbatim}
  5272. {
  5273. [ 1 ]
  5274. [ ]
  5275. [ 0 ]
  5276. [ ]
  5277. [ - 3]
  5278. [ ]
  5279. [ 2 ]
  5280. ,
  5281. [ 0 ]
  5282. [ ]
  5283. [ 1 ]
  5284. [ ]
  5285. [ - 2]
  5286. [ ]
  5287. [ 1 ]
  5288. }
  5289. \end{verbatim}}
  5290. In addition to the {\REDUCE} matrix form, {\tt NULLSPACE} accepts as input a
  5291. matrix given as a list of lists, that is interpreted as a row matrix. If
  5292. that form of input is chosen, the vectors in the result will be
  5293. represented by lists as well. This additional input syntax facilitates
  5294. the use of {\tt NULLSPACE} in applications different from classical linear
  5295. algebra.
  5296. \subsection{RANK Operator}\ttindex{RANK}
  5297. Syntax:
  5298. {\small\begin{verbatim}
  5299. RANK(EXPRN:matrix_expression):integer
  5300. \end{verbatim}}
  5301. {\tt RANK} calculates the rank of its argument, that, like {\tt NULLSPACE}
  5302. can either be a standard matrix expression, or a list of lists, that can
  5303. be interpreted either as a row matrix or a set of equations.
  5304. {\tt Example:}
  5305. {\small\begin{verbatim}
  5306. rank mat((a,b,c),(d,e,f));
  5307. \end{verbatim}}
  5308. returns the value 2.
  5309. \section{Matrix Assignments} \index{Matrix assignment}
  5310. Matrix expressions may appear in the right-hand side of assignment
  5311. statements. If the left-hand side of the assignment, which must be a
  5312. variable, has not already been declared a matrix, it is declared by default
  5313. to the size of the right-hand side. The variable is then set to the value
  5314. of the right-hand side.
  5315. Such an assignment may be used very conveniently to find the solution of a
  5316. set of linear equations. For example, to find the solution of the
  5317. following set of equations
  5318. {\small\begin{verbatim}
  5319. a11*x(1) + a12*x(2) = y1
  5320. a21*x(1) + a22*x(2) = y2
  5321. \end{verbatim}}
  5322. we simply write
  5323. {\small\begin{verbatim}
  5324. x := 1/mat((a11,a12),(a21,a22))*mat((y1),(y2));
  5325. \end{verbatim}}
  5326. \section{Evaluating Matrix Elements}
  5327. Once an element of a matrix has been assigned, it may be referred to in
  5328. standard array element notation. Thus {\tt y(2,1)} refers to the element
  5329. in the second row and first column of the matrix {\tt Y}.
  5330. \chapter{Procedures}\ttindex{PROCEDURE}
  5331. It is often useful to name a statement for repeated use in calculations
  5332. with varying parameters, or to define a complete evaluation procedure for
  5333. an operator. {\REDUCE} offers a procedural declaration for this purpose. Its
  5334. general syntax is:
  5335. {\small\begin{verbatim}
  5336. [<procedural type>] PROCEDURE <name>[<varlist>];<statement>;
  5337. \end{verbatim}}
  5338. where
  5339. {\small\begin{verbatim}
  5340. <varlist> ::= (<variable>,...,<variable>)
  5341. \end{verbatim}}
  5342. This will be explained more fully in the following sections.
  5343. In the algebraic mode of {\REDUCE} the {\tt <procedure type>} can be
  5344. omitted, since the default is {\tt ALGEBRAIC}. Procedures of type {\tt
  5345. INTEGER} or {\tt REAL} may also be used. In the former case, the system
  5346. checks that the value of the procedure is an integer. At present, such
  5347. checking is not done for a real procedure, although this will change in
  5348. the future when a more complete type checking mechanism is installed.
  5349. Users should therefore only use these types when appropriate. An empty
  5350. variable list may also be omitted.
  5351. All user-defined procedures are automatically declared to be operators.
  5352. In order to allow users relatively easy access to the whole {\REDUCE} source
  5353. program, system procedures are not protected against user redefinition. If
  5354. a procedure is redefined, a message
  5355. {\small\begin{verbatim}
  5356. *** <procedure name> REDEFINED
  5357. \end{verbatim}}
  5358. is printed. If this occurs, and the user is not redefining his own
  5359. procedure, he is well advised to rename it, and possibly start over
  5360. (because he has {\em already\/} redefined some internal procedure whose correct
  5361. functioning may be required for his job!)
  5362. All required procedures should be defined at the top level, since they
  5363. have global scope throughout a program. In particular, an attempt to
  5364. define a procedure within a procedure will cause an error to occur.
  5365. \section{Procedure Heading}\index{Procedure heading}
  5366. Each procedure has a heading consisting of the word {\tt PROCEDURE}
  5367. (optionally preceded by the word {\tt ALGEBRAIC}), followed by the name of
  5368. the procedure to be defined, and followed by its formal parameters -- the
  5369. symbols that will be used in the body of the definition to illustrate
  5370. what is to be done. There are three cases:
  5371. \begin{enumerate}
  5372. \item No parameters. Simply follow the procedure name with a terminator
  5373. (semicolon or dollar sign).
  5374. {\small\begin{verbatim}
  5375. procedure abc;
  5376. \end{verbatim}}
  5377. When such a procedure is used in an expression or command, {\tt abc()}, with
  5378. empty parentheses, must be written.
  5379. \item One parameter. Enclose it in parentheses {\em or\/} just leave at
  5380. least one space, then follow with a terminator.
  5381. {\small\begin{verbatim}
  5382. procedure abc(x);
  5383. \end{verbatim}}
  5384. or
  5385. {\small\begin{verbatim}
  5386. procedure abc x;
  5387. \end{verbatim}}
  5388. \item More than one parameter. Enclose them in parentheses, separated by
  5389. commas, then follow with a terminator.
  5390. {\small\begin{verbatim}
  5391. procedure abc(x,y,z);
  5392. \end{verbatim}}
  5393. \end{enumerate}
  5394. Referring to the last example, if later in some expression being evaluated
  5395. the symbols {\tt abc(u,p*q,123)} appear, the operations of the procedure
  5396. body will be carried out as if {\tt X} had the same value as {\tt U} does,
  5397. {\tt Y} the same value as {\tt p*q} does, and {\tt Z} the value 123. The
  5398. values of {\tt X}, {\tt Y}, {\tt Z}, after the procedure body operations
  5399. are completed are unchanged. So, normally, are the values of {\tt U},
  5400. {\tt P}, {\tt Q}, and (of course) 123. (This is technically referred to as
  5401. call by value.)\index{Call by value}
  5402. The reader will have noted the word {\em normally\/} a few lines earlier. The
  5403. call by value protections can be bypassed if necessary, as described
  5404. elsewhere.
  5405. \section{Procedure Body}\index{Procedure body}
  5406. Following the delimiter that ends the procedure heading must be a {\em
  5407. single} statement defining the action to be performed or the value to be
  5408. delivered. A terminator must follow the statement. If it is a semicolon,
  5409. the name of the procedure just defined is printed. It is not printed if a
  5410. dollar sign is used.
  5411. If the result wanted is given by a formula of some kind, the body is just
  5412. that formula, using the variables in the procedure heading.
  5413. {\it Simple Example:}
  5414. If {\tt f(x)} is to mean {\tt (x+5)*(x+6)/(x+7)}, the entire procedure
  5415. definition could read
  5416. {\small\begin{verbatim}
  5417. procedure f x; (x+5)*(x+6)/(x+7);
  5418. \end{verbatim}}
  5419. Then {\tt f(10)} would evaluate to 240/17, {\tt f(a-6)} to
  5420. {\tt A*(A-1)/(A+1)}, and so on.
  5421. {\it More Complicated Example:}
  5422. Suppose we need a function {\tt p(n,x)} that, for any positive integer
  5423. {\tt N}, is the Legendre polynomial\index{Legendre polynomials} of order
  5424. {\em n}. We can define this operator using the
  5425. textbook formula defining these functions:
  5426. \begin{displaymath}
  5427. p_n(x) = \displaystyle{1\over{n!}}\
  5428. \displaystyle{d^n\over dy^n}\ \displaystyle{{1\over{(y^2 - 2xy + 1)
  5429. ^{{1\over2}}}}}\Bigg\vert_{y=0}
  5430. \end{displaymath}
  5431. Put into words, the Legendre polynomial $p_n(x)$ is the result of
  5432. substituting $y=0$ in the $n^{th}$ partial derivative with respect to $y$
  5433. of a certain fraction involving $x$ and $y$, then dividing that by $n!$.
  5434. This verbal formula can easily be written in {\REDUCE}:
  5435. {\small\begin{verbatim}
  5436. procedure p(n,x);
  5437. sub(y=0,df(1/(y^2-2*x*y+1)^(1/2),y,n))
  5438. /(for i:=1:n product i);
  5439. \end{verbatim}}
  5440. Having input this definition, the expression evaluation
  5441. {\small\begin{verbatim}
  5442. 2p(2,w);
  5443. \end{verbatim}}
  5444. would result in the output
  5445. {\small\begin{verbatim}
  5446. 2
  5447. 3*W - 1 .
  5448. \end{verbatim}}
  5449. If the desired process is best described as a series of steps, then a group
  5450. or compound statement can be used.
  5451. \extendedmanual{\newpage}
  5452. {\it Example:}
  5453. The above Legendre polynomial example can be rewritten as a series of steps
  5454. instead of a single formula as follows:
  5455. {\small\begin{verbatim}
  5456. procedure p(n,x);
  5457. begin scalar seed,deriv,top,fact;
  5458. seed:=1/(y^2 - 2*x*y +1)^(1/2);
  5459. deriv:=df(seed,y,n);
  5460. top:=sub(y=0,deriv);
  5461. fact:=for i:=1:n product i;
  5462. return top/fact
  5463. end;
  5464. \end{verbatim}}
  5465. Procedures may also be defined recursively. In other words, the procedure
  5466. body\index{Procedure body} can include references to the procedure name
  5467. itself, or to other procedures that themselves reference the given
  5468. procedure. As an example, we can define the Legendre polynomial through
  5469. its standard recurrence relation:
  5470. {\small\begin{verbatim}
  5471. procedure p(n,x);
  5472. if n<0 then rederr "Invalid argument to P(N,X)"
  5473. else if n=0 then 1
  5474. else if n=1 then x
  5475. else ((2*n-1)*x*p(n-1,x)-(n-1)*p(n-2,x))/n;
  5476. \end{verbatim}}
  5477. The operator {\tt REDERR}\ttindex{REDERR} in the above example provides
  5478. for a simple error exit from an algebraic procedure (and also a block).
  5479. It can take a string as argument.
  5480. It should be noted however that all the above definitions of {\tt p(n,x)} are
  5481. quite inefficient if extensive use is to be made of such polynomials, since
  5482. each call effectively recomputes all lower order polynomials. It would be
  5483. better to store these expressions in an array, and then use say the
  5484. recurrence relation to compute only those polynomials that have not already
  5485. been derived. We leave it as an exercise for the reader to write such a
  5486. definition.
  5487. \section{Using LET Inside Procedures}
  5488. By using {\tt LET}\ttindex{LET} instead of an assignment in the procedure
  5489. body\index{Procedure body} it is possible to bypass the call-by-value
  5490. \index{Call by value} protection. If {\tt X} is a formal parameter or local
  5491. variable of the procedure (i.e. is in the heading or in a local
  5492. declaration), and {\tt LET} is used instead of {\tt :=} to make an
  5493. assignment to {\tt X}, e.g.
  5494. {\small\begin{verbatim}
  5495. let x = 123;
  5496. \end{verbatim}}
  5497. then it is the variable that is the value of {\tt X} that is changed.
  5498. This effect also occurs with local variables defined in a block. If the
  5499. value of {\tt X} is not a variable, but a more general expression, then it
  5500. is that expression that is used on the left-hand side of the {\tt LET}
  5501. statement. For example, if {\tt X} had the value {\tt p*q}, it is as if
  5502. {\tt let p*q = 123} had been executed.
  5503. \section{LET Rules as Procedures}
  5504. The {\tt LET}\ttindex{LET} statement offers an alternative syntax and
  5505. semantics for procedure definition.
  5506. In place of
  5507. {\small\begin{verbatim}
  5508. procedure abc(x,y,z); <procedure body>;
  5509. \end{verbatim}}
  5510. one can write
  5511. {\small\begin{verbatim}
  5512. for all x,y,z let abc(x,y,z) = <procedure body>;
  5513. \end{verbatim}}
  5514. There are several differences to note.
  5515. If the procedure body contains an assignment to one of the formal
  5516. parameters, e.g.
  5517. {\small\begin{verbatim}
  5518. x := 123;
  5519. \end{verbatim}}
  5520. in the {\tt PROCEDURE} case it is a variable holding a copy of the first
  5521. actual argument that is changed. The actual argument is not changed.
  5522. In the {\tt LET} case, the actual argument is changed. Thus, if {\tt ABC}
  5523. is defined using {\tt LET}, and {\tt abc(u,v,w)} is evaluated, the value
  5524. of {\tt U} changes to 123. That is, the {\tt LET} form of definition
  5525. allows the user to bypass the protections that are enforced by the call
  5526. by value conventions of standard {\tt PROCEDURE} definitions.
  5527. {\it Example:} We take our earlier {\tt FACTORIAL}\ttindex{FACTORIAL}
  5528. procedure and write it as a {\tt LET} statement.
  5529. {\small\begin{verbatim}
  5530. for all n let factorial n =
  5531. begin scalar m,s;
  5532. m:=1; s:=n;
  5533. l1: if s=0 then return m;
  5534. m:=m*s;
  5535. s:=s-1;
  5536. go to l1
  5537. end;
  5538. \end{verbatim}}
  5539. The reader will notice that we introduced a new local variable, {\tt S},
  5540. and set it equal to {\tt N}. The original form of the procedure contained
  5541. the statement {\tt n:=n-1;}. If the user asked for the value of {\tt
  5542. factorial(5)} then {\tt N} would correspond to, not just have the value
  5543. of, 5, and {\REDUCE} would object to trying to execute the statement
  5544. 5 := $5-1$.
  5545. If {\tt PQR} is a procedure with no parameters,
  5546. {\small\begin{verbatim}
  5547. procedure pqr;
  5548. <procedure body>;
  5549. \end{verbatim}}
  5550. it can be written as a {\tt LET} statement quite simply:
  5551. {\small\begin{verbatim}
  5552. let pqr = <procedure body>;
  5553. \end{verbatim}}
  5554. To call {\em procedure\/} {\tt PQR}, if defined in the latter form, the empty
  5555. parentheses would not be used: use {\tt PQR} not {\tt PQR()} where a call
  5556. on the procedure is needed.
  5557. The two notations for a procedure with no arguments can be combined. {\tt PQR}
  5558. can be defined in the standard {\tt PROCEDURE} form. Then a {\tt LET}
  5559. statement
  5560. {\small\begin{verbatim}
  5561. let pqr = pqr();
  5562. \end{verbatim}}
  5563. would allow a user to use {\tt PQR} instead of {\tt PQR()} in calling the
  5564. procedure.
  5565. A feature available with {\tt LET}-defined procedures and not with procedures
  5566. defined in the standard way is the possibility of defining partial
  5567. functions.\index{Function}
  5568. {\small\begin{verbatim}
  5569. for all x such that numberp x let uvw(x)=<procedure body>;
  5570. \end{verbatim}}
  5571. Now {\tt UVW} of an integer would be calculated as prescribed by the procedure
  5572. body, while {\tt UVW} of a general argument, such as {\tt Z} or {\tt p+q}
  5573. (assuming these evaluate to themselves) would simply stay {\tt uvw(z)}
  5574. or {\tt uvw(p+q)} as the case may be.
  5575. \section{REMEMBER Statement}\ttindex{REMEMBER}
  5576. Setting the remember option for an algebraic procedure by
  5577. {\small\begin{verbatim}
  5578. REMEMBER (PROCNAME:procedure);
  5579. \end{verbatim}}
  5580. saves all intermediate results of such procedure evaluations, including
  5581. recursive calls. Subsequent calls to the procedure can then be determined
  5582. from the saved results, and thus the number of evaluations (or the
  5583. complexity) can be reduced. This mode of evalation costs extra memory, of
  5584. course. In addition, the procedure must be free of side--effects.
  5585. The following examples show the effect of the remember statement
  5586. on two well--known examples.
  5587. \begin{samepage}
  5588. {\small\begin{verbatim}
  5589. procedure H(n); % Hofstadter's function
  5590. if numberp n then
  5591. << cnn := cnn +1; % counts the calls
  5592. if n < 3 then 1 else H(n-H(n-1))+H(n-H(n-2))>>;
  5593. remember h;
  5594. > << cnn := 0; H(100); cnn>>;
  5595. 100
  5596. % H has been called 100 times only.
  5597. procedure A(m,n); % Ackermann function
  5598. if m=0 then n+1 else
  5599. if n=0 then A(m-1,1) else
  5600. A(m-1,A(m,n-1));
  5601. remember a;
  5602. A(3,3);
  5603. \end{verbatim}}
  5604. \end{samepage}
  5605. \chapter{User Contributed Packages} \index{User packages}
  5606. \label{chap-user}
  5607. The complete {\REDUCE} system includes a number of packages contributed by
  5608. users that are provided as a service to the user community. Questions
  5609. regarding these packages should be directed to their individual authors.
  5610. All such packages have been precompiled as part of the installation process.
  5611. However, many must be specifically loaded before they can be used. (Those
  5612. that are loaded automatically are so noted in their description.) You should
  5613. also consult the user notes for your particular implementation for further
  5614. information on whether this is necessary. If it is, the relevant command is
  5615. {\tt LOAD\_PACKAGE},\ttindex{LOAD\_PACKAGE} which takes a list of one or
  5616. more package names as argument, for example:
  5617. {\small\begin{verbatim}
  5618. load_package algint;
  5619. \end{verbatim}}
  5620. although this syntax may vary from implementation to implementation.
  5621. Nearly all these packages come with separate documentation and test files
  5622. (except those noted here that have no additional documentation), which is
  5623. included, along with the source of the package, in the {\REDUCE} system
  5624. distribution. These items should be studied for any additional details on
  5625. the use of a particular package.
  5626. Part 2 of this manual contains short documentation for the packages
  5627. \begin{itemize}
  5628. %%
  5629. %%The packages available in the current release of {\REDUCE} are as follows:
  5630. %%
  5631. \item
  5632. {ALGINT: Integration of square roots} (chapter~\ref{ALGINT});\ttindex{ALGINT}
  5633. %%
  5634. %%This package, which is an extension of the basic integration package
  5635. %%distributed with {\REDUCE}, will analytically integrate a wide range of
  5636. %%expressions involving square roots where the answer exists in that class
  5637. %%of functions. It is an implementation of the work described in J.H.
  5638. %%Davenport, ``On the Integration of Algebraic Functions", LNCS 102,
  5639. %%Springer Verlag, 1981. Both this and the source code should be consulted
  5640. %%for a more detailed description of this work.
  5641. %%
  5642. %%Once the {\tt ALGINT} package has been loaded, using {\tt LOAD\_PACKAGE},
  5643. %%one enters an expression for integration, as with the regular integrator,
  5644. %%for example:
  5645. %%{\small\begin{verbatim}
  5646. %% int(sqrt(x+sqrt(x**2+1))/x,x);
  5647. %%\end{verbatim}}
  5648. %%If one later wishes to integrate expressions without using the facilities of
  5649. %%this package, the switch {\tt ALGINT}\ttindex{ALGINT} should be turned
  5650. %%off. This is turned on automatically when the package is loaded.
  5651. %%
  5652. %%The switches supported by the standard integrator (e.g., {\tt TRINT})
  5653. %%\ttindex{TRINT} are also supported by this package. In addition, the
  5654. %%switch {\tt TRA},\ttindex{TRA} if on, will give further tracing
  5655. %%information about the specific functioning of the algebraic integrator.
  5656. %%
  5657. %%There is no additional documentation for this package.
  5658. %%
  5659. %%Author: James H. Davenport.
  5660. %%
  5661. \item
  5662. {APPLYSYM: Infinitesimal symmetries of differential equations}
  5663. (chapter~\ref{APPLYSYM});\ttindex{APPLYSYM}
  5664. %%\ttindex{APPLYSYM}
  5665. %%
  5666. %%This package provides programs APPLYSYM, QUASILINPDE and DETRAFO for
  5667. %%computing with infinitesimal symmetries of differential equations.
  5668. %%
  5669. %%Author: Thomas Wolf.
  5670. %%
  5671. \item
  5672. {ARNUM: An algebraic number package} (chapter~\ref{ARNUM});\ttindex{ARNUM}
  5673. %%
  5674. %%This package provides facilities for handling algebraic numbers as
  5675. %%polynomial coefficients in {\REDUCE} calculations. It includes facilities for
  5676. %%introducing indeterminates to represent algebraic numbers, for calculating
  5677. %%splitting fields, and for factoring and finding greatest common divisors
  5678. %%in such domains.
  5679. %%
  5680. %%Author: Eberhard Schr\"ufer.
  5681. %%
  5682. \item
  5683. {ASSIST: Useful utilities for various applications}
  5684. (chapter~\ref{ASSIST});\ttindex{ASSIST}
  5685. %%
  5686. %%ASSIST contains a large number of additional general purpose functions
  5687. %%that allow a user to better adapt \REDUCE\ to various calculational
  5688. %%strategies and to make the programming task more straightforward and more
  5689. %%efficient.
  5690. %%
  5691. %%Author: Hubert Caprasse.
  5692. %%
  5693. \item
  5694. {AVECTOR: A vector algebra and calculus package}
  5695. (chapter~\ref{AVECTOR});\ttindex{AVECTOR}
  5696. %%
  5697. %%This package provides REDUCE with the ability to perform vector algebra
  5698. %%using the same notation as scalar algebra. The basic algebraic operations
  5699. %%are supported, as are differentiation and integration of vectors with
  5700. %%respect to scalar variables, cross product and dot product, component
  5701. %%manipulation and application of scalar functions (e.g. cosine) to a vector
  5702. %%to yield a vector result.
  5703. %%
  5704. %%Author: David Harper.
  5705. %%
  5706. \item
  5707. {BOOLEAN: A package for boolean algebra} (chapter~\ref{BOOLEAN});
  5708. \ttindex{BOOLEAN}
  5709. %%
  5710. %%This package supports the computation with boolean expressions in the
  5711. %%propositional calculus. The data objects are composed from algebraic
  5712. %%expressions connected by the infix boolean operators {\bf and}, {\bf or},
  5713. %%{\bf implies}, {\bf equiv}, and the unary prefix operator {\bf not}.
  5714. %%{\bf Boolean} allows you to simplify expressions built from these
  5715. %%operators, and to test properties like equivalence, subset property etc.
  5716. %%
  5717. %%Author: Herbert Melenk.
  5718. %%
  5719. \item
  5720. {CALI: A package for computational commutative algebra}
  5721. (chapter~\ref{CALI});\ttindex{CALI}
  5722. %%\ttindex{CALI}
  5723. %%
  5724. %%This package contains algorithms for computations in commutative algebra
  5725. %%closely related to the Gr\"obner algorithm for ideals and modules. Its
  5726. %%heart is a new implementation of the Gr\"obner algorithm that also allows
  5727. %%for the computation of syzygies. This implementation is also applicable to
  5728. %%submodules of free modules with generators represented as rows of a matrix.
  5729. %%
  5730. %%Author: Hans-Gert Gr\"abe.
  5731. %%
  5732. \item
  5733. {CAMAL: Calculations in celestial mechanics} (chapter~\ref{CAMAL});
  5734. \ttindex{CAMAL}
  5735. %%
  5736. %%This packages implements in REDUCE the Fourier transform procedures of the
  5737. %%CAMAL package for celestial mechanics.
  5738. %%
  5739. %%Author: John P. Fitch.
  5740. %%
  5741. \item
  5742. {CHANGEVR: Change of Independent Variable(s) in DEs}
  5743. (chapter~\ref{CHANGEVR});\ttindex{CHANGEVR}
  5744. %%
  5745. %%This package provides facilities for changing the independent variables in
  5746. %%a differential equation. It is basically the application of the chain rule.
  5747. %%
  5748. %%Author: G. \"{U}\c{c}oluk.
  5749. %%
  5750. \item
  5751. {COMPACT: Package for compacting expressions} (chapter~\ref{COMPACT});
  5752. \ttindex{COMPACT}
  5753. %%
  5754. %%COMPACT is a package of functions for the reduction of a polynomial in the
  5755. %%presence of side relations. COMPACT applies the side relations to the
  5756. %%polynomial so that an equivalent expression results with as few terms as
  5757. %%possible. For example, the evaluation of
  5758. %%{\small\begin{verbatim}
  5759. %% compact(s*(1-sin x^2)+c*(1-cos x^2)+sin x^2+cos x^2,
  5760. %% {cos x^2+sin x^2=1});
  5761. %%\end{verbatim}}
  5762. %%yields the result\pagebreak[1]
  5763. %%\begin{samepage}
  5764. %%{\small\begin{verbatim}
  5765. %% 2 2
  5766. %% SIN(X) *C + COS(X) *S + 1 .
  5767. %%\end{verbatim}}
  5768. %%
  5769. %%Author: Anthony C. Hearn.
  5770. %%\end{samepage}
  5771. %%
  5772. \item
  5773. {CONTFR: Approximation of a number by continued fractions}
  5774. (chapter~\ref{CONTFR});\ttindex{CONTFR}
  5775. %%
  5776. %%This package provides for the simultaneous approximation of a real number
  5777. %%by a continued fraction and a rational number with optional user
  5778. %%controlled precision (upper bound for numerator).
  5779. %%
  5780. %%To use this package, the {\bf misc} package should be loaded. One can then
  5781. %%use the operator\ttindex{continued\_fraction} to calculate the required
  5782. %%sequence. For example:
  5783. %%{\small\begin{verbatim}
  5784. %%
  5785. %% continued_fraction pi; ->
  5786. %%
  5787. %% 1146408
  5788. %% {---------,{3,7,15,1,292,1,1,1,2,1}}
  5789. %% 364913
  5790. %%\end{verbatim}}
  5791. %%
  5792. %%There is no further documentation for this package.
  5793. %%
  5794. %%Author: Herbert Melenk.
  5795. %%
  5796. \item
  5797. {CRACK: Solving overdetermined systems of PDEs or ODEs}
  5798. (chapter~\ref{CRACK});\ttindex{CRACK}
  5799. %%
  5800. %%CRACK is a package for solving overdetermined systems of partial or
  5801. %%ordinary differential equations (PDEs, ODEs). Examples of programs which
  5802. %%make use of CRACK for investigating ODEs (finding symmetries, first
  5803. %%integrals, an equivalent Lagrangian or a ``differential factorization'') are
  5804. %%included.
  5805. %%
  5806. %%Authors: Andreas Brand, Thomas Wolf.
  5807. %%
  5808. \item
  5809. {CVIT: Fast calculation of Dirac gamma matrix traces}
  5810. (chapter~\ref{CVIT});\ttindex{CVIT}
  5811. %%
  5812. %%This package provides an alternative method for computing traces of Dirac
  5813. %%gamma matrices, based on an algorithm by Cvitanovich that treats gamma
  5814. %%matrices as 3-j symbols.
  5815. %%
  5816. %%Authors: V.Ilyin, A.Kryukov, A.Rodionov, A.Taranov.
  5817. %%
  5818. \item
  5819. {DEFINT: A definite integration interface for REDUCE}
  5820. (chapter~\ref{DEFINT});\ttindex{DEFINT}
  5821. %%
  5822. %%This package finds the definite integral of an expression in a stated
  5823. %%interval. It uses several techniques, including an innovative approach
  5824. %%based on the Meijer G-function, and contour integration.
  5825. %%
  5826. %%Authors: Kerry Gaskell, Stanley M. Kameny, Winfried Neun.
  5827. %%
  5828. \item
  5829. {DESIR: Differential linear homogeneous equation solutions in the
  5830. neighborhood of irregular and regular singular points}
  5831. (chapter~\ref{DESIR});\ttindex{DESIR}
  5832. %%
  5833. %%This package enables the basis of formal solutions to be computed for an
  5834. %%ordinary homogeneous differential equation with polynomial coefficients
  5835. %%over Q of any order, in the neighborhood of zero (regular or irregular
  5836. %%singular point, or ordinary point).
  5837. %%
  5838. %%Documentation for this package is in plain text.
  5839. %%
  5840. %%Authors: C. Dicrescenzo, F. Richard-Jung, E. Tournier.
  5841. %%
  5842. \item
  5843. {DFPART: Derivatives of generic functions}
  5844. (chapter~\ref{DFPART});\ttindex{DFPART}
  5845. %%
  5846. %%This package supports computations with total and partial derivatives of
  5847. %%formal function objects. Such computations can be useful in the context
  5848. %%of differential equations or power series expansions.
  5849. %%
  5850. %%Author: Herbert Melenk.
  5851. %%
  5852. \item
  5853. {DUMMY: Canonical form of expressions with dummy variables}
  5854. (chapter~\ref{DUMMY});\ttindex{DUMMY}
  5855. %%
  5856. %%This package allows a user to find the canonical form of expressions
  5857. %%involving dummy variables. In that way, the simplification of
  5858. %%polynomial expressions can be fully done. The indeterminates are general
  5859. %%operator objects endowed with as few properties as possible. In that way
  5860. %%the package may be used in a large spectrum of applications.
  5861. %%
  5862. %%Author: Alain Dresse.
  5863. %%
  5864. \item
  5865. {EXCALC: A differential geometry package} (chapter~\ref{EXCALC});
  5866. \ttindex{EXCALC}
  5867. %%
  5868. %%EXCALC is designed for easy use by all who are familiar with the calculus
  5869. %%of Modern Differential Geometry. The program is currently able to handle
  5870. %%scalar-valued exterior forms, vectors and operations between them, as well
  5871. %%as non-scalar valued forms (indexed forms). It is thus an ideal tool for
  5872. %%studying differential equations, doing calculations in general relativity
  5873. %%and field theories, or doing simple things such as calculating the
  5874. %%Laplacian of a tensor field for an arbitrary given frame.
  5875. %%
  5876. %%Author: Eberhard Schr\"ufer.
  5877. %%
  5878. \item
  5879. {FPS: Automatic calculation of formal power series}
  5880. (chapter~\ref{FPS});\ttindex{FPS}
  5881. %%
  5882. %%This package can expand a specific class of functions into their
  5883. %%corresponding Laurent-Puiseux series.
  5884. %%
  5885. %%Authors: Wolfram Koepf and Winfried Neun.
  5886. %%
  5887. \item
  5888. {FIDE: Finite difference method for partial differential equations}
  5889. (chapter~\ref{FIDE});\ttindex{FIDE}
  5890. %%
  5891. %%This package performs automation of the process of numerically
  5892. %%solving partial differential equations systems (PDES) by means of
  5893. %%computer algebra. For PDES solving, the finite difference method is applied.
  5894. %%The computer algebra system REDUCE and the numerical programming
  5895. %%language FORTRAN are used in the presented methodology. The main aim of
  5896. %%this methodology is to speed up the process of preparing numerical
  5897. %%programs for solving PDES. This process is quite often, especially for
  5898. %%complicated systems, a tedious and time consuming task.
  5899. %%
  5900. %%Documentation for this package is in plain text.
  5901. %%
  5902. %%Author: Richard Liska.
  5903. %%
  5904. \item
  5905. {GENTRAN: A code generation package} (chapter~\ref{GENTRAN});
  5906. \ttindex{GENTRAN}
  5907. %%
  5908. %%GENTRAN is an automatic code GENerator and TRANslator. It constructs
  5909. %%complete numerical programs based on sets of algorithmic specifications
  5910. %%and symbolic expressions. Formatted FORTRAN, RATFOR, PASCAL or C code can be
  5911. %%generated through a series of interactive commands or under the control of
  5912. %%a template processing routine. Large expressions can be automatically
  5913. %%segmented into subexpressions of manageable size, and a special
  5914. %%file-handling mechanism maintains stacks of open I/O channels to allow
  5915. %%output to be sent to any number of files simultaneously and to facilitate
  5916. %%recursive invocation of the whole code generation process.
  5917. %%
  5918. %%Author: Barbara L. Gates.
  5919. %%
  5920. \item
  5921. {GNUPLOT: Display of functions and surfaces}
  5922. (chapter~\ref{GNUPLOT});\ttindex{PLOT}\ttindex{GNUPLOT}
  5923. %%
  5924. %%This package is an interface to the popular GNUPLOT package.
  5925. %%It allows you to display functions in 2D and surfaces in 3D
  5926. %%on a variety of output devices including X terminals, PC monitors, and
  5927. %%postscript and Latex printer files.
  5928. %%
  5929. %%NOTE: The GNUPLOT package may not be included in all versions of REDUCE.
  5930. %%
  5931. %%Author: Herbert Melenk.
  5932. %%
  5933. \item
  5934. {GROEBNER: A Gr\"obner basis package} (chapter~\ref{GROEBNER});
  5935. \ttindex{GROEBNER}
  5936. %%
  5937. %%GROEBNER\ttindex{GROEBNER} is a package for the computation of Gr\"obner
  5938. %%Bases using the Buchberger algorithm and related methods
  5939. %%for polynomial ideals and modules. It can be used over a variety of
  5940. %%different coefficient domains, and for different variable and term
  5941. %%orderings.
  5942. %%
  5943. %%Gr\"obner Bases can be used for various purposes in commutative
  5944. %%algebra, e.g. for elimination of variables,\index{Variable elimination}
  5945. %%converting surd expressions to implicit polynomial form,
  5946. %%computation of dimensions, solution of polynomial equation systems
  5947. %%\index{Polynomial equations} etc.
  5948. %%The package is also used internally by the {\tt SOLVE}\ttindex{SOLVE}
  5949. %%operator.
  5950. %%
  5951. %%Authors: Herbert Melenk, H.M. M\"oller and Winfried Neun.
  5952. %%
  5953. \item
  5954. {IDEALS: Arithmetic for polynomial ideals} (chapter~\ref{IDEALS});
  5955. \ttindex{IDEALS}
  5956. %%
  5957. %%This package implements the basic arithmetic for polynomial ideals by
  5958. %%exploiting the Gr\"obner bases package of REDUCE. In order to save
  5959. %%computing time all intermediate Gr\"obner bases are stored internally such
  5960. %%that time consuming repetitions are inhibited.
  5961. %%
  5962. %%Author: Herbert Melenk.
  5963. %%
  5964. \item
  5965. {INEQ: Support for solving inequalities} (chapter~\ref{INEQ});\ttindex{INEQ}
  5966. %%
  5967. %%This package supports the operator {\bf ineq\_solve} that
  5968. %%tries to solves single inequalities and sets of coupled inequalities.
  5969. %%
  5970. %%Author: Herbert Melenk.
  5971. %%
  5972. \item
  5973. {INVBASE: A package for computing involutive bases}
  5974. (chapter~\ref{INVBASE});\ttindex{INVBASE}
  5975. %%
  5976. %%Involutive bases are a new tool for solving problems in connection with
  5977. %%multivariate polynomials, such as solving systems of polynomial equations
  5978. %%and analyzing polynomial ideals. An involutive basis of polynomial ideal
  5979. %%is nothing but a special form of a redundant Gr\"obner basis. The
  5980. %%construction of involutive bases reduces the problem of solving polynomial
  5981. %%systems to simple linear algebra.
  5982. %%
  5983. %%Authors: A.Yu. Zharkov and Yu.A. Blinkov.
  5984. %%
  5985. \item
  5986. {LAPLACE: Laplace and inverse Laplace transforms}
  5987. (chapter~\ref{LAPLACE});\ttindex{LAPLACE}
  5988. %%
  5989. %%This package can calculate ordinary and inverse Laplace transforms of
  5990. %%expressions. Documentation is in plain text.
  5991. %%
  5992. %%Authors: C. Kazasov, M. Spiridonova, V. Tomov.
  5993. %%
  5994. \item
  5995. {LIE: Functions for the classification of real n-dimensional Lie
  5996. algebras} (chapter~\ref{LIE});\ttindex{LIE}
  5997. %%algebras}
  5998. %%\ttindex{LIE}
  5999. %%
  6000. %%{\bf LIE} is a package of functions for the classification of real
  6001. %%n-dimensional Lie algebras. It consists of two modules: {\bf liendmc1}
  6002. %%and {\bf lie1234}. With the help of the functions in the {\bf liendmcl}
  6003. %%module, real n-dimensional Lie algebras $L$ with a derived algebra
  6004. %%$L^{(1)}$ of dimension 1 can be classified.
  6005. %%
  6006. %%Authors: Carsten and Franziska Sch\"obel.
  6007. %%
  6008. \item
  6009. {LIMITS: A package for finding limits} (chapter~\ref{LIMITS});\ttindex{LIMITS}
  6010. %%
  6011. %%LIMITS is a fast limit package for REDUCE for functions which are
  6012. %%continuous except for computable poles and singularities, based on some
  6013. %%earlier work by Ian Cohen and John P. Fitch. The Truncated Power Series
  6014. %%package is used for non-critical points, at which the value of the
  6015. %%function is the constant term in the expansion around that point.
  6016. %%L'H\^opital's rule is used in critical cases, with preprocessing of
  6017. %%$\infty - \infty$ forms and reformatting of product forms in order to
  6018. %%be able to apply l'H\^opital's rule. A limited amount of bounded arithmetic
  6019. %%is also employed where applicable.
  6020. %%
  6021. %%This package defines a {\tt LIMIT} operator, called with the syntax:
  6022. %%{\small\begin{verbatim}
  6023. %% LIMIT(EXPRN:algebraic,VAR:kernel,LIMPOINT:algebraic):
  6024. %% algebraic.
  6025. %%\end{verbatim}}
  6026. %%For example:
  6027. %%{\small\begin{verbatim}
  6028. %% limit(x*sin(1/x),x,infinity) -> 1
  6029. %% limit(sin x/x^2,x,0) -> INFINITY
  6030. %%\end{verbatim}}
  6031. %%Direction-dependent limit operators {\tt LIMIT!+} and {\tt LIMIT!-} are
  6032. %%also defined.
  6033. %%
  6034. %%This package loads automatically.
  6035. %%
  6036. %%Author: Stanley L. Kameny.
  6037. %%
  6038. \item
  6039. {LINALG: Linear algebra package} (chapter~\ref{LINALG});\ttindex{LINALG}
  6040. %%
  6041. %%This package provides a selection of functions that are useful
  6042. %%in the world of linear algebra.
  6043. %%
  6044. %%Author: Matt Rebbeck.
  6045. %%
  6046. \item
  6047. {MODSR: Modular solve and roots} (chapter~\ref{MODSR});\ttindex{MODSR}
  6048. %%
  6049. %%This package supports solve (M\_SOLVE) and roots (M\_ROOTS) operators for
  6050. %%modular polynomials and modular polynomial systems. The moduli need not
  6051. %%be primes. M\_SOLVE requires a modulus to be set. M\_ROOTS takes the
  6052. %%modulus as a second argument. For example:
  6053. %%
  6054. %%{\small\begin{verbatim}
  6055. %%on modular; setmod 8;
  6056. %%m_solve(2x=4); -> {{X=2},{X=6}}
  6057. %%m_solve({x^2-y^3=3});
  6058. %% -> {{X=0,Y=5}, {X=2,Y=1}, {X=4,Y=5}, {X=6,Y=1}}
  6059. %%m_solve({x=2,x^2-y^3=3}); -> {{X=2,Y=1}}
  6060. %%off modular;
  6061. %%m_roots(x^2-1,8); -> {1,3,5,7}
  6062. %%m_roots(x^3-x,7); -> {0,1,6}
  6063. %%\end{verbatim}}
  6064. %%
  6065. %%There is no further documentation for this package.
  6066. %%
  6067. %%Author: Herbert Melenk.
  6068. %%
  6069. \item
  6070. {NCPOLY: Non--commutative polynomial ideals}
  6071. (chapter~\ref{NCPOLY});\ttindex{NCPOLY}
  6072. %%\ttindex{NCPOLY}
  6073. %%
  6074. %%This package allows the user to set up automatically a consistent
  6075. %%environment for computing in an algebra where the non--commutativity is
  6076. %%defined by Lie-bracket commutators. The package uses the {REDUCE} {\bf
  6077. %%noncom} mechanism for elementary polynomial arithmetic; the commutator
  6078. %%rules are automatically computed from the Lie brackets.
  6079. %%
  6080. %%Authors: Herbert Melenk and Joachim Apel.
  6081. %%
  6082. \item
  6083. {NORMFORM: Computation of matrix normal forms}
  6084. (chapter~\ref{NORMFORM});\ttindex{NORMFORM}
  6085. %%
  6086. %%This package contains routines for computing the following
  6087. %%normal forms of matrices:
  6088. %%\begin{itemize}
  6089. %%\item smithex\_int
  6090. %%\item smithex
  6091. %%\item frobenius
  6092. %%\item ratjordan
  6093. %%\item jordansymbolic
  6094. %%\item jordan.
  6095. %%\end{itemize}
  6096. %%
  6097. %%Author: Matt Rebbeck.
  6098. %%
  6099. \item
  6100. {NUMERIC: Solving numerical problems} (chapter~\ref{NUMERIC});\ttindex{NUMERIC}
  6101. %%\ttindex{NUM\_SOLVE}\index{Newton's method}\ttindex{NUM\_ODESOLVE}
  6102. %%\ttindex{BOUNDS}\index{Chebyshev fit}
  6103. %%\ttindex{NUM\_MIN}\index{Minimum}\ttindex{NUM\_INT}\index{Quadrature}
  6104. %%This package implements basic algorithms of numerical analysis.
  6105. %%These include:
  6106. %%\begin{itemize}
  6107. %%\item solution of algebraic equations by Newton's method
  6108. %%{\small\begin{verbatim}
  6109. %% num_solve({sin x=cos y, x + y = 1},{x=1,y=2})
  6110. %%\end{verbatim}}
  6111. %%\item solution of ordinary differential equations
  6112. %%{\small\begin{verbatim}
  6113. %% num_odesolve(df(y,x)=y,y=1,x=(0 .. 1), iterations=5)
  6114. %%\end{verbatim}}
  6115. %%\item bounds of a function over an interval
  6116. %%{\small\begin{verbatim}
  6117. %% bounds(sin x+x,x=(1 .. 2));
  6118. %%\end{verbatim}}
  6119. %%\item minimizing a function (Fletcher Reeves steepest descent)
  6120. %%{\small\begin{verbatim}
  6121. %% num_min(sin(x)+x/5, x);
  6122. %%\end{verbatim}}
  6123. %%\item Chebyshev curve fitting
  6124. %%{\small\begin{verbatim}
  6125. %% chebyshev_fit(sin x/x,x=(1 .. 3),5);
  6126. %%\end{verbatim}}
  6127. %%\item numerical quadrature
  6128. %%{\small\begin{verbatim}
  6129. %% num_int(sin x,x=(0 .. pi));
  6130. %%\end{verbatim}}
  6131. %%\end{itemize}
  6132. %%
  6133. %%Author: Herbert Melenk.
  6134. %%
  6135. \item
  6136. {ODESOLVE: Ordinary differential equations solver}
  6137. (chapter~\ref{ODESOLVE});\ttindex{ODESOLVE}
  6138. %%
  6139. %%The ODESOLVE package is a solver for ordinary differential equations. At
  6140. %%the present time it has very limited capabilities. It can handle only a
  6141. %%single scalar equation presented as an algebraic expression or equation,
  6142. %%and it can solve only first-order equations of simple types, linear
  6143. %%equations with constant coefficients and Euler equations. These solvable
  6144. %%types are exactly those for which Lie symmetry techniques give no useful
  6145. %%information. For example, the evaluation of
  6146. %%{\small\begin{verbatim}
  6147. %% depend(y,x);
  6148. %% odesolve(df(y,x)=x**2+e**x,y,x);
  6149. %%\end{verbatim}}
  6150. %%yields the result
  6151. %%{\small\begin{verbatim}
  6152. %% X 3
  6153. %% 3*E + 3*ARBCONST(1) + X
  6154. %% {Y=---------------------------}
  6155. %% 3
  6156. %%\end{verbatim}}
  6157. %%
  6158. %%Main Author: Malcolm A.H. MacCallum.
  6159. %%
  6160. %%Other contributors: Francis Wright, Alan Barnes.
  6161. %%
  6162. \item
  6163. {ORTHOVEC: Manipulation of scalars and vectors}
  6164. (chapter~\ref{ORTHOVEC});\ttindex{ORTHOVEC}
  6165. %%
  6166. %%ORTHOVEC is a collection of REDUCE procedures and operations which
  6167. %%provide a simple-to-use environment for the manipulation of scalars and
  6168. %%vectors. Operations include addition, subtraction, dot and cross
  6169. %%products, division, modulus, div, grad, curl, laplacian, differentiation,
  6170. %%integration, and Taylor expansion.
  6171. %%
  6172. %%Author: James W. Eastwood.
  6173. %%
  6174. \item
  6175. {PHYSOP: Operator calculus in quantum theory}
  6176. (chapter~\ref{PHYSOP});\ttindex{PHYSOP}
  6177. %%
  6178. %%This package has been designed to meet the requirements of theoretical
  6179. %%physicists looking for a computer algebra tool to perform complicated
  6180. %%calculations in quantum theory with expressions containing operators.
  6181. %%These operations consist mainly of the calculation of commutators between
  6182. %%operator expressions and in the evaluations of operator matrix elements in
  6183. %%some abstract space.
  6184. %%
  6185. %%Author: Mathias Warns.
  6186. %%
  6187. \item
  6188. {PM: A REDUCE pattern matcher} (chapter~\ref{PM});\ttindex{PM}
  6189. %%
  6190. %%PM is a general pattern matcher similar in style to those found in systems
  6191. %%such as SMP and Mathematica, and is based on the pattern matcher described
  6192. %%in Kevin McIsaac, ``Pattern Matching Algebraic Identities'', SIGSAM Bulletin,
  6193. %%19 (1985), 4-13.
  6194. %%
  6195. %%Documentation for this package is in plain text.
  6196. %%
  6197. %%Author: Kevin McIsaac.
  6198. %%
  6199. \item
  6200. {RANDPOLY: A random polynomial generator} (chapter~\ref{RANDPOLY});
  6201. \ttindex{RANDPOLY}
  6202. %%
  6203. %%This package is based on a port of the Maple random polynomial
  6204. %%generator together with some support facilities for the generation
  6205. %%of random numbers and anonymous procedures.
  6206. %%
  6207. %%Author: Francis J. Wright.
  6208. %%
  6209. \item
  6210. {REACTEQN: Support for chemical reaction equation systems}
  6211. (chapter~\ref{REACTEQN});\ttindex{REACTEQN}
  6212. %%
  6213. %%This package allows a user to transform chemical reaction systems into
  6214. %%ordinary differential equation systems (ODE) corresponding to the laws of
  6215. %%pure mass action.
  6216. %%
  6217. %%Documentation for this package is in plain text.
  6218. %%
  6219. %%Author: Herbert Melenk.
  6220. %%
  6221. \item
  6222. {RESET: Code to reset REDUCE to its initial state}
  6223. (chapter~\ref{RESET});\ttindex{RESET}
  6224. %%
  6225. %%This package defines a command command RESETREDUCE that works through the
  6226. %%history of previous commands, and clears any values which have been
  6227. %%assigned, plus any rules, arrays and the like. It also sets the various
  6228. %%switches to their initial values. It is not complete, but does work for
  6229. %%most things that cause a gradual loss of space. It would be relatively
  6230. %%easy to make it interactive, so allowing for selective resetting.
  6231. %%
  6232. %%There is no further documentation on this package.
  6233. %%
  6234. %%Author: John Fitch.
  6235. %%
  6236. \item
  6237. {RESIDUE: A residue package} (chapter~\ref{RESIDUE});\ttindex{RESIDUE}
  6238. %%
  6239. %%This package supports the calculation of residues of arbitrary
  6240. %%expressions.
  6241. %%
  6242. %%Author: Wolfram Koepf.
  6243. %%
  6244. \item
  6245. {RLFI: REDUCE LaTeX formula interface} (chapter~\ref{RLFI});\ttindex{RLFI}
  6246. %%
  6247. %%This package adds \LaTeX syntax to REDUCE. Text generated by REDUCE in
  6248. %%this mode can be directly used in \LaTeX source documents. Various
  6249. %%mathematical constructions are supported by the interface including
  6250. %%subscripts, superscripts, font changing, Greek letters, divide-bars,
  6251. %%integral and sum signs, derivatives, and so on.
  6252. %%
  6253. %%Author: Richard Liska.
  6254. %%
  6255. \item
  6256. {RSOLVE: Rational/integer polynomial solvers} (chapter~\ref{RSOLVE});\ttindex{RSOLVE}
  6257. %%
  6258. %%This package provides operators that compute the exact rational zeros
  6259. %%of a single univariate polynomial using fast modular methods. The
  6260. %%algorithm used is that described by R. Loos (1983): Computing rational
  6261. %%zeros of integral polynomials by $p$-adic expansion, {\it SIAM J.
  6262. %%Computing}, {\bf 12}, 286--293.
  6263. %%
  6264. %%Author: Francis J. Wright.
  6265. %%
  6266. \item
  6267. {ROOTS: A REDUCE root finding package} (chapter~\ref{ROOTS});\ttindex{ROOTS}
  6268. %%
  6269. %%This root finding package can be used to find some or all of the roots of a
  6270. %%univariate polynomial with real or complex coefficients, to the accuracy
  6271. %%specified by the user.
  6272. %%
  6273. %%It is designed so that it can be used as an independent package, or it may
  6274. %%be called from {\tt SOLVE} if {\tt ROUNDED} is on. For example,
  6275. %%the evaluation of
  6276. %%{\small\begin{verbatim}
  6277. %% on rounded,complex;
  6278. %% solve(x**3+x+5,x);
  6279. %%\end{verbatim}}
  6280. %%yields the result
  6281. %%{\small\begin{verbatim}
  6282. %% {X= - 1.51598,X=0.75799 + 1.65035*I,X=0.75799 - 1.65035*I}
  6283. %%\end{verbatim}}
  6284. %%
  6285. %%This package loads automatically.
  6286. %%
  6287. %%Author: Stanley L. Kameny.
  6288. %%
  6289. \item
  6290. {SCOPE: REDUCE source code optimization package}
  6291. (chapter~\ref{SCOPE});\ttindex{SCOPE}
  6292. %%
  6293. %%SCOPE is a package for the production of an optimized form of a set of
  6294. %%expressions. It applies an heuristic search for common (sub)expressions
  6295. %%to almost any set of proper REDUCE assignment statements. The
  6296. %%output is obtained as a sequence of assignment statements. GENTRAN is
  6297. %%used to facilitate expression output.
  6298. %%
  6299. %%Author: J.A. van Hulzen.
  6300. %%
  6301. \item
  6302. {SETS: A basic set theory package} (chapter~\ref{SETS});\ttindex{SETS}
  6303. %%
  6304. %%The SETS package provides algebraic-mode support for set operations on
  6305. %%lists regarded as sets (or representing explicit sets) and on implicit
  6306. %%sets represented by identifiers.
  6307. %%
  6308. %%Author: Francis J. Wright.
  6309. %%
  6310. \item
  6311. {SPDE: A package for finding symmetry groups of {PDE}'s}
  6312. (chapter~\ref{SPDE});\ttindex{SPDE}
  6313. %%
  6314. %%The package SPDE provides a set of functions which may be used to
  6315. %%determine the symmetry group of Lie- or point-symmetries of a given system
  6316. %%of partial differential equations. In many cases the determining system is
  6317. %%solved completely automatically. In other cases the user has to provide
  6318. %%additional input information for the solution algorithm to terminate.
  6319. %%
  6320. %%Author: Fritz Schwarz.
  6321. %%
  6322. \item
  6323. {SPECFN: Package for special functions} (chapter~\ref{SPECFN});
  6324. \ttindex{SPECFN}
  6325. %%
  6326. %%\index{Gamma function} \ttindex{Gamma}
  6327. %%\index{Digamma function} \ttindex{Digamma}
  6328. %%\index{Polygamma functions} \ttindex{Polygamma}
  6329. %%\index{Pochhammer's symbol} \ttindex{Pochhammer}
  6330. %%\index{Euler numbers} \ttindex{Euler}
  6331. %%\index{Bernoulli numbers} \ttindex{Bernoulli}
  6332. %%\index{Zeta function (Riemann's)} \ttindex{Zeta}
  6333. %%\index{Bessel functions}\ttindex{BesselJ}\ttindex{BesselY}
  6334. %% \ttindex{BesselK}\ttindex{BesselI}
  6335. %%\index{Hankel functions}\ttindex{Hankel1}\ttindex{Hankel2}
  6336. %%\index{Kummer functions}\ttindex{KummerM}\ttindex{KummerU}
  6337. %%\index{Struve functions}\ttindex{StruveH}\ttindex{StruveL}
  6338. %%\index{Lommel functions}\ttindex{Lommel1}\ttindex{Lommel2}
  6339. %%\index{Polygamma functions}\ttindex{Polygamma}
  6340. %%\index{Beta function} \ttindex{Beta}
  6341. %%\index{Whittaker functions}\ttindex{WhittakerM}
  6342. %% \ttindex{WhittakerW}
  6343. %%\index{Dilogarithm function} \ttindex{Dilog}
  6344. %%\index{Psi function} \ttindex{Psi}
  6345. %%\index{Orthogonal polynomials}
  6346. %%\index{Hermite polynomials} \ttindex{HermiteP}
  6347. %%\index{Jacobi's polynomials} \ttindex{JacobiP}
  6348. %%\index{Legendre polynomials} \ttindex{LegendreP}
  6349. %%\index{Laguerre polynomials} \ttindex{LaguerreP}
  6350. %%\index{Chebyshev polynomials} \ttindex{ChebyshevT}\ttindex{ChebyshevU}
  6351. %%\index{Gegenbauer polynomials}\ttindex{GegenbauerP}
  6352. %%\index{Euler polynomials} \ttindex{EulerP}
  6353. %%\index{Binomial coefficients} \ttindex{Binomial}
  6354. %%\index{Stirling numbers}\ttindex{Stirling1}\ttindex{Stirling2}
  6355. %%
  6356. %%This special function package is separated into two portions to make it
  6357. %%easier to handle. The packages are called SPECFN and SPECFN2. The first
  6358. %%one is more general in nature, whereas the second is devoted to special
  6359. %%special functions. Documentation for the first package can be found in
  6360. %%the file specfn.tex in the ``doc'' directory, and examples in specfn.tst
  6361. %%and specfmor.tst in the examples directory.
  6362. %%
  6363. %%The package SPECFN is designed to provide algebraic and numerical
  6364. %%manipulations of several common special functions, namely:
  6365. %%
  6366. %%\begin{itemize}
  6367. %%\item Bernoulli Numbers and Euler Numbers;
  6368. %%\item Stirling Numbers;
  6369. %%\item Binomial Coefficients;
  6370. %%\item Pochhammer notation;
  6371. %%\item The Gamma function;
  6372. %%\item The Psi function and its derivatives;
  6373. %%\item The Riemann Zeta function;
  6374. %%\item The Bessel functions J and Y of the first and second kind;
  6375. %%\item The modified Bessel functions I and K;
  6376. %%\item The Hankel functions H1 and H2;
  6377. %%\item The Kummer hypergeometric functions M and U;
  6378. %%\item The Beta function, and Struve, Lommel and Whittaker functions;
  6379. %%\item The Exponential Integral, the Sine and Cosine Integrals;
  6380. %%\item The Hyperbolic Sine and Cosine Integrals;
  6381. %%\item The Fresnel Integrals and the Error function;
  6382. %%\item The Dilog function;
  6383. %%\item Hermite Polynomials;
  6384. %%\item Jacobi Polynomials;
  6385. %%\item Legendre Polynomials;
  6386. %%\item Laguerre Polynomials;
  6387. %%\item Chebyshev Polynomials;
  6388. %%\item Gegenbauer Polynomials;
  6389. %%\item Euler Polynomials;
  6390. %%\item Bernoulli Polynomials.
  6391. %%\end{itemize}
  6392. %%
  6393. %%Author: Chris Cannam, with contributions from Winfried Neun, Herbert
  6394. %%Melenk, Victor Adamchik, Francis Wright and several others.
  6395. %%
  6396. \item
  6397. {SPECFN2: Package for special special functions}
  6398. (chapter~\ref{SPECFN2});\ttindex{SPECFN2}
  6399. %%
  6400. %%\index{Generalized Hypergeometric functions}
  6401. %%\index{Meijer's G function}
  6402. %%
  6403. %%This package provides algebraic manipulations of generalized
  6404. %%hypergeometric functions and Meijer's G function. Generalized
  6405. %%hypergeometric functions are simplified towards special functions and
  6406. %%Meijer's G function is simplified towards special functions or generalized
  6407. %%hypergeometric functions.
  6408. %%
  6409. %%Author: Victor Adamchik, with major updates by Winfried Neun.
  6410. %%
  6411. \item
  6412. {SUM: A package for series summation} (chapter~\ref{SUM});\ttindex{SUM}
  6413. %%
  6414. %%This package implements the Gosper algorithm for the summation of series.
  6415. %%It defines operators {\tt SUM} and {\tt PROD}. The operator {\tt SUM}
  6416. %%returns the indefinite or definite summation of a given expression, and
  6417. %%{\tt PROD} returns the product of the given expression.
  6418. %%
  6419. %%This package loads automatically.
  6420. %%
  6421. %%Author: Fujio Kako.
  6422. %%
  6423. \item
  6424. {SYMMETRY: Operations on symmetric matrices} (chapter~\ref{SYMMETRY});
  6425. \ttindex{SYMMETRY}
  6426. %%
  6427. %%This package computes symmetry-adapted bases and block diagonal forms of
  6428. %%matrices which have the symmetry of a group. The package is the
  6429. %%implementation of the theory of linear representations for small finite
  6430. %%groups such as the dihedral groups.
  6431. %%
  6432. %%Author: Karin Gatermann.
  6433. %%
  6434. \item
  6435. {TAYLOR: Manipulation of Taylor series} (chapter~\ref{TAYLOR});\ttindex{TAYLOR}
  6436. %%
  6437. %%This package carries out the Taylor expansion of an expression in one or
  6438. %%more variables and efficient manipulation of the resulting Taylor series.
  6439. %%Capabilities include basic operations (addition, subtraction,
  6440. %%multiplication and division) and also application of certain algebraic and
  6441. %%transcendental functions.
  6442. %%
  6443. %%Author: Rainer Sch\"opf.
  6444. %%
  6445. \item
  6446. {TPS: A truncated power series package} (chapter~\ref{TPS});
  6447. \ttindex{TPS}\ttindex{PS}
  6448. %%
  6449. %%This package implements formal Laurent series expansions in one variable
  6450. %%using the domain mechanism of REDUCE. This means that power series
  6451. %%objects can be added, multiplied, differentiated etc., like other first
  6452. %%class objects in the system. A lazy evaluation scheme is used and thus
  6453. %%terms of the series are not evaluated until they are required for printing
  6454. %%or for use in calculating terms in other power series. The series are
  6455. %%extendible giving the user the impression that the full infinite series is
  6456. %%being manipulated. The errors that can sometimes occur using series that
  6457. %%are truncated at some fixed depth (for example when a term in the required
  6458. %%series depends on terms of an intermediate series beyond the truncation
  6459. %%depth) are thus avoided.
  6460. %%
  6461. %%Authors: Alan Barnes and Julian Padget.
  6462. %%
  6463. \item
  6464. {TRI: TeX REDUCE interface} (chapter~\ref{TRI});\ttindex{TRI}
  6465. %%
  6466. %%This package provides facilities written in REDUCE-Lisp for typesetting
  6467. %%REDUCE formulas using \TeX. The \TeX-REDUCE-Interface incorporates three
  6468. %%levels of \TeX output: without line breaking, with line breaking, and
  6469. %%with line breaking plus indentation.
  6470. %%
  6471. %%Author: Werner Antweiler.
  6472. %%
  6473. \item
  6474. {TRIGSIMP: Simplification and factorization of trigonometric and
  6475. hyperbolic functions} (chapter~\ref{TRIGSIMP});\ttindex{TRIGSIMP}
  6476. %%and hyperbolic functions}\ttindex{TRIGSIMP}
  6477. %%
  6478. %%TRIGSIMP is a useful tool for all kinds of trigonometric and hyperbolic
  6479. %%simplification and factorization. There are three procedures included in
  6480. %%TRIGSIMP: trigsimp, trigfactorize and triggcd. The first is for finding
  6481. %%simplifications of trigonometric or hyperbolic expressions with many
  6482. %%options, the second for factorizing them and the third for finding the
  6483. %%greatest common divisor of two trigonometric or hyperbolic polynomials.
  6484. %%
  6485. %%Author: Wolfram Koepf.
  6486. %%
  6487. \item
  6488. {XCOLOR: Calculation of the color factor in non-abelian gauge field
  6489. theories} (chapter~\ref{XCOLOR});\ttindex{XCOLOR}
  6490. %%
  6491. %%This package calculates the color factor in non-abelian gauge field
  6492. %%theories using an algorithm due to Cvitanovich.
  6493. %%
  6494. %%Documentation for this package is in plain text.
  6495. %%
  6496. %%Author: A. Kryukov.
  6497. %%
  6498. \item
  6499. {XIDEAL: Gr\"obner Bases for exterior algebra} (chapter~\ref{XIDEAL});
  6500. \ttindex{XIDEAL}
  6501. %%
  6502. %%XIDEAL constructs Gr\"obner bases for solving the left ideal membership
  6503. %%problem: Gr\"obner left ideal bases or GLIBs. For graded ideals, where each
  6504. %%form is homogeneous in degree, the distinction between left and right
  6505. %%ideals vanishes. Furthermore, if the generating forms are all homogeneous,
  6506. %%then the Gr\"obner bases for the non-graded and graded ideals are
  6507. %%identical. In this case, XIDEAL is able to save time by truncating the
  6508. %%Gr\"obner basis at some maximum degree if desired.
  6509. %%
  6510. %%Author: David Hartley.
  6511. %%
  6512. \item
  6513. {WU: Wu algorithm for polynomial systems} (chapter~\ref{WU});\ttindex{WU}
  6514. %%
  6515. %%This is a simple implementation of the Wu algorithm implemented in REDUCE
  6516. %%working directly from ``A Zero Structure Theorem for
  6517. %%Polynomial-Equations-Solving,'' Wu Wen-tsun, Institute of Systems Science,
  6518. %%Academia Sinica, Beijing.
  6519. %%
  6520. %%Author: Russell Bradford.
  6521. %%
  6522. \item
  6523. {ZEILBERG: A package for indefinite and definite summation}
  6524. (chapter~\ref{ZEILBERG});\ttindex{ZEILBERG}
  6525. %%
  6526. %%This package is a careful implementation of the Gosper and Zeilberger
  6527. %%algorithms for indefinite and definite summation of hypergeometric terms,
  6528. %%respectively. Extensions of these algorithms are also included that are
  6529. %%valid for ratios of products of powers, factorials, $\Gamma$ function
  6530. %%terms, binomial coefficients, and shifted factorials that are
  6531. %%rational-linear in their arguments.
  6532. %%
  6533. %%Authors: Gregor St\"olting and Wolfram Koepf.
  6534. %%
  6535. \item
  6536. {ZTRANS: $Z$-transform package} (chapter~\ref{ZTRANS});\ttindex{ZTRANS}
  6537. %%
  6538. %%This package is an implementation of the $Z$-transform of a sequence.
  6539. %%This is the discrete analogue of the Laplace Transform.
  6540. %%
  6541. %%Authors: Wolfram Koepf and Lisa Temme.
  6542. \end{itemize}
  6543. \chapter{Symbolic Mode}\index{Symbolic mode}
  6544. At the system level, {\REDUCE} is based on a version of the programming
  6545. language Lisp\index{Lisp} known as {\em Standard Lisp\/} which is described
  6546. in J. Marti, Hearn, A. C., Griss, M. L. and Griss, C., ``Standard LISP
  6547. Report" SIGPLAN Notices, ACM, New York, 14, No 10 (1979) 48-68. We shall
  6548. assume in this section that the reader is familiar with the material in
  6549. that paper. This also assumes implicitly that the reader has a reasonable
  6550. knowledge about Lisp in general, say at the level of the LISP 1.5
  6551. Programmer's Manual (McCarthy, J., Abrahams, P. W., Edwards, D. J., Hart,
  6552. T. P. and Levin, M. I., ``LISP 1.5 Programmer's Manual'', M.I.T. Press,
  6553. 1965) or any of the books mentioned at the end of this section. Persons
  6554. unfamiliar with this material will have some difficulty understanding this
  6555. section.
  6556. Although {\REDUCE} is designed primarily for algebraic calculations, its
  6557. source language is general enough to allow for a full range of Lisp-like
  6558. symbolic calculations. To achieve this generality, however, it is
  6559. necessary to provide the user with two modes of evaluation, namely an
  6560. algebraic mode\index{Algebraic mode} and a symbolic mode.\index{Symbolic
  6561. mode} To enter symbolic mode, the user types {\tt symbolic;}
  6562. \ttindex{SYMBOLIC} (or {\tt lisp;})\ttindex{LISP} and to return to
  6563. algebraic mode one types {\tt algebraic;}.\ttindex{ALGEBRAIC}
  6564. Evaluations proceed differently in each mode so the user is advised to
  6565. check what mode he is in if a puzzling error arises. He can find his mode
  6566. by typing\ttindex{EVAL\_MODE}
  6567. {\small\begin{verbatim}
  6568. eval_mode;
  6569. \end{verbatim}}
  6570. The current mode will then be printed as {\tt ALGEBRAIC} or {\tt SYMBOLIC}.
  6571. Expression evaluation may proceed in either mode at any level of a
  6572. calculation, provided the results are passed from mode to mode in a
  6573. compatible manner. One simply prefixes the relevant expression by the
  6574. appropriate mode. If the mode name prefixes an expression at the top
  6575. level, it will then be handled as if the global system mode had been
  6576. changed for the scope of that particular calculation.
  6577. For example, if the current mode is {\tt ALGEBRAIC}, then the commands
  6578. \extendedmanual{\newpage}
  6579. {\small\begin{verbatim}
  6580. symbolic car '(a);
  6581. x+y;
  6582. \end{verbatim}}
  6583. will cause the first expression to be evaluated and printed in symbolic
  6584. mode and the second in algebraic mode. Only the second evaluation will
  6585. thus affect the expression workspace. On the other hand, the statement
  6586. {\small\begin{verbatim}
  6587. x + symbolic car '(12);
  6588. \end{verbatim}}
  6589. will result in the algebraic value {\tt X+12}.
  6590. The use of {\tt SYMBOLIC} (and equivalently {\tt ALGEBRAIC}) in this
  6591. manner is the same as any operator. That means that parentheses could be
  6592. omitted in the above examples since the meaning is obvious. In other
  6593. cases, parentheses must be used, as in
  6594. {\small\begin{verbatim}
  6595. symbolic(x := 'a);
  6596. \end{verbatim}}
  6597. Omitting the parentheses, as in
  6598. {\small\begin{verbatim}
  6599. symbolic x := a;
  6600. \end{verbatim}}
  6601. would be wrong, since it would parse as
  6602. {\small\begin{verbatim}
  6603. symbolic(x) := a;
  6604. \end{verbatim}}
  6605. For convenience, it is assumed that any operator whose {\em first\/} argument is
  6606. quoted is being evaluated in symbolic mode, regardless of the mode in
  6607. effect at that time. Thus, the first example above could be equally well
  6608. written:
  6609. {\small\begin{verbatim}
  6610. car '(a);
  6611. \end{verbatim}}
  6612. Except where explicit limitations have been made, most {\REDUCE} algebraic
  6613. constructions carry over into symbolic mode.\index{Symbolic mode}
  6614. However, there are some differences. First, expression evaluation now
  6615. becomes Lisp evaluation. Secondly, assignment statements are handled
  6616. differently, as we shall discuss shortly. Thirdly, local variables and array
  6617. elements are initialized to {\tt NIL} rather than {\tt 0}. (In fact, any
  6618. variables not explicitly declared {\tt INTEGER} are also initialized to
  6619. {\tt NIL} in algebraic mode, but the algebraic evaluator recognizes {\tt
  6620. NIL} as {\tt 0}.) Finally, function definitions follow the conventions of
  6621. Standard Lisp.
  6622. To begin with, we mention a few extensions to our basic syntax which are
  6623. designed primarily if not exclusively for symbolic mode.
  6624. \section{Symbolic Infix Operators}
  6625. There are three binary infix operators in {\REDUCE} intended for use in
  6626. symbolic mode, namely . {\tt (CONS), EQ and MEMQ}. The precedence of
  6627. these operators was given in another section.
  6628. \section{Symbolic Expressions}
  6629. These consist of scalar variables and operators and follow the normal
  6630. rules of the Lisp meta language.
  6631. {\it Examples:}
  6632. {\small\begin{verbatim}
  6633. x
  6634. car u . reverse v
  6635. simp (u+v^2)
  6636. \end{verbatim}}
  6637. \section{Quoted Expressions}\ttindex{QUOTE}
  6638. Because symbolic evaluation requires that each variable or expression has a
  6639. value, it is necessary to add to {\REDUCE} the concept of a quoted expression
  6640. by analogy with the Lisp {\tt QUOTE} function. This is provided by the single
  6641. quote mark {\tt '}. For example,
  6642. \begin{quote}
  6643. \begin{tabbing}
  6644. {\tt '(a b c)} \= represents the Lisp S-expression \= {\tt (quote (a b
  6645. c))}\kill
  6646. {\tt 'a} \> represents the Lisp S-expression \>
  6647. {\tt (quote a)} \\
  6648. {\tt '(a b c)} \> represents the Lisp S-expression \> {\tt (quote (a b c))}
  6649. \end{tabbing}
  6650. \end{quote}
  6651. Note, however, that strings are constants and therefore evaluate to
  6652. themselves in symbolic mode. Thus, to print the string {\tt "A String"}, one
  6653. would write
  6654. {\small\begin{verbatim}
  6655. prin2 "A String";
  6656. \end{verbatim}}
  6657. Within a quoted expression, identifier syntax rules are those of {\REDUCE}.
  6658. Thus {\tt (A~!.~~B)} is the list consisting of the three elements {\tt A},
  6659. {\tt .}, and {\tt B}, whereas {\tt (A . B)} is the dotted pair of {\tt A}
  6660. and {\tt B}.
  6661. \section{Lambda Expressions}\ttindex{LAMBDA}
  6662. \label{sec-lambda}
  6663. {\tt LAMBDA} expressions provide the means for constructing Lisp {\tt LAMBDA}
  6664. expressions in symbolic mode. They may not be used in algebraic mode.
  6665. Syntax:
  6666. {\small\begin{verbatim}
  6667. <LAMBDA expression> ::=
  6668. LAMBDA <varlist><terminator><statement>
  6669. \end{verbatim}}
  6670. where
  6671. {\small\begin{verbatim}
  6672. <varlist> ::= (<variable>,...,<variable>)
  6673. \end{verbatim}}
  6674. e.g.,
  6675. {\small\begin{verbatim}
  6676. lambda (x,y); car x . cdr y;
  6677. \end{verbatim}}
  6678. is equivalent to the Lisp {\tt LAMBDA} expression
  6679. {\small\begin{verbatim}
  6680. (lambda (x y) (cons (car x) (cdr y)))
  6681. \end{verbatim}}
  6682. The parentheses may be omitted in specifying the variable list if desired.
  6683. {\tt LAMBDA} expressions may be used in symbolic mode in place of prefix
  6684. operators, or as an argument of the reserved word {\tt FUNCTION}.
  6685. In those cases where a {\tt LAMBDA} expression is used to introduce local
  6686. variables to avoid recomputation, a {\tt WHERE} statement can also be
  6687. used. For example, the expression
  6688. {\small\begin{verbatim}
  6689. (lambda (x,y); list(car x,cdr x,car y,cdr y))
  6690. (reverse u,reverse v)
  6691. \end{verbatim}}
  6692. can also be written
  6693. {\small\begin{verbatim}
  6694. {car x,cdr x,car y,cdr y} where x=reverse u,y=reverse v
  6695. \end{verbatim}}
  6696. Where possible, {\tt WHERE} syntax is preferred to {\tt LAMBDA} syntax,
  6697. since it is more natural.
  6698. \section{Symbolic Assignment Statements}\index{Assignment}
  6699. In symbolic mode, if the left side of an assignment statement is a
  6700. variable, a {\tt SETQ} of the right-hand side to that variable occurs. If
  6701. the left-hand side is an expression, it must be of the form of an array
  6702. element, otherwise an error will result. For example, {\tt x:=y}
  6703. translates into {\tt (SETQ X Y)} whereas {\tt a(3) := 3} will be valid if
  6704. {\tt A} has been previously declared a single dimensioned array of at
  6705. least four elements.
  6706. \section{FOR EACH Statement}\ttindex{FOR EACH}
  6707. The {\tt FOR EACH} form of the {\tt FOR} statement, designed for iteration
  6708. down a list, is more general in symbolic mode. Its syntax is:
  6709. {\small\begin{verbatim}
  6710. FOR EACH ID:identifier {IN|ON} LST:list
  6711. {DO|COLLECT|JOIN|PRODUCT|SUM} EXPRN:S-expr
  6712. \end{verbatim}}
  6713. As in algebraic mode, if the keyword {\tt IN} is used, iteration is on
  6714. each element of the list. With {\tt ON}, iteration is on the whole list
  6715. remaining at each point in the iteration. As a result, we have the
  6716. following equivalence between each form of {\tt FOR EACH} and the various
  6717. mapping functions in Lisp:
  6718. \begin{center}
  6719. {\tt
  6720. \begin{tabular}{|l|lr r|} \hline
  6721. & DO & COLLECT & JOIN \\ \hline
  6722. IN & MAPC & MAPCAR & MAPCAN \\
  6723. ON & MAP & MAPLIST & MAPCON \\ \hline
  6724. \end{tabular}}
  6725. \end{center}
  6726. {\it Example:} To list each element of the list {\tt (a b c)}:
  6727. {\small\begin{verbatim}
  6728. for each x in '(a b c) collect list x;
  6729. \end{verbatim}}
  6730. \section{Symbolic Procedures}\index{Symbolic procedure}
  6731. All the functions described in the Standard Lisp Report are available to
  6732. users in symbolic mode. Additional functions may also be defined as
  6733. symbolic procedures. For example, to define the Lisp function {\tt ASSOC},
  6734. the following could be used:
  6735. {\small\begin{verbatim}
  6736. symbolic procedure assoc(u,v);
  6737. if null v then nil
  6738. else if u = caar v then car v
  6739. else assoc(u, cdr v);
  6740. \end{verbatim}}
  6741. If the default mode were symbolic, then {\tt SYMBOLIC} could be omitted in
  6742. the above definition. {\tt MACRO}s\ttindex{MACRO} may be defined by
  6743. prefixing the keyword {\tt PROCEDURE} by the word {\tt MACRO}.
  6744. (In fact, ordinary functions may be defined with the keyword {\tt EXPR}
  6745. \ttindex{EXPR} prefixing {\tt PROCEDURE} as was used in the Standard Lisp
  6746. Report.) For example, we could define a {\tt MACRO CONSCONS} by
  6747. {\small\begin{verbatim}
  6748. symbolic macro procedure conscons l;
  6749. expand(cdr l,'cons);
  6750. \end{verbatim}}
  6751. Another form of macro, the {\tt SMACRO}\ttindex{SMACRO} is also available.
  6752. These are described in the Standard Lisp Report. The Report also defines
  6753. a function type {\tt FEXPR}.\ttindex{FEXPR}
  6754. However, its use is discouraged since it is hard to implement efficiently,
  6755. and most uses can be replaced by macros. At the present time, there are
  6756. no {\tt FEXPR}s in the core REDUCE system.
  6757. \section{Standard Lisp Equivalent of Reduce Input}
  6758. A user can obtain the Standard Lisp equivalent of his {\REDUCE} input by
  6759. turning on the switch {\tt DEFN}\ttindex{DEFN} (for definition). The
  6760. system then prints the Lisp translation of his input but does not evaluate
  6761. it. Normal operation is resumed when {\tt DEFN} is turned off.
  6762. \section{Communicating with Algebraic Mode}\index{Mode communication}
  6763. One of the principal motivations for a user of the algebraic facilities of
  6764. {\REDUCE} to learn about symbolic mode\index{Symbolic mode} is that it
  6765. gives one access to a wider range of techniques than is possible in
  6766. algebraic mode\index{Algebraic mode} alone. For example, if a user
  6767. wishes to use parts of the system defined in the basic system source code,
  6768. or refine their algebraic code definitions to make them more efficient,
  6769. then it is necessary to understand the source language in fairly complete
  6770. detail. Moreover, it is also necessary to know a little more about the
  6771. way {\REDUCE} operates internally. Basically, {\REDUCE} considers
  6772. expressions in two forms: prefix form, which follow the normal Lisp rules
  6773. of function composition, and so-called canonical form, which uses a
  6774. completely different syntax.
  6775. Once these details are understood, the most critical problem faced by a
  6776. user is how to make expressions and procedures communicate between symbolic
  6777. and algebraic mode. The purpose of this section is to teach a user the
  6778. basic principles for this.
  6779. If one wants to evaluate an expression in algebraic mode, and then use
  6780. that expression in symbolic mode calculations, or vice versa, the easiest
  6781. way to do this is to assign a variable to that expression whose value is
  6782. easily obtainable in both modes. To facilitate this, a declaration {\tt
  6783. SHARE}\ttindex{SHARE} is available. {\tt SHARE} takes a list of
  6784. identifiers as argument, and marks these variables as having recognizable
  6785. values in both modes. The declaration may be used in either mode.
  6786. E.g.,
  6787. {\small\begin{verbatim}
  6788. share x,y;
  6789. \end{verbatim}}
  6790. says that {\tt X} and {\tt Y} will receive values to be used in both modes.
  6791. If a {\tt SHARE} declaration is made for a variable with a previously
  6792. assigned algebraic value, that value is also made available in symbolic
  6793. mode.
  6794. \subsection{Passing Algebraic Mode Values to Symbolic Mode}
  6795. If one wishes to work with parts of an algebraic mode
  6796. \index{Algebraic mode} expression in symbolic mode,\index{Symbolic mode}
  6797. one simply makes an assignment\index{Assignment} of a shared variable to
  6798. the relevant expression in algebraic mode. For example, if one wishes to
  6799. work with {\tt (a+b)\verb|^|2}, one would say, in algebraic mode:
  6800. {\small\begin{verbatim}
  6801. x := (a+b)^2;
  6802. \end{verbatim}}
  6803. assuming that {\tt X} was declared shared as above. If we now change to
  6804. symbolic mode and say
  6805. {\small\begin{verbatim}
  6806. x;
  6807. \end{verbatim}}
  6808. its value will be printed as a prefix form with the syntax:
  6809. {\small\begin{verbatim}
  6810. (*SQ <standard quotient> T)
  6811. \end{verbatim}}
  6812. This particular format reflects the fact that the algebraic mode processor
  6813. currently likes to transfer prefix forms from command to command, but
  6814. doesn't like to reconvert standard forms\index{Standard form} (which
  6815. represent polynomials) and standard quotients back to a true Lisp prefix
  6816. form for the expression (which would result in excessive computation). So
  6817. {\tt *SQ} is used to tell the algebraic processor that it is dealing with
  6818. a prefix form which is really a standard quotient\index{Standard
  6819. quotient} and the second argument ({\tt T} or {\tt NIL}) tells it whether
  6820. it needs further processing (essentially, an {\em already simplified\/}
  6821. flag).
  6822. So to get the true standard quotient form in symbolic mode, one needs
  6823. {\tt CADR} of the variable. E.g.,
  6824. {\small\begin{verbatim}
  6825. z := cadr x;
  6826. \end{verbatim}}
  6827. would store in {\tt Z} the standard quotient form for {\tt (a+b)\verb|^|2}.
  6828. Once you have this expression, you can now manipulate it as you wish. To
  6829. facilitate this, a standard set of selectors\index{Selector} and
  6830. constructors\index{Constructor} are available for getting at parts of the
  6831. form. Those presently defined are as follows:
  6832. \extendedmanual{\newpage}
  6833. \begin{center}
  6834. \vspace{10pt}
  6835. {\large REDUCE Selectors\par}
  6836. %\end{center}
  6837. %\begin{center}
  6838. \renewcommand{\arraystretch}{1.5}
  6839. \begin{tabular}{lp{\rboxwidth}}
  6840. {\tt DENR} & denominator of standard quotient \\
  6841. %
  6842. {\tt LC} & leading coefficient of polynomial \\
  6843. %
  6844. {\tt LDEG} & leading degree of polynomial \\
  6845. %
  6846. {\tt LPOW} & leading power of polynomial \\
  6847. %
  6848. {\tt LT} & leading term of polynomial \\
  6849. %
  6850. {\tt MVAR} & main variable of polynomial \\
  6851. %
  6852. {\tt NUMR} & numerator (of standard quotient) \\
  6853. %
  6854. {\tt PDEG} & degree of a power \\
  6855. %
  6856. {\tt RED} & reductum of polynomial \\
  6857. %
  6858. {\tt TC} & coefficient of a term \\
  6859. %
  6860. {\tt TDEG} & degree of a term \\
  6861. %
  6862. {\tt TPOW} & power of a term
  6863. \end{tabular}
  6864. \end{center}
  6865. \begin{center}
  6866. \vspace{10pt}
  6867. {\large REDUCE Constructors \par}
  6868. %\end{center}
  6869. %\begin{center}
  6870. \renewcommand{\arraystretch}{1.5}
  6871. \begin{tabular}{lp{\redboxwidth}}
  6872. \verb|.+| & add a term to a polynomial \\
  6873. %
  6874. \verb|./| & divide (two polynomials to get quotient) \\
  6875. \verb|.*| & multiply power by coefficient to produce term \\
  6876. %
  6877. \verb|.^| & raise a variable to a power
  6878. \end{tabular}
  6879. \end{center}
  6880. For example, to find the numerator of the standard quotient above, one
  6881. could say:
  6882. {\small\begin{verbatim}
  6883. numr z;
  6884. \end{verbatim}}
  6885. or to find the leading term of the numerator:
  6886. {\small\begin{verbatim}
  6887. lt numr z;
  6888. \end{verbatim}}
  6889. Conversion between various data structures is facilitated by the use of a
  6890. set of functions defined for this purpose. Those currently implemented
  6891. include:
  6892. {\renewcommand{\arraystretch}{1.5}
  6893. \begin{tabular}{lp{\reduceboxwidth}}
  6894. {\tt !*A2F} & convert an algebraic expression to
  6895. a standard form. If result is rational, an error results; \\
  6896. %
  6897. {\tt !*A2K} & converts an algebraic expression to
  6898. a kernel. If this is not possible, an error results; \\
  6899. %
  6900. {\tt !*F2A} & converts a standard form to an
  6901. algebraic expression; \\
  6902. %
  6903. {\tt !*F2Q} & convert a standard form to a
  6904. standard quotient; \\
  6905. %
  6906. {\tt !*K2F} & convert a kernel to a standard form; \\
  6907. {\tt !*K2Q} & convert a kernel to a standard quotient; \\
  6908. %
  6909. {\tt !*P2F} & convert a standard power to a
  6910. standard form; \\
  6911. %
  6912. {\tt !*P2Q} & convert a standard power to a standard quotient; \\
  6913. %
  6914. {\tt !*Q2F} & convert a standard quotient to a
  6915. standard form. If the quotient denominator is not 1, an error results; \\
  6916. %
  6917. {\tt !*Q2K} & convert a standard quotient to a
  6918. kernel. If this is not possible, an error results; \\
  6919. %
  6920. {\tt !*T2F} & convert a standard term to a standard form \\
  6921. %
  6922. {\tt !*T2Q} & convert a standard term to a standard quotient.
  6923. \end{tabular}}
  6924. \subsection{Passing Symbolic Mode Values to Algebraic Mode}
  6925. In order to pass the value of a shared variable from symbolic mode to
  6926. algebraic mode, the only thing to do is make sure that the value in
  6927. symbolic mode is a prefix expression. E.g., one uses
  6928. {\tt (expt (plus a b) 2)} for {\tt (a+b)\verb|^|2}, or the format ({\tt *sq
  6929. <standard quotient> t}) as described above. However, if you have
  6930. been working with parts of a standard form they will probably not be in
  6931. this form. In that case, you can do the following:
  6932. \begin{enumerate}
  6933. \item If it is a standard quotient, call {\tt PREPSQ} on it. This takes a
  6934. standard quotient as argument, and returns a prefix expression.
  6935. Alternatively, you can call {\tt MK!*SQ} on it, which returns a prefix
  6936. form like ({\tt *SQ <standard quotient> T)} and avoids translation of
  6937. the expression into a true prefix form.
  6938. \item If it is a standard form, call {\tt PREPF} on it. This takes a
  6939. standard form as argument, and returns the equivalent prefix expression.
  6940. Alternatively, you can convert it to a standard quotient and then call
  6941. {\tt MK!*SQ}.
  6942. \item If it is a part of a standard form, you must usually first build up a
  6943. standard form out of it, and then go to step 2. The conversion functions
  6944. described earlier may be used for this purpose. For example,
  6945. \begin{enumerate}
  6946. \item If {\tt Z} is an expression which is a term, {\tt !*T2F Z} is a
  6947. standard form.
  6948. \item If {\tt Z} is a standard power, {\tt !*P2F Z} is a standard form.
  6949. \item If {\tt Z} is a variable, you can pass it direct to algebraic mode.
  6950. \end{enumerate}
  6951. \end{enumerate}
  6952. For example, to pass the leading term of {\tt (a+b)\verb|^|2} back to
  6953. algebraic mode, one could say:
  6954. {\small\begin{verbatim}
  6955. y:= mk!*sq !*t2q lt numr z;
  6956. \end{verbatim}}
  6957. where {\tt Y} has been declared shared as above. If you now go back to
  6958. algebraic mode, you can work with {\tt Y} in the usual way.
  6959. \subsection{Complete Example}
  6960. The following is the complete code for doing the above steps. The end
  6961. result will be that the square of the leading term of $(a+b)^{2}$ is
  6962. calculated.
  6963. %%\begin{tabular}{lp{\rboxwidth}}
  6964. %%{\tt share x,y;} & {\tt \% declare {\tt X} and
  6965. %%{\tt Y} as shared} \\
  6966. %%{\tt x := (a+b)\verb|^|2;} & {\tt \% store (a+b)\verb|^|2 in X} \\
  6967. %%{\tt symbolic;} & {\tt \% transfer to symbolic mode} \\
  6968. %%{\tt z := cadr x;} & {\tt \% store a true standard quotient \newline
  6969. %% \% in Z} \\[1.7pt]
  6970. %%{\tt lt numr z;} & {\tt \% print the leading term of the \newline
  6971. %% \% numerator of Z} \\
  6972. %%{\tt y := mk!*sq !*t2q lt numr z;} & {\tt \% store the
  6973. %% prefix form of this \newline
  6974. %% \% leading term in Y} \\
  6975. %%{\tt algebraic;} & {\tt \% return to algebraic mode} \\
  6976. %%{\tt y\verb|^|2;} & {\tt \% evaluate square of the leading \newline
  6977. %%\% term of (a+b)\verb|^|2}
  6978. %%\end{tabular}
  6979. {\small\begin{verbatim}
  6980. share x,y; % declare X and Y as shared
  6981. x := (a+b)^2; % store (a+b)^2 in X
  6982. symbolic; % transfer to symbolic mode
  6983. z := cadr x; % store a true standard quotient in Z
  6984. lt numr z; % print the leading term of the
  6985. % numerator of Z
  6986. y := mk!*sq !*t2q lt numr z; % store the prefix form of this
  6987. % leading term in Y
  6988. algebraic; % return to algebraic mode
  6989. y^2; % evaluate square of the leading term
  6990. % of (a+b)^2
  6991. \end{verbatim}}
  6992. \subsection{Defining Procedures for Intermode Communication}
  6993. If one wishes to define a procedure in symbolic mode for use as an
  6994. operator in algebraic mode, it is necessary to declare this fact to the
  6995. system by using the declaration {\tt OPERATOR}\ttindex{OPERATOR} in
  6996. symbolic mode. Thus
  6997. {\small\begin{verbatim}
  6998. symbolic operator leadterm;
  6999. \end{verbatim}}
  7000. would declare the procedure {\tt LEADTERM} as an algebraic operator. This
  7001. declaration {\em must\/} be made in symbolic mode as the effect in algebraic
  7002. mode is different. The value of such a procedure must be a prefix form.
  7003. The algebraic processor will pass arguments to such procedures in prefix
  7004. form. Therefore if you want to work with the arguments as standard
  7005. quotients you must first convert them to that form by using the function
  7006. {\tt SIMP!*}. This function takes a prefix form as argument and returns the
  7007. evaluated standard quotient.
  7008. For example, if you want to define a procedure {\tt LEADTERM} which gives the
  7009. leading term of an algebraic expression, one could do this as follows:
  7010. \begin{samepage}
  7011. {\small\begin{verbatim}
  7012. symbolic operator leadterm; % Declare LEADTERM as a symbolic
  7013. % mode procedure to be used in
  7014. % algebraic mode.
  7015. symbolic procedure leadterm u; % Define LEADTERM.
  7016. mk!*sq !*t2q lt numr simp!* u;
  7017. \end{verbatim}}
  7018. \end{samepage}
  7019. Note that this operator has a different effect than the operator {\tt LTERM}
  7020. \ttindex{LTERM}. In the latter case, the calculation is done
  7021. with respect to the second argument of the operator. In the example here,
  7022. we simply extract the leading term with respect to the system's choice of
  7023. main variable.
  7024. Finally, if you wish to use the algebraic evaluator on an argument in a
  7025. symbolic mode definition, the function {\tt REVAL} can be used. The one
  7026. argument of {\tt REVAL} must be the prefix form of an expression. {\tt
  7027. REVAL} returns the evaluated expression as a true Lisp prefix form.
  7028. \section{Rlisp '88}
  7029. Rlisp '88 is a superset of the Rlisp that has been traditionally used for
  7030. the support of REDUCE. It is fully documented in the book
  7031. Marti, J.B., ``{RLISP} '88: An Evolutionary Approach to Program Design
  7032. and Reuse'', World Scientific, Singapore (1993).
  7033. Rlisp '88 adds to the traditional Rlisp the following facilities:
  7034. \begin{enumerate}
  7035. \item more general versions of the looping constructs {\tt for},
  7036. {\tt repeat} and {\tt while};
  7037. \item support for a backquote construct;
  7038. \item support for active comments;
  7039. \item support for vectors of the form name[index];
  7040. \item support for simple structures;
  7041. \item support for records.
  7042. \end{enumerate}
  7043. In addition, ``--'' is a letter in Rlisp '88. In other words, {\tt A-B} is an
  7044. identifier, not the difference of the identifiers {\tt A} and {\tt B}. If
  7045. the latter construct is required, it is necessary to put spaces around the
  7046. - character. For compatibility between the two versions of Rlisp, we
  7047. recommend this convention be used in all symbolic mode programs.
  7048. To use Rlisp '88, type {\tt on rlisp88;}\ttindex{RLISP88}. This switches to
  7049. symbolic mode with the Rlisp '88 syntax and extensions. While in this
  7050. environment, it is impossible to switch to algebraic mode, or prefix
  7051. expressions by ``algebraic''. However, symbolic mode programs written in
  7052. Rlisp '88 may be run in algebraic mode provided the rlisp88 package has been
  7053. loaded. We also expect that many of the extensions defined in Rlisp '88
  7054. will migrate to the basic Rlisp over time. To return to traditional Rlisp
  7055. or to switch to algebraic mode, say ``off rlisp88''.
  7056. \section{References}
  7057. There are a number of useful books which can give you further information
  7058. about LISP. Here is a selection:
  7059. Allen, J.R., ``The Anatomy of LISP'', McGraw Hill, New York, 1978.
  7060. McCarthy J., P.W. Abrahams, J. Edwards, T.P. Hart and
  7061. M.I. Levin, ``LISP 1.5 Programmer's Manual'', M.I.T. Press, 1965.
  7062. Touretzky, D.S, ``{LISP}: A Gentle Introduction to Symbolic Computation'',
  7063. Harper \& Row, New York, 1984.
  7064. Winston, P.H. and Horn, B.K.P., ``LISP'', Addison-Wesley, 1981.
  7065. \chapter{Calculations in High Energy Physics}
  7066. A set of {\REDUCE} commands is provided for users interested in symbolic
  7067. calculations in high energy physics. Several extensions to our basic
  7068. syntax are necessary, however, to allow for the different data structures
  7069. encountered.
  7070. \section{High Energy Physics Operators}
  7071. \label{HEPHYS}
  7072. We begin by introducing three new operators required in these calculations.
  7073. \subsection{. (Cons) Operator}\index{Dot product}
  7074. Syntax:
  7075. {\small\begin{verbatim}
  7076. (EXPRN1:vector_expression)
  7077. . (EXPRN2:vector_expression):algebraic.
  7078. \end{verbatim}}
  7079. The binary {\tt .} operator, which is normally used to denote the addition
  7080. of an element to the front of a list, can also be used in algebraic mode
  7081. to denote the scalar product of two Lorentz four-vectors. For this to
  7082. happen, the second argument must be recognizable as a vector expression
  7083. \index{High energy vector expression} at the time of
  7084. evaluation. With this meaning, this operator is often referred to as the
  7085. {\em dot\/} operator. In the present system, the index handling routines all
  7086. assume that Lorentz four-vectors are used, but these routines could be
  7087. rewritten to handle other cases.
  7088. Components of vectors can be represented by including representations of
  7089. unit vectors in the system. Thus if {\tt EO} represents the unit vector
  7090. {\tt (1,0,0,0)}, {\tt (p.eo)} represents the zeroth component of the
  7091. four-vector P. Our metric and notation follows Bjorken and Drell
  7092. ``Relativistic Quantum Mechanics'' (McGraw-Hill, New York, 1965).
  7093. Similarly, an arbitrary component {\tt P} may be represented by
  7094. {\tt (p.u)}. If contraction over components of vectors is required, then
  7095. the declaration {\tt INDEX}\ttindex{INDEX} must be used. Thus
  7096. {\small\begin{verbatim}
  7097. index u;
  7098. \end{verbatim}}
  7099. declares {\tt U} as an index, and the simplification of
  7100. {\small\begin{verbatim}
  7101. p.u * q.u
  7102. \end{verbatim}}
  7103. would result in
  7104. {\small\begin{verbatim}
  7105. P.Q
  7106. \end{verbatim}}
  7107. The metric tensor $g^{\mu \nu}$ may be represented by {\tt (u.v)}. If
  7108. contraction over {\tt U} and {\tt V} is required, then they should be
  7109. declared as indices.
  7110. Errors occur if indices are not properly matched in expressions.
  7111. If a user later wishes to remove the index property from specific vectors,
  7112. he can do it with the declaration {\tt REMIND}.\ttindex{REMIND} Thus
  7113. {\tt remind v1...vn;} removes the index flags from the variables {\tt V1}
  7114. through {\tt Vn}. However, these variables remain vectors in the system.
  7115. \subsection{G Operator for Gamma Matrices}\index{Dirac $\gamma$ matrix}
  7116. \ttindex{G}
  7117. Syntax:
  7118. {\small\begin{verbatim}
  7119. G(ID:identifier[,EXPRN:vector_expression])
  7120. :gamma_matrix_expression.
  7121. \end{verbatim}}
  7122. {\tt G} is an n-ary operator used to denote a product of $\gamma$ matrices
  7123. contracted with Lorentz four-vectors. Gamma matrices are associated with
  7124. fermion lines in a Feynman diagram. If more than one such line occurs,
  7125. then a different set of $\gamma$ matrices (operating in independent spin
  7126. spaces) is required to represent each line. To facilitate this, the first
  7127. argument of {\tt G} is a line identification identifier (not a number)
  7128. used to distinguish different lines.
  7129. Thus
  7130. {\small\begin{verbatim}
  7131. g(l1,p) * g(l2,q)
  7132. \end{verbatim}}
  7133. denotes the product of {\tt $\gamma$.p} associated with a fermion line
  7134. identified as {\tt L1}, and {\tt $\gamma$.q} associated with another line
  7135. identified as {\tt L2} and where {\tt p} and {\tt q} are Lorentz
  7136. four-vectors. A product of $\gamma$ matrices associated with the same
  7137. line may be written in a contracted form.
  7138. Thus
  7139. {\small\begin{verbatim}
  7140. g(l1,p1,p2,...,p3) = g(l1,p1)*g(l1,p2)*...*g(l1,p3) .
  7141. \end{verbatim}}
  7142. The vector {\tt A} is reserved in arguments of G to denote the special
  7143. $\gamma$ matrix $\gamma^{5}$. Thus
  7144. \begin{quote}
  7145. \begin{tabbing}
  7146. \ \ \ \ \ {\tt g(l,a)}\hspace{0.2in} \= =\ \ \ $\gamma^{5}$ \hspace{0.5in}
  7147. \= associated with the line {\tt L} \\[0.1in]
  7148. \ \ \ \ \ {\tt g(l,p,a)} \> =\ \ \ $\gamma$.p $\times \gamma^{5}$ \>
  7149. associated with the line {\tt L}.
  7150. \end{tabbing}
  7151. \end{quote}
  7152. $\gamma^{\mu}$ (associated with the line {\tt L}) may be written as
  7153. {\tt g(l,u)}, with {\tt U} flagged as an index if contraction over {\tt U}
  7154. is required.
  7155. The notation of Bjorken and Drell is assumed in all operations involving
  7156. $\gamma$ matrices.
  7157. \subsection{EPS Operator}\ttindex{EPS}
  7158. Syntax:
  7159. {\small\begin{verbatim}
  7160. EPS(EXPRN1:vector_expression,...,EXPRN4:vector_exp)
  7161. :vector_exp.
  7162. \end{verbatim}}
  7163. The operator {\tt EPS} has four arguments, and is used only to denote the
  7164. completely antisymmetric tensor of order 4 and its contraction with Lorentz
  7165. four-vectors. Thus
  7166. \[ \epsilon_{i j k l} = \left\{ \begin{array}{cl}
  7167. +1 & \mbox{if $i,j,k,l$ is an even permutation
  7168. of 0,1,2,3} \\
  7169. -1 & \mbox{if an odd permutation} \\
  7170. 0 & \mbox{otherwise}
  7171. \end{array}
  7172. \right. \]
  7173. A contraction of the form $\epsilon_{i j \mu \nu}p_{\mu}q_{\nu}$ may be
  7174. written as {\tt eps(i,j,p,q)}, with {\tt I} and {\tt J} flagged as indices,
  7175. and so on.
  7176. \section{Vector Variables}
  7177. Apart from the line identification identifier in the {\tt G} operator, all
  7178. other arguments of the operators in this section are vectors. Variables
  7179. used as such must be declared so by the type declaration {\tt VECTOR},
  7180. \ttindex{VECTOR} for example:
  7181. {\small\begin{verbatim}
  7182. vector p1,p2;
  7183. \end{verbatim}}
  7184. declares {\tt P1} and {\tt P2} to be vectors. Variables declared as
  7185. indices or given a mass\ttindex{MASS} are automatically declared
  7186. vector by these declarations.
  7187. \section{Additional Expression Types}
  7188. Two additional expression types are necessary for high energy
  7189. calculations, namely
  7190. \subsection{Vector Expressions}\index{High energy vector expression}
  7191. These follow the normal rules of vector combination. Thus the product of a
  7192. scalar or numerical expression and a vector expression is a vector, as are
  7193. the sum and difference of vector expressions. If these rules are not
  7194. followed, error messages are printed. Furthermore, if the system finds an
  7195. undeclared variable where it expects a vector variable, it will ask the
  7196. user in interactive mode whether to make that variable a vector or not. In
  7197. batch mode, the declaration will be made automatically and the user
  7198. informed of this by a message.
  7199. {\tt Examples:}
  7200. Assuming {\tt P} and {\tt Q} have been declared vectors, the following are
  7201. vector expressions
  7202. {\small\begin{verbatim}
  7203. p
  7204. 2*q/3
  7205. 2*x*y*p - p.q*q/(3*q.q)
  7206. \end{verbatim}}
  7207. whereas {\tt p*q} and {\tt p/q} are not.
  7208. \subsection{Dirac Expressions}
  7209. These denote those expressions which involve $\gamma$ matrices. A $\gamma$
  7210. matrix is implicitly a 4 $\times$ 4 matrix, and so the product, sum and
  7211. difference of such expressions, or the product of a scalar and Dirac
  7212. expression is again a Dirac expression. There are no Dirac variables in
  7213. the system, so whenever a scalar variable appears in a Dirac expression
  7214. without an associated $\gamma$ matrix expression, an implicit unit 4
  7215. by 4 matrix is assumed. For example, {\tt g(l,p) + m} denotes {\tt
  7216. g(l,p) + m*<unit 4 by 4 matrix>}. Multiplication of Dirac
  7217. expressions, as for matrix expressions, is of course non-commutative.
  7218. \section{Trace Calculations}\index{High energy trace}
  7219. When a Dirac expression is evaluated, the system computes one quarter of
  7220. the trace of each $\gamma$ matrix product in the expansion of the expression.
  7221. One quarter of each trace is taken in order to avoid confusion between the
  7222. trace of the scalar {\tt M}, say, and {\tt M} representing {\tt M * <unit
  7223. 4 by 4 matrix>}. Contraction over indices occurring in such expressions is
  7224. also performed. If an unmatched index is found in such an expression, an
  7225. error occurs.
  7226. The algorithms used for trace calculations are the best available at the
  7227. time this system was produced. For example, in addition to the algorithm
  7228. developed by Chisholm for contracting indices in products of traces,
  7229. {\REDUCE} uses the elegant algorithm of Kahane for contracting indices in
  7230. $\gamma$ matrix products. These algorithms are described in Chisholm, J. S.
  7231. R., Il Nuovo Cimento X, 30, 426 (1963) and Kahane, J., Journal Math.
  7232. Phys. 9, 1732 (1968).
  7233. It is possible to prevent the trace calculation over any line identifier
  7234. by the declaration {\tt NOSPUR}.\ttindex{NOSPUR} For example,
  7235. {\small\begin{verbatim}
  7236. nospur l1,l2;
  7237. \end{verbatim}}
  7238. will mean that no traces are taken of $\gamma$ matrix terms involving the line
  7239. numbers {\tt L1} and {\tt L2}. However, in some calculations involving
  7240. more than one line, a catastrophic error
  7241. {\small\begin{verbatim}
  7242. This NOSPUR option not implemented
  7243. \end{verbatim}}
  7244. can occur (for the reason stated!) If you encounter this error, please let
  7245. us know!
  7246. A trace of a $\gamma$ matrix expression involving a line identifier which has
  7247. been declared {\tt NOSPUR} may be later taken by making the declaration
  7248. {\tt SPUR}.\ttindex{SPUR}
  7249. See also the CVIT package for an alternative
  7250. mechanism\extendedmanual{ (chapter~\ref{CVIT})}.
  7251. \section{Mass Declarations}\ttindex{MASS}
  7252. It is often necessary to put a particle ``on the mass shell'' in a
  7253. calculation. This can, of course, be accomplished with a {\tt LET}
  7254. command such as
  7255. {\small\begin{verbatim}
  7256. let p.p= m^2;
  7257. \end{verbatim}}
  7258. but an alternative method is provided by two commands {\tt MASS} and
  7259. {\tt MSHELL}.\ttindex{MSHELL}
  7260. {\tt MASS} takes a list of equations of the form:
  7261. {\small\begin{verbatim}
  7262. <vector variable> = <scalar variable>
  7263. \end{verbatim}}
  7264. for example,
  7265. {\small\begin{verbatim}
  7266. mass p1=m, q1=mu;
  7267. \end{verbatim}}
  7268. The only effect of this command is to associate the relevant scalar
  7269. variable as a mass with the corresponding vector. If we now say
  7270. {\small\begin{verbatim}
  7271. mshell <vector variable>,...,<vector variable>;
  7272. \end{verbatim}}
  7273. and a mass has been associated with these arguments, a substitution of the
  7274. form
  7275. {\small\begin{verbatim}
  7276. <vector variable>.<vector variable> = <mass>^2
  7277. \end{verbatim}}
  7278. is set up. An error results if the variable has no preassigned mass.
  7279. \section{Example}
  7280. We give here as an example of a simple calculation in high energy physics
  7281. the computation of the Compton scattering cross-section as given in
  7282. Bjorken and Drell Eqs. (7.72) through (7.74). We wish to compute the trace of
  7283. $$\left. \alpha^2\over2 \right. \left({k^\prime\over k}\right)^2
  7284. \left({\gamma.p_f+m\over2m}\right)\left({\gamma.e^\prime \gamma.e
  7285. \gamma.k_i\over2k.p_i} + {\gamma.e\gamma.e^\prime
  7286. \gamma.k_f\over2k^\prime.p_i}\right)
  7287. \left({\gamma.p_i+m\over2m}\right)$$
  7288. $$
  7289. \left({\gamma.k_i\gamma.e\gamma.e^\prime\over2k.p_i} +
  7290. {\gamma.k_f\gamma.e^\prime\gamma.e\over2k^\prime.p_i}
  7291. \right)
  7292. $$
  7293. where $k_i$ and $k_f$ are the four-momenta of incoming and outgoing photons
  7294. (with polarization vectors $e$ and $e^\prime$ and laboratory energies
  7295. $k$ and $k^\prime$
  7296. respectively) and $p_i$, $p_f$ are incident and final electron four-momenta.
  7297. Omitting therefore an overall factor
  7298. ${\alpha^2\over2m^2}\left({k^\prime\over k}\right)^2$ we need to find
  7299. one quarter of the trace of
  7300. $${
  7301. \left( \gamma.p_f + m\right)
  7302. \left({\gamma.e^\prime \gamma.e\gamma.k_i\over2k.p_i} +
  7303. {\gamma.e\gamma.e^\prime \gamma.k_f\over 2k^\prime.p_i}\right) \left(
  7304. \gamma.p_i + m\right)}$$
  7305. $${
  7306. \left({\gamma.k_i\gamma.e\gamma.e^\prime\over 2k.p_i} +
  7307. {\gamma.k_f\gamma.e^\prime \gamma.e\over2k^\prime.p_i}\right) }$$
  7308. A straightforward REDUCE program for this, with appropriate substitutions
  7309. (using {\tt P1} for $p_i$, {\tt PF} for $p_f$, {\tt KI}
  7310. for $k_i$ and {\tt KF} for $k_f$) is
  7311. {\small\begin{verbatim}
  7312. on div; % this gives output in same form as Bjorken and Drell.
  7313. mass ki= 0, kf= 0, p1= m, pf= m; vector e,ep;
  7314. % if e is used as a vector, it loses its scalar identity as
  7315. % the base of natural logarithms.
  7316. mshell ki,kf,p1,pf;
  7317. let p1.e= 0, p1.ep= 0, p1.pf= m^2+ki.kf, p1.ki= m*k,p1.kf=
  7318. m*kp, pf.e= -kf.e, pf.ep= ki.ep, pf.ki= m*kp, pf.kf=
  7319. m*k, ki.e= 0, ki.kf= m*(k-kp), kf.ep= 0, e.e= -1,
  7320. ep.ep=-1;
  7321. for all p let gp(p)= g(l,p)+m;
  7322. comment this is just to save us a lot of writing;
  7323. gp(pf)*(g(l,ep,e,ki)/(2*ki.p1) + g(l,e,ep,kf)/(2*kf.p1))
  7324. * gp(p1)*(g(l,ki,e,ep)/(2*ki.p1) + g(l,kf,ep,e)/
  7325. (2*kf.p1))$
  7326. write "The Compton cxn is",ws;
  7327. \end{verbatim}}
  7328. (We use {\tt P1} instead of {\tt PI} in the above to avoid confusion with
  7329. the reserved variable {\tt PI}).
  7330. This program will print the following result
  7331. {\small\begin{verbatim}
  7332. (-1) (-1) 2
  7333. The Compton cxn is 1/2*K*KP + 1/2*K *KP + 2*E.EP - 1
  7334. \end{verbatim}}
  7335. \section{Extensions to More Than Four Dimensions}
  7336. In our discussion so far, we have assumed that we are working in the
  7337. normal four dimensions of QED calculations. However, in most cases, the
  7338. programs will also work in an arbitrary number of dimensions. The command
  7339. \ttindex{VECDIM}
  7340. {\small\begin{verbatim}
  7341. vecdim <expression>;
  7342. \end{verbatim}}
  7343. sets the appropriate dimension. The dimension can be symbolic as well as
  7344. numerical. Users should note however, that the {\tt EPS} operator and the
  7345. $\gamma_{5}$ symbol ({\tt A}) are not properly defined in other than four
  7346. dimensions and will lead to an error if used.
  7347. \chapter{{\REDUCE} and Rlisp Utilities}
  7348. {\REDUCE} and its associated support language system Rlisp\index{Rlisp}
  7349. include a number of utilities which have proved useful for program
  7350. development over the years. The following are supported in most of the
  7351. implementations of {\REDUCE} currently available.
  7352. \section{The Standard Lisp Compiler}\index{Compiler}
  7353. Many versions of {\REDUCE} include a Standard Lisp compiler that is
  7354. automatically loaded on demand. You should check your system specific
  7355. user guide to make sure you have such a compiler. To make the compiler
  7356. active, the switch {\tt COMP}\ttindex{COMP} should be turned on. Any
  7357. further definitions input after this will be compiled automatically. If
  7358. the compiler used is a derivative version of the original Griss-Hearn
  7359. compiler,
  7360. (M. L. Griss and A.
  7361. C. Hearn, ``A Portable LISP Compiler", SOFTWARE --- Practice and Experience
  7362. 11 (1981) 541-605),
  7363. there are other switches that might also be
  7364. used in this regard. However, these additional switches are not supported
  7365. in all compilers. They are as follows:
  7366. %\ttindex{PLAP}\ttindex{PGWD}\ttindex{PWRDS}
  7367. {\renewcommand{\arraystretch}{2}
  7368. \begin{tabular}{lp{\reduceboxwidth}}
  7369. {\tt PLAP} & If ON, causes the printing of the
  7370. portable macros produced by the compiler; \\
  7371. %
  7372. {\tt PGWD} & If ON, causes the printing of the
  7373. actual assembly language instructions generated from the macros; \\
  7374. %
  7375. {\tt PWRDS} & If ON, causes a statistic
  7376. message of the form \newline
  7377. {\tt <function> COMPILED, <words> WORDS, <words> LEFT} \newline
  7378. to be printed. The first number is the number of words of binary
  7379. program space the compiled function took, and the second number
  7380. the number of words left unused in binary program space. \\
  7381. \end{tabular}}
  7382. \section{Fast Loading Code Generation Program}\index{Fast loading of code}
  7383. \label{sec-load}
  7384. In most versions of {\REDUCE}, it is possible to take any set of Lisp, Rlisp
  7385. or {\REDUCE} commands and build a fast loading version of them. In Rlisp or
  7386. {\REDUCE}, one does the following:
  7387. {\small\begin{verbatim}
  7388. faslout <filename>;
  7389. <commands or IN statements>
  7390. faslend;
  7391. \end{verbatim}}
  7392. To load such a file, one uses the command {\tt LOAD},\ttindex{LOAD}
  7393. e.g. {\tt load foo;}
  7394. or {\tt load foo,bah;}
  7395. This process produces a fast-loading version of the original file. In some
  7396. implementations, this means another file is created with the same name but
  7397. a different extension. For example, in PSL-based systems, the extension is
  7398. {\tt b} (for binary). In CSL-based systems, however, this process adds the
  7399. fast-loading code to a single file in which all such code is stored.
  7400. Particular functions are provided by CSL for managing this file, and
  7401. described in the CSL user documentation.
  7402. In doing this build, as with the production of a Standard Lisp form of
  7403. such statements, it is important to remember that some of the commands
  7404. must be instantiated during the building process. For example, macros
  7405. must be expanded, and some property list operations must happen.
  7406. The {\REDUCE} sources should be consulted for further details on this.
  7407. % To facilitate this, the {\tt EVAL} and {\tt IGNORE} flags may be
  7408. % used. Note also that there can be no {\tt LOAD} command within the input
  7409. % statements.
  7410. To avoid excessive printout, input statements should be followed by a \$
  7411. instead of the semicolon. With {\tt LOAD} however, the input doesn't
  7412. print out regardless of which terminator is used with the command.
  7413. If you subsequently change the source files used in producing a fast
  7414. loading file, don't forget to repeat the above process in order to update
  7415. the fast loading file correspondingly. Remember also that the text which
  7416. is read in during the creation of the fast load file, in the compiling
  7417. process described above, is {\em not\/} stored in your {\REDUCE}
  7418. environment, but only translated and output. If you want to use the file
  7419. just created, you must then use {\tt LOAD} to load the output of the
  7420. fast-loading file generation program.
  7421. When the file to be loaded contains a complete package for a given
  7422. application, {\tt LOAD\_PACKAGE}\ttindex{LOAD\_PACKAGE} rather than
  7423. {\tt LOAD} should be used. The syntax is the same. However,
  7424. {\tt LOAD\_PACKAGE} does some additional bookkeeping such as recording that
  7425. this package has now been loaded, that is required for the correct
  7426. operation of the system.
  7427. \section{The Standard Lisp Cross Reference Program}\index{Cross reference}
  7428. {\tt CREF}\ttindex{CREF} is a Standard Lisp program for processing a
  7429. set of Standard LISP function definitions to produce:
  7430. \begin{enumerate}
  7431. \item A ``summary'' showing:
  7432. \begin{enumerate}
  7433. \item A list of files processed;
  7434. \item A list of ``entry points'' (functions which are not called or
  7435. are only called by themselves);
  7436. \item A list of undefined functions (functions called but not
  7437. defined in this set of functions);
  7438. \item A list of variables that were used non-locally but not
  7439. declared {\tt GLOBAL} or {\tt FLUID} before their use;
  7440. \item A list of variables that were declared {\tt GLOBAL} but not used
  7441. as {\tt FLUID}s, i.e., bound in a function;
  7442. \item A list of {\tt FLUID} variables that were not bound in a function
  7443. so that one might consider declaring them {\tt GLOBAL}s;
  7444. \item A list of all {\tt GLOBAL} variables present;
  7445. \item A list of all {\tt FLUID} variables present;
  7446. \item A list of all functions present.
  7447. \end{enumerate}
  7448. \item A ``global variable usage'' table, showing for each non-local
  7449. variable:
  7450. \begin{enumerate}
  7451. \item Functions in which it is used as a declared {\tt FLUID} or {\tt GLOBAL};
  7452. \item Functions in which it is used but not declared;
  7453. \item Functions in which it is bound;
  7454. \item Functions in which it is changed by {\tt SETQ}.
  7455. \end{enumerate}
  7456. \item A ``function usage'' table showing for each function:
  7457. \begin{enumerate}
  7458. \item Where it is defined;
  7459. \item Functions which call this function;
  7460. \item Functions called by it;
  7461. \item Non-local variables used.
  7462. \end{enumerate}
  7463. \end{enumerate}
  7464. The program will also check that functions are called with the correct
  7465. number of arguments, and print a diagnostic message otherwise.
  7466. The output is alphabetized on the first seven characters of each function
  7467. name.
  7468. \subsection{Restrictions}
  7469. Algebraic procedures in {\REDUCE} are treated as if they were symbolic, so
  7470. that algebraic constructs will actually appear as calls to symbolic
  7471. functions, such as {\tt AEVAL}.
  7472. \subsection{Usage}
  7473. To invoke the cross reference program, the switch {\tt CREF}
  7474. \ttindex{CREF} is used. {\tt on cref} causes the cref program to load
  7475. and the cross-referencing process to begin. After all the required
  7476. definitions are loaded, {\tt off cref} will cause the cross-reference
  7477. listing to be produced. For example, if you wish to cross-reference all
  7478. functions in the file {\tt tst.red}, and produce the cross-reference
  7479. listing in the file {\tt tst.crf}, the following sequence can be used:
  7480. {\small\begin{verbatim}
  7481. out "tst.crf";
  7482. on cref;
  7483. in "tst.red"$
  7484. off cref;
  7485. shut "tst.crf";
  7486. \end{verbatim}}
  7487. To process more than one file, more {\tt IN} statements may be added
  7488. before the call of {\tt off cref}, or the {\tt IN} statement changed to
  7489. include a list of files.
  7490. \subsection{Options}
  7491. Functions with the flag {\tt NOLIST} will not be examined or output.
  7492. Initially, all Standard Lisp functions are so flagged. (In fact, they are
  7493. kept on a list {\tt NOLIST!*}, so if you wish to see references to {\em
  7494. all} functions, then {\tt CREF} should be first loaded with the command {\tt
  7495. load cref}, and this variable then set to {\tt NIL}).
  7496. It should also be remembered that any macros with the property list flag
  7497. {\tt EXPAND}, or, if the switch {\tt FORCE} is on, without the property
  7498. list flag {\tt NOEXPAND}, will be expanded before the definition is seen
  7499. by the cross-reference program, so this flag can also be used to select
  7500. those macros you require expanded and those you do not.
  7501. \section{Prettyprinting Reduce Expressions}\index{Prettyprinting}
  7502. {\REDUCE} includes a module for printing {\REDUCE} syntax in a standard
  7503. format. This module is activated by the switch {\tt PRET},
  7504. \ttindex{PRET} which is normally off.
  7505. Since the system converts algebraic input into an equivalent symbolic form,
  7506. the printing program tries to interpret this as an algebraic expression
  7507. before printing it. In most cases, this can be done successfully. However,
  7508. there will be occasional instances where results are printed in symbolic
  7509. mode form that bears little resemblance to the original input, even though
  7510. it is formally equivalent.
  7511. If you want to prettyprint a whole file, say {\tt off output,msg;}
  7512. \ttindex{MSG} and (hopefully) only clean output will result. Unlike {\tt
  7513. DEFN},\ttindex{DEFN} input is also evaluated with {\tt PRET}
  7514. \ttindex{PRET} on.
  7515. \section{Prettyprinting Standard Lisp S-Expressions}\index{Prettyprinting}
  7516. REDUCE includes a module for printing
  7517. S-expressions in a standard format. The Standard Lisp function for this
  7518. purpose is {\tt PRETTYPRINT}\ttindex{PRETTYPRINT} which takes a Lisp
  7519. expression and prints the formatted equivalent.
  7520. Users can also have their {\REDUCE} input printed in this form by use of
  7521. the switch {\tt DEFN}.\ttindex{DEFN} This is in fact a convenient way to
  7522. convert {\REDUCE} (or Rlisp) syntax into Lisp. {\tt off msg;} will prevent
  7523. warning messages from being printed.
  7524. NOTE: When {\tt DEFN} is on, input is not evaluated.
  7525. \chapter {Maintaining {\REDUCE}}
  7526. {\REDUCE} continues to evolve both in terms of the number of facilities
  7527. available, and the power of the individual facilities. Corrections are
  7528. made as bugs are discovered, and awkward features simplified. In order to
  7529. provide users with easy access to such enhancements, a {\em {\REDUCE}
  7530. network library\/} has been established from which material can be extracted
  7531. by anyone with electronic mail access to the Internet computer network.
  7532. In addition to miscellaneous documents, source and utility files, the
  7533. library includes a bibliography of papers referencing {\REDUCE} which
  7534. contains over 800 entries. Instructions on using this library are sent to
  7535. all registered {\REDUCE} users who provide a network address. If you
  7536. would like a more complete list of the contents of the library, send to
  7537. {\em reduce-netlib@rand.org\/} the single line message {\em send index\/} or
  7538. {\em help}. The current {\REDUCE} information
  7539. package can be obtained from the network library by including on a
  7540. separate line {\em send info-package\/} and a demonstration file by
  7541. including the line {\em send demonstration}. If you prefer, hard copies
  7542. of the information package and the bibliography are available from the
  7543. {\REDUCE} secretary at RAND, 1700 Main Street, P.O. Box 2138, Santa
  7544. Monica, CA 90407-2138 ({\em reduce@rand.org}). Copies of the network
  7545. library are also maintained at other addresses. At the time of writing,
  7546. {\em reduce-netlib@can.nl\/} and {\em reduce-netlib@pi.cc.u-tokyo.ac.jp\/}
  7547. may also be used instead of {\em reduce-netlib@rand.org}.
  7548. A World Wide Web {\REDUCE} server with URL
  7549. {\small\begin{verbatim}
  7550. http://www.rrz.uni-koeln.de/REDUCE/
  7551. \end{verbatim}}
  7552. is also supported. In addition to general information about {\REDUCE}, this
  7553. server has pointers to the network library, the demonstration versions,
  7554. examples of {\REDUCE} programming, a set of manuals, and the {\REDUCE} online
  7555. help system.
  7556. Finally, there is a {\REDUCE} electronic forum accessible from the same
  7557. networks. This enables {\REDUCE} users to raise questions and discuss
  7558. ideas concerning the use and development of {\REDUCE} with other users.
  7559. Additions and changes to the network library and new releases of {\REDUCE}
  7560. are also announced in this forum. Any user with appropriate electronic
  7561. mail access is encouraged to register for membership in this forum. To do
  7562. so, send a message requesting inclusion to \\
  7563. {\em reduce-forum-request@rand.org}.
  7564. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BeginCodemist
  7565. %%% Taken from Reduce.sty
  7566. % \s{...} is a sentential form in descriptions. Enclosed \em text in <...>
  7567. \newcommand{\s}[1] {$<${\em #1}$>$}
  7568. % \meta{...} is an alternative sentential form in descriptions using \it.
  7569. %\newcommand{\meta}[1]{\mbox{$\langle$\it#1\/$\rangle$}}
  7570. % \k{...} is a keyword. Just do in bold for the moment.
  7571. \renewcommand{\k}[1] {{\bf #1}}
  7572. % \f is a function name. Just do this as tt.
  7573. \newcommand{\f}[1] {{\tt #1}}
  7574. % An example macro for numbering and indenting examples.
  7575. \newcounter{examplectr}
  7576. \newcommand{\example}{\refstepcounter{examplectr}
  7577. \noindent{\bf Example \theexamplectr}}
  7578. \part{Additional {\REDUCE} Documentation}
  7579. \setcounter{examplectr}{0}
  7580. The documentation in this section was written using to a large part
  7581. the \LaTeX\ files provided by the authors, and distributed with
  7582. \REDUCE. There has been extensive editing and much rewriting, so
  7583. the responsibility for this part of the manual rests with the editor,
  7584. John Fitch. It is hoped that this version of the documentation
  7585. contains sufficient information about the facilities available that a
  7586. user may be able to progress. It deliberately avoids discussions of
  7587. algorithms or advanced use; for these the package author's own
  7588. documentation should be consulted. In general the package
  7589. documentation will contain more examples and in some cases additional
  7590. facilities such as tracing.
  7591. \chapter{ALGINT: Integration of square roots}
  7592. \label{ALGINT}
  7593. \typeout{{ALGINT: Integration of square roots}}
  7594. {\footnotesize
  7595. \begin{center}
  7596. James Davenport \\
  7597. School of Mathematical Sciences \\
  7598. University of Bath \\
  7599. Bath BA2 7AY \\
  7600. England \\[0.05in]
  7601. e--mail: jhd@maths.bath.ac.uk
  7602. \end{center}
  7603. }
  7604. The package supplies no new functions, but extends the {\tt
  7605. INT}\ttindex{INT} operator for indefinite integration so it can handle
  7606. a wider range of expressions involving square roots. When it is
  7607. loaded the controlling switch {\tt ALGINT}\ttindex{ALGINT} is turned
  7608. on. If it is desired to revert to the standard integrator, then it
  7609. may be turned off. The normal integrator can deal with some square
  7610. roots but in an unsystematic fashion.
  7611. {\small\begin{verbatim}
  7612. 1: load_package algint;
  7613. 2: int(sqrt(sqrt(a^2+x^2)+x)/x,x);
  7614. 2 2
  7615. sqrt(a)*atan((sqrt(a)*sqrt(sqrt(a + x ) + x)
  7616. 2 2
  7617. *sqrt(a + x )
  7618. 2 2
  7619. - sqrt(a)*sqrt(sqrt(a + x ) + x)*a
  7620. 2 2
  7621. - sqrt(a)*sqrt(sqrt(a + x ) + x)*x)/(2
  7622. \end{verbatim}}
  7623. \newpage
  7624. {\small\begin{verbatim}
  7625. 2 2 2
  7626. *a )) + 2*sqrt(sqrt(a + x ) + x)
  7627. 2 2
  7628. + sqrt(a)*log(sqrt(sqrt(a + x ) + x) - sqrt(a))
  7629. 2 2
  7630. - sqrt(a)*log(sqrt(sqrt(a + x ) + x) + sqrt(a))
  7631. 3: off algint;
  7632. 4: int(sqrt(sqrt(a^2+x^2)+x)/x,x);
  7633. 2 2
  7634. sqrt(sqrt(a + x ) + x)
  7635. int(-------------------------,x)
  7636. x
  7637. \end{verbatim}}
  7638. There is also a switch {\tt TRA},\ttindex{TRA} which may be set on to
  7639. provide detailed tracing of the algorithm used. This is not
  7640. recommended for casual use.
  7641. \chapter[APPLYSYM: Infinitesimal symmetries]{APPLYSYM: Infinitesimal symmetries of differential equations}
  7642. \label{APPLYSYM}
  7643. \typeout{[APPLYSYM: Infinitesimal symmetries]}
  7644. {\footnotesize
  7645. \begin{center}
  7646. Thomas Wolf \\
  7647. School of Mathematical Sciences, Queen Mary and Westfield College \\
  7648. University of London \\
  7649. London E1 4NS, England \\[0.05in]
  7650. e--mail: T.Wolf@maths.qmw.ac.uk
  7651. \end{center}
  7652. }
  7653. The investigation of infinitesimal symmetries of differential equations
  7654. (DEs) with computer algebra programs attracted considerable attention
  7655. over the last years. The package {\tt APPLYSYM} concentrates on the
  7656. implementation of applying symmetries for calculating similarity
  7657. variables to perform a point transformation which lowers the order of
  7658. an ODE or effectively reduces the number of explicitly occuring
  7659. independent variables of a PDE(-system) and for generalising given
  7660. special solutions of ODEs/PDEs with new constant parameters.
  7661. A prerequisite for applying symmetries is the solution of first order
  7662. quasilinear PDEs. The corresponding program
  7663. {\tt QUASILINPDE}\ttindex{QUASILINPDE} can as well be used without
  7664. {\tt APPLYSYM}\ttindex{APPLYSYM} for solving first order PDEs which are
  7665. linear in their first order derivative and otherwise at most rationally
  7666. non-linear. The following two PDEs are equations (2.40) and (3.12)
  7667. taken from E. Kamke, "Loesungsmethoden und Loesungen von Differential-
  7668. gleichungen, Partielle Differentialgleichungen erster Ordnung",
  7669. B.G. Teubner, Stuttgart (1979).
  7670. \newpage
  7671. {\small
  7672. {\small\begin{verbatim}
  7673. ------------------------ Equation 2.40 ------------------------
  7674. 2 3 4
  7675. The quasilinear PDE: 0 = df(z,x)*x*y + 2*df(z,y)*y - 2*x
  7676. 2 2 2
  7677. + 4*x *y*z - 2*y *z .
  7678. The equivalent characteristic system:
  7679. 3 4 2 2 2
  7680. 0=2*(df(z,y)*y - x + 2*x *y*z - y *z )
  7681. 2
  7682. 0=y *(2*df(x,y)*y - x)
  7683. for the functions: x(y) z(y) .
  7684. The general solution of the PDE is given through
  7685. 4 2 2
  7686. log(y)*x - log(y)*x *y*z - y *z sqrt(y)*x
  7687. 0 = ff(----------------------------------,-----------)
  7688. 4 2 y
  7689. x - x *y*z
  7690. with arbitrary function ff(..).
  7691. ------------------------ Equation 3.12 ------------------------
  7692. The quasilinear PDE: 0 = df(w,x)*x + df(w,y)*a*x + df(w,y)*b*y
  7693. + df(w,z)*c*x + df(w,z)*d*y + df(w,z)*f*z.
  7694. The equivalent characteristic system:
  7695. 0=df(w,x)*x
  7696. 0=df(z,x)*x - c*x - d*y - f*z
  7697. 0=df(y,x)*x - a*x - b*y
  7698. for the functions: z(x) y(x) w(x) .
  7699. The general solution of the PDE is given through
  7700. a*x + b*y - y
  7701. 0 = ff(---------------,( - a*d*x + b*c*x + b*f*z - b*z - c*f*x
  7702. b b
  7703. x *b - x
  7704. 2 f f f 2 f
  7705. - d*f*y + d*y - f *z + f*z)/(x *b*f - x *b - x *f + x *f)
  7706. ,w)
  7707. with arbitrary function ff(..).
  7708. \end{verbatim}}
  7709. }
  7710. The program {\tt DETRAFO}\ttindex{DETRAFO} can be used to perform
  7711. point transformations of ODEs/PDEs (and -systems).
  7712. For detailed explanations the user is
  7713. referred to the paper {\em Programs for Applying Symmetries of PDEs}
  7714. by Thomas Wolf, supplied as part of the Reduce documentation as {\tt
  7715. applysym.tex} and published in the Proceedings of ISSAC'95 - 7/95
  7716. Montreal, Canada, ACM Press (1995).
  7717. \chapter{ARNUM: An algebraic number package}
  7718. \label{ARNUM}
  7719. \typeout{{ARNUM: An algebraic number package}}
  7720. {\footnotesize
  7721. \begin{center}
  7722. Eberhard Schr\"{u}fer \\
  7723. Institute SCAI.Alg \\
  7724. German National Research Center for Information Technology (GMD) \\
  7725. Schloss Birlinghoven \\
  7726. D-53754 Sankt Augustin, Germany \\[0.05in]
  7727. e--mail: schruefer@gmd.de
  7728. \end{center}
  7729. }
  7730. Algebraic numbers are the solutions of an irreducible polynomial over
  7731. some ground domain. \index{i} The algebraic number $i$ (imaginary
  7732. unit),\index{imaginary unit} for example, would be defined by the
  7733. polynomial $i^2 + 1$. The arithmetic of algebraic number $s$ can be
  7734. viewed as a polynomial arithmetic modulo the defining polynomial.
  7735. The {\tt ARNUM}\ttindex{ARNUM} package provides a mechanism to
  7736. define other algebraic numbers, and compute with them.
  7737. \section{DEFPOLY}\ttindex{DEFPOLY}
  7738. {\tt DEFPOLY} takes as its argument the defining polynomial for an
  7739. algebraic number, or a number of defining polynomials for different
  7740. algebraic numbers, and arranges that arithmetic with the new symbol(s) is
  7741. performed relative to these polynomials.
  7742. {\small\begin{verbatim}
  7743. load_package arnum;
  7744. defpoly sqrt2**2-2;
  7745. 1/(sqrt2+1);
  7746. SQRT2 - 1
  7747. (x**2+2*sqrt2*x+2)/(x+sqrt2);
  7748. X + SQRT2
  7749. on gcd;
  7750. (x**3+(sqrt2-2)*x**2-(2*sqrt2+3)*x-3*sqrt2)/(x**2-2);
  7751. 2
  7752. X - 2*X - 3
  7753. --------------
  7754. X - SQRT2
  7755. off gcd;
  7756. sqrt(x**2-2*sqrt2*x*y+2*y**2);
  7757. ABS(X - SQRT2*Y)
  7758. \end{verbatim}}
  7759. The following example introduces both $\sqrt 2$ and $5^{1 \over 3}$:
  7760. {\small\begin{verbatim}
  7761. defpoly sqrt2**2-2,cbrt5**3-5;
  7762. *** defining polynomial for primitive element:
  7763. 6 4 3 2
  7764. A1 - 6*A1 - 10*A1 + 12*A1 - 60*A1 + 17
  7765. sqrt2;
  7766. 5 4 3 2
  7767. 48/1187*A1 + 45/1187*A1 - 320/1187*A1 - 780/1187*A1 +
  7768. 735/1187*A1 - 1820/1187
  7769. sqrt2**2;
  7770. 2
  7771. \end{verbatim}}
  7772. \section{SPLIT\_FIELD}\ttindex{SPLIT\_FIELD}
  7773. The function {\tt SPLIT\_FIELD} calculates a primitive element of
  7774. minimal degree for which a given polynomial splits into linear
  7775. factors.
  7776. {\small\begin{verbatim}
  7777. split_field(x**3-3*x+7);
  7778. *** Splitting field is generated by:
  7779. 6 4 2
  7780. A5 - 18*A5 + 81*A5 + 1215
  7781. 4 2
  7782. {1/126*A5 - 5/42*A5 - 1/2*A5 + 2/7,
  7783. 4 2
  7784. - (1/63*A5 - 5/21*A5 + 4/7),
  7785. 4 2
  7786. 1/126*A5 - 5/42*A5 + 1/2*A5 + 2/7}
  7787. for each j in ws product (x-j);
  7788. 3
  7789. X - 3*X + 7
  7790. \end{verbatim}}
  7791. \chapter{ASSIST: Various Useful Utilities}
  7792. \label{ASSIST}
  7793. \typeout{{ASSIST: Various Useful Utilities}}
  7794. {\footnotesize
  7795. \begin{center}
  7796. Hubert Caprasse \\
  7797. D\'epartement d'Astronomie et d'Astrophysique \\
  7798. Institut de Physique, B--5, Sart Tilman \\
  7799. B--4000 LIEGE 1, Belgium\\[0.05in]
  7800. e--mail: caprasse@vm1.ulg.ac.be
  7801. \end{center}
  7802. }
  7803. The {\tt ASSIST}\ttindex{ASSIST} package provides a number of general
  7804. purpose functions which adapt \REDUCE\ to various
  7805. calculational strategies. All the examples in this section require
  7806. the {\tt ASSIST} package to be loaded.
  7807. \section{Control of Switches}
  7808. The two functions \f{SWITCHES, SWITCHORG}
  7809. \ttindex{SWITCHES}\ttindex{SWITCHORG} have no argument and are called
  7810. as if they were mere identifiers.
  7811. \f{SWITCHES} displays the current status of the most often used switches
  7812. when manipulating rational functions;
  7813. {\tt EXP}, {\tt DIV}, {\tt MCD}, {\tt GCD}, {\tt ALLFAC}, {\tt
  7814. INTSTR}, {\tt RAT}, {\tt RATIONAL}, {\tt FACTOR}.
  7815. The switch {\tt DISTRIBUTE} which controls the handling
  7816. of distributed polynomials is included as well (see section~\ref{DISTRIBUTE}).
  7817. \f{SWITCHORG} resets (almost) {\em all} switches in the status they
  7818. have when {\bf entering} into \REDUCE. (See also {\tt RESET},
  7819. chapter~\ref{RESET}\ttindex{RESET}). The new switch {\tt DISTRIBUTE}
  7820. facilitates changing polynomials to a distributed form.
  7821. \section{Manipulation of the List Structure}
  7822. Functions for list manipulation are provided and are generalised
  7823. to deal with the new structure {\tt BAG}.
  7824. \begin{itemize}
  7825. \item[i.]
  7826. Generation of a list of length $n$ with its elements initialised to 0
  7827. and also to append to a list $l$ sufficient zeros to
  7828. make it of length $n$:\ttindex{MKLIST}
  7829. {\small\begin{verbatim}
  7830. MKLIST n; %% n is an INTEGER
  7831. MKLIST(l,n); %% l is List-like, n is an INTEGER
  7832. \end{verbatim}}
  7833. \item[ii.]
  7834. Generation of a list of sublists of length $n$ containing $p$ elements
  7835. equal to $0$ and $n-p$ elements equal to $1$.
  7836. {\small\begin{verbatim}
  7837. SEQUENCES 2; ==> {{0,0},{0,1},{1,0},{1,1}}
  7838. \end{verbatim}}
  7839. The function \f{KERNLIST}\ttindex{KERNLIST} transforms any prefix of
  7840. a kernel into the {\bf \verb+list+} prefix. The output list is a copy:
  7841. {\small\begin{verbatim}
  7842. KERNLIST (<kernel>); ==> {<kernel arguments>}
  7843. \end{verbatim}}
  7844. There are four functions to delete elements from lists. The
  7845. \f{DELETE} function deletes the first occurrence of its first argument
  7846. from the second, while \f{REMOVE} removes a numbered element.
  7847. \f{DELETE\_ALL} eliminates from a list {\em all} elements equal to its
  7848. first argument. \f{DELPAIR} acts on list of pairs and eliminates from
  7849. it the {\em first} pair whose first element is equal to its first
  7850. argument:\ttindex{DELETE}\ttindex{REMOVE}\ttindex{DELETE\_ALL}\ttindex{DELPAIR}
  7851. {\small\begin{verbatim}
  7852. DELETE(x,{a,b,x,f,x}); ==> {a,b,f,x}
  7853. REMOVE({a,b,x,f,x},3); ==> {a,b,f,x}
  7854. DELETE_ALL(x,{a,b,x,f,x}); ==> {a,b,f}
  7855. DELPAIR(a,{{a,1},{b,2},{c,3}}; ==> {{b,2},{c,3}}
  7856. \end{verbatim}}
  7857. \item[iv.]
  7858. The function \f{ELMULT}\ttindex{ELMULT} returns an {\em integer} which is the
  7859. {\em multiplicity} of its first argument in the list which is its
  7860. second argument.
  7861. The function \f{FREQUENCY}\ttindex{FREQUENCY} gives a list of pairs
  7862. whose second element indicates the number of times the first element
  7863. appears inside the original list:
  7864. {\small\begin{verbatim}
  7865. ELMULT(x,{a,b,x,f,x}) ==> 2
  7866. FREQUENCY({a,b,c,a}); ==> {{a,2},{b,1},{c,1}}
  7867. \end{verbatim}}
  7868. \item[v.] The function \f{INSERT}\ttindex{INSERT} inserts a
  7869. given object into a list at the wanted position. The functions
  7870. \f{INSERT\_KEEP\_ORDER}\ttindex{INSERT\_KEEP\_ORDER} and
  7871. \f{MERGE\_LIST}\ttindex{MERGE\_LIST} keep a given ordering when
  7872. inserting one element inside a list or when merging two lists. Both
  7873. have 3 arguments. The last one is the name of a binary boolean
  7874. ordering function:
  7875. {\small\begin{verbatim}
  7876. ll:={1,2,3}$
  7877. INSERT(x,ll,3); ==> {1,2,x,3}
  7878. INSERT_KEEP_ORDER(5,ll,lessp); ==> {1,2,3,5}
  7879. MERGE_LIST(ll,ll,lessp); ==> {1,1,2,2,3,3}
  7880. \end{verbatim}}
  7881. \item[vi.]
  7882. Algebraic lists can be read from right to left or left to right.
  7883. They {\em look} symmetrical. It is sometimes convenient to have
  7884. functions which reflect this. So, as well as \f{FIRST} and \f{REST}
  7885. this package provides the functions \f{LAST}\ttindex{LAST} and
  7886. \f{BELAST}\ttindex{BELAST}. \f{LAST} gives the last element of the
  7887. list while \f{BELAST} gives the list {\em without} its last element. \\
  7888. Various additional functions are provided. They are:
  7889. \f{CONS}, \f{(.)}, \f{POSITION}, \f{DEPTH}, \f{PAIR}, \f{APPENDN},
  7890. \f{REPFIRST}, \f{REPLAST}
  7891. \ttindex{CONS}\ttindex{.}\ttindex{POSITION}\ttindex{DEPTH}
  7892. \ttindex{PAIR}\ttindex{APPENDN}\ttindex{REPLAST}\ttindex{REPLAST}
  7893. The token ``dot'' needs a special comment. It corresponds to
  7894. several different operations.
  7895. \begin{enumerate}
  7896. \item If one applies it on the left of a list, it acts as the \f{CONS}
  7897. function. Note however that blank spaces are required around the dot:
  7898. {\small\begin{verbatim}
  7899. 4 . {a,b}; ==> {4,a,b}
  7900. \end{verbatim}}
  7901. \item If one applies it on the right of a list, it has the same
  7902. effect as the \f{PART} operator:
  7903. {\small\begin{verbatim}
  7904. {a,b,c}.2; ==> b
  7905. \end{verbatim}}
  7906. \item If one applies it on 4--dimensional vectors, it acts as in the
  7907. HEPHYS package (chapter~\ref{HEPHYS}
  7908. \end{enumerate}
  7909. \f{POSITION} returns the position of the first occurrence of x in
  7910. a list or a message if x is not present in it.
  7911. \f{DEPTH} returns an {\em integer} equal to the number of levels where
  7912. a list is found if and only if this number is the {\em same} for each
  7913. element of the list otherwise it returns a message telling the user
  7914. that list is of {\em unequal depth}.
  7915. \f{PAIR} has two arguments which must be lists. It returns a list
  7916. whose elements are {\em lists of two elements.} The $n^{th}$ sublist
  7917. contains the $n^{th}$ element of the first list and the $n^{th}$
  7918. element of the second list. These types of lists are called {\em
  7919. association lists} or ALISTS in the following.
  7920. \f{APPENDN} has {\em any} number of lists as arguments, and appends
  7921. them all.
  7922. \f{REPFIRST} has two arguments. The first one is any object, the
  7923. second one is a list. It replaces the first element of the list by the
  7924. object.
  7925. \f{REPREST} has also two arguments. It replaces the rest of the list
  7926. by its first argument and returns the new list without destroying the
  7927. original list.
  7928. {\small\begin{verbatim}
  7929. ll:={{a,b}}$
  7930. ll1:=ll.1; ==> {a,b}
  7931. ll.0; ==> list
  7932. 0 . ll; ==> {0,{a,b}}
  7933. DEPTH ll; ==> 2
  7934. PAIR(ll1,ll1); ==> {{a,a},{b,b}}
  7935. REPFIRST{new,ll); ==> {new}
  7936. ll3:=APPENDN(ll1,ll1,ll1); ==> {a,b,a,b,a,b}
  7937. POSITION(b,ll3); ==> 2
  7938. REPREST(new,ll3); ==> {a,new}
  7939. \end{verbatim}}
  7940. \item[vii.]
  7941. The functions \f{ASFIRST}\ttindex{ASFIRST},
  7942. \f{ASLAST}\ttindex{ASLAST}, \f{ASREST}\ttindex{ASREST},
  7943. \f{ASFLIST}\ttindex{ASFLIST}, \f{ASSLIST}\ttindex{ASSLIST},
  7944. and \f{RESTASLIST}\ttindex{RESTASLIST}
  7945. act on ALISTS or on list of lists of well defined depths
  7946. and have two arguments. The first is the key object
  7947. which one seeks to associate in some way to an element of the association
  7948. list which is the second argument. \f{ASFIRST} returns the pair whose
  7949. first element is equal to the first argument. \f{ASLAST} returns the
  7950. pair whose last element is equal to the first argument. \f{ASREST}
  7951. needs a {\em list} as its first argument. The function seeks the first
  7952. sublist of a list of lists (which is its second argument)
  7953. equal to its first argument and returns it.
  7954. \f{RESTASLIST} has a {\em list of keys} as its first arguments. It
  7955. returns the collection of pairs which meet the criterion of \f{ASREST}.
  7956. \f{ASFLIST} returns a list containing {\em all pairs} which
  7957. satisfy to the criteria of the function \f{ASFIRST}. So the output
  7958. is also an ALIST or a list of lists.
  7959. \f{ASSLIST} returns a list which contains {\em all pairs} which have
  7960. their second element equal to the first argument.
  7961. {\small\begin{verbatim}
  7962. lp:={{a,1},{b,2},{c,3}}$
  7963. ASFIRST(a,lp); ==> {a,1}
  7964. ASLAST(1,lp); ==> {a,1}
  7965. ASREST({1},lp); ==> {a,1}
  7966. RESTASLIST({a,b},lp); ==> {{1},{2}}
  7967. lpp:=APPEND(lp,lp)$
  7968. ASFLIST(a,lpp); ==> {{a,1},{a,1}}
  7969. ASSLIST(1,lpp); ==> {{a,1},{a,1}}
  7970. \end{verbatim}}
  7971. \end{itemize}
  7972. \section{The Bag Structure and its Associated Functions}
  7973. The LIST structure of \REDUCE\ is very convenient for manipulating
  7974. groups of objects which are, {\em a priori}, unknown. This structure is
  7975. endowed with other properties such as ``mapping'' {\em i.e.\ }the fact
  7976. that if \verb+OP+ is an operator one gets, by default,
  7977. {\small\begin{verbatim}
  7978. OP({x,y}); ==> {OP(x),OP(y)}
  7979. \end{verbatim}}
  7980. It is not permitted to submit lists to the operations valid on rings
  7981. so that lists cannot be indeterminates of polynomials. Frequently
  7982. procedure arguments cannot be lists.
  7983. At the other extreme, so to say, one has the \verb+KERNEL+
  7984. structure associated
  7985. to the algebraic declaration \verb+operator+. This structure behaves as
  7986. an ``unbreakable'' one and, for that reason, behaves
  7987. like an ordinary identifier.
  7988. It may generally be bound to all non-numeric procedure parameters
  7989. and it may appear
  7990. as an ordinary indeterminate inside polynomials. \\
  7991. The \verb+BAG+ structure is intermediate between a list and an operator.
  7992. From the operator it borrows the property to be a \verb+KERNEL+ and,
  7993. therefore, may be an indeterminate of a polynomial. From the list structure
  7994. it borrows the property to be a {\em composite} object.\\[5pt]
  7995. \mbox{\underline{{\bf Definition}:\hfill}}\\[4pt]
  7996. A bag is an object endowed with the following properties:
  7997. \begin{enumerate}
  7998. \item It is a \verb+KERNEL+ composed of an atomic prefix (its
  7999. envelope) and
  8000. its content (miscellaneous objects).
  8001. \item Its content may be changed in an analogous way as the content of a
  8002. list. During these manipulations the name of the bag is {\em conserved}.
  8003. \item Properties may be given to the envelope. For instance, one may
  8004. declare it \verb+NONCOM+ or \verb+SYMMETRIC+ etc.\ $\ldots$
  8005. \end{enumerate}
  8006. \vspace{5pt}
  8007. \mbox{\underline{{\bf Available Functions}:\hfill}}
  8008. \begin{itemize}
  8009. \item[i.] A default bag envelope \verb+BAG+\index{BAG} is defined.
  8010. It is a reserved identifier.
  8011. An identifier other than \verb+LIST+ or one which is already associated
  8012. with a boolean function may be defined as a bag envelope through the
  8013. command \f{PUTBAG}\ttindex{PUTBAG}. In particular, any operator may
  8014. also be declared to be a bag. {\bf When and only when} the identifier
  8015. is not an already defined function does \f{PUTBAG} puts on it the
  8016. property of an OPERATOR PREFIX.
  8017. The command:
  8018. {\small\begin{verbatim}
  8019. PUTBAG id1,id2,....idn;
  8020. \end{verbatim}}
  8021. declares \verb+id1,.....,idn+ as bag envelopes.
  8022. Analogously, the command\ttindex{CLEARBAG}
  8023. {\small\begin{verbatim}
  8024. CLEARBAG id1,...idn;
  8025. \end{verbatim}}
  8026. eliminates the bag property on \verb+id1,...,idn+.
  8027. \item[ii.] The boolean function \f{BAGP}\ttindex{BAGP} detects the bag
  8028. property.
  8029. {\small\begin{verbatim}
  8030. aa:=bag(x,y,z)$
  8031. if BAGP aa then "ok"; ==> ok
  8032. \end{verbatim}}
  8033. \item[iii.] Most functions defined above for lists do also work for
  8034. bags.
  8035. Moreover functions subsequently defined for SETS (see
  8036. section~\ref{A-SETS}) also work.
  8037. However, because of the conservation of the envelope, they act
  8038. somewhat differently.
  8039. {\small\begin{verbatim}
  8040. PUTBAG op; ==> T
  8041. aa:=op(x,y,z)$
  8042. FIRST op(x,y,z); ==> op(x)
  8043. REST op(x,y,z); ==> op(y,z)
  8044. BELAST op(x,y,z); ==> op(x,y)
  8045. APPEND(aa,aa); ==> op(x,y,z,x,y,z)
  8046. LENGTH aa; ==> 3
  8047. DEPTH aa; ==> 1
  8048. \end{verbatim}}
  8049. When ``appending'' two bags with {\em different} envelopes, the
  8050. resulting bag gets the name of the one bound to the first parameter of
  8051. \f{APPEND}.
  8052. The function \f{LENGTH} gives the actual number of variables on which
  8053. the operator (or the function) depends.
  8054. The NAME of the ENVELOPE is kept by the functions \f{FIRST},
  8055. \f{SECOND}, \f{LAST} and \f{BELAST}.
  8056. \item[iv.]
  8057. The connection between the list and the bag structures is made easy
  8058. thanks to \f{KERNLIST} which transforms a bag into a list and thanks to
  8059. the coercion function \f{LISTBAG}\ttindex{LISTBAG}. This function has
  8060. 2 arguments and is used as follows:
  8061. {\small\begin{verbatim}
  8062. LISTBAG(<list>,<id>); ==> <id>(<arg_list>)
  8063. \end{verbatim}}
  8064. The identifier \verb+<id>+ if allowed is automatically declared as a bag
  8065. envelope or an error message is generated.
  8066. Finally, two boolean functions which work both for bags and lists are
  8067. provided. They are \f{BAGLISTP}\ttindex{BAGLISTP} and
  8068. \f{ABAGLISTP}\ttindex{ABAGLISTP}.
  8069. They return T or NIL (in a conditional statement) if their argument
  8070. is a bag or a list for the first one, if their argument is a list of
  8071. sublists or a bag containing bags for the second one.
  8072. \end{itemize}
  8073. \section{Sets and their Manipulation Functions}
  8074. \label{A-SETS}
  8075. The ASSIST package makes the Standard LISP set functions available in
  8076. algebraic mode and also {\em generalises} them so that they can be
  8077. applied on bag--like objects as well.
  8078. \begin{itemize}
  8079. \item[i.]
  8080. The constructor \f{MKSET}\ttindex{MKSET} transforms a list or bag into
  8081. a set by eliminating duplicates.
  8082. {\small\begin{verbatim}
  8083. MKSET({1,a,a1}); ==> {1,a}
  8084. MKSET bag(1,a,a1); ==> bag(1,a)
  8085. \end{verbatim}}
  8086. \f{SETP}\ttindex{SETP} is a boolean function which recognises
  8087. set--like objects.
  8088. \item[ii.]
  8089. The standard functions are \f{UNION}\ttindex{UNION},
  8090. \f{INTERSECT}\ttindex{INTERSECT}, \f{DIFFSET}\ttindex{DIFFSET}
  8091. and \f{SYMDIFF}\ttindex{SYMDIFF}.
  8092. They have two arguments which must be sets; otherwise an error message
  8093. is issued.
  8094. \end{itemize}
  8095. \section{General Purpose Utility Functions}
  8096. \begin{itemize}
  8097. \item[i.]
  8098. The functions \f{MKIDNEW}\ttindex{MKIDNEW},
  8099. \f{DELLASTDIGIT}\ttindex{DELLASTDIGIT},
  8100. \f{DETIDNUM}\ttindex{DETIDNUM},
  8101. \f{LIST\_TO\_IDS}\ttindex{LIST\_TO\_IDS}
  8102. handle identifiers. \f{MKIDNEW}\ttindex{MKIDNEW} is a variant of \f{MKID}.
  8103. \f{MKIDNEW} has either 0 or 1 argument. It generates an identifier which
  8104. has not yet been used before.
  8105. {\small\begin{verbatim}
  8106. MKIDNEW(); ==> g0001
  8107. MKIDNEW(a); ==> ag0002
  8108. \end{verbatim}}
  8109. \f{DELLASTDIGIT} takes an integer as argument, it strips it from its last
  8110. digit.
  8111. {\small\begin{verbatim}
  8112. DELLASTDIGIT 45; ==> 4
  8113. \end{verbatim}}
  8114. \f{DETIDNUM}, determines the trailing integer from an identifier. It is
  8115. convenient when one wants to make a do loop starting from a set of
  8116. indices $ a_1, \ldots , a_{n} $.
  8117. {\small\begin{verbatim}
  8118. DETIDNUM a23; ==> 23
  8119. \end{verbatim}}
  8120. \f{LIST\_to\_IDS} generalises the function \f{MKID} to a list of
  8121. atoms. It creates and interns an identifier from the concatenation of
  8122. the atoms. The first atom cannot be an integer.
  8123. {\small\begin{verbatim}
  8124. LIST_TO_IDS {a,1,id,10}; ==> a1id10
  8125. \end{verbatim}}
  8126. The function \f{ODDP}\ttindex{ODDP} detects odd integers.
  8127. The function \f{FOLLOWLINE}\ttindex{FOLLOWLINE} is convenient when
  8128. using the function \f{PRIN2} for controlling layout.
  8129. {\small\begin{verbatim}
  8130. <<prin2 2; prin2 5>>$
  8131. 25
  8132. <<prin2 2; followline(3); prin2 5>>$
  8133. 2
  8134. 5
  8135. \end{verbatim}}
  8136. The function \f{RANDOMLIST}\ttindex{RANDOMLIST} generates a list of
  8137. positive random numbers. It takes
  8138. two arguments which are both integers. The first one indicates the range
  8139. inside which the random numbers are chosen. The second one indicates how
  8140. many numbers are to be generated.
  8141. {\small\begin{verbatim}
  8142. RANDOMLIST(10,5); ==> {2,1,3,9,6}
  8143. \end{verbatim}}
  8144. \f{MKRANDTABL}\ttindex{MKRANDTABL} generates a table of random
  8145. numbers. This table is either
  8146. a one or two dimensional array. The base of random numbers may be either
  8147. an integer or a floating point number. In this latter case
  8148. the switch \f{rounded} must be ON. The function has three
  8149. arguments. The first is either a one integer or a two integer
  8150. list. The second is the base chosen to generate the random
  8151. numbers. The third is the chosen name for the generated array. In the
  8152. example below a two-dimensional table of integer random numbers is
  8153. generated as array elements of the identifier {\f ar}.
  8154. {\small\begin{verbatim}
  8155. MKRANDTABL({3,4},10,ar); ==>
  8156. *** array ar redefined
  8157. {3,4}
  8158. \end{verbatim}}
  8159. The output is the array dimension.
  8160. \f{COMBNUM(n,p)}\ttindex{COMBNUM} gives the number of combinations of
  8161. $n$ objects taken $p$ at a time. It has the two integer arguments $n$
  8162. and $p$.
  8163. \f{PERMUTATIONS(n)}\ttindex{PERMUTATIONS} gives the list of permutations
  8164. on $n$ objects, each permutation being represented as a list.
  8165. \f{CYCLICPERMLIST}\ttindex{CYCLICPERMLIST} gives the list of
  8166. {\em cyclic} permutations. For both functions, the argument may
  8167. also be a {\tt bag}.
  8168. {\small\begin{verbatim}
  8169. PERMUTATIONS {1,2} ==> {{1,2},{2,1}}
  8170. CYCLICPERMLIST {1,2,3} ==>
  8171. {{1,2,3},{2,3,1},{3,1,2}}
  8172. \end{verbatim}}
  8173. \f{COMBINATIONS}\ttindex{COMBINATIONS} gives a list of combinations on
  8174. $n$ objects taken $p$ at a time. The first argument is a
  8175. list (or a bag) and the second is the integer $p$.
  8176. {\small\begin{verbatim}
  8177. COMBINATIONS({1,2,3},2) ==> {{2,3},{1,3},{1,2}}
  8178. \end{verbatim}}
  8179. \f{REMSYM}\ttindex{REMSYM} is a command that erases the \REDUCE\ commands
  8180. {\tt symmetric} or {\tt antisymmetric}.
  8181. \f{SYMMETRIZE}\ttindex{SYMMETRIZE} is a powerful function which
  8182. generate a symmetric expression.
  8183. It has 3 arguments. The first is a list (or a list of lists) containing
  8184. the expressions which will appear as variables for a kernel. The second
  8185. argument is the kernel-name and the third is a permutation function
  8186. which either exist in the algebraic or in the symbolic mode. This
  8187. function may have been constructed by the user. Within this package
  8188. the two functions \f{PERMUTATIONS} and \f{CYCLICPERMLIST} may be used.
  8189. {\small\begin{verbatim}
  8190. ll:={a,b,c}$
  8191. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  8192. OP(A,B,C) + OP(B,C,A) + OP(C,A,B)
  8193. SYMMETRIZE(list ll,op,cyclicpermlist); ==>
  8194. OP({A,B,C}) + OP({B,C,A}) + OP({C,A,B})
  8195. \end{verbatim}}
  8196. Notice that taking for the first argument a list of lists gives rise to
  8197. an expression where each kernel has a {\em list as argument}. Another
  8198. peculiarity of this function is that, unless a pattern matching is
  8199. made on the operator \verb+OP+, it needs to be reevaluated. Here is
  8200. an illustration:
  8201. {\small\begin{verbatim}
  8202. op(a,b,c):=a*b*c$
  8203. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  8204. OP(A,B,C) + OP(B,C,A) + OP(C,A,B)
  8205. for all x let op(x,a,b)=sin(x*a*b);
  8206. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  8207. OP(B,C,A) + SIN(A*B*C) + OP(A,B,C)
  8208. \end{verbatim}}
  8209. The functions \f{SORTNUMLIST}\ttindex{SORTNUMLIST} and
  8210. \f{SORTLIST}\ttindex{SORTLIST} are functions which sort
  8211. lists. They use {\em bubblesort} and {\em quicksort} algorithms.
  8212. \f{SORTNUMLIST} takes as argument a list of numbers. It sorts it in
  8213. increasing order.
  8214. \f{SORTLIST} is a generalisation of the above function.
  8215. It sorts the list according
  8216. to any well defined ordering. Its first argument is the list and its
  8217. second argument is the ordering function. The content of the list
  8218. is not necessary numbers but must be such that the ordering function has
  8219. a meaning.
  8220. {\small\begin{verbatim}
  8221. l:={1,3,4,0}$ SORTNUMLIST l; ==> {0,1,3,4}
  8222. ll:={1,a,tt,z}$ SORTLIST(ll,ordp); ==> {a,z,tt,1}
  8223. \end{verbatim}}
  8224. Note: using these functions for kernels or bags may be
  8225. dangerous since they are destructive. If it is needed, it is recommended
  8226. first to apply \f{KERNLIST} on them.
  8227. The function \f{EXTREMUM}\ttindex{EXTREMUM} is a generalisation of the
  8228. functions \f{MIN} and \f{MAX} to include general orderings. It is a 2
  8229. arguments function.
  8230. The first is the list and the second is the ordering function.
  8231. With the list \verb+ll+ defined in the last example, one gets
  8232. {\small\begin{verbatim}
  8233. EXTREMUM(ll,ordp); ==> 1
  8234. \end{verbatim}}
  8235. \item[iii.] There are four functions to identify dependencies.
  8236. \f{FUNCVAR}\ttindex{FUNCVAR} takes any expression as argument and
  8237. returns the set of variables on which it depends. Constants are eliminated.
  8238. {\small\begin{verbatim}
  8239. FUNCVAR(e+pi+sin(log(y)); ==> {y}
  8240. \end{verbatim}}
  8241. \f{DEPATOM}\ttindex{DEPATOM} has an {\bf atom} as argument. It returns
  8242. its argument if it is
  8243. a number or if no dependency has previously been declared. Otherwise,
  8244. it returns the list of variables on which in depends as declared in
  8245. various {\tt DEPEND} declarations.
  8246. {\small\begin{verbatim}
  8247. DEPEND a,x,y;
  8248. DEPATOM a; ==> {x,y}
  8249. \end{verbatim}}
  8250. The functions \f{EXPLICIT}\ttindex{EXPLICIT} and
  8251. \f{IMPLICIT}\ttindex{IMPLICIT} make explicit or
  8252. implicit the dependencies.
  8253. {\small\begin{verbatim}
  8254. depend a,x; depend x,y,z;
  8255. EXPLICIT a; ==> a(x(y,z))
  8256. IMPLICIT ws; ==> a
  8257. \end{verbatim}}
  8258. These are useful when one does not know the names of the variables
  8259. and (or) the nature of the dependencies.
  8260. \f{KORDERLIST}\ttindex{KORDERLIST} is a zero argument function which
  8261. display the actual ordering.
  8262. {\small\begin{verbatim}
  8263. KORDER x,y,z;
  8264. KORDERLIST; ==> (x,y,z)
  8265. \end{verbatim}}
  8266. \item[iv.] A function \f{SIMPLIFY}\ttindex{SIMPLIFY} which takes an
  8267. arbitrary expression
  8268. is available which {\em forces} down-to-the-bottom simplification of
  8269. an expression. It is useful with \f{SYMMETRIZE}. It has also proved
  8270. useful to simplify some output expressions of the package EXCALC
  8271. (chapter~\ref{EXCALC}).
  8272. {\small\begin{verbatim}
  8273. l:=op(x,y,z)$
  8274. op(x,y,z):=x*y*z$
  8275. SYMMETRIZE(l,op,cyclicpermlist); ==>
  8276. op(x,y,z)+op(y,z,x)+op(z,x,y)
  8277. SIMPLIFY ws; ==> op(y,z,x)+op(z,x,y)+x*y*z
  8278. \end{verbatim}}
  8279. \item[v.] Filtering functions for lists.
  8280. \f{CHECKPROLIST}\ttindex{CHECKPROLIST} is a boolean function which
  8281. checks if the elements of a list have a definite property. Its first
  8282. argument is the list, and its second argument is a boolean function
  8283. (\f{FIXP NUMBERP $\ldots$}) or an ordering function (as \f{ORDP}).
  8284. \f{EXTRACTLIST}\ttindex{EXTRACTLIST} extracts from the list given as
  8285. its first argument the elements which satisfy the boolean function
  8286. given as its second argument.
  8287. {\small\begin{verbatim}
  8288. l:={1,a,b,"st")$
  8289. EXTRACTLIST(l,fixp); ==> {1}
  8290. EXTRACTLIST(l,stringp); ==> {st}
  8291. \end{verbatim}}
  8292. \end{itemize}
  8293. \section{Properties and Flags}
  8294. It may be useful to provide analogous functions in algebraic mode to
  8295. the properties and flags of LISP. Just using the symbolic mode
  8296. functions to alter property lists of objects may easily destroy the
  8297. integrity of the system. The functions which are here described {\bf
  8298. do ignore} the property list and flags already defined by the system
  8299. itself. They generate and track the {\em additional properties and
  8300. flags} that the user issues using them. They offer the possibility of
  8301. working on property lists in an algebraic context.
  8302. \begin{description}
  8303. \item[i. Flags]
  8304. To a given identifier, one may
  8305. associates another one linked to it ``in the background''. The three
  8306. functions \f{PUTFLAG}\ttindex{PUTFLAG},
  8307. \f{DISPLAYFLAG}\ttindex{DISPLAYFLAG} and
  8308. \f{CLEARFLAG}\ttindex{CLEARFLAG} handle them.
  8309. \f{PUTFLAG} has 3 arguments. The first is the identifier or a list
  8310. of identifiers, the second is the name of the flag,
  8311. the third is T (true) or 0 (zero).
  8312. When the third argument is T, it creates the flag, when it is 0 it
  8313. destroys it.
  8314. {\small\begin{verbatim}
  8315. PUTFLAG(z1,flag_name,t); ==> flag_name
  8316. PUTFLAG({z1,z2},flag1_name,t); ==> t
  8317. PUTFLAG(z2,flag1_name,0); ==>
  8318. \end{verbatim}}
  8319. \f{DISPLAYFLAG} allows to extract flags. Continuing the example:
  8320. {\small\begin{verbatim}
  8321. DISPLAYFLAG z1; ==> {flag_name,flag1_name}
  8322. DISPLAYFLAG z2; ==> {}
  8323. \end{verbatim}}
  8324. \f{CLEARFLAG} is a command which clears {\em all} flags associated to
  8325. the identifiers $id_1, \ldots , id_n$.
  8326. \item[ii. Properties]
  8327. \f{PUTPROP}\ttindex{PUTPROP} has four arguments. The second argument
  8328. is the {\em indicator} of the property. The third argument may
  8329. be {\em any valid expression}. The fourth one is also T or 0.
  8330. {\small\begin{verbatim}
  8331. PUTPROP(z1,property,x^2,t); ==> z1
  8332. \end{verbatim}}
  8333. In general, one enter
  8334. {\small\begin{verbatim}
  8335. PUTPROP(LIST(idp1,idp2,..),<propname>,<value>,T);
  8336. \end{verbatim}}
  8337. If the last argument is 0 then the property is removed.
  8338. To display a specific property, one uses
  8339. \f{DISPLAYPROP} which takes two arguments. The first is the name of the
  8340. identifier, the second is the indicator of the property.
  8341. {\small\begin{verbatim}
  8342. 2
  8343. DISPLAYPROP(z1,property); ==> {property,x }
  8344. \end{verbatim}}
  8345. Finally, \f{CLEARPROP} is a nary commmand which clears {\em all}
  8346. properties of the identifiers which appear as arguments.
  8347. \end{description}
  8348. \section{Control Functions}
  8349. The ASSIST package also provides additional functions which
  8350. improve the user control of the environment.
  8351. \begin{itemize}
  8352. \item[i.]
  8353. The first set of functions is composed of unary and binary boolean functions.
  8354. They are:
  8355. {\small\begin{verbatim}
  8356. ALATOMP x; x is anything.
  8357. ALKERNP x; x is anything.
  8358. DEPVARP(x,v); x is anything.
  8359. (v is an atom or a kernel)
  8360. \end{verbatim}}
  8361. \f{ALATOMP}\ttindex{ALATOMP} has the value T iff x is an integer or
  8362. an identifier {\em after} it has been evaluated down to the bottom.
  8363. \f{ALKERNP}\ttindex{ALKERNP} has the value T iff x is a kernel {\em
  8364. after} it has been evaluated down to the bottom.
  8365. \f{DEPVARP}\ttindex{DEPVARP} returns T iff the expression x depends on
  8366. v at {\bf any level}.
  8367. The above functions together with \f{PRECP}\ttindex{PRECP} have been
  8368. declared operator functions to ease the verification of their value.
  8369. \f{NORDP}\ttindex{NORDP} is essentially equivalent to \verb+not+\f{ORDP}
  8370. when inside a conditional statement. Otherwise, it can be used
  8371. while \verb+not+\f{ORDP} cannot.
  8372. \item[ii.]
  8373. The next functions allow one to {\em analyse} and to {\em clean} the
  8374. environment of \REDUCE\ which is created by the user while
  8375. working interactively. Two functions are provided:\\
  8376. \f{SHOW}\ttindex{SHOW} allows to get the various identifiers already
  8377. assigned and to see their type. \f{SUPPRESS}\ttindex{SUPPRESS}
  8378. selectively clears the used identifiers or clears them all. It is to
  8379. be stressed that identifiers assigned from the input of files are {\bf
  8380. ignored}. Both functions have one argument and the same options for
  8381. this argument:
  8382. {\small\begin{verbatim}
  8383. SHOW (SUPPRESS) all
  8384. SHOW (SUPPRESS) scalars
  8385. SHOW (SUPPRESS) lists
  8386. SHOW (SUPPRESS) saveids (for saved expressions)
  8387. SHOW (SUPPRESS) matrices
  8388. SHOW (SUPPRESS) arrays
  8389. SHOW (SUPPRESS) vectors
  8390. (contains vector, index and tvector)
  8391. SHOW (SUPPRESS) forms
  8392. \end{verbatim}}
  8393. The option \verb+all+ is the most convenient for \f{SHOW} but it may
  8394. takes time to get the answer after one has worked several hours.
  8395. When entering \REDUCE\ the option \verb+all+ for \f{SHOW} gives:
  8396. {\small\begin{verbatim}
  8397. SHOW all; ==> scalars are: NIL
  8398. arrays are: NIL
  8399. lists are: NIL
  8400. matrices are: NIL
  8401. vectors are: NIL
  8402. forms are: NIL
  8403. \end{verbatim}}
  8404. It is a convenient way to remember the various options.
  8405. Starting from a fresh environment
  8406. {\small\begin{verbatim}
  8407. a:=b:=1$
  8408. SHOW scalars; ==> scalars are: (A B)
  8409. SUPPRESS scalars; ==> t
  8410. SHOW scalars; ==> scalars are: NIL
  8411. \end{verbatim}}
  8412. \item[iii.]
  8413. The \f{CLEAR}\ttindex{CLEAR} function of the system does not do a
  8414. complete cleaning of \verb+OPERATORS+ and \verb+FUNCTIONS+. The
  8415. following two functions do a more complete cleaning and, also
  8416. automatically takes into account the {\em user} flag and properties that the
  8417. functions \f{PUTFLAG} and \f{PUTPROP} may have introduced.
  8418. Their names are \f{CLEAROP}\ttindex{CLEAROP} and
  8419. \f{CLEARFUNCTIONS}\ttindex{CLEARFUNCTIONS}.
  8420. \f{CLEAROP} takes one operator as its argument. \f{CLEARFUNCTIONS} is
  8421. a nary command. If one issues
  8422. {\small\begin{verbatim}
  8423. CLEARFUNCTIONS a1,a2, ... , an $
  8424. \end{verbatim}}
  8425. The functions with names \verb+ a1,a2, ... ,an+ are cleared.
  8426. One should be careful when using this facility since the
  8427. only functions which cannot be erased are those which are
  8428. protected with the \verb+lose+ flag.
  8429. \end{itemize}
  8430. \section{Handling of Polynomials}
  8431. The module contains some utility functions to handle
  8432. standard quotients and several new facilities to manipulate polynomials.
  8433. \begin{itemize}
  8434. \item[i.] Two functions \f{ALG\_TO\_SYMB}\ttindex{ALG\_TO\_SYMB} and
  8435. \f{SYMB\_TO\_ALG}\ttindex{SYMB\_TO\_ALG} allow the changing of an expression
  8436. which is in the algebraic standard quotient form into a prefix lisp
  8437. form and vice-versa. This is made
  8438. in such a way that the symbol \verb+list+ which appears in the
  8439. algebraic mode disappear in the symbolic form (there it becomes
  8440. a parenthesis ``()'' ) and it is reintroduced in the translation
  8441. from a symbolic prefix lisp expression to an algebraic one.
  8442. The following example shows how the well-known lisp function
  8443. \f{FLATTENS} can be trivially transportd into algebraic mode:
  8444. {\small\begin{verbatim}
  8445. algebraic procedure ecrase x;
  8446. lisp symb_to_alg flattens1 alg_to_symb algebraic x;
  8447. symbolic procedure flattens1 x;
  8448. % ll; ==> ((A B) ((C D) E))
  8449. % flattens1 ll; (A B C D E)
  8450. if atom x then list x else
  8451. if cdr x then
  8452. append(flattens1 car x, flattens1 cdr x)
  8453. else flattens1 car x;
  8454. \end{verbatim}}
  8455. gives, for instance,
  8456. {\small\begin{verbatim}
  8457. ll:={a,{b,{c},d,e},{{{z}}}}$
  8458. ECRASE ll; ==> {A, B, C, D, E, Z}
  8459. \end{verbatim}}
  8460. \item[ii.] \f{LEADTERM}\ttindex{LEADTERM} and
  8461. \f{REDEXPR}\ttindex{REDEXPR} are the algebraic equivalent of the
  8462. symbolic functions \f{LT} and \f{RED}. They give the
  8463. {\em leading term} and the {\em reductum} of a polynomial. They also
  8464. work for rational functions. Their interest lies in the fact that they
  8465. do not require to extract the main variable. They work according to
  8466. the current ordering of the system:
  8467. {\small\begin{verbatim}
  8468. pol:=x+y+z$
  8469. LEADTERM pol; ==> x
  8470. korder y,x,z;
  8471. LEADTERM pol; ==> y
  8472. REDEXPR pol; ==> x + z
  8473. \end{verbatim}}
  8474. By default, the representation of multivariate polynomials is recursive.
  8475. With such a representation, the function \f{LEADTERM} does not necessarily
  8476. extract a true monom. It extracts a monom in the leading indeterminate
  8477. multiplied by a polynomial in the other indeterminates. However, very often
  8478. one needs to handle true monoms separately. In that case, one needs a
  8479. polynomial in {\em distributive} form. Such a form is provided by the
  8480. package GROEBNER (chapter~\ref{GROEBNER}). The facility there may be
  8481. too involved and the need to load an additional package can be a
  8482. problem. So,
  8483. a new switch is created to handle {\em distributed} polynomials. It is
  8484. called {\tt DISTRIBUTE}\ttindex{DISTRIBUTE} and a new function
  8485. \label{DISTRIBUTE} \f{DISTRIBUTE} puts a polynomial in distributive
  8486. form. With the switch {\bf on}, \f{LEADTERM} gives {\bf true} monoms.
  8487. \f{MONOM}\ttindex{MONOM} transforms a polynomial into a list of
  8488. monoms. It works whatever the setting of the switch {\tt DISTRIBUTE}.
  8489. \f{SPLITTERMS}\ttindex{SPLITTERMS} is analoguous to \f{MONOM} except
  8490. that it gives a list of two lists. The first sublist contains the
  8491. positive terms while the second sublist contains the negative terms.
  8492. \f{SPLITPLUSMINUS}\ttindex{SPLITPLUSMINUS} gives a list whose first
  8493. element is an expression of the positive part of the polynomial and
  8494. its second element is its negative part.
  8495. \item[iii.]
  8496. Two complementary functions \f{LOWESTDEG}\ttindex{LOWESTDEG} and
  8497. \f{DIVPOL}\ttindex{DIVPOL} are provided.
  8498. The first takes a polynomial as its first argument and the name of an
  8499. indeterminate as its second argument. It returns the {\em lowest degree}
  8500. in that indeterminate. The second function takes two polynomials and
  8501. returns both the quotient and its remainder.
  8502. \end{itemize}
  8503. \section{Handling of Transcendental Functions}
  8504. The functions \f{TRIGREDUCE}\ttindex{TRIGREDUCE} and
  8505. \f{TRIGEXPAND}\ttindex{TRIGEXPAND} and the equivalent
  8506. ones for hyperbolic functions \f{HYPREDUCE}\ttindex{HYPREDUCE} and
  8507. \f{HYPEXPAND}\ttindex{HYPEXPAND}
  8508. make the transformations to multiple arguments and from
  8509. multiple arguments to elementary arguments.
  8510. {\small\begin{verbatim}
  8511. aa:=sin(x+y)$
  8512. TRIGEXPAND aa; ==> SIN(X)*COS(Y) + SIN(Y)*COS(X)
  8513. TRIGREDUCE ws; ==> SIN(Y + X)
  8514. \end{verbatim}}
  8515. When a trigonometric or hyperbolic expression is symmetric with
  8516. respect to the interchange of {\tt SIN (SINH)} and {\tt COS (COSH)},
  8517. the application of \f{TRIG(HYP)REDUCE} may often lead to great
  8518. simplifications. However, if it is highly asymmetric, the repeated
  8519. application of \f{TRIG(HYP)REDUCE} followed by the use of
  8520. \f{TRIG(HYP)EXPAND} will lead to {\em more} complicated
  8521. but more symmetric expressions:
  8522. {\small\begin{verbatim}
  8523. aa:=(sin(x)^2+cos(x)^2)^3$
  8524. TRIGREDUCE aa; ==> 1
  8525. bb:=1+sin(x)^3$
  8526. TRIGREDUCE bb; ==>
  8527. - SIN(3*X) + 3*SIN(X) + 4
  8528. ---------------------------
  8529. 4
  8530. TRIGEXPAND ws; ==>
  8531. 3 2
  8532. SIN(X) - 3*SIN(X)*COS(X) + 3*SIN(X) + 4
  8533. -------------------------------------------
  8534. 4
  8535. \end{verbatim}}
  8536. See also the TRIGSIMP package (chapter~\ref{TRIGSIMP}).
  8537. \section{Coercion from lists to arrays and converse}
  8538. Sometimes when a list is very long and especially if frequent access
  8539. to its elements are needed it is advantageous (temporarily) to
  8540. transform it into an array.
  8541. \f{LIST\_TO\_ARRAY}\ttindex{LIST\_TO\_ARRAY} has three arguments. The
  8542. first is the list. The second is an integer which indicates the array
  8543. dimension required. The third is the name of an identifier which will
  8544. play the role of the array name generated by it. If the chosen
  8545. dimension is not compatible with the list depth and structure an error
  8546. message is issued. \f{ARRAY\_TO\_LIST}\ttindex{ARRAY\_TO\_LIST} does
  8547. the opposite coercion. It takes the array name as its sole argument.
  8548. \section{Handling of n--dimensional Vectors}
  8549. Explicit vectors in {\tt EUCLIDEAN} space may be represented by
  8550. list-like or bag-like objects of depth 1. The components may be bags
  8551. but may {\bf not} be lists. Functions are provided to do the sum, the
  8552. difference and the scalar product. When space-dimension is three
  8553. there are also functions for the cross and mixed products.
  8554. \f{SUMVECT}\ttindex{SUMVECT}, \f{MINVECT}\ttindex{MINVECT},
  8555. \f{SCALVECT}\ttindex{SCALVECT}, \f{CROSSVECT}\ttindex{CROSSVECT} have
  8556. two arguments. \f{MPVECT}\ttindex{MPVECT} has three arguments.
  8557. {\small\begin{verbatim}
  8558. l:={1,2,3}$
  8559. ll:=list(a,b,c)$
  8560. SUMVECT(l,ll); ==> {A + 1,B + 2,C + 3}
  8561. MINVECT(l,ll); ==> { - A + 1, - B + 2, - C + 3}
  8562. SCALVECT(l,ll); ==> A + 2*B + 3*C
  8563. CROSSVECT(l,ll); ==> { - 3*B + 2*C,3*A - C, - 2*A + B}
  8564. MPVECT(l,ll,l); ==> 0
  8565. \end{verbatim}}
  8566. \section{Handling of Grassmann Operators}
  8567. \index{Grassmann Operators}
  8568. Grassman variables are often used in physics. For them the
  8569. multiplication operation is associative, distributive but
  8570. anticommutative. The basic \REDUCE\ does not provide this.
  8571. However implementing it in full generality would almost certainly
  8572. decrease the overall efficiency of the system. This small module
  8573. together with the declaration of antisymmetry for operators is enough
  8574. to deal with most calculations. The reason is, that a product of
  8575. similar anticommuting kernels can easily be transformed into an
  8576. antisymmetric operator with as many indices as the number of these
  8577. kernels. Moreover, one may also issue pattern matching rules to
  8578. implement the anticommutativity of the product. The functions in this
  8579. module represent the minimum functionality required to identify them
  8580. and to handle their specific features.
  8581. \f{PUTGRASS}\ttindex{PUTGRASS} is a (nary) command which give
  8582. identifiers the property to be the names of Grassmann kernels.
  8583. \f{REMGRASS}\ttindex{REMGRASS} removes this property.
  8584. \f{GRASSP}\ttindex{GRASSP} is a boolean function which detects
  8585. Grassmann kernels.
  8586. \f{GRASSPARITY}\ttindex{GRASSPARITY} takes a {\bf monom} as argument
  8587. and gives its parity. If the monom is a simple Grassmann kernel it
  8588. returns 1.
  8589. \f{GHOSTFACTOR}\ttindex{GHOSTFACTOR} has two arguments. Each one is a
  8590. monom. It is equal to
  8591. {\small\begin{verbatim}
  8592. (-1)**(GRASSPARITY u * GRASSPARITY v)
  8593. \end{verbatim}}
  8594. Here is an illustration to show how the above functions work:
  8595. {\small\begin{verbatim}
  8596. PUTGRASS eta;
  8597. if GRASSP eta(1) then "Grassmann kernel"; ==>
  8598. Grassmann kernel
  8599. aa:=eta(1)*eta(2)-eta(2)*eta(1); ==>
  8600. AA := - ETA(2)*ETA(1) + ETA(1)*ETA(2)
  8601. GRASSPARITY eta(1); ==> 1
  8602. GRASSPARITY (eta(1)*eta(2)); ==> 0
  8603. GHOSTFACTOR(eta(1),eta(2)); ==> -1
  8604. grasskernel:=
  8605. {eta(~x)*eta(~y) => -eta y * eta x when nordp(x,y),
  8606. (~x)*(~x) => 0 when grassp x}$
  8607. exp:=eta(1)^2$
  8608. exp where grasskernel; ==> 0
  8609. aa where grasskernel; ==> - 2*ETA(2)*ETA(1)
  8610. \end{verbatim}}
  8611. \section{Handling of Matrices}
  8612. There are additional facilities for matrices.
  8613. \begin{itemize}
  8614. \item[i.]
  8615. Often one needs to construct some {\tt UNIT} matrix of
  8616. a given dimension. This construction is performed by the function
  8617. \f{UNITMAT}\ttindex{UNITMAT}. It is a nary function. The command is
  8618. {\small\begin{verbatim}
  8619. UNITMAT M1(n1), M2(n2), .....Mi(ni) ;
  8620. \end{verbatim}}
  8621. where \verb+M1,...Mi+ are names of matrices and
  8622. \verb+ n1, n2, ..., ni+ are integers.
  8623. \f{MKIDM}\ttindex{MKIDM} is a generalisation of
  8624. \f{MKID}\ttindex{MKID}. It allows the indexing of matrix names. If
  8625. \verb+u+ and \verb+u1+ are two matrices, one can go from one to the
  8626. other:
  8627. {\small\begin{verbatim}
  8628. matrix u(2,2);$ unitmat u1(2)$
  8629. u1; ==>
  8630. [1 0]
  8631. [ ]
  8632. [0 1]
  8633. mkidm(u,1); ==>
  8634. [1 0]
  8635. [ ]
  8636. [0 1]
  8637. \end{verbatim}}
  8638. Note: MKIDM(V,1) will fail even if the matrix V1 exists, unless V is
  8639. also a matrix.
  8640. This function allows to make loops on matrices like the following.
  8641. If \verb+U, U1, U2,.., U5+ are matrices:
  8642. {\small\begin{verbatim}
  8643. FOR I:=1:5 DO U:=U-MKIDM(U,I);
  8644. \end{verbatim}}
  8645. \item[ii.]
  8646. The next functions map matrices onto bag-like or list-like objects
  8647. and conversely they generate matrices from bags or lists.
  8648. \f{COERCEMAT}\ttindex{COERCEMAT} transforms the matrix first argument
  8649. into a list of lists.
  8650. {\small\begin{verbatim}
  8651. COERCEMAT(U,id)
  8652. \end{verbatim}}
  8653. When \verb+id+ is \verb+list+ the matrix is transformed into a list of
  8654. lists. Otherwise it transforms it into a bag of bags whose envelope is
  8655. equal to \verb+id+.
  8656. \f{BAGLMAT}\ttindex{BAGLMAT} does the inverse. The {\bf first}
  8657. argument is the bag-like or list-like object while the second argument
  8658. is the matrix identifier.
  8659. {\small\begin{verbatim}
  8660. BAGLMAT(bgl,U)
  8661. \end{verbatim}}
  8662. \verb+bgl+ becomes the matrix \verb+U+. The transformation is
  8663. {\bf not} done if \verb+U+ is {\em already} the name of a
  8664. previously defined matrix, to avoid accidental redefinition
  8665. of that matrix.
  8666. \item[ii.]
  8667. The functions \f{SUBMAT}\ttindex{SUBMAT},
  8668. \f{MATEXTR}\ttindex{MATEXTR}, \f{MATEXTC}\ttindex{MATEXTC} take parts
  8669. of a given matrix.
  8670. \f{SUBMAT} has three arguments.
  8671. {\small\begin{verbatim}
  8672. SUBMAT(U,nr,nc)
  8673. \end{verbatim}}
  8674. The first is the matrix name, and the other two are the row and column
  8675. numbers. It gives the submatrix obtained from \verb+U+ deleting the
  8676. row \verb+nr+ and the column \verb+nc+. When one of them is equal to
  8677. zero only column \verb+nc+ or row \verb+nr+ is deleted.
  8678. \f{MATEXTR} and \f{MATEXTC} extract a row or a column and place it into
  8679. a list-like or bag-like object.
  8680. {\small\begin{verbatim}
  8681. MATEXTR(U,VN,nr)
  8682. MATEXTC(U,VN,nc)
  8683. \end{verbatim}}
  8684. where \verb+U+ is the matrix, \verb+VN+ is the ``vector name'',
  8685. \verb+nr+ and \verb+nc+ are integers. If \verb+VN+ is equal
  8686. to {\tt list} the vector is given as a list otherwise it is
  8687. given as a bag.
  8688. \item[iii.]
  8689. Functions which manipulate matrices: \f{MATSUBR}\ttindex{MATSUBR},
  8690. \f{MATSUBC}\ttindex{MATSUBC}, \f{HCONCMAT}\ttindex{HCONCMAT},
  8691. \f{VCONCMAT}\ttindex{VCONCMAT}, \f{TPMAT}\ttindex{TPMAT},
  8692. \f{HERMAT}\ttindex{HERMAT}.
  8693. \f{MATSUBR} and \f{MATSUBC} substitute rows and columns. They have
  8694. three arguments.
  8695. {\small\begin{verbatim}
  8696. MATSUBR(U,bgl,nr)
  8697. MATSUBC(U,bgl,nc)
  8698. \end{verbatim}}
  8699. The meaning of the variables \verb+U, nr, nc+ is the same as above
  8700. while \verb+bgl+ is a list-like or bag-like vector.
  8701. Its length should be compatible with the dimensions of the matrix.
  8702. \f{HCONCMAT} and \f{VCONCMAT} concatenate two matrices.
  8703. {\small\begin{verbatim}
  8704. HCONCMAT(U,V)
  8705. VCONCMAT(U,V)
  8706. \end{verbatim}}
  8707. The first function concatenates horizontally, the second one
  8708. concatenates vertically. The dimensions must match.
  8709. \f{TPMAT} makes the tensor product of two matrices. It is also an
  8710. {\em infix} function.
  8711. {\small\begin{verbatim}
  8712. TPMAT(U,V) or U TPMAT V
  8713. \end{verbatim}}
  8714. \f{HERMAT} takes the hermitian conjugate of a matrix
  8715. {\small\begin{verbatim}
  8716. HERMAT(U,HU)
  8717. \end{verbatim}}
  8718. where \verb+HU+ is the identifier for the hermitian matrix of
  8719. \verb+U+. It should {\bf unassigned} for this function to work
  8720. successfully. This is done on purpose to prevent accidental
  8721. redefinition of an already used identifier.
  8722. \item[iv.]
  8723. \f{SETELMAT} and \f{GETELMAT} are functions of two integers. The first
  8724. one reset the element \verb+(i,j)+ while the second one extract an
  8725. element identified by \verb+(i,j)+. They may be useful when
  8726. dealing with matrices {\em inside procedures}.
  8727. \end{itemize}
  8728. \chapter[ATENSOR: Tensor Simplification]%
  8729. {ATENSOR: Package for Tensor Simplification}
  8730. \label{ATENSOR}
  8731. \typeout{{ATENSOR: Package for Tensor Simplification}}
  8732. {\footnotesize
  8733. \begin{center}
  8734. V.~A.~Ilyin and A.~P.~Kryukov \\
  8735. \end{center}
  8736. }
  8737. \ttindex{ATENSOR}
  8738. %\markboth{CHAPTER \ref{ATENSOR}. ATENSOR: TENSOR SIMPLIFICATION}{}
  8739. %\thispagestyle{myheadings}
  8740. Tensors are classical examples for Objects often used in mathematics and physics.
  8741. Indexed objects can have very complicated and intricated properties.
  8742. For example the Riemann tensor has symmetry properties with respect to
  8743. permutation of indices. Moreover it satisfies the cyclic identity. There are a
  8744. number of linear identities with many terms in the case of Riemann-Cartan geometry
  8745. with torsion.
  8746. From the user's point of view, there are three groups of tensor properties:
  8747. \begin{itemize}
  8748. \item {\bf S} - symmetry with respect to index permutation;
  8749. \item {\bf I} - linear identities;
  8750. \item {\bf D} - invariance with respect to renamings of dummy indices;
  8751. \end{itemize}
  8752. The problem under investigation can be formulated as whether two tensor
  8753. expressions are equal or not by taking into account S-I-D properties.
  8754. \section{Basic tensors and tensor expressions}
  8755. Under basic tensors we understand the object with finite number of indices
  8756. which can have such properties as {\it symmetry} and {\it multiterm linear identities}
  8757. (including the {\it symmetry relations}). \\
  8758. Under tensor expression we understand any expression which can be obtained
  8759. from basic tensors by summation with integer coefficients and multiplication
  8760. (commutative) of basic tensors. \\
  8761. It is assumed that all terms in the tensor expression have the same number of
  8762. indices. Some pairs of them are marked as dummy ones. The set of nondummy
  8763. names have to be the same for each term in the tensor expression. The names
  8764. of dummies can be arbitrary.
  8765. \section{Operators for tensors}
  8766. Use \f{TENSOR}\ttindex{TENSOR} to declare tensors and \f{TCLEAR}\ttindex{TCLEAR}
  8767. to remove them. The command \f{TSYM}\ttindex{TSYM} defines symmetry relations of basic
  8768. tensors and \f{KBASIS}\ttindex{KBASIS} determines the
  8769. {\bf K}-Basis, which is the general name for a ``triangle'' set of linear independent
  8770. vectors for a basic tensor considered as a separate tensor expression.
  8771. It is possible to build the sum, the difference and the multiplication for tensors.
  8772. It is assumed that indices with identical names means the summation over their values. \par
  8773. {\bf Example}:
  8774. {\small\begin{verbatim}
  8775. 1: load atensor;
  8776. 2: tensor s2,a3;
  8777. 3: tsym s2(i,j) - s2(j,i), % Symmetric
  8778. 3: a3(i,j,k) + a3(j,i,k), % Antisymm.
  8779. 3: a3(i,j,k) - a3(j,k,i);
  8780. 4: kbasis s2,a3;
  8781. s2(j,i) + (-1)*s2(i,j)
  8782. 1
  8783. a3(k,i,j) + a3(j,i,k)
  8784. a3(k,j,i) + (-1)*a3(j,i,k)
  8785. a3(i,k,j) + (-1)*a3(j,i,k)
  8786. a3(i,j,k) + a3(j,i,k)
  8787. a3(j,k,i) + a3(j,i,k)
  8788. 5
  8789. \end{verbatim}}
  8790. \section{Switches}
  8791. There are two switches defined. The switch \f{DUMMYPRI}\ttindex{DUMMYPRI} prints dummy
  8792. indices with internal names and numbers. It's default value is {\tt OFF}.
  8793. The other switch called \f{SHORTEST}\ttindex{SHORTEST} prints tensor expressions in shortest
  8794. form that was produced during evaluation. The default value is {\tt OFF}. \par
  8795. \ \\
  8796. For further information refer to the documentation which comes with this package.
  8797. \chapter[AVECTOR: Vector Algebra]%
  8798. {AVECTOR: A vector algebra and calculus package}
  8799. \label{AVECTOR}
  8800. \typeout{{AVECTOR: Vector Algebra}}
  8801. {\footnotesize
  8802. \begin{center}
  8803. David Harper \\
  8804. Astronomy Unit, Queen Mary and Westfield College \\
  8805. University of London \\
  8806. Mile End Road \\
  8807. London E1 4NS, England \\[0.05in]
  8808. e--mail: adh@star.qmw.ac.uk
  8809. \end{center}
  8810. }
  8811. \ttindex{AVECTOR}
  8812. This package provides \REDUCE\ with the ability to perform vector
  8813. algebra using the same notation as scalar algebra. The basic
  8814. algebraic operations are supported, as are differentiation and
  8815. integration of vectors with respect to scalar variables, cross product
  8816. and dot product, component manipulation and application of scalar
  8817. functions ({\em e.g.} cosine) to a vector to yield a vector result.
  8818. \section{Vector declaration and initialisation}
  8819. To declare a list of names to be vectors use the VEC command:
  8820. \index{VEC command}
  8821. {\small\begin{verbatim}
  8822. VEC A,B,C;
  8823. \end{verbatim}}
  8824. declares the variables {\tt A}, {\tt B} and {\tt C} to be vectors.
  8825. If they have already been assigned (scalar) values, these will be lost.
  8826. When a vector is declared using the {\tt VEC} command, it does not
  8827. have an initial value.
  8828. If a vector value is assigned to a scalar variable, then that
  8829. variable will automatically be declared as a vector and the
  8830. user will be notified that this has happened.
  8831. \index{AVEC function}
  8832. A vector may be initialised using the {\tt AVEC} function which
  8833. takes three scalar arguments and returns a vector made up
  8834. from those scalars. For example
  8835. {\small\begin{verbatim}
  8836. A := AVEC(A1, A2, A3);
  8837. \end{verbatim}}
  8838. sets the components of the vector {\tt A} to {\tt A1}, {\tt A2} and
  8839. {\tt A3}.
  8840. \section{Vector algebra}
  8841. (In the examples which follow, {\tt V}, {\tt V1}, {\tt V2} {\em etc}
  8842. are assumed to be vectors while {\tt S}, {\tt S1}, {\tt S2} etc are
  8843. scalars.)
  8844. \index{+ ! vector}\index{- ! vector}\index{* ! vector}\index{/ ! vector}
  8845. The scalar algebra operators +,-,* and / may be used with
  8846. vector operands according to the rules of vector algebra.
  8847. Thus multiplication and division of a vector by a scalar
  8848. are both allowed, but it is an error to multiply or
  8849. divide one vector by another.
  8850. \begin{tabular}{l l}
  8851. {\tt V := V1 + V2 - V3;} & Addition and subtraction \\
  8852. {\tt V := S1*3*V1;} & Scalar multiplication \\
  8853. {\tt V := V1/S;} & Scalar division \\
  8854. {\tt V := -V1;} & Negation \\
  8855. \end{tabular}
  8856. \index{DOT ! vector}\index{Dot product}\index{CROSS ! vector}
  8857. \index{cross product}
  8858. \noindent Vector multiplication is carried out using the infix
  8859. operators {\tt DOT} and {\tt CROSS}. These are defined to have
  8860. higher precedence than scalar multiplication and
  8861. division.
  8862. \begin{tabular}{l l}
  8863. {\tt V := V1 CROSS V2;} & Cross product \\
  8864. {\tt S := V1 DOT V2;} & Dot product \\
  8865. {\tt V := V1 CROSS V2 + V3;} & \\
  8866. {\tt V := (V1 CROSS V2) + V3;} & \\
  8867. \end{tabular}
  8868. The last two expressions are equivalent due to the precedence of
  8869. the {\tt CROSS} operator.
  8870. \index{VMOD operator}
  8871. The modulus of a vector may be calculated using the {\tt VMOD} operator.
  8872. {\small\begin{verbatim}
  8873. S := VMOD V;
  8874. \end{verbatim}}
  8875. A unit vector may be generated from any vector using the {\tt VMOD}
  8876. operator.
  8877. {\small\begin{verbatim}
  8878. V1 := V/(VMOD V);
  8879. \end{verbatim}}
  8880. Components may be extracted from any vector using index notation
  8881. in the same way as an array.
  8882. \begin{tabular}{l l}
  8883. {\tt V := AVEC(AX, AY, AZ);} & \\
  8884. {\tt V(0);} & yields AX \\
  8885. {\tt V(1);} & yields AY \\
  8886. {\tt V(2);} & yields AZ \\
  8887. \end{tabular}
  8888. It is also possible to set values of individual components. Following
  8889. from above:
  8890. {\small\begin{verbatim}
  8891. V(1) := B;
  8892. \end{verbatim}}
  8893. The vector {\tt V} now has components {\tt AX}, {\tt B}, {\tt AZ}.
  8894. \index{vector ! differentiation}
  8895. \index{vector ! integration}
  8896. \index{differentiation ! vector}
  8897. \index{differentiation ! vector}
  8898. Vectors may be used as arguments in the differentiation and
  8899. integration routines in place of the dependent expression.
  8900. \begin{tabular}{l l}
  8901. {\tt V := AVEC(X**2, SIN(X), Y);} & \\
  8902. {\tt DF(V,X);} & yields (2*X, COS(X), 0) \\
  8903. {\tt INT(V,X);} & yields (X**3/3, -COS(X), Y*X) \\
  8904. \end{tabular}
  8905. Vectors may be given as arguments to monomial functions such as {\tt
  8906. SIN}, {\tt LOG} and {\tt TAN}. The result is a vector obtained by
  8907. applying the function component-wise to the argument vector.
  8908. \begin{tabular}{l l}
  8909. {\tt V := AVEC(A1, A2, A3);} & \\
  8910. {\tt SIN(V);} & yields (SIN(A1), SIN(A2), SIN(A3)) \\
  8911. \end{tabular}
  8912. \section{Vector calculus}
  8913. \index{DIV ! operator}\index{divergence ! vector field}
  8914. \index{GRAD ! operator}\index{gradient ! vector field}
  8915. \index{CURL ! operator}\index{curl ! vector field}
  8916. \index{DELSQ ! operator}\index{Laplacian ! vector field}
  8917. The vector calculus operators div, grad and curl are recognised.
  8918. The Laplacian operator is also available and may be applied to
  8919. scalar and vector arguments.
  8920. \begin{tabular}{l l}
  8921. {\tt V := GRAD S;} & Gradient of a scalar field \\
  8922. {\tt S := DIV V;} & Divergence of a vector field \\
  8923. {\tt V := CURL V1;} & Curl of a vector field \\
  8924. {\tt S := DELSQ S1;} & Laplacian of a scalar field \\
  8925. {\tt V := DELSQ V1;} & Laplacian of a vector field \\
  8926. \end{tabular}
  8927. These operators may be used in any orthogonal curvilinear coordinate
  8928. system. The user may alter the names of the coordinates and the values
  8929. of the scale factors. Initially the coordinates are {\tt X}, {\tt Y}
  8930. and {\tt Z} and the scale factors are all unity.
  8931. \index{COORDS vector}\index{HFACTORS scale factors}
  8932. There are two special vectors : {\tt COORDS} contains the names
  8933. of the coordinates in the current system and {\tt HFACTORS}
  8934. contains the values of the scale factors.
  8935. \index{COORDINATES operator}
  8936. The coordinate names may be changed using the {\tt COORDINATES}
  8937. operator.
  8938. {\small\begin{verbatim}
  8939. COORDINATES R,THETA,PHI;
  8940. \end{verbatim}}
  8941. This command changes the coordinate names to {\tt R}, {\tt THETA} and
  8942. {\tt PHI}.
  8943. \index{SCALEFACTORS operator}
  8944. The scale factors may be altered using the {\tt SCALEFACTORS} operator.
  8945. {\small\begin{verbatim}
  8946. SCALEFACTORS(1,R,R*SIN(THETA));
  8947. \end{verbatim}}
  8948. This command changes the scale factors to {\tt 1}, {\tt R} and {\tt R
  8949. SIN(THETA)}.
  8950. Note that the arguments of {\tt SCALEFACTORS} must be enclosed in
  8951. parentheses. This is not necessary with {\tt COORDINATES}.
  8952. When vector differential operators are applied to an expression,
  8953. the current set of coordinates are used as the independent
  8954. variables and the scale factors are employed in the calculation.
  8955. %%(See, for example, Batchelor G.K. 'An Introduction to Fluid
  8956. %%Mechanics', Appendix 2.)
  8957. \index{"!*CSYSTEMS global (AVECTOR)}
  8958. Several coordinate systems are pre-defined and may be invoked by
  8959. name. To see a list of valid names enter
  8960. {\small\begin{verbatim}
  8961. SYMBOLIC !*CSYSTEMS;
  8962. \end{verbatim}}
  8963. and \REDUCE\ will respond with something like
  8964. {\small\begin{verbatim}
  8965. (CARTESIAN SPHERICAL CYLINDRICAL)
  8966. \end{verbatim}}
  8967. \index{GETCSYSTEM command}
  8968. To choose a coordinate system by name, use the command {\tt GETCSYSTEM}.
  8969. To choose the Cartesian coordinate system :
  8970. {\small\begin{verbatim}
  8971. GETCSYSTEM 'CARTESIAN;
  8972. \end{verbatim}}
  8973. \index{PUTCSYSTEM command}
  8974. Note the quote which prefixes the name of the coordinate system. This
  8975. is required because {\tt GETCSYSTEM} (and its complement {\tt
  8976. PUTCSYSTEM}) is a {\tt SYMBOLIC} procedure which requires a literal
  8977. argument.
  8978. \REDUCE\ responds by typing a list of the coordinate names in that
  8979. coordinate system. The example above would produce the response
  8980. {\small\begin{verbatim}
  8981. (X Y Z)
  8982. \end{verbatim}}
  8983. whilst
  8984. {\small\begin{verbatim}
  8985. GETCSYSTEM 'SPHERICAL;
  8986. \end{verbatim}}
  8987. would produce
  8988. {\small\begin{verbatim}
  8989. (R THETA PHI)
  8990. \end{verbatim}}
  8991. Note that any attempt to invoke a coordinate system is subject to the
  8992. same restrictions as the implied calls to {\tt COORDINATES} and {\tt
  8993. SCALEFACTORS}. In particular, {\tt GETCSYSTEM} fails if any of the
  8994. coordinate names has been assigned a value and the previous coordinate
  8995. system remains in effect.
  8996. A user-defined coordinate system can be assigned a name using the
  8997. command {\tt PUTCSYSTEM}. It may then be re-invoked at a later stage using
  8998. {\tt GETCSYSTEM}.
  8999. \example\index{AVECTOR package ! example}
  9000. We define a general coordinate system with coordinate names {\tt
  9001. X},{\tt Y},{\tt Z} and scale factors {\tt H1},{\tt H2},{\tt H3} :
  9002. {\small\begin{verbatim}
  9003. COORDINATES X,Y,Z;
  9004. SCALEFACTORS(H1,H2,H3);
  9005. PUTCSYSTEM 'GENERAL;
  9006. \end{verbatim}}
  9007. This system may later be invoked by entering
  9008. {\small\begin{verbatim}
  9009. GETCSYSTEM 'GENERAL;
  9010. \end{verbatim}}
  9011. \section{Volume and Line Integration}
  9012. Several functions are provided to perform volume and line integrals.
  9013. These operate in any orthogonal curvilinear coordinate system and
  9014. make use of the scale factors described in the previous section.
  9015. Definite integrals of scalar and vector expressions may be calculated
  9016. using the {\tt DEFINT} function\footnote{Not to be confused with the
  9017. DEFINT package described in chapter~\ref{DEFINT}}.
  9018. \example\index{AVECTOR package ! example}
  9019. \index{DEFINT function}\index{integration ! definite (simple)}
  9020. \index{definite integration (simple)}
  9021. \noindent To calculate the definite integral of $\sin(x)^2$ between 0 and
  9022. 2$\pi$ we enter
  9023. {\small\begin{verbatim}
  9024. DEFINT(SIN(X)**2,X,0,2*PI);
  9025. \end{verbatim}}
  9026. This function is a simple extension of the {\tt INT} function taking
  9027. two extra arguments, the lower and upper bounds of integration
  9028. respectively.
  9029. \index{VOLINTEGRAL function}\index{integration ! volume}
  9030. Definite volume integrals may be calculated using the {\tt
  9031. VOLINTEGRAL} function whose syntax is as follows :
  9032. \noindent {\tt VOLINTEGRAL}({\tt integrand}, vector {\tt lower-bound},
  9033. vector {\tt upper-bound});
  9034. \example\index{AVECTOR package ! example}
  9035. \noindent In spherical polar coordinates we may calculate the volume of a
  9036. sphere by integrating unity over the range $r$=0 to {\tt RR}, $\theta$=0 to
  9037. {\tt PI}, $\phi$=0 to 2*$\pi$ as follows :
  9038. \begin{tabular}{l l}
  9039. {\tt VLB := AVEC(0,0,0);} & Lower bound \\
  9040. {\tt VUB := AVEC(RR,PI,2*PI);} & Upper bound in $r, \theta, \phi$
  9041. respectively \\
  9042. {\tt VOLINTORDER := (0,1,2);} & The order of integration \\
  9043. {\tt VOLINTEGRAL(1,VLB,VUB);} & \\
  9044. \end{tabular}
  9045. \index{VOLINTORDER vector}
  9046. Note the use of the special vector {\tt VOLINTORDER} which controls
  9047. the order in which the integrations are carried out. This vector
  9048. should be set to contain the number 0, 1 and 2 in the required order.
  9049. The first component of {\tt VOLINTORDER} contains the index of the
  9050. first integration variable, the second component is the index of the
  9051. second integration variable and the third component is the index of
  9052. the third integration variable.
  9053. \example\index{AVECTOR package ! example}
  9054. Suppose we wish to calculate the volume of a right circular cone. This
  9055. is equivalent to integrating unity over a conical region with the
  9056. bounds:
  9057. \begin{tabular}{l l}
  9058. z = 0 to H & (H = the height of the cone) \\
  9059. r = 0 to pZ & (p = ratio of base diameter to height) \\
  9060. phi = 0 to 2*PI & \\
  9061. \end{tabular}
  9062. We evaluate the volume by integrating a series of infinitesimally thin
  9063. circular disks of constant z-value. The integration is thus performed
  9064. in the order : d($\phi$) from 0 to $2\pi$, dr from 0 to p*Z, dz from 0 to H.
  9065. The order of the indices is thus 2, 0, 1.
  9066. {\small\begin{verbatim}
  9067. VOLINTORDER := AVEC(2,0,1);
  9068. VLB := AVEC(0,0,0);
  9069. VUB := AVEC(P*Z,H,2*PI);
  9070. VOLINTEGRAL(1,VLB,VUB);
  9071. \end{verbatim}}
  9072. \index{LINEINT function}\index{DEFLINEINT function}
  9073. \index{integration ! line}\index{line integrals}
  9074. Line integrals may be calculated using the {\tt LINEINT} and {\tt DEFLINEINT}
  9075. functions. Their general syntax is
  9076. \noindent {\tt LINEINT}({\tt vector-fnct}, {\tt vector-curve},
  9077. {\tt variable});
  9078. \noindent{\tt DEFLINENINT}({\tt vector-fnct}, {\tt vector-curve},
  9079. {\tt variable},\\
  9080. \noindent\verb+ +{\tt lower-bnd}, {\tt upper-bnd});
  9081. \noindent where
  9082. \begin{description}
  9083. \item[{\tt vector-fnct}] is any vector-valued expression;
  9084. \item[{\tt vector-curve}] is a vector expression which describes the path of
  9085. integration in terms of the independent variable;
  9086. \item[{\tt variable}] is the independent variable;
  9087. \item[{\tt lower-bnd}]
  9088. \item[{\tt upper-bnd}] are the bounds of integration in terms of the
  9089. independent variable.
  9090. \end{description}
  9091. \example\index{AVECTOR package ! example}
  9092. In spherical polar coordinates, we may integrate round a line of
  9093. constant theta (`latitude') to find the length of such a line. The
  9094. vector function is thus the tangent to the `line of latitude', (0,0,1)
  9095. and the path is {\tt (0,LAT,PHI)} where {\tt PHI} is the independent
  9096. variable. We show how to obtain the definite integral {\em i.e.} from
  9097. $\phi=0$ to $2 \pi$ :
  9098. {\small\begin{verbatim}
  9099. DEFLINEINT(AVEC(0,0,1),AVEC(0,LAT,PHI),PHI,0,2*PI);
  9100. \end{verbatim}}
  9101. \chapter{BOOLEAN: A package for boolean algebra}
  9102. \label{BOOLEAN}
  9103. \typeout{{BOOLEAN: A package for boolean algebra}}
  9104. {\footnotesize
  9105. \begin{center}
  9106. Herbert Melenk\\
  9107. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  9108. Takustra\"se 7 \\
  9109. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  9110. e--mail: melenk@zib.de
  9111. \end{center}
  9112. }
  9113. \ttindex{BOOLEAN}
  9114. The package {\bf Boolean} supports the computation with boolean
  9115. expressions in the propositional calculus. The data objects are
  9116. composed from algebraic expressions (``atomic parts'', ``leafs'')
  9117. connected by the infix boolean operators {\bf and}, {\bf or}, {\bf
  9118. implies}, {\bf equiv}, and the unary prefix operator {\bf not}. {\bf
  9119. Boolean} allows simplification of expressions built from these
  9120. operators, and to test properties like equivalence, subset property
  9121. etc. Also the reduction of a boolean expression by a partial
  9122. evaluation and combination of its atomic parts is supported.
  9123. \section{Entering boolean expressions}
  9124. In order to distinguish boolean data expressions from
  9125. boolean expressions in the \REDUCE\ programming
  9126. language ({\em e.g.} in an {\bf if} statement), each expression
  9127. must be tagged explicitly by an operator {\bf boolean}.
  9128. Otherwise the boolean operators are not accepted in the
  9129. \REDUCE\ algebraic mode input.
  9130. The first argument of {\bf boolean} can be any boolean expression,
  9131. which may contain references to other boolean values.
  9132. {\small\begin{verbatim}
  9133. load_package boolean;
  9134. boolean (a and b or c);
  9135. q := boolean(a and b implies c);
  9136. boolean(q or not c);
  9137. \end{verbatim}}
  9138. Brackets are used to override the operator precedence as usual.
  9139. The leafs or atoms of a boolean expression are those parts which
  9140. do not contain a leading boolean operator. These are
  9141. considered as constants during the boolean evaluation. There
  9142. are two pre-defined values:
  9143. \begin{itemize}
  9144. \item {\bf true}, {\bf t} or {\bf 1}
  9145. \item {\bf false}, {\bf nil} or {\bf 0}
  9146. \end{itemize}
  9147. These represent the boolean constants. In a result
  9148. form they are used only as {\bf 1} and {\bf 0}.
  9149. By default, a {\bf boolean} expression is converted to a
  9150. disjunctive normal form.
  9151. On output, the operators {\bf and} and {\bf or} are represented as
  9152. \verb+/\+ and \verb+\/+, respectively.
  9153. {\small\begin{verbatim}
  9154. boolean(true and false); -> 0
  9155. boolean(a or not(b and c)); -> boolean(not(b) \/ not(c) \/ a)
  9156. boolean(a equiv not c); -> boolean(not(a)/\c \/ a/\not(c))
  9157. \end{verbatim}}
  9158. \section{Normal forms}
  9159. The {\bf disjunctive} normal form is used by default.
  9160. Alternatively a {\bf conjunctive} normal form can be
  9161. selected as simplification target, which is a form with
  9162. leading operator {\bf and}. To produce that form add the keyword {\bf and}
  9163. as an additional argument to a call of {\bf boolean}.
  9164. {\small\begin{verbatim}
  9165. boolean (a or b implies c);
  9166. ->
  9167. boolean(not(a)/\not(b) \/ c)
  9168. boolean (a or b implies c, and);
  9169. ->
  9170. boolean((not(a) \/ c)/\(not(b) \/ c))
  9171. \end{verbatim}}
  9172. Usually the result is a fully reduced disjunctive or conjuntive normal
  9173. form, where all redundant elements have been eliminated following the
  9174. rules
  9175. $ a \wedge b \vee \neg a \wedge b \longleftrightarrow b$
  9176. $ a \vee b \wedge \neg a \vee b \longleftrightarrow b$
  9177. Internally the full normal forms are computed
  9178. as intermediate result; in these forms each term contains
  9179. all leaf expressions, each one exactly once. This unreduced form is
  9180. returned when the additional keyword {\bf full} is set:
  9181. \newpage
  9182. {\small\begin{verbatim}
  9183. boolean (a or b implies c, full);
  9184. ->
  9185. boolean(a/\b/\c \/ a/\not(b)/\c \/ not(a)/\b/\c \/ not(a)/\not(b)/\c
  9186. \/ not(a)/\not(b)/\not(c))
  9187. \end{verbatim}}
  9188. The keywords {\bf full} and {\bf and} may be combined.
  9189. \section{Evaluation of a boolean expression}
  9190. If the leafs of the boolean expression are algebraic expressions which
  9191. may evaluate to logical values because the environment has changed
  9192. ({\em e.g.\ }variables have been bound), one can re--investigate the
  9193. expression using the operator \f{TESTBOOL}\ttindex{TESTBOOL} with the
  9194. boolean expression as argument. This operator tries to evaluate all
  9195. leaf expressions in \REDUCE\ boolean style. As many terms as possible
  9196. are replaced by their boolean values; the others remain unchanged.
  9197. The resulting expression is contracted to a minimal form. The result
  9198. {\bf 1} (= true) or {\bf 0} (=false) signals that the complete
  9199. expression could be evaluated.
  9200. In the following example the leafs are built as numeric greater test.
  9201. For using ${\bf >}$ in the expressions the greater sign must
  9202. be declared operator first. The error messages are meaningless.
  9203. {\small\begin{verbatim}
  9204. operator >;
  9205. fm:=boolean(x>v or not (u>v));
  9206. ->
  9207. fm := boolean(not(u>v) \/ x>v)
  9208. v:=10$ testbool fm;
  9209. ***** u - 10 invalid as number
  9210. ***** x - 10 invalid as number
  9211. ->
  9212. boolean(not(u>10) \/ x>10)
  9213. x:=3$ testbool fm;
  9214. ***** u - 10 invalid as number
  9215. ->
  9216. boolean(not(u>10))
  9217. x:=17$ testbool fm;
  9218. ***** u - 10 invalid as number
  9219. ->
  9220. 1
  9221. \end{verbatim}}
  9222. \chapter[CALI: Commutative Algebra]{CALI: Computational Commutative Algebra}
  9223. \label{CALI}
  9224. \typeout{{CALI: Computational Commutative Algebra}}
  9225. {\footnotesize
  9226. \begin{center}
  9227. Hans-Gert Gr\"abe \\
  9228. Institut f\"ur Informatik, Universit\"at Leipzig\\
  9229. Augustusplatz 10 -- 11\\
  9230. 04109 Leipzig, Germany \\[0.05in]
  9231. e--mail: graebe@informatik.uni-leipzig.de
  9232. \end{center}
  9233. }
  9234. \ttindex{CALI}
  9235. This package contains algorithms for computations in commutative algebra
  9236. closely related to the Gr\"obner algorithm for ideals and modules. Its
  9237. heart is a new implementation of the Gr\"obner algorithm that also allows
  9238. for the computation of syzygies. This implementation is also applicable to
  9239. submodules of free modules with generators represented as rows of a matrix.
  9240. As main topics CALI contains facilities for
  9241. \begin{itemize}
  9242. \item defining rings, ideals and modules,
  9243. \item computing Gr\"obner bases and local standard bases,
  9244. \item computing syzygies, resolutions and (graded) Betti numbers,
  9245. \item computing (now also weighted) Hilbert series, multiplicities,
  9246. independent sets, and dimensions,
  9247. \item computing normal forms and representations,
  9248. \item computing sums, products, intersections, quotients, stable
  9249. quotients, elimination ideals etc.,
  9250. \item primality tests, computation of radicals, unmixed radicals,
  9251. equidimensional parts, primary decompositions etc. of ideals and
  9252. modules,
  9253. \item advanced applications of Gr\"obner bases (blowup, associated graded
  9254. ring, analytic spread, symmetric algebra, monomial curves etc.),
  9255. \item applications of linear algebra techniques to zero dimensional
  9256. ideals, as {\em e.g.\ }the FGLM change of term orders, border bases
  9257. and affine and projective ideals of sets of points,
  9258. \item splitting polynomial systems of equations mixing factorisation and
  9259. the Gr\"obner algorithm, triangular systems, and different versions of the
  9260. extended Gr\"obner factoriser.
  9261. \end{itemize}
  9262. There is more extended documentation on this package elsewhere, which
  9263. includes facilities for tracing and switches to control its behaviour.
  9264. \chapter[CAMAL: Celestial Mechanics]{CAMAL: Calculations in Celestial Mechanics}
  9265. \label{CAMAL}
  9266. \typeout{{CAMAL: Calculations in Celestial Mechanics}}
  9267. {\footnotesize
  9268. \begin{center}
  9269. J. P. Fitch \\
  9270. School of Mathematical Sciences, University of Bath\\
  9271. BATH BA2 7AY, England \\[0.05in]
  9272. e--mail: jpff@cs.bath.ac.uk
  9273. \end{center}
  9274. }
  9275. \ttindex{CAMAL}
  9276. The CAMAL package provides facilities for calculations in Fourier
  9277. series similar to those in the specialist Celestial Mechanics system
  9278. of the 1970s, and the Cambridge Algebra system in
  9279. particular.\index{Fourier Series}\index{CAMAL}\index{Celestial
  9280. Mechanics}
  9281. \section{Operators for Fourier Series}
  9282. \subsection*{\f{HARMONIC}}\ttindex{HARMONIC}
  9283. The celestial mechanics system distinguish between polynomial
  9284. variables and angular variables. All angles must be declared before
  9285. use with the \f{HARMONIC} function.
  9286. {\small\begin{verbatim}
  9287. harmonic theta, phi;
  9288. \end{verbatim}}
  9289. \subsection*{\f{FOURIER}}\ttindex{FOURIER}
  9290. The \f{FOURIER} function coerces its argument into the domain of a
  9291. Fourier Series. The expression may contain {\em sine} and {\em
  9292. cosine} terms of linear sums of harmonic variables.
  9293. {\small\begin{verbatim}
  9294. fourier sin(theta)
  9295. \end{verbatim}}
  9296. Fourier series expressions may be added, subtracted multiplies and
  9297. differentiated in the usual \REDUCE\ fashion. Multiplications involve
  9298. the automatic linearisation of products of angular functions.
  9299. There are three other functions which correspond to the usual
  9300. restrictive harmonic differentiation and integration, and harmonic
  9301. substitution.
  9302. \subsection*{\f{HDIFF} and \f{HINT}}\ttindex{HDIFF}\ttindex{HINT{}}
  9303. Differentiate or integrate a Fourier expression with respect to an angular
  9304. variable. Any secular terms in the integration are disregarded without
  9305. comment.
  9306. {\small\begin{verbatim}
  9307. load_package camal;
  9308. harmonic u;
  9309. bige := fourier (sin(u) + cos(2*u));
  9310. aa := fourier 1+hdiff(bige,u);
  9311. ff := hint(aa*aa*fourier cc,u);
  9312. \end{verbatim}}
  9313. \subsection*{\f{HSUB}}\ttindex{HSUB}
  9314. The operation of substituting an angle plus a Fourier expression for
  9315. an angles and expanding to some degree is called harmonic substitution.
  9316. The function takes 5 arguments; the basic expression, the angle being
  9317. replaced, the angular part of the replacement, the fourier part of the
  9318. replacement and a degree to which to expand.
  9319. {\small\begin{verbatim}
  9320. harmonic u,v,w,x,y,z;
  9321. xx:=hsub(fourier((1-d*d)*cos(u)),u,u-v+w-x-y+z,yy,n);
  9322. \end{verbatim}}
  9323. \section{A Short Example}
  9324. The following program solves Kepler's Equation as a Fourier series to
  9325. the degree $n$.
  9326. {\small\begin{verbatim}
  9327. bige := fourier 0;
  9328. for k:=1:n do <<
  9329. wtlevel k;
  9330. bige:=fourier e * hsub(fourier(sin u), u, u, bige, k);
  9331. >>;
  9332. write "Kepler Eqn solution:", bige$
  9333. \end{verbatim}}
  9334. \chapter{CGB: Comprehensive Gr\"obner Bases}
  9335. \label{CGB}
  9336. \typeout{{CGB: Comprehensive Gr\"obner Bases}}
  9337. {\footnotesize
  9338. \begin{center}
  9339. Andreas Dolzmann \& Thomas Sturm\\
  9340. Department of Mathematics and Computer Science\\ University of Passau\\
  9341. D-94030 Passau, Germany\\[1ex]
  9342. e-mail: dolzmann@uni-passau.de, sturm@uni-passau.de
  9343. \end{center}
  9344. }
  9345. \ttindex{REDLOG}
  9346. \section{Introduction}
  9347. Consider the ideal basis $F=\{ax,x+y\}$. Treating $a$ as a parameter,
  9348. the calling sequence
  9349. {\small\begin{verbatim}
  9350. torder({x,y},lex)$
  9351. groebner{a*x,x+y};
  9352. {x,y}
  9353. \end{verbatim}}
  9354. yields $\{x,y\}$ as reduced Gr\"obner basis. This is, however, not
  9355. correct under the specialization $a=0$. The reduced Gr\"obner basis
  9356. would then be $\{x+y\}$. Taking these results together, we obtain
  9357. $C=\{x+y,ax,ay\}$, which is correct wrt.~{\em all} specializations for
  9358. $a$ including zero specializations. We call this set $C$ a {\em
  9359. comprehensive Gr\"obner basis} ({\sc cgb}).
  9360. The notion of a {\sc cgb} and a corresponding algorithm has been
  9361. introduced bei Weispfenning \cite{Weispfenning:92}. This algorithm
  9362. works by performing case distinctions wrt.~parametric coefficient
  9363. polynomials in order to find out what the head monomials are under all
  9364. possible specializations. It does thus not only determine a {\sc cgb},
  9365. but even classifies the contained polynomials wrt.~the specializations
  9366. they are relevant for. If we keep the Gr\"obner bases for all cases
  9367. separate and associate information on the respective specializations
  9368. with them, we obtain a {\em Gr\"obner system}. For our example, the
  9369. Gr\"obner system is the following;
  9370. $$
  9371. \left[
  9372. \begin{array}{c|c}
  9373. a\neq0 & \{x+y,ax,ay\}\\
  9374. a=0 & \{x+y\}
  9375. \end{array}
  9376. \right].
  9377. $$
  9378. A {\sc cgb} is obtained as the union of the single Gr\"obner bases in
  9379. a Gr\"obner system. It has also been shown that, on the other hand, a
  9380. Gr\"obner system can easily be reconstructed from a given {\sc cgb}
  9381. \cite{Weispfenning:92}.
  9382. The CGB package provides functions for computing both {\sc cgb}'s and
  9383. Gr\"obner systems, and for turning Gr\"obner systems into {\sc cgb}'s.
  9384. %
  9385. \section{Using the REDLOG Package}
  9386. For managing the conditions occurring with the {\sc cgb} computations,
  9387. the CGB package uses the package REDLOG implementing first-order
  9388. formulas, \cite{DolzmannSturm:97a,DolzmannSturm:99}, which is also
  9389. part of the \textsc{reduce} distribution.
  9390. %
  9391. \section{Term Ordering Mode}
  9392. The CGB package uses the settings made with the function \f{TORDER}
  9393. of the GROEBNER package. This includes in particular the choice of the
  9394. main variables. All variables not mentioned in the variable list
  9395. argument of \f{TORDER} are parameters. The only term ordering modes
  9396. recognized by \textsc{cgb} are \f{LEX} and \f{REVGRADLEX}.
  9397. %
  9398. \section{CGB: Comprehensive Gr\"ob\-ner Basis}
  9399. The function \f{CGB}\ttindex{CGB} expects a list $F$ of expressions.
  9400. It returns a {\sc cgb} of $F$ wrt.~the current \f{TORDER} setting.
  9401. %
  9402. \subsection*{Example:}
  9403. {\small\begin{verbatim}
  9404. torder({x,y},lex)$
  9405. cgb{a*x+y,x+b*y};
  9406. {x + b*y,a*x + y,(a*b - 1)*y}
  9407. ws;
  9408. {b*y + x,
  9409. a*x + y,
  9410. y*(a*b - 1)}
  9411. \end{verbatim}}
  9412. Note that the basis returned by the \f{CGB} call has not undergone
  9413. the standard evaluation process: The returned polynomials are ordered
  9414. wrt.~the chosen term order. Reevaluation changes this as can be seen
  9415. with the output of \f{WS}.
  9416. %
  9417. \section{GSYS: Gr\"obner System}
  9418. The function \f{GSYS}\ttindex{GSYS} follows the same calling conventions as
  9419. \f{CGB}. It returns the complete Gr\"obner system represented as a nested
  9420. list
  9421. \begin{center}
  9422. \begin{tt}
  9423. $\bigl\{\bigl\{c_1,\{g_{11},\ldots,g_{1n_1}\}\bigr\},\dots,
  9424. \bigl\{c_m,\{g_{m1},\dots,g_{1n_m}\}\bigr\}\bigr\}$.
  9425. \end{tt}
  9426. \end{center}
  9427. The {\tt $c_i$} are conditions in the parameters represented as
  9428. quantifier-free REDLOG formulas. Each choice of parameters will obey
  9429. at least one of the {\tt $c_i$}. Whenever a choice of parameters obeys
  9430. some {\tt $c_i$}, the corresponding {\tt $\{g_{i1},\ldots,g_{in_i}\}$}
  9431. is a Gr\"obner basis for this choice.
  9432. %
  9433. \subsection*{Example:}
  9434. {\small\begin{verbatim}
  9435. torder({x,y},lex)$
  9436. gsys {a*x+y,x+b*y};
  9437. {{a*b - 1 <> 0 and a <> 0,
  9438. {a*x + y,x + b*y,(a*b - 1)*y}},
  9439. {a <> 0 and a*b - 1 = 0,
  9440. {a*x + y,x + b*y}},
  9441. {a = 0,{a*x + y,x + b*y}}}
  9442. \end{verbatim}}
  9443. As with the function \f{CGB}, the contained polynomials remain
  9444. unevaluated.
  9445. Computing a Gr\"obner system is not harder than computing a {\sc cgb}.
  9446. In fact, \f{CGB} also computes a Gr\"obner system and then turns it
  9447. into a {\sc cgb}.
  9448. \subsection{Switch CGBGEN: Only the Generic Case}
  9449. If the switch \f{CGBGEN}\ttindex{CGBGEN} is turned on, both \f{GSYS} and
  9450. \f{CGB} will assume all parametric coefficients to be non-zero ignoring
  9451. the other cases. For \f{CGB} this means that the result equals---up
  9452. to auto-reduction---that of \f{GROEBNER}. A call to \f{GSYS} will
  9453. return this result as a single case including the assumptions made
  9454. during the computation:
  9455. %
  9456. \subsection*{Example:}
  9457. {\small\begin{verbatim}
  9458. torder({x,y},lex)$
  9459. on cgbgen;
  9460. gsys{a*x+y,x+b*y};
  9461. {{a*b - 1 <> 0 and a <> 0,
  9462. {a*x + y,x + b*y,(a*b - 1)*y}}}
  9463. off cgbgen;
  9464. \end{verbatim}}
  9465. %
  9466. \section{GSYS2CGB: Gr\"obner System to CGB}
  9467. The call \f{GSYS2CGB}\ttindex{GSYS2CGB} turns a given Gr\"obner system into a
  9468. {\sc cgb} by constructing the union of the Gr\"obner bases of the single
  9469. cases.
  9470. %
  9471. \subsection*{Example:}
  9472. {\small\begin{verbatim}
  9473. torder({x,y},lex)$
  9474. gsys{a*x+y,x+b*y}$
  9475. gsys2cgb ws;
  9476. {x + b*y,a*x + y,(a*b - 1)*y}
  9477. \end{verbatim}}
  9478. %
  9479. \section{Switch CGBREAL: Computing over the Real Numbers}\label{cgbreal}
  9480. All computations considered so far have taken place over the complex
  9481. numbers, more precisely, over algebraically closed fields. Over the
  9482. real numbers, certain branches of the {\sc cgb} computation can become
  9483. inconsitent though they are not inconsistent over the complex numbers.
  9484. Consider, e.g., a condition $a^2+1=0$.
  9485. When turning on the switch \f{CGBREAL}\ttindex{CGBREAL}, all
  9486. simplifications of conditions are performed over the real numbers.
  9487. The methods used for this are described in \cite{DolzmannSturm:97c}.
  9488. %
  9489. \subsection*{Example:}
  9490. {\small\begin{verbatim}
  9491. torder({x,y},lex)$
  9492. off cgbreal;
  9493. gsys {a*x+y,x-a*y};
  9494. 2
  9495. {{a + 1 <> 0 and a <> 0,
  9496. 2
  9497. {a*x + y,x - a*y,(a + 1)*y}},
  9498. 2
  9499. {a <> 0 and a + 1 = 0,{a*x + y,x - a*y}},
  9500. {a = 0,{a*x + y,x - a*y}}}
  9501. on cgbreal;
  9502. gsys({a*x+y,x-a*y});
  9503. {{a <> 0,
  9504. 2
  9505. {a*x + y,x - a*y,(a + 1)*y}},
  9506. {a = 0,{a*x + y,x - a*y}}}
  9507. \end{verbatim}}
  9508. \section{Switches}
  9509. \begin{description}
  9510. \item[\f{CGBREAL}] Compute over the real numbers. See
  9511. Section~\ref{cgbreal} for details.
  9512. \item[\f{CGBGS}\ttindex{CGBGS}] Gr\"obner simplification of the condition. The switch
  9513. \f{CGBGS} can be turned on for applying advanced algebraic
  9514. simplification techniques to the conditions. This will, in general,
  9515. slow down the computation, but lead to a simpler Gr\"obner system.
  9516. \item[\f{CGBSTAT}\ttindex{CGBSTAT}] Statistics of the CGB run. The switch \f{CGBSTAT}
  9517. toggles the creation and output of statistical information on the CGB
  9518. run. The statistical information is printed at the end of the run.
  9519. \item[\f{CGBFULLRED}\ttindex{CGBFULLRED}] Full reduction. By default, the CGB functions
  9520. perform full reductions in contrast to pure top reductions. By turning
  9521. off the switch \f{CGBFULLRED}, reduction can be restricted to top
  9522. reductions.
  9523. \end{description}
  9524. \chapter[CHANGEVR: Change of Variables in DEs]%
  9525. {CHANGEVR: Change of Independent Variables in DEs}
  9526. \label{CHANGEVR}
  9527. \typeout{[CHANGEVR: Change of Variables in DEs]}
  9528. {\footnotesize
  9529. \begin{center}
  9530. G. \"{U}\c{c}oluk \\
  9531. Department of Physics, Middle East Technical University \\
  9532. Ankara, Turkey\\[0.05in]
  9533. e--mail: ucoluk@trmetu.bitnet
  9534. \end{center}
  9535. }
  9536. The function {\tt CHANGEVAR} has (at least) four different
  9537. arguments.\ttindex{CHANGEVAR}
  9538. \begin{itemize}
  9539. \item {\bf FIRST ARGUMENT} \\
  9540. is a list of the dependent variables of the differential equation.
  9541. If there is only one dependent variable it can be given directly,
  9542. not as a list.
  9543. \item {\bf SECOND ARGUMENT} \\
  9544. is a list of the {\bf new} independent variables, or in the case
  9545. of only one, the variable.
  9546. \item {\bf THIRD ARGUMENT, FOURTH {\em etc.}} \\
  9547. are equations is of the form
  9548. \begin{quote}{\tt{\em old variable} = {\em a function in new variables}}\end{quote}
  9549. The left hand side cannot be a non-kernel structure. These give
  9550. the old variables in terms of the new ones.
  9551. \item {\bf LAST ARGUMENT} \\
  9552. is a list of algebraic expressions which evaluates to differential
  9553. equations in the usual list notation.
  9554. Again it is possible to omit the list form if there is
  9555. only {\bf one} differential equation.
  9556. \end{itemize}
  9557. If the last argument is a list then the result of {\tt CHANGEVAR} is a
  9558. list too.
  9559. It is possible to display the entries of the inverse Jacobian. To do
  9560. so, turn {\tt ON} the flag {\tt DISPJACOBIAN}\ttindex{DISPJACOBIAN}.
  9561. \section{An example: the 2-D Laplace Equation}
  9562. The 2-dimensional Laplace equation in Cartesian coordinates is:
  9563. \[
  9564. \frac{\partial^{2} u}{\partial x^{2}} +
  9565. \frac{\partial^{2} u}{\partial y^{2}} = 0
  9566. \]
  9567. Now assume we want to obtain the polar coordinate form of Laplace equation.
  9568. The change of variables is:
  9569. \[
  9570. x = r \cos \theta, {\;\;\;\;\;\;\;\;\;\;} y = r \sin \theta
  9571. \]
  9572. The solution using {\tt CHANGEVAR} is
  9573. {\small\begin{verbatim}
  9574. CHANGEVAR({u},{r,theta},{x=r*cos theta,y=r*sin theta},
  9575. {df(u(x,y),x,2)+df(u(x,y),y,2)} );
  9576. \end{verbatim}}
  9577. Here we could omit the curly braces in the first and last arguments (because
  9578. those lists have only one member) and the curly braces in the third argument
  9579. (because they are optional), but not in the second. So one could
  9580. equivalently write
  9581. {\small\begin{verbatim}
  9582. CHANGEVAR(u,{r,theta},x=r*cos theta,y=r*sin theta,
  9583. df(u(x,y),x,2)+df(u(x,y),y,2) );
  9584. \end{verbatim}}
  9585. The {\tt u(x,y)} operator will be changed to {\tt u(r,theta)} in the
  9586. result as one would do with pencil and paper. {\tt u(r,theta)}
  9587. represents the the transformed dependent variable.
  9588. \chapter[COMPACT: Compacting expressions]{COMPACT: Package for compacting expressions}
  9589. \label{COMPACT}
  9590. \typeout{{COMPACT: Package for compacting expressions}}
  9591. {\footnotesize
  9592. \begin{center}
  9593. Anthony C. Hearn\\
  9594. RAND\\
  9595. Santa Monica \\
  9596. CA 90407-2138, U.S.A. \\[0.05in]
  9597. e--mail: hearn@rand.org
  9598. \end{center}
  9599. }
  9600. \ttindex{COMPACT}\index{COMPACT package}\index{side relations}
  9601. \index{relations ! side}
  9602. {COMPACT} is a package of functions for the reduction of a polynomial in
  9603. the presence of side relations. The package defines one operator {COMPACT}
  9604. \index{COMPACT operator}
  9605. whose syntax is:
  9606. \begin{quote}
  9607. \k{COMPACT}(\s{expression}, \s{list}):\s{expression}
  9608. \end{quote}
  9609. \s{expression} can be any well-formed algebraic expression, and
  9610. \s{list} an expression whose value is a list
  9611. of either expressions or equations. For example
  9612. {\small\begin{verbatim}
  9613. compact(x**2+y**3*x-5y,{x+y-z,x-y-z1});
  9614. compact(sin(x)**10*cos(x)**3+sin(x)**8*cos(x)**5,
  9615. {cos(x)**2+sin(x)**2=1});
  9616. let y = {cos(x)**2+sin(x)**2-1};
  9617. compact(sin(x)**10*cos(x)**3+sin(x)**8*cos(x)**5,y);
  9618. \end{verbatim}}
  9619. {COMPACT} applies the relations to the expression so that an equivalent
  9620. expression results with as few terms as possible. The method used is
  9621. briefly as follows:
  9622. \begin{enumerate}
  9623. \item Side relations are applied separately to numerator and denominator, so
  9624. that the problem is reduced to the reduction of a polynomial with respect to
  9625. a set of polynomial side relations.
  9626. \item Reduction is performed sequentially, so that the problem is reduced
  9627. further to the reduction of a polynomial with respect to a single
  9628. polynomial relation.
  9629. \item The polynomial being reduced is reordered so that the variables
  9630. (kernels) occurring in the side relation have least precedence.
  9631. \item Each coefficient of the remaining kernels (which now only contain
  9632. the kernels
  9633. in the side relation) is reduced with respect to that side relation.
  9634. \item A polynomial quotient/remainder calculation is performed on the
  9635. coefficient. The remainder is
  9636. used instead of the original if it has fewer terms.
  9637. \item The remaining expression is reduced with respect to the side relation
  9638. using a ``nearest neighbour'' approach.
  9639. \end{enumerate}
  9640. \chapter[CRACK: Overdetermined systems of DEs]%
  9641. {CRACK: Solving overdetermined systems of PDEs or ODEs}
  9642. \label{CRACK}
  9643. \typeout{[CRACK: Overdetermined systems of DEs]}
  9644. {\footnotesize
  9645. \begin{center}
  9646. Thomas Wolf \\
  9647. School of Mathematical Sciences, Queen Mary and Westfield College \\
  9648. University of London \\
  9649. London E1 4NS, England \\[0.05in]
  9650. e--mail: T.Wolf@maths.qmw.ac.uk \\ [0.10in]
  9651. %%WWW: http://www.zib-berlin.de/Symbolik/crack.html \\[0.10in]
  9652. Andreas Brand \\
  9653. Institut f\"{u}r Informatik \\
  9654. Friedrich Schiller Universit\"{a}t Jena \\
  9655. 07740 Jena, Germany \\[0.05in]
  9656. e--mail: maa@hpux.rz.uni-jena.de
  9657. \end{center}
  9658. }
  9659. \ttindex{CRACK}
  9660. The package CRACK aims at solving or at least partially
  9661. integrating single ordinary differential equations or partial
  9662. differential equations (ODEs/PDEs), and systems of them, exactly and in full
  9663. generality. Calculations done with input DEs include the
  9664. \begin{itemize}
  9665. \item integration of exact DEs and generalised exact DEs
  9666. \item determination of monomial integrating factors
  9667. \item direct and indirect separation of DEs
  9668. \item systematic application of integrability conditions
  9669. \item solution of single elementary ODEs by using the REDUCE
  9670. package ODESOLVE (chapter~\ref{ODESOLVE}).
  9671. \end{itemize}
  9672. %More details are given in the manual CRACK.TEX.
  9673. Input DEs may be polynomially non-linear in the unknown functions
  9674. and their derivatives and may depend arbitrarily on the independent
  9675. variables.
  9676. Suitable applications of CRACK are the solution of
  9677. \begin{itemize}
  9678. \item overdetermined ODE/PDE-systems (overdetermined here just means
  9679. that the number of unknown functions of all independent variables
  9680. is less than the number of given equations for these functions).
  9681. \item simple non-overdetermined DE-systems (such as characteristic
  9682. ODE-systems of first order quasilinear PDEs).
  9683. \end{itemize}
  9684. The strategy is to have {\bf one} universal program (CRACK) which
  9685. is as effective as possible for solving overdetermined PDE-systems
  9686. and many application programs (such as LIEPDE) which merely generate an
  9687. overdetermined PDE-system depending on what is to be investigated
  9688. (for example, symmetries or conservation laws).
  9689. Examples are:
  9690. \begin{itemize}
  9691. \item the investigation of infinitesimal symmetries of DEs (LIEPDE),
  9692. \item the determination of an equivalent Lagrangian for second order
  9693. ODEs (LAGRAN)
  9694. \item the investigation of first integrals of ODEs which are polynomial
  9695. in their highest derivative (FIRINT)
  9696. \item the splitting of an $n^{th}$ order ODE into a first order ODE and
  9697. an $(n-1)^{th}$ order problem (DECOMP)
  9698. %%\item the search for conservation laws of PDEs (-systems) (CONLAW, not
  9699. %% yet added to the library (Sep.\ 1995) but obtainable from T.W.)
  9700. \end{itemize}
  9701. Other applications where non-overdetermined problems are treated are
  9702. \begin{itemize}
  9703. \item the application of infinitesimal symmetries ({\em e.g.\
  9704. }calculated by LIEPDE) in the package APPLYSYM (chapter~\ref{APPLYSYM}),
  9705. \item the program QUASILINPDE (also in the package APPLYSYM)
  9706. for solving single first order quasilinear PDEs.
  9707. \end{itemize}
  9708. The kernel package for solving overdetermined or simple non-overdetermined
  9709. DE-systems is accessible through a call to the program CRACK
  9710. in the package CRACK. All the application programs (LIEPDE, LAGRAN,
  9711. FIRINT, DECOMP except APPLYSYM) are contained in the package CRACKAPP.
  9712. The programs APPLYSYM and QUASILINPDE are contained in the package
  9713. APPLYSYM (described in chapter~\ref{APPLYSYM}).
  9714. %%A short description of all the applications mentioned above including
  9715. %%examples are given in an paper to be published in a special issue of
  9716. %%"Mathematical and Computer Modelling", ed. B.\ Fuchssteiner, V.\ Gerdt
  9717. %%and W.\ Oevel which also is available through ftp from
  9718. %%euclid.maths.qmw.ac.uk as preprint file pub/crack/demo.ps. More details are
  9719. %%given in the files CRACK.TEX and APPLYSYM.TEX and input examples are available
  9720. %%in the test files CRACK.TST and APPLYSYM.TST.
  9721. %%The latest versions of the programs, manuals and test files
  9722. %%are available through ftp
  9723. %%from euclid.maths.qmw.ac.uk and the directory /pub/crack.
  9724. Details of the CRACK applications can be found in the example file.
  9725. {\tt CRACK} is called by
  9726. \begin{tabbing}
  9727. {\tt CRACK}(\=\{{\it equ}$_1$, {\it equ}$_2$, \ldots , {\it equ}$_m$\}, \\
  9728. \>\{{\it ineq}$_1$, {\it ineq}$_2$, \ldots , {\it ineq}$_n$\}, \\
  9729. \>\{{\it fun}$_1$, {\it fun}$_2$, \ldots , {\it fun}$_p$\}, \\
  9730. \>\{{\it var}$_1$, {\it var}$_2$, \ldots , {\it var}$_q$\});
  9731. \end{tabbing}
  9732. $m,n,p,q$ are arbitrary.
  9733. \begin{itemize}
  9734. \item
  9735. The {\it equ}$_i$ are identically vanishing partial differential expressions,
  9736. {\em i.e.\ }
  9737. they represent equations $0 = {\it equ}_i$, which are to be solved for the
  9738. functions ${\it fun}_j$ as far as possible, thereby drawing only necessary
  9739. conclusions and not restricting the general solution.
  9740. \item
  9741. The {\it ineq}$_i$ are expressions which must not vanish identically for
  9742. any solution to be determined, {\em i.e.\ }only such solutions are
  9743. computed for which none of the {\it ineq}$_i$ vanishes identically in
  9744. all independent variables.
  9745. \item
  9746. The dependence of the (scalar) functions ${\it fun}_j$ on possibly a
  9747. number of variables is assumed to have been defined with DEPEND rather
  9748. than declaring these functions as operators. Their arguments may
  9749. themselves only be independent variables and not expressions.
  9750. \item
  9751. The functions ${\it fun}_j$ and their derivatives may only occur
  9752. polynomially. Other unknown functions in ${\it equ}_i$ may be
  9753. represented as operators.
  9754. \item
  9755. The ${\it var}_k$ are further independent variables, which are not
  9756. already arguments of any of the ${\it fun}_j$. If there are none then
  9757. the third argument is the empty list \{\}.
  9758. \item
  9759. The dependence of the ${\it equ}_i$ on the independent variables and on
  9760. constants and functions other than ${\it fun}_j$ is arbitrary.
  9761. \end{itemize}
  9762. The result is a list of solutions
  9763. \[ \{{\it sol}_1, \ldots \} \]
  9764. where each solution is a list of 3 lists:
  9765. \begin{tabbing}
  9766. \{\=\{${\it con}_1, \; {\it con}_2, \ldots , \; {\it con}_q$\}, \\
  9767. \>\{${\it fun}_a={\it ex}_a, \;\;
  9768. {\it fun}_b={\it ex}_b, \ldots , \;\; {\it fun}_p={\it ex}_p$\},\= \\
  9769. \>\{${\it fun}_c, \;\; {\it fun}_d, \ldots , \;\; {\it fun}_r$\} \>\}
  9770. \end{tabbing}
  9771. with integer $a, b, c, d, p, q, r.$
  9772. If {\tt CRACK} finds a contradiction as $0=1$ then there exists no
  9773. solution and it returns the empty list \{\}.
  9774. The empty list is also returned if no solution exists
  9775. which does not violate the inequalities
  9776. {\it ineq}$_i \neq 0.$
  9777. For example, in the case of a linear system as input, there is
  9778. at most one solution ${\it sol}_1$.
  9779. The expressions ${\it con}_i$ (if there are any), are the
  9780. remaining necessary and sufficient conditions for the functions
  9781. ${\it fun}_c,\ldots,{\it fun}_r$ in the third list. Those
  9782. functions can be original functions from the equations to be
  9783. solved (of the second argument of the call of {\tt CRACK}) or new
  9784. functions or constants which arose from integrations.
  9785. The dependence of new functions on variables is declared with {\tt DEPEND}
  9786. and to visualise this dependence the algebraic mode function
  9787. ${\tt FARGS({\it fun}_i)}$ can be used.
  9788. If there are no ${\it con}_i$ then all equations are solved and the
  9789. functions in the third list are unconstrained.
  9790. The second list contains
  9791. equations ${\it fun}_i={\it ex}_i$ where each ${\it fun}_i$ is an
  9792. original function and ${\it ex}_i$ is the computed expression
  9793. for ${\it fun}_i$.
  9794. The exact behaviour of {\tt CRACK} can be modified by internal
  9795. variables, and there is a help system particularly associated with
  9796. {\tt CRACK}. Users are referred to the detailed documentation for
  9797. more information.
  9798. \chapter[CVIT:Dirac gamma matrix traces]%
  9799. {CVIT: Fast calculation of Dirac gamma matrix traces}
  9800. \label{CVIT}
  9801. \typeout{[CVIT:Dirac gamma matrix traces]}
  9802. {\footnotesize
  9803. \begin{center}
  9804. V. Ilyin, A. Kryukov, A. Rodionov and A. Taranov \\
  9805. Institute for Nuclear Physics \\
  9806. Moscow State University \\
  9807. Moscow, 119899 Russia
  9808. \end{center}
  9809. }
  9810. \ttindex{CVIT}
  9811. The package consists of 5 sections, and provides an alternative to the
  9812. \REDUCE\ high-energy physics system. Instead of being based on
  9813. $\Gamma$-matrices as a basis for a Clifford algebra, it is based on
  9814. treating $\Gamma$-matrices as 3-j symbols, as described by
  9815. Cvitanovic.
  9816. The functions it provides are the same as those of the standard
  9817. package. It does have four switches which control its behaviour.
  9818. \noindent{\tt CVIT}\ttindex{CVIT}
  9819. If it is on then use Kennedy-Cvitanovic algorithm else use standard
  9820. facilities.
  9821. \noindent{\tt CVITOP}\ttindex{CVITOP}
  9822. Switches on Fierz optimisation. Default is off;
  9823. \noindent{\tt CVITBTR}\ttindex{CVITBTR}
  9824. Switches on the bubbles and triangles factorisation. The default is
  9825. on.
  9826. \noindent{\tt CVITRACE}\ttindex{CVITRACE}
  9827. Controls internal tracing of the CVIT package. Default is off.
  9828. {\small\begin{verbatim}
  9829. index j1,j2,j3,;
  9830. vecdim n$
  9831. g(l,j1,j2,j2,j1);
  9832. 2
  9833. n
  9834. g(l,j1,j2)*g(l1,j3,j1,j2,j3);
  9835. 2
  9836. n
  9837. g(l,j1,j2)*g(l1,j3,j1,j3,j2);
  9838. n*( - n + 2)
  9839. \end{verbatim}}
  9840. \chapter{DEFINT: Definite Integration for REDUCE}
  9841. \label{DEFINT}
  9842. \typeout{{DEFINT: Definite Integration for REDUCE}}
  9843. {\footnotesize
  9844. \begin{center}
  9845. Kerry Gaskell and Winfried Neun \\
  9846. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  9847. Takustra\"se 7 \\
  9848. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  9849. e--mail: neun@zib.de \\[0.10in]
  9850. Stanley L. Kameny \\
  9851. Los Angeles, U.S.A.
  9852. \end{center}
  9853. }
  9854. \ttindex{DEFINT}
  9855. \REDUCE{}'s definite integration package is able to calculate the
  9856. definite integrals of many functions, including several special
  9857. functions. There are a number of parts of this package, including
  9858. contour integration. The innovative integration process is to
  9859. represent each function as a Meijer G-function, and then calculating
  9860. the integral by using the following Meijer G integration formula.
  9861. \begin{displaymath}
  9862. \int_{0}^{\infty} x^{\alpha-1} G^{s t}_{u v}
  9863. \left( \sigma x \ \Bigg\vert \ {( c_u) \atop (d_v)} \right)
  9864. G^{m n}_{p q} \left( \omega x^{l/k} \ \Bigg\vert \ {(a_p) \atop (b_q)}
  9865. \right) dx = k G^{i j}_{k l} \left( \xi \ \Bigg\vert \
  9866. {(g_k) \atop (h_l)} \right) \hspace{5mm} (1)
  9867. \end{displaymath}
  9868. The resulting Meijer G-function is then retransformed, either directly
  9869. or via a hypergeometric function simplification, to give
  9870. the answer.
  9871. The user interface is via a four argument version of the
  9872. \f{INT}\ttindex{INT} operator, with the lower and upper limits added.
  9873. {\small\begin{verbatim}
  9874. load_package defint;
  9875. int(sin x,x,0,pi/2);
  9876. 1
  9877. \end{verbatim}}
  9878. \newpage
  9879. {\small\begin{verbatim}
  9880. int(log(x),x,1,5);
  9881. 5*log(5) - 4
  9882. int(x*e^(-1/2x),x,0,infinity);
  9883. 4
  9884. int(x^2*cos(x)*e^(-2*x),x,0,infinity);
  9885. 4
  9886. -----
  9887. 125
  9888. int(x^(-1)*besselj(2,sqrt(x)),x,0,infinity);
  9889. 1
  9890. int(si(x),x,0,y);
  9891. cos(y) + si(y)*y - 1
  9892. int(besselj(2,x^(1/4)),x,0,y);
  9893. 1/4
  9894. 4*besselj(3,y )*y
  9895. ---------------------
  9896. 1/4
  9897. y
  9898. \end{verbatim}}
  9899. The DEFINT package also defines a number of additional transforms,
  9900. such as the Laplace transform\index{Laplace transform}\footnote{See
  9901. Chapter~\ref{LAPLACE} for an alternative Laplace transform with
  9902. inverse Laplace transform}, the Hankel
  9903. transform\index{Hankel transform}, the Y-transform\index{Y-transform},
  9904. the K-transform\index{K-transform}, the StruveH
  9905. transform\index{StruveH transform}, the Fourier sine
  9906. transform\index{Fourier sine transform}, and the Fourier cosine
  9907. transform\index{Fourier cosine transform}.
  9908. {\small\begin{verbatim}
  9909. laplace_transform(cosh(a*x),x);
  9910. - s
  9911. ---------
  9912. 2 2
  9913. a - s
  9914. laplace_transform(Heaviside(x-1),x);
  9915. 1
  9916. ------
  9917. s
  9918. e *s
  9919. hankel_transform(x,x);
  9920. n + 4
  9921. gamma(-------)
  9922. 2
  9923. -------------------
  9924. n - 2 2
  9925. gamma(-------)*s
  9926. 2
  9927. fourier_sin(e^(-x),x);
  9928. s
  9929. --------
  9930. 2
  9931. s + 1
  9932. fourier_cos(x,e^(-1/2*x^2),x);
  9933. 2
  9934. i*s s /2
  9935. sqrt( - pi)*erf(---------)*s + e *sqrt(2)
  9936. sqrt(2)
  9937. ----------------------------------------------
  9938. 2
  9939. s /2
  9940. e *sqrt(2)
  9941. \end{verbatim}}
  9942. It is possible to the user to extend the pattern-matching process by
  9943. which the relevant Meijer G representation for any function is found.
  9944. Details can be found in the complete documentation.
  9945. \noindent{\bf Acknowledgement:}
  9946. This package depends greatly on the pioneering work of Victor
  9947. Adamchik, to whom thanks are due.
  9948. \chapter[DESIR: Linear Homogeneous DEs]%
  9949. {DESIR: Differential linear homogeneous equation solutions in the
  9950. neighbourhood of irregular and regular singular points}
  9951. \label{DESIR}
  9952. \typeout{[DESIR: Linear Homogeneous DEs]}
  9953. {\footnotesize
  9954. \begin{center}
  9955. C. Dicrescenzo, F. Richard--Jung, E. Tournier \\
  9956. Groupe de Calcul Formel de Grenoble \\
  9957. laboratoire TIM3 \\
  9958. France \\[0.05in]
  9959. e--mail: dicresc@afp.imag.fr
  9960. \end{center}
  9961. }
  9962. \ttindex{DESIR}
  9963. This software enables the basis of formal solutions to be computed for an
  9964. ordinary homogeneous differential equation with polynomial coefficients
  9965. over Q of any order, in the neighbourhood of zero (regular or irregular
  9966. singular point, or ordinary point).
  9967. This software can be used in two ways, directly via the \f{DELIRE}
  9968. procedure, or interactively with the \f{DESIR} procedure. The basic
  9969. procedure is the f{DELIRE} procedure which enables the solutions of a
  9970. linear homogeneous differential equation to be computed in the
  9971. neighbourhood of zero.
  9972. The \f{DESIR} procedure is a procedure without argument whereby
  9973. \f{DELIRE} can be called without preliminary treatment to the data,
  9974. that is to say, in an interactive autonomous way. This procedure also
  9975. proposes some transformations on the initial equation. This allows one
  9976. to start comfortably with an equation which has a non zero singular
  9977. point, a polynomial right-hand side and parameters.
  9978. \noindent{\tt delire(x,k,grille,lcoeff,param)}
  9979. This procedure computes formal solutions of a linear homogeneous
  9980. differential equation with polynomial coefficients over Q and of any
  9981. order, in the neighbourhood of zero, regular or irregular singular
  9982. point. {\tt x} is the variable, {\tt k} is the number of desired
  9983. terms (that is for each formal series in $x_t$ appearing in polysol,
  9984. $a_0+a_1 x_t+a_2 x_t^2+\ldots + a_n x_t^n+ \ldots$ we compute the
  9985. $k+1$ first coefficients $a_0$, $a_1$ to $a_k$. The coefficients of
  9986. the differential operator as polynomial in $x^{grille}$. In general
  9987. grille is 1. The argument {\tt lcoeff} is a list of coefficients of
  9988. the differential operator (in increasing order of differentiation) and
  9989. {\tt param} is a list of parameters. The procedure returns the list
  9990. of general solutions.
  9991. {\small\begin{verbatim}
  9992. lcoeff:={1,x,x,x**6};
  9993. 6
  9994. lcoeff := {1,x,x,x }
  9995. param:={};
  9996. param := {}
  9997. sol:=delire(x,4,1,lcoeff,param);
  9998. 4 3 2
  9999. xt - 4*xt + 12*xt - 24*xt + 24
  10000. sol := {{{{0,1,-----------------------------------,1},{
  10001. 12
  10002. }}},
  10003. 4 3
  10004. {{{0,1,(6*log(xt)*xt - 18*log(xt)*xt
  10005. 2
  10006. + 36*log(xt)*xt - 36*log(xt)*xt
  10007. 4 3
  10008. - 5*xt + 9*xt - 36*xt + 36)/36,0},{}
  10009. }},
  10010. 1
  10011. {{{-------,1,
  10012. 4
  10013. 4*xt
  10014. 4 3 2
  10015. 361*xt + 4*xt + 12*xt + 24*xt + 24
  10016. ---------------------------------------,10},
  10017. 24
  10018. {}}}}
  10019. \end{verbatim}}
  10020. \chapter{DFPART: Derivatives of generic functions}
  10021. \label{DFPART}
  10022. \typeout{{DFPART: Derivatives of generic functions}}
  10023. {\footnotesize
  10024. \begin{center}
  10025. Herbert Melenk \\
  10026. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  10027. Takustra\"se 7 \\
  10028. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  10029. e--mail: melenk@zib.de
  10030. \end{center}
  10031. }
  10032. \ttindex{DFPART}
  10033. \index{derivatives}
  10034. \index{partial derivatives}
  10035. \index{generic function}
  10036. The package {\tt DFPART} supports computations with total and partial
  10037. derivatives of formal function objects. Such computations can be
  10038. useful in the context of differential equations or power series
  10039. expansions.
  10040. \section{Generic Functions}
  10041. A generic function is a symbol which represents a mathematical
  10042. function. The minimal information about a generic function
  10043. function is the number of its arguments. In order to facilitate
  10044. the programming and for a better readable output this package
  10045. assumes that the arguments of a generic function have default
  10046. names such as $f(x,y)$, $q(rho,phi)$.
  10047. A generic function is declared by prototype form in a
  10048. statement\ttindex{GENERIC\_FUNCTION}
  10049. \vspace{.1in}
  10050. {\tt GENERIC\_FUNCTION} $fname(arg_1,arg_2\cdots arg_n)$;
  10051. \vspace{.1in}
  10052. \noindent
  10053. where $fname$ is the (new) name of a function and $arg_i$ are
  10054. symbols for its formal arguments. In the following $fname$ is
  10055. referred to as ``generic function'', $arg_1,arg_2\cdots arg_n$ as
  10056. ``generic arguments'' and $fname(arg_1,arg_2\cdots arg_n)$ as
  10057. ``generic form''.
  10058. Examples:
  10059. {\small\begin{verbatim}
  10060. generic_function f(x,y);
  10061. generic_function g(z);
  10062. \end{verbatim}}
  10063. After this declaration {\REDUCE} knows that
  10064. \begin{itemize}
  10065. \item there are formal partial derivatives $\frac{\partial f}{\partial x}$,
  10066. $\frac{\partial f}{\partial y}$ $\frac{\partial g}{\partial z}$
  10067. and higher ones, while partial derivatives of $f$ and $g$
  10068. with respect to other variables are assumed as zero,
  10069. \item expressions of the type $f()$, $g()$ are abbreviations for
  10070. $f(x,y)$, $g(z)$,
  10071. \item expressions of the type $f(u,v)$ are abbreviations for\\
  10072. $sub(x=u,y=v,f(x,y))$
  10073. \item a total derivative $\frac{d f(u,v)}{d w}$ has to be computed
  10074. as $\frac{\partial f}{\partial x} \frac{d u}{d w} +
  10075. \frac{\partial f}{\partial y} \frac{d v}{d w}$
  10076. \end{itemize}
  10077. \section{Partial Derivatives}
  10078. The operator {\tt DFP}\ttindex{DFP} represents a partial derivative:
  10079. \vspace{.1in}
  10080. {\tt DFP}($expr,{dfarg_1,dfarg_2\cdots dfarg_n}$);
  10081. \vspace{.1in}
  10082. \noindent
  10083. where $expr$ is a function expression and $dfarg_i$ are
  10084. the differentiation variables. Examples:
  10085. {\small\begin{verbatim}
  10086. dfp(f(),{x,y});
  10087. \end{verbatim}}
  10088. means $\frac{\partial ^2 f}{\partial x \partial y}$ and
  10089. {\small\begin{verbatim}
  10090. dfp(f(u,v),{x,y});
  10091. \end{verbatim}}
  10092. stands for $\frac{\partial ^2 f}{\partial x \partial y} (u,v)$.
  10093. For compatibility with the $DF$ operator the differentiation
  10094. variables need not be entered in list form; instead the syntax
  10095. of {\tt DF} can be used, where the function expression is followed
  10096. by the differentiation variables, eventually with repetition
  10097. numbers. Such forms are internally converted to the above
  10098. form with a list as second parameter.
  10099. The expression $expr$ can be a generic function
  10100. with or without arguments, or an arithmetic expression built
  10101. from generic functions and other algebraic parts. In the
  10102. second case the standard differentiation rules are applied
  10103. in order to reduce each derivative expressions to a minimal
  10104. form.
  10105. When the switch {\tt NAT} is on partial derivatives of generic
  10106. functions are printed in standard index notation, that is
  10107. $f_{xy}$ for $\frac{\partial ^2 f}{\partial x \partial y}$
  10108. and $f_{xy}(u,v)$ for $\frac{\partial ^2 f}{\partial x \partial y}(u,v)$.
  10109. Therefore single characters should be used for the arguments
  10110. whenever possible. Examples:
  10111. {\small\begin{verbatim}
  10112. generic_function f(x,y);
  10113. generic_function g(y);
  10114. dfp(f(),x,2);
  10115. F
  10116. XX
  10117. dfp(f()*g(),x,2);
  10118. F *G()
  10119. XX
  10120. dfp(f()*g(),x,y);
  10121. F *G() + F *G
  10122. XY X Y
  10123. \end{verbatim}}
  10124. The difference between partial and total derivatives is
  10125. illustrated by the following example:
  10126. {\small\begin{verbatim}
  10127. generic_function h(x);
  10128. dfp(f(x,h(x))*g(h(x)),x);
  10129. F (X,H(X))*G(H(X))
  10130. X
  10131. df(f(x,h(x))*g(h(x)),x);
  10132. F (X,H(X))*G(H(X)) + F (X,H(X))*H (X)*G(H(X))
  10133. X Y X
  10134. + G (H(X))*H (X)*F(X,H(X))
  10135. Y X
  10136. \end{verbatim}}
  10137. Normally partial differentials are assumed as non-commutative
  10138. {\small\begin{verbatim}
  10139. dfp(f(),x,y)-dfp(f(),y,x);
  10140. F - F
  10141. XY YX
  10142. \end{verbatim}}
  10143. However, a generic function can be declared to have globally
  10144. interchangeable partial derivatives using the declaration
  10145. {\tt DFP\_COMMUTE}\ttindex{DFP\_COMMUTE}
  10146. which takes the name of a generic function or a generic function
  10147. form as argument. For such a function differentiation variables are
  10148. rearranged corresponding to the sequence of the generic variables.
  10149. {\small\begin{verbatim}
  10150. generic_function q(x,y);
  10151. dfp_commute q(x,y);
  10152. dfp(q(),{x,y,y}) + dfp(q(),{y,x,y}) + dfp(q(),{y,y,x});
  10153. 3*Q
  10154. XYY
  10155. \end{verbatim}}
  10156. If only a part of the derivatives commute, this has to be
  10157. declared using the standard {\REDUCE} rule mechanism. Please
  10158. note that then the derivative variables must be written as
  10159. list.
  10160. \section{Substitutions}
  10161. When a generic form or a {\tt DFP} expression takes part in a
  10162. substitution the following steps are performed:
  10163. \begin{enumerate}
  10164. \item The substitutions are performed for the arguments. If the
  10165. argument list is empty the substitution is applied to the
  10166. generic arguments of the function; if these change, the resulting
  10167. forms are used as new actual arguments.
  10168. If the generic function itself is not affected by the substitution,
  10169. the process stops here.
  10170. \item If the function name or the generic function
  10171. form occurs as a left hand side in the substitution list,
  10172. it is replaced by the corresponding right hand side.
  10173. \item The new form is partially differentiated according to the
  10174. list of partial derivative variables.
  10175. \item The (eventually modified) actual parameters are substituted
  10176. into the form for their corresponding generic variables.
  10177. This substitution is done by name.
  10178. \end{enumerate}
  10179. Examples:
  10180. {\small\begin{verbatim}
  10181. generic_function f(x,y);
  10182. sub(y=10,f());
  10183. F(X,10)
  10184. sub(y=10,dfp(f(),x,2));
  10185. F (X,10)
  10186. XX
  10187. sub(y=10,dfp(f(y,y),x,2));
  10188. F (10,10)
  10189. XX
  10190. sub(f=x**3*y**3,dfp(f(),x,2));
  10191. 3
  10192. 6*X*Y
  10193. generic_function ff(y,z);
  10194. sub(f=ff,f(a,b));
  10195. FF(B,Z)
  10196. \end{verbatim}}
  10197. \chapter[DUMMY: Expressions with dummy vars]%
  10198. {DUMMY: Canonical form of expressions with dummy variables}
  10199. \label{DUMMY}
  10200. \typeout{[DUMMY: Expressions with dummy variables]}
  10201. {\footnotesize
  10202. \begin{center}
  10203. Alain Dresse \\
  10204. Universit\'e Libre de Bruxelles \\
  10205. Boulevard du Triomphe, CP 210/01 \\
  10206. B--1050 BRUXELLES, Belgium \\[0.05in]
  10207. e--mail: adresse@ulb.ac.be
  10208. \end{center}
  10209. }
  10210. \ttindex{DUMMY}
  10211. An expression of the type
  10212. $$
  10213. \sum_{a=1}^{n} f(a)
  10214. $$
  10215. for any $n$ is simply written as
  10216. $$
  10217. f(a)
  10218. $$
  10219. and $a$ is a {\em dummy} index.
  10220. If the previous expression is written as
  10221. $$
  10222. \sum_{b=1}^{n} f(b)
  10223. $$
  10224. $b$ is also a dummy index and, obviously we should be able to get the
  10225. equality
  10226. $$
  10227. f(a)-f(b);\, \rightarrow 0
  10228. $$
  10229. To declare dummy variables, two declarations are
  10230. available:\ttindex{DUMMY\_BASE}
  10231. \begin{itemize}
  10232. \item[i.]
  10233. {\small\begin{verbatim}
  10234. dummy_base <idp>;
  10235. \end{verbatim}}
  10236. where {\tt idp} is the name of any unassigned identifier.
  10237. \item[ii.]\ttindex{dummy\_names}
  10238. {\small\begin{verbatim}
  10239. dummy_names <d>,<dp>,<dpp> ....;
  10240. \end{verbatim}}
  10241. \end{itemize}
  10242. The first declares {\tt idp1,$\cdots$, idpn} as dummy variables {\em
  10243. i.e.\ }all variables of the form ``{\tt idxxx}'' where {\tt xxx} is a
  10244. number will be dummy variables, such as {\tt id1, id2, ... , id23}.
  10245. The second gives special names for dummy variables.
  10246. All other arguments are assumed to be {\tt free}.\\
  10247. An example:
  10248. {\small\begin{verbatim}
  10249. dummy_base dv; ==> dv
  10250. % dummy indices are dv1, dv2, dv3, ...
  10251. dummy_names i,j,k; ==> t
  10252. % dummy names are i,j,k.
  10253. \end{verbatim}}
  10254. When this is done, an expression like
  10255. {\small\begin{verbatim}
  10256. op(dv1)*sin(dv2)*abs(x)*op(i)^3*op(dv2)$
  10257. \end{verbatim}}
  10258. is allowed. Notice that, dummy indices may not be repeated (it is not
  10259. limited to tensor calculus) or that they be repeated many times inside
  10260. the expression.
  10261. By default all operators with dummy arguments are assumed to be {\em
  10262. commutative} and without symmetry properties. This can be varied by
  10263. declarations {\tt NONCOM}, {\tt SYMMETRIC} and {\tt AN\-TI\-SYM\-ME\-TRIC}
  10264. may be used on the
  10265. operators.\ttindex{NONCOM}\ttindex{SYMMETRIC}\ttindex{ANTISYMMETRIC}
  10266. They can also be declared anticommutative.\ttindex{ANTICOM}
  10267. {\small\begin{verbatim}
  10268. anticom ao1, ao2;
  10269. \end{verbatim}}
  10270. More complex symmetries can be handled with {\tt
  10271. SYMTREE}.\ttindex{SYMTREE}
  10272. The corresponding declaration for the Riemann tensor is
  10273. {\small\begin{verbatim}
  10274. symtree (r, {!+, {!-, 1, 2}, {!-, 3, 4}});
  10275. \end{verbatim}}
  10276. The symbols !*, !+ and !- at the beginning of each list mean that the
  10277. operator has no symmetry, is symmetric and is antisymmetric with
  10278. respect to the indices inside the list. Notice that the indices are
  10279. not designated by their names but merely by their natural order of
  10280. appearance. 1 means the first written argument of {\tt r}, 2 its
  10281. second argument {\em etc.} In the example above r is symmetric with
  10282. respect to interchange of the pairs of indices 1,2 and 3,4
  10283. respectively.
  10284. \chapter{EDS: Exterior differential systems}
  10285. \label{EDS}
  10286. \typeout{{EDS: Exterior differential systems}}
  10287. {\footnotesize
  10288. \begin{center}
  10289. David Hartley \\
  10290. Physics and Mathematical Physics \\
  10291. University of Adelaide SA 5005, Australia \\
  10292. e-mail: DHartley@physics.adelaide.edu.au
  10293. \end{center}
  10294. }
  10295. \ttindex{EDS: Exterior differential dystems}
  10296. \ttindex{EDS}
  10297. \section{Introduction}
  10298. Exterior differential systems give a geometrical framework for partial
  10299. differential equations and more general differential geometric problems.
  10300. The geometrical formulation has several advantages stemming from its
  10301. coordinate-independence, including superior treatment of nonlinear and
  10302. global problems. {\tt EDS} provides a number of tools for setting up and
  10303. manipulating exterior differential systems and implements many features of
  10304. the theory. Its main strengths are the ability to use anholonomic or moving
  10305. frames and the care taken with nonlinear problems.
  10306. The package is loaded
  10307. %\footnote{The package {\tt EXCALC}
  10308. %(Chap. \ref{EXCALC} p. \pageref{EXCALC}) and the package {\tt XIDEAL}
  10309. %(Chap. \ref{XIDEAL} p. \pageref{XIDEAL}) are loaded automatically with
  10310. %this package.}
  10311. by typing \quad {\tt load eds;} \par
  10312. Reading the full documentation, which comes with this
  10313. package, is strongly recommended.
  10314. The test file eds.tst, which is also in the package, provides
  10315. three inspiring examples on the subject. \\
  10316. EDS uses E.~Schr{\"u}fer's EXCALC package for the underlying
  10317. exterior calculus operations.
  10318. \section{Data Structures and Concepts}
  10319. \subsection{EDS}
  10320. A simple \meta{EDS}, or exterior differential system, is a triple
  10321. {\tt (S,$\Omega$,M)}, where {\it M} is a {\it coframing}, {\it S} is a
  10322. system on {\it M}, and {\it $\Omega$} is an independence condition.
  10323. Exterior differential equations without independence condition are not
  10324. treated by {\tt EDS}. {\it $\Omega$} should be either a decomposable
  10325. \meta{p-form} or a \meta{system} of 1-forms on {\it M}. \\
  10326. More generally an \meta{EDS} is a list of simple \meta{EDS} objects
  10327. where the various coframings are all disjoint. \\
  10328. The solutions of {\it (S,$\Omega$,M)} are integral manifolds, or immersions
  10329. on which {\it S} vanishes and the rank of $\Omega$ is preserved. Solutions
  10330. at a single point are described by integral elements.
  10331. \subsection{Coframing}
  10332. Within the context of {\tt EDS}, a {\it coframing} means a real
  10333. finite-dimensional differentiable manifold with a given global cobasis.
  10334. The information about a coframing required by {\tt EDS} is kept in a
  10335. \meta{coframing} object. The cobasis is the identifying element of
  10336. an {\tt EDS}. In addition to the cobasis, there can be given {\it coordinates,
  10337. structure equations} and {\it restrictions}.
  10338. In addition to the cobasis, {\it coordinates, structure equations} and
  10339. {\it restrictions} can be given.
  10340. The coordinates may be an incomplete or
  10341. overcomplete set. The structure equations express the exterior derivative of the
  10342. coordinates and cobasis elements as needed. All coordinate differentials must
  10343. be expressed in terms of the given cobasis, but not all cobasis derivatives
  10344. need be known.
  10345. The restrictions are a set of inequalities describing point sets
  10346. not in the manifold. \\
  10347. Please note that the \meta{coframing} object is by no means a full description
  10348. of a differentiable manifold. However, the \meta{coframing} object carries
  10349. sufficient information about the underlying manifold to allow a range of exterior
  10350. systems calculations to be carried out.
  10351. \subsection{Systems and background coframing}
  10352. The label \meta{system} refers to a list $\{<${\it p-form expr}$>,\ldots\}$ of
  10353. differential forms. If an {\tt EDS} operator also accepts a \meta{system} as
  10354. argument, then any extra information which is required is taken from the
  10355. background coframing. \\
  10356. It is possible to activate the rules and orderings of a \f{COFRAMING} operator
  10357. globally, by making it the {\it background coframing}. All subsequent \f{EXCALC}
  10358. \ttindex{EXCALC} operations will be governed by those rules. Operations on
  10359. \meta{EDS} objects are unaffected, since their coframings are still activated
  10360. locally.
  10361. \subsection{Integral elements}
  10362. An \meta{integral element} of an exterior system $(S,\Omega,M)$ is a subspace
  10363. $P \subset T_pM$ of the tangent space at some point $p \in M$. This integral
  10364. element can be represented by its annihilator $P^\perp \subset T^*_pM$, comprising
  10365. those 1-forms at $p$ which annihilate every vector in $P$. This can also be understood
  10366. as a maximal set of 1-forms at $p$ such that $S \simeq 0 \pmod{P^\perp}$ and the
  10367. rank of $\Omega$ is preserved modulo $P^\perp$. \\
  10368. An \meta{integral element} in EDS is a distribution of 1-forms on $M$,
  10369. specified as a \meta{system} of 1-forms.
  10370. \subsection{Properties and normal form}
  10371. For large problems, it can require a great deal of computation to establish
  10372. whether, for example, a system is closed or not. In order to save
  10373. recomputing such properties, an \meta{EDS} object carries a list of
  10374. \meta{properties} of the form
  10375. \begin{list}{}
  10376. \item {\tt \{\meta{keyword} = \meta{value},$\cdots$\}}
  10377. \end{list}
  10378. where \meta{keyword} is one of \f{closed}, \f{quasilinear}, \f{pfaffian} or
  10379. \f{involutive}, and \meta{value} is either \f{0} (false) or \f{1}
  10380. (true). These properties are suppressed when an \meta{EDS} is printed,
  10381. unless the \f{nat} switch is \f{off}. They can be examined using the
  10382. \f{PROPERTIES} operator. \\
  10383. Parts of the theory of exterior differential systems apply only at points
  10384. on the underlying manifold where the system is in some sense
  10385. non-singular. To ensure the theory applies, EDS automatically works all
  10386. exterior systems $(S,\Omega,M)$ into a {\em normal form}. This means that
  10387. the Pfaffian component of $S$ and the independence condition $\Omega$ are
  10388. in {\it solved} forms, distinguished terms from the 1-forms in $S$ have
  10389. been eliminated from the rest of $S$ and from $\Omega$ and any 1-forms in
  10390. $S$ which vanish modulo the independence condition are removed from the
  10391. system and their coefficients are appended as 0-forms.
  10392. \section{The EDS Package}
  10393. In the descriptions of the various operators we define the following
  10394. abbreviations for function parameters:
  10395. \vspace{0.25cm}
  10396. \begin{tabular}{ll}
  10397. $E$, $E'$ & \meta{EDS}\\
  10398. $S$ & \meta{system}\\
  10399. $M$, $N$ & \meta{coframing}, or a \meta{system} specifying a \meta{coframing}\\
  10400. $r$ & \meta{integer}\\
  10401. $\Omega$ & \meta{p-form}\\
  10402. $f$ & \meta{map}\\
  10403. $rsx$ & \meta{list of inequalities}\\
  10404. $cob$ & \meta{list of 1-form variables}\\
  10405. $crd$, $dep$, $ind$
  10406. & \meta{list of 0-form variables}\\
  10407. $drv$ & \meta{list of rules for exterior derivatives}\\
  10408. $pde$ & \meta{list of expressions or equations}\\
  10409. $X$ & \meta{transform}\\
  10410. $T$ & \meta{tableau}\\
  10411. $P$ & \meta{integral element}\\
  10412. \end{tabular}
  10413. \subsection{Constructing EDS objects}
  10414. An EDS \meta{coframing} is constructed using the \f{COFRAMING} operator.
  10415. In one form it examines the argument for 0-form and 1-form variables. The more
  10416. basic syntax takes the \meta{cobasis} as a list of 1-forms, \meta{coordinates}
  10417. as a list of 0-forms, \meta{restrictions} as a list of inequalities and
  10418. \meta{structure equations} as a list giving the exterior derivatives of the
  10419. coordinates and cobasis elements. All arguments except the cobasis are optional. \\
  10420. A simple \meta{EDS} is constructed using the \f{EDS} operator where the
  10421. \meta{indep. condition} can be either a decomposable \meta{p-form} or a
  10422. \meta{system} of 1-forms. The \meta{coframing} and the \meta{properties}
  10423. arguments can be omitted. The {\it EDS} is put into normal form before being
  10424. returned. With \f{SET\_COFRAMING} the background coframing is set. \\
  10425. The operator \f{PDS2EDS} encodes a PDE system into an \meta{EDS} object. \\
  10426. \begin{tabular}{lll}
  10427. \f{COFRAMING}(cob,crd,rsx,drv)\ttindex{COFRAMING} &
  10428. \f{COFRAMING}(S)\ttindex{COFRAMING} &
  10429. \f{EDS}(S,$\Omega$,M)\ttindex{EDS} \\
  10430. \f{CONTACT}(r,M,N)\ttindex{CONTACT} &
  10431. \f{PDE2EDS}(pde,dep,ind)\ttindex{PDE2EDS} &
  10432. \f{SET\_COFRAMING}(M)\ttindex{SET\_COFRAMING} \\
  10433. \f{SET\_COFRAMING}(E)\ttindex{SET\_COFRAMING} &
  10434. \f{SET\_COFRAMING}()\ttindex{SET\_COFRAMING}
  10435. \end{tabular}
  10436. \vspace{0.5cm}
  10437. {\bf Example:}
  10438. {\small\begin{verbatim}
  10439. 1: load eds;
  10440. 2: pform {x,y,z,p,q}=0,{e(i),w(i,j)}=1;
  10441. 3: indexrange {i,j,k}={1,2},{a,b,c}={3};
  10442. 4: eds({d z - p*d x - q*d y, d p^d q},{d x,d y});
  10443. EDS({d z - p*d x - q*d y,d p^d q},d x^d y)
  10444. 5: OMrules:=index_expand {d e(i)=>-w(i,-j)^e(j),w(i,-j)+w(j,-i)=>0}$
  10445. 6: eds({e(a)},{e(i)}) where OMrules;
  10446. 3 1 2
  10447. EDS({e },{e ,e })
  10448. 7: coframing ws;
  10449. 3 2 1 2 1 2 2
  10450. coframing({e ,w ,e ,e },{},{d e => - e ^w ,
  10451. 1 1
  10452. 2 1 2
  10453. d e => e ^w },{})
  10454. 1
  10455. \end{verbatim}}
  10456. \subsection{Inspecting EDS objects}
  10457. Using these operators you can get parts of your \meta{EDS} object. The
  10458. \f{PROPERTIES}(E) operator for example returns a list of properties which are
  10459. normally not printed out, unless the \f{NAT}\ttindex{NAT} switch is off. \\
  10460. \begin{tabular}{lll}
  10461. \f{COFRAMING}(E)\ttindex{COFRAMING} &
  10462. \f{COFRAMING}()\ttindex{COFRAMING} &
  10463. \f{COBASIS}(M)\ttindex{COBASIS} \\
  10464. \f{COBASIS}(E)\ttindex{COBASIS} &
  10465. \f{COORDINATES}(M)\ttindex{COORDINATES} &
  10466. \f{COORDINATES}(E)\ttindex{COORDINATES} \\
  10467. \f{STRUCTURE\_EQUATIONS}(M)\ttindex{STRUCTURE\_EQUATIONS} &
  10468. \f{STRUCTURE\_EQUATIONS}(E)\ttindex{STRUCTURE\_EQUATIONS} &
  10469. \f{RESTRICTIONS}(M)\ttindex{RESTRICTIONS} \\
  10470. \f{RESTRICTIONS}(E)\ttindex{RESTRICTIONS} &
  10471. \f{SYSTEM}(E)\ttindex{SYSTEM} &
  10472. \f{INDEPENDENCE}(E)\ttindex{INDEPENDENCE} \\
  10473. \f{PROPERTIES}(E)\ttindex{PROPERTIES} &
  10474. \f{ONE\_FORMS}(E)\ttindex{ONE\_FORMS} &
  10475. \f{ONE\_FORMS}(S)\ttindex{ONE\_FORMS} \\
  10476. \f{ZERO\_FORMS}(E)\ttindex{ZERO\_FORMS} &
  10477. \f{ZERO\_FORMS}(S)\ttindex{ZERO\_FORMS} &
  10478. \end{tabular}
  10479. \vspace{0.5cm}
  10480. {\bf Example:}
  10481. {\small\begin{verbatim}
  10482. 8: depend u,x,y; depend v,x,y;
  10483. 9: pde2eds({df(u,y,y)=df(v,x),df(v,y)=y*df(v,x)});
  10484. EDS({d u - u *d x - u *d y, d u - u *d x - u *d y,
  10485. x y x x x y x
  10486. d u - u *d x - v *d y, d v - v *d x - v *y*d y},d x^d y)
  10487. y y x x x x
  10488. 10: dependencies;
  10489. {{u,y,x},{v,y,x}}
  10490. 11: coordinates contact(3,{x},{u});
  10491. {x,u,u ,u ,u }
  10492. x x x x x x
  10493. 12: fdomain u=u(x);
  10494. 13: coordinates {d u+d y};
  10495. {x,y}
  10496. \end{verbatim}}
  10497. \subsection{Manipulating EDS objects}
  10498. These operators allow you to manipulate your \meta{EDS} objects. The
  10499. \f{AUGMENT}(E,S) operator, see example below, appends the extra forms in the second
  10500. argument to the system part of the first. The original \meta{EDS} remains
  10501. unchanged. As another example by using the \f{TRANSFORM} operator
  10502. a change of the cobasis is made, where the argument \meta{transform} is a list of
  10503. substitutions. \\
  10504. \begin{tabular}{llll}
  10505. \f{AUGMENT}(E,S)\ttindex{AUGMENT} &
  10506. $M$ \f{CROSS} $N$\ttindex{CROSS} &
  10507. $E$ \f{CROSS} $N$\ttindex{CROSS} &
  10508. \f{PULLBACK(E,f)}\ttindex{PULLBACK} \\
  10509. \f{PULLBACK}(S,f)\ttindex{PULLBACK} &
  10510. \f{PULLBACK}($\Omega$,f)\ttindex{PULLBACK} &
  10511. \f{PULLBACK}(M,f)\ttindex{PULLBACK} &
  10512. \f{RESTRICT}(E,f)\ttindex{RESTRICT} \\
  10513. \f{RESTRICT}(S,f)\ttindex{RESTRICT} &
  10514. \f{RESTRICT}($\Omega$,f)\ttindex{RESTRICT} &
  10515. \f{RESTRICT}(M,f)\ttindex{RESTRICT} &
  10516. \f{TRANSFORM}(M,X)\ttindex{TRANSFORM} \\
  10517. \f{TRANSFORM}(E,X)\ttindex{TRANSFORM} &
  10518. \f{TRANSFORM}(S,X)\ttindex{TRANSFORM} &
  10519. \f{TRANSFORM}($\Omega$,X)\ttindex{TRANSFORM} &
  10520. \f{LIFT(E)}\ttindex{LIFT} \\
  10521. \end{tabular}
  10522. \vspace{0.5cm}
  10523. {\bf Example:}
  10524. {\small\begin{verbatim}
  10525. % Non-Pfaffian system for a Monge-Ampere equation
  10526. 14: PFORM {x,y,z}=0$
  10527. 15: S := CONTACT(1,{x,y},{z});
  10528. s := EDS({d z - z *d x - z *d y},d x^d y)
  10529. x y
  10530. 16: S:= AUGMENT(S,{d z(-x)^d z(-y)});
  10531. s := EDS({d z - z *d x - z *d y,
  10532. x y
  10533. d z ^d z },d x^d y)
  10534. x y
  10535. \end{verbatim}}
  10536. \subsection{Analysing and Testing exterior systems}
  10537. {\bf Analysing exterior systems} \par
  10538. This section introduces higher level operators for extracting information about
  10539. exterior systems. Many of them require a \meta{EDS} in normal form generated
  10540. in positive degree as input, but some can also analyse a \meta{system} or a
  10541. single \meta{p-form}. \\
  10542. \begin{tabular}{lll}
  10543. \f{CARTAN\_SYSTEM}(E)\ttindex{CARTAN\_SYSTEM} &
  10544. \f{CARTAN\_SYSTEM}(S)\ttindex{CARTAN\_SYSTEM} &
  10545. \f{CARTAN\_SYSTEM}($\Omega$)\ttindex{CARTAN\_SYSTEM} \\
  10546. \f{CAUCHY\_SYSTEM}(E)\ttindex{CAUCHY\_SYSTEM} &
  10547. \f{CAUCHY\_SYSTEM}(S)\ttindex{CAUCHY\_SYSTEM} &
  10548. \f{CAUCHY\_SYSTEM}($\Omega$)\ttindex{CAUCHY\_SYSTEM} \\
  10549. \f{CHARACTERS}(E)\ttindex{CHARACTERS} &
  10550. \f{CHARACTERS}(T)\ttindex{CHARACTERS} &
  10551. \f{CHARACTERS}(E,P)\ttindex{CHARACTERS} \\
  10552. \f{CLOSURE}(E)\ttindex{CLOSURE} &
  10553. \f{DERIVED\_SYSTEM}(E)\ttindex{DERIVED\_SYSTEMS} &
  10554. \f{DERIVED\_SYSTEM}(S)\ttindex{DERIVED\_SYSTEMS} \\
  10555. \f{DIM\_GRASSMANN\_VARIETY}(E)\ttindex{DIM\_GRASSMANN\_VARIETY} &
  10556. \f{DIM\_GRASSMANN\_VARIETY}(E,P)\ttindex{DIM\_GRASSMANN\_VARIETY} &
  10557. \f{DIM}(M)\ttindex{DIM} \\
  10558. \f{DIM}(E)\ttindex{DIM} &
  10559. \f{INVOLUTION}(E)\ttindex{INVOLUTION} &
  10560. \f{LINEARISE}(E,P)\ttindex{LINEARISE} \\
  10561. \f{INTEGRAL\_ELEMENT}(E)\ttindex{INTEGRAL\_ELEMENT} &
  10562. \f{PROLONG}(E)\ttindex{PROLONG} &
  10563. \f{TABLEAU}(E)\ttindex{TABLEAU} \\
  10564. \f{TORSION}(E)\ttindex{TORSION} &
  10565. \f{GRASSMANN\_VARIETY}(E)\ttindex{GRASSMANN\_VARIETY} &
  10566. \end{tabular}
  10567. \par
  10568. \ \\
  10569. {\bf Testing exterior systems} \par
  10570. The following operators allow various properties of an \meta{EDS} to be checked.
  10571. The result is either a {\bf 1} or a {\bf 0}, so these operators can be used in
  10572. boolean expressions. Since checking these properties is very time-consuming, the
  10573. result of the first test is stored on the \meta{properties} record of an
  10574. \meta{EDS} to avoid re-checking. This memory can be cleared using the
  10575. \f{CLEANUP}\ttindex{CLEANUP} opearator. \\
  10576. \begin{tabular}{llll}
  10577. \f{CLOSED}(E)\ttindex{CLOSED} &
  10578. \f{CLOSED}(S)\ttindex{CLOSED} &
  10579. \f{CLOSED}($\Omega$)\ttindex{CLOSED} &
  10580. \f{INVOLUTIVE}(E)\ttindex{INVOLUTIVE} \\
  10581. \f{PFAFFIAN}(E)\ttindex{PFAFFIAN} &
  10582. \f{QUASILINEAR}(E)\ttindex{QUASILINEAR} &
  10583. \f{SEMILINEAR}(E)\ttindex{SEMILINEAR} &
  10584. $E$ \f{EQUIV} $E'$\ttindex{EQUIV} \\
  10585. \end{tabular}
  10586. \vspace{0.5cm}
  10587. \subsection{Switches}
  10588. EDS provides several switches to govern the display of information and enhance
  10589. the speed or reliability of the calculations. For example the switch \f{EDSVERBOSE}
  10590. if {\tt ON} will display additional information as the calculation progresses,
  10591. which might generate too much output for larger problems. \\
  10592. All switches are {\tt OFF} by default.
  10593. \begin{tabular}{llllll}
  10594. \f{EDSVERBOSE}\ttindex{EDSVERBOSE} &
  10595. \f{EDSDEBUG}\ttindex{EDSDEBUG} &
  10596. \f{EDSSLOPPY}\ttindex{EDSSLOPPY} &
  10597. \f{EDSDISJOINT}\ttindex{EDSDISJOINT} &
  10598. \f{RANPOS}\ttindex{RANPOS} &
  10599. \f{GENPOS}\ttindex{GENPOS} \\
  10600. \end{tabular}
  10601. \subsection{Auxilliary functions}
  10602. The operators of this section are designed to ease working with exterior forms
  10603. and exterior systems in {\REDUCE}\ . \\
  10604. \begin{tabular}{lll}
  10605. \f{COORDINATES}(S)\ttindex{COORDINATES} &
  10606. \f{INVERT}(X)\ttindex{INVERT} &
  10607. \f{STRUCTURE\_EQUATIONS}(X)\ttindex{STRUCTURE\_EQUATIONS} \\
  10608. \f{STRUCTURE\_EQUATIONS}(X,$X^{-1}$)\ttindex{STRUCTURE\_EQUATIONS} &
  10609. \f{LINEAR\_DIVISORS}($\Omega$)\ttindex{LINEAR\_DIVISORS} &
  10610. \f{EXFACTORS}($\Omega$)\ttindex{EXFACTORS} \\
  10611. \f{INDEX\_EXPAND}(ANY)\ttindex{INDEX\_EXPAND} &
  10612. \f{PDE2JET}(pde,dep,ind)\ttindex{PDE2JET} &
  10613. \f{MKDEPEND}(list)\ttindex{MKDEPEND} \\
  10614. \f{DISJOIN}(f,g,...)\ttindex{DISJOIN} &
  10615. \f{CLEANUP}(E)\ttindex{CLEANUP} &
  10616. \f{CLEANUP}(M)\ttindex{CLEANUP} \\
  10617. \f{REORDER}(E)\ttindex{REORDER} &
  10618. \f{REORDER}(M)\ttindex{REORDER} &
  10619. \end{tabular}
  10620. \subsection{Experimental Functions}
  10621. The following operators are experimental facilities since, they are
  10622. either algorithmically not well-founded, or their implementation is
  10623. very unstable, or they have known bugs. \\
  10624. \begin{tabular}{lll}
  10625. \f{POINCARE}($\Omega$)\ttindex{POINCARE} &
  10626. \f{INVARIANTS}(E,crd)\ttindex{INVARIANTS} &
  10627. \f{INVARIANTS}(S,crd)\ttindex{INVARIANTS} \\
  10628. \f{SYMBOL\_RELATIONS}(E,$\pi$)\ttindex{SYMBOL\_RELATIONS} &
  10629. \f{SYMBOL\_MATRIX}(E,$\xi$)\ttindex{SYMBOL\_MATRIX} &
  10630. \f{CHARACTERISTIC\_VARIETY}(E,$\xi$)\ttindex{CHARACTERISTIC\_VARIETY} \\
  10631. \end{tabular}
  10632. \vspace{0.5cm}
  10633. {\bf Example:}
  10634. {\small\begin{verbatim}
  10635. 17: % Riemann invariants for Euler-Poisson-Darboux equation.
  10636. 17: % Set up the EDS for the equation, and examine tableau.
  10637. 17: depend u,x,y; EPD :=PDE2EDS{DF(u,x,y)=-(df(u,x)+df(u,y))/(x+y)}$
  10638. 19: tableau EPD;
  10639. [d u 0 ]
  10640. [ x x ]
  10641. [ ]
  10642. [ 0 d u ]
  10643. [ y y]
  10644. 20: % 1-form dx is characteristic: construct characteristic EDS.
  10645. 20: xvars {}; C := cartan_system select(~f^d x=0,system closure epd)$
  10646. 22: S := augment(eds(system EPD,d y),C)$
  10647. 23: % Compute derived flag
  10648. 23: while not equiv(S,S1 := derived_system S) do S := S1;
  10649. 24: % Stabilised. Find the Riemann invariants.
  10650. 24: invariants(S,reverse coordinates S);
  10651. {x,
  10652. u *x + u *y + u,
  10653. x x
  10654. - u *x - u *y - 2*u }
  10655. x x x x x
  10656. \end{verbatim}}
  10657. \chapter[EXCALC: Differential Geometry]%
  10658. {EXCALC: A differential geometry package}
  10659. \label{EXCALC}
  10660. \typeout{{EXCALC: A differential geometry package}}
  10661. {\footnotesize
  10662. \begin{center}
  10663. Eberhard Schr\"{u}fer \\
  10664. GMD, Institut I1 \\
  10665. Postfach 1316 \\
  10666. 53757 St. Augustin, GERMANY \\[0.05in]
  10667. e--mail: schruefer@gmd.de
  10668. \end{center}
  10669. }
  10670. \ttindex{EXCALC}
  10671. {\bf EXCALC} is designed for easy use by all who are familiar with the
  10672. calculus of Modern Differential Geometry. Its syntax is kept as close
  10673. as possible to standard textbook notations. Therefore, no great
  10674. experience in writing computer algebra programs is required. It is
  10675. almost possible to input to the computer the same as what would have
  10676. been written down for a hand-calculation. For example, the statement
  10677. {\small\begin{verbatim}
  10678. f*x^y + u _| (y^z^x)
  10679. \end{verbatim}}
  10680. \index{exterior calculus}
  10681. would be recognized by the program as a formula involving exterior
  10682. products and an inner product. The program is currently able to
  10683. handle scalar-valued exterior forms, vectors and operations between
  10684. them, as well as non-scalar valued forms (indexed forms). With this,
  10685. it should be an ideal tool for studying differential equations,
  10686. doing calculations in general relativity and field theories, or doing
  10687. such simple things as calculating the Laplacian of a tensor field for
  10688. an arbitrary given frame. With the increasing popularity of this
  10689. calculus, this program should have an application in almost any field
  10690. of physics and mathematics.
  10691. \section{Declarations}
  10692. Geometrical objects like exterior forms or vectors are introduced to the
  10693. system by declaration commands. The declarations can appear anywhere in
  10694. a program, but must, of course, be made prior to the use of the object.
  10695. Everything that has no declaration is treated as a constant; therefore
  10696. zero-forms must also be declared.
  10697. An exterior form is introduced by\label{PFORM}\index{PFORM statement}
  10698. \index{exterior form ! declaration}
  10699. \hspace*{2em} \k{PFORM} \s{declaration$_1$}, \s{declaration$_2$}, \ldots;
  10700. where
  10701. \begin{tabbing}
  10702. \s{declaration} ::= \s{name} $\mid$ \s{list of names}=\s{number} $\mid$ \s{identifier} $\mid$ \\
  10703. \s{expression} \\
  10704. \s{name} ::= \s{identifier} $\mid$ \s{identifier}(\s{arguments})
  10705. \end{tabbing}
  10706. For example
  10707. {\small\begin{verbatim}
  10708. pform u=k,v=4,f=0,w=dim-1;
  10709. \end{verbatim}}
  10710. declares {\tt U} to be an exterior form of degree {\tt K}, {\tt V} to be a
  10711. form of degree 4, {\tt F} to be a form of degree 0 (a function), and {\tt W}
  10712. to be a form of degree {\tt DIM}-1.
  10713. The declaration of vectors is similar. The command {\tt TVECTOR}\label{TVECTOR}
  10714. takes a list of names.\index{TVECTOR command}\index{exterior form ! vector}
  10715. \hspace*{2em} \k{TVECTOR} \s{name$_1$}, \s{name$_2$}, \ldots;
  10716. For example, to declare {\tt X} as a vector and {\tt COMM} as a vector with
  10717. two indices, one would say
  10718. {\small\begin{verbatim}
  10719. tvector x,comm(a,b);
  10720. \end{verbatim}}
  10721. The exterior degree of a symbol or a general expression can be obtained
  10722. with the function \label{EXDEGREE}\index{EXDEGREE command}
  10723. \hspace*{2em} \k{EXDEGREE} \s{expression};
  10724. Example:
  10725. {\small\begin{verbatim}
  10726. exdegree(u + 3*chris(k,-k));
  10727. 1
  10728. \end{verbatim}}
  10729. \section{Exterior Multiplication}
  10730. \index{"\^{} ! exterior multiplication}\index{exterior product}
  10731. Exterior multiplication between exterior forms is carried out with the
  10732. nary infix operator \^{ } (wedge)\label{wedge}. Factors are ordered
  10733. according to the usual ordering in {\REDUCE} using the commutation
  10734. rule for exterior products.
  10735. {\small\begin{verbatim}
  10736. pform u=1,v=1,w=k;
  10737. u^v;
  10738. U^V
  10739. v^u;
  10740. - U^V
  10741. u^u;
  10742. 0
  10743. w^u^v;
  10744. K
  10745. ( - 1) *U^V^W
  10746. (3*u-a*w)^(w+5*v)^u;
  10747. A*(5*U^V^W - U^W^W)
  10748. \end{verbatim}}
  10749. It is possible to declare the dimension of the underlying space
  10750. by\label{SPACEDIM}\index{SPACEDIM command}\index{dimension}
  10751. \hspace*{2em} \k{SPACEDIM} \s{number} $\mid$ \s{identifier};
  10752. If an exterior product has a degree higher than the dimension of the
  10753. space, it is replaced by 0:
  10754. \section{Partial Differentiation}
  10755. Partial differentiation is denoted by the operator {\tt @}\label{at}.
  10756. Its capability is the same as the {\REDUCE} {\tt DF} operator.
  10757. \index{"@ operator}\index{partial differentiation}
  10758. \index{differentiation ! partial}
  10759. \example\index{EXCALC package ! example}
  10760. {\small\begin{verbatim}
  10761. @(sin x,x);
  10762. COS(X)
  10763. @(f,x);
  10764. 0
  10765. \end{verbatim}}
  10766. An identifier can be declared to be a function of certain variables.
  10767. \index{FDOMAIN command}
  10768. This is done with the command {\tt FDOMAIN}\label{FDOMAIN}. The
  10769. following would tell the partial differentiation operator that {\tt F}
  10770. is a function of the variables {\tt X} and {\tt Y} and that {\tt H} is
  10771. a function of {\tt X}.
  10772. {\small\begin{verbatim}
  10773. fdomain f=f(x,y),h=h(x);
  10774. \end{verbatim}}
  10775. Applying {\tt @} to {\tt F} and {\tt H} would result in
  10776. {\small\begin{verbatim}
  10777. @(x*f,x);
  10778. F + X*@ F
  10779. X
  10780. @(h,y);
  10781. 0
  10782. \end{verbatim}}
  10783. \index{tangent vector}
  10784. The partial derivative symbol can also be an operator with a single
  10785. argument. It then represents a natural base element of a tangent
  10786. vector\label{at1}.
  10787. \section{Exterior Differentiation}
  10788. \index{exterior differentiation}
  10789. Exterior differentiation of exterior forms is carried out by the
  10790. operator {\tt d}\label{d}. Products are normally differentiated out,
  10791. {\small\begin{verbatim}
  10792. pform x=0,y=k,z=m;
  10793. d(x * y);
  10794. X*d Y + d X^Y
  10795. \end{verbatim}}
  10796. This expansion can be suppressed by the command {\tt NOXPND
  10797. D}\label{NOXPNDD}.\index{NOXPND ! D}
  10798. Expansion is performed again when the command {\tt XPND D}\label{XPNDD}
  10799. is executed.\index{XPND ! D}
  10800. If an argument of an implicitly defined function has further
  10801. dependencies the chain rule will be applied {\em e.g.}\index{chain rule}
  10802. {\small\begin{verbatim}
  10803. fdomain y=y(z);
  10804. d f;
  10805. @ F*d X + @ F*@ Y*d Z
  10806. X Y Z
  10807. \end{verbatim}}
  10808. Expansion into partial derivatives can be inhibited by
  10809. {\tt NOXPND @}\label{NOXPNDA}
  10810. and enabled again by {\tt XPND @}\label{XPNDA}.
  10811. \index{NOXPND ! "@}\index{XPND ! "@}
  10812. \section{Inner Product}
  10813. \index{inner product ! exterior form}
  10814. The inner product between a vector and an exterior form is represented
  10815. by the diphthong \_$|$ \label{innerp} (underscore or-bar), which is the
  10816. notation of many textbooks. If the exterior form is an exterior
  10817. product, the inner product is carried through any factor.
  10818. \index{\_$\mid$ operator}
  10819. \example\index{EXCALC package ! example}
  10820. {\small\begin{verbatim}
  10821. pform x=0,y=k,z=m;
  10822. tvector u,v;
  10823. u _| (x*y^z);
  10824. K
  10825. X*(( - 1) *Y^U _| Z + U _| Y^Z)
  10826. \end{verbatim}}
  10827. \section{Lie Derivative}
  10828. \index{Lie Derivative}
  10829. The Lie derivative can be taken between a vector and an exterior form
  10830. or between two vectors. It is represented by the infix operator $|$\_
  10831. \label{lie}. In the case of Lie differentiating, an exterior form by
  10832. a vector, the Lie derivative is expressed through inner products and
  10833. exterior differentiations, {\em i.e.}\index{$\mid$\_ operator}
  10834. {\small\begin{verbatim}
  10835. pform z=k;
  10836. tvector u;
  10837. u |_ z;
  10838. U _| d Z + d(U _| Z)
  10839. \end{verbatim}}
  10840. \section{Hodge-* Duality Operator}
  10841. \index{Hodge-* duality operator}\index{"\# ! Hodge-* operator}
  10842. The Hodge-*\label{hodge} duality operator maps an exterior form of degree
  10843. {\tt K} to an exterior form of degree {\tt N-K}, where {\tt N} is the
  10844. dimension of the space. The double application of the operator must
  10845. lead back to the original exterior form up to a factor. The following
  10846. example shows how the factor is chosen here
  10847. {\small\begin{verbatim}
  10848. spacedim n;
  10849. pform x=k;
  10850. # # x;
  10851. 2
  10852. (K + K*N)
  10853. ( - 1) *X*SGN
  10854. \end{verbatim}}
  10855. \index{SGN ! indeterminate sign}\index{coframe}
  10856. The indeterminate SGN in the above example denotes the sign of the
  10857. determinant of the metric. It can be assigned a value or will be
  10858. automatically set if more of the metric structure is specified (via
  10859. COFRAME), {\em i.e.} it is then set to $g/|g|$, where $g$ is the
  10860. determinant of the metric. If the Hodge-* operator appears in an
  10861. exterior product of maximal degree as the leftmost factor, the Hodge-*
  10862. is shifted to the right according to
  10863. {\small\begin{verbatim}
  10864. pform {x,y}=k;
  10865. # x ^ y;
  10866. 2
  10867. (K + K*N)
  10868. ( - 1) *X^# Y
  10869. \end{verbatim}}
  10870. \section{Variational Derivative}
  10871. \index{derivative ! variational}\index{variational derivative}
  10872. \ttindex{VARDF}
  10873. The function {\tt VARDF}\label{VARDF} returns as its value the
  10874. variation of a given Lagrangian n-form with respect to a specified
  10875. exterior form (a field of the Lagrangian). In the shared variable
  10876. \ttindex{BNDEQ"!*}
  10877. {\tt BNDEQ!*}, the expression is stored that has to yield zero if
  10878. integrated over the boundary.
  10879. Syntax:
  10880. \hspace*{2em} \k{VARDF}(\s{Lagrangian n-form},\s{exterior form})
  10881. \example\index{EXCALC package ! example}
  10882. {\small\begin{verbatim}
  10883. spacedim 4;
  10884. pform l=4,a=1,j=3;
  10885. l:=-1/2*d a ^ # d a - a^# j$ %Lagrangian of the e.m. field
  10886. vardf(l,a);
  10887. - (# J + d # d A) %Maxwell's equations
  10888. bndeq!*;
  10889. - 'A^# d A %Equation at the boundary
  10890. \end{verbatim}}
  10891. For the calculation of the conserved currents induced by symmetry
  10892. operators (vector fields), the function {\tt NOETHER}\label{NOETHER}
  10893. \index{NOETHER function}
  10894. is provided. It has the syntax:
  10895. \hspace*{2em}
  10896. \k{NOETHER}(\s{Lagrangian n-form},\s{field},\s{symmetry generator})
  10897. \example\index{EXCALC package ! example}
  10898. {\small\begin{verbatim}
  10899. pform l=4,a=1,f=2;
  10900. spacedim 4;
  10901. l:= -1/2*d a^#d a; %Free Maxwell field;
  10902. tvector x(k); %An unspecified generator;
  10903. noether(l,a,x(-k));
  10904. ( - 2*d(X _|A)^# d A - (X _|d A)^# d A + d A^(X _|# d A))/2
  10905. K K K
  10906. \end{verbatim}}
  10907. \section{Handling of Indices}
  10908. \index{exterior form ! with indices}
  10909. Exterior forms and vectors may have indices. On input, the indices
  10910. are given as arguments of the object. A positive argument denotes a
  10911. superscript and a negative argument a subscript. On output, the
  10912. indexed quantity is displayed two dimensionally if {\tt NAT} is on.
  10913. \index{NAT flag}
  10914. Indices may be identifiers or numbers.
  10915. \example\index{EXCALC package ! example}
  10916. {\small\begin{verbatim}
  10917. pform om(k,l)=m,e(k)=1;
  10918. e(k)^e(-l);
  10919. K
  10920. E ^E
  10921. L
  10922. om(4,-2);
  10923. 4
  10924. OM
  10925. 2
  10926. \end{verbatim}}
  10927. In certain cases, one would like to inhibit the summation over
  10928. specified index names, or at all. For this the command
  10929. \index{NOSUM command}
  10930. \hspace*{2em} \k{NOSUM} \s{indexname$_1$}, \ldots;\label{NOSUM}
  10931. and the switch {\tt NOSUM} are\index{NOSUM switch}
  10932. available. The command {\tt NOSUM} has the effect that summation is
  10933. not performed over those indices which had been listed. The command
  10934. {\tt RENOSUM}\label{RENOSUM} enables summation again. The switch {\tt
  10935. NOSUM}, if on, inhibits any summation.\index{RENOSUM command}
  10936. \label{INDEXSYMMETRIES}\index{INDEXSYMMETRIES command}
  10937. It is possible to declare symmetry properties for an indexed quantity by
  10938. the command {\tt INDEX\_SYMMETRIES}. A prototypical example is as
  10939. follows
  10940. {\small\begin{verbatim}
  10941. index_symmetries u(k,l,m,n): symmetric in {k,l},{m,n}
  10942. antisymmetric in {{k,l},{m,n}},
  10943. g(k,l),h(k,l): symmetric;
  10944. \end{verbatim}}
  10945. It declares the object {\tt u} symmetric in the first two and last
  10946. two indices and antisymmetric with respect to commutation of the given
  10947. index pairs. If an object is completely symmetric or antisymmetric,
  10948. the indices need not to be given after the corresponding keyword as
  10949. shown above for {\tt g} and {\tt h}.
  10950. \section{Metric Structures}
  10951. \index{metric structure}\index{coframe}
  10952. A metric structure is defined in {\bf EXCALC} by specifying a set of
  10953. basis one-forms (the coframe) together with the metric.
  10954. Syntax:\label{COFRAME}
  10955. \begin{tabbing}
  10956. \hspace*{2em} \k{COFRAME} \=
  10957. \s{identifier}\s{(index$_1$)}=\s{expression$_1$}, \\
  10958. \> \s{identifier}\s{(index$_2$)}=\s{expression$_2$}, \\
  10959. \> . \\
  10960. \> . \\
  10961. \> . \\
  10962. \> \s{identifier}\s{(index$_n$)}=\s{expression$_n$} \\
  10963. \> \hspace{1em} \k{WITH} \k{METRIC} \s{name}=\s{expression}; \\
  10964. \end{tabbing}
  10965. \index{Euclidean metric}\index{COFRAME ! WITH METRIC}
  10966. This statement automatically sets the dimension of the space and the
  10967. index range. The clause {\tt WITH METRIC} can be omitted if the metric
  10968. \index{COFRAME ! WITH SIGNATURE}
  10969. is Euclidean and the shorthand {\tt WITH SIGNATURE \s{diagonal elements}}
  10970. \label{SIGNATURE} can be used in the case of a pseudo-Euclidean
  10971. metric. The splitting of a metric structure in its metric tensor
  10972. coefficients and basis one-forms is completely arbitrary including the
  10973. extremes of an orthonormal frame and a coordinate frame.
  10974. \newpage
  10975. \example\index{EXCALC package ! example}
  10976. {\small\begin{verbatim}
  10977. coframe e r=d r, e(ph)=r*d ph
  10978. with metric g=e(r)*e(r)+e(ph)*e(ph); %Polar coframe
  10979. \end{verbatim}}
  10980. The frame dual to the frame defined by the {\tt COFRAME} command can
  10981. be introduced by \k{FRAME} command.\index{FRAME command}
  10982. \hspace*{2em} \k{FRAME} \s{identifier};\label{FRAME}
  10983. This command causes the
  10984. dual property to be recognised, and the tangent vectors of the
  10985. coordinate functions are replaced by the frame basis vectors.
  10986. \example\index{EXCALC package ! example}
  10987. {\small\begin{verbatim}
  10988. coframe b r=d r,b ph=r*d ph,e z=d z; %Cylindrical coframe;
  10989. frame x; on nero;
  10990. x(-k) _| b(l);
  10991. R
  10992. NS := 1
  10993. R
  10994. PH
  10995. NS := 1
  10996. PH
  10997. Z
  10998. NS := 1
  10999. Z
  11000. x(-k) |_ x(-l); %The commutator of the dual frame;
  11001. NS := X /R
  11002. PH R PH
  11003. NS := ( - X )/R %i.e. it is not a coordinate base;
  11004. R PH PH
  11005. \end{verbatim}}
  11006. \index{DISPLAYFRAME command}\index{tracing ! EXCALC}
  11007. As a convenience, the frames can be displayed at any point in a program
  11008. by the command {\tt DISPLAYFRAME;}\label{DISPLAYFRAME}.
  11009. \index{Hodge-* duality operator}
  11010. The Hodge-* duality operator returns the explicitly constructed dual
  11011. element if applied to coframe base elements. The metric is properly
  11012. taken into account.
  11013. \index{Levi-Cevita tensor}\ttindex{EPS}
  11014. The total antisymmetric Levi-Cevita tensor {\tt EPS}\label{EPS} is
  11015. also available. The value of {\tt EPS} with an even permutation of the
  11016. indices in a covariant position is taken to be +1.
  11017. \section{Riemannian Connections}
  11018. \index{Riemannian Connections}
  11019. The command {\tt RIEMANNCONX} is provided for calculating the
  11020. \index{RIEMANNCONX command} \label{RIEMANNCONX}
  11021. connection 1 forms. The values are stored on the name given to {\tt
  11022. RIEMANNCONX}. This command is far more efficient than calculating the
  11023. connection from the differential of the basis one-forms and using
  11024. inner products.
  11025. \section{Ordering and Structuring}
  11026. \index{ordering ! exterior form}\index{FORDER command}
  11027. The ordering of an exterior form or vector can be changed by the
  11028. command {\tt FORDER}.\label{FORDER} In an expression, the first
  11029. identifier or kernel in the arguments of {\tt FORDER} is ordered ahead
  11030. of the second, and so on, and ordered ahead of all not appearing as
  11031. arguments. This ordering is done on the internal level and not only
  11032. on output. The execution of this statement can therefore have
  11033. tremendous effects on computation time and memory requirements. {\tt
  11034. REMFORDER}\label{REMFORDER} brings back standard ordering for those
  11035. elements that are listed as arguments.\index{REMFORDER command}
  11036. An expression can be put in a more structured form by renaming a
  11037. subexpression. This is done with the command {\tt KEEP} which
  11038. has the syntax\index{KEEP command}\label{KEEP}
  11039. \hspace*{2em} \k{KEEP}
  11040. \s{name$_1$}=\s{expression$_1$},\s{name$_2$}=\s{expression$_2$}, \ldots
  11041. \index{exterior product}
  11042. The capabilities of {\tt KEEP} are currently very limited. Only exterior
  11043. products should occur as righthand sides in {\tt KEEP}.
  11044. \noindent{\bf Note:}
  11045. This is just an introduction to the full power of {\tt EXCALC}. The
  11046. reader if referred to the full documentation.
  11047. \chapter[FIDE: Finite differences for PDEs]%
  11048. {FIDE: Finite difference method for partial differential equations}
  11049. \label{FIDE}
  11050. \typeout{[FIDE: Finite differences for PDEs]}
  11051. {\footnotesize
  11052. \begin{center}
  11053. Richard Liska \\
  11054. Faculty of Nuclear Science and Physical Engineering \\
  11055. Technical University of Prague \\
  11056. Brehova 7, 115 19 Prague 1, Czech Republic \\[0.05in]
  11057. e--mail: tjerl@aci.cvut.cz
  11058. \end{center}
  11059. }
  11060. \ttindex{FIDE}
  11061. The FIDE package performs automation of the process of numerical
  11062. solving partial differential equations systems (PDES) by generating
  11063. finite difference methods. In the process one can find several stages
  11064. in which computer algebra can be used for performing routine
  11065. analytical calculations, namely: transforming differential equations
  11066. into different coordinate systems, discretisation of differential
  11067. equations, analysis of difference schemes and generation of numerical
  11068. programs. The FIDE package consists of the following modules:
  11069. \begin{description}
  11070. \item[EXPRES] for transforming PDES into any orthogonal coordinate system.
  11071. \item[IIMET] for discretisation of PDES by integro-interpolation method.
  11072. \item[APPROX] for determining the order of approximation of
  11073. difference scheme.
  11074. \item[CHARPOL] for calculation of amplification matrix and
  11075. characteristic polynomial of difference scheme, which are needed in
  11076. Fourier stability analysis.\
  11077. \item[HURWP] for polynomial roots locating necessary in verifying the
  11078. von Neumann stability condition.
  11079. \item[LINBAND] for generating the block of FORTRAN code, which solves
  11080. a system of linear algebraic equations with band matrix appearing
  11081. quite often in difference schemes.
  11082. \end{description}
  11083. For more details on this package are given in the FIDE documentation,
  11084. and in the examples. A flavour of its capabilities can be seen from
  11085. the following simple example.
  11086. {\small\begin{verbatim}
  11087. off exp;
  11088. factor diff;
  11089. on rat,eqfu;
  11090. % Declare which indexes will be given to coordinates
  11091. coordinates x,t into j,m;
  11092. % Declares uniform grid in x coordinate
  11093. grid uniform,x;
  11094. % Declares dependencies of functions on coordinates
  11095. dependence eta(t,x),v(t,x),eps(t,x),p(t,x);
  11096. % Declares p as known function
  11097. given p;
  11098. same eta,v,p;
  11099. iim a, eta,diff(eta,t)-eta*diff(v,x)=0,
  11100. v,diff(v,t)+eta/ro*diff(p,x)=0,
  11101. eps,diff(eps,t)+eta*p/ro*diff(v,x)=0;
  11102. *****************************
  11103. ***** Program ***** IIMET Ver 1.1.2
  11104. *****************************
  11105. Partial Differential Equations
  11106. ==============================
  11107. diff(eta,t) - diff(v,x)*eta = 0
  11108. diff(p,x)*eta
  11109. --------------- + diff(v,t) = 0
  11110. ro
  11111. diff(v,x)*eta*p
  11112. diff(eps,t) + ----------------- = 0
  11113. ro
  11114. Backtracking needed in grid optimalization
  11115. 0 interpolations are needed in x coordinate
  11116. Equation for eta variable is integrated in half grid point
  11117. Equation for v variable is integrated in half grid point
  11118. Equation for eps variable is integrated in half grid point
  11119. 0 interpolations are needed in t coordinate
  11120. Equation for eta variable is integrated in half grid point
  11121. Equation for v variable is integrated in half grid point
  11122. Equation for eps variable is integrated in half grid point
  11123. Equations after Discretization Using IIM :
  11124. ==========================================
  11125. (4*(eta(j,m + 1) - eta(j,m) - eta(j + 1,m)
  11126. + eta(j + 1,m + 1))*hx - (
  11127. (eta(j + 1,m + 1) + eta(j,m + 1))
  11128. *(v(j + 1,m + 1) - v(j,m + 1))
  11129. + (eta(j + 1,m) + eta(j,m))*(v(j + 1,m) - v(j,m)))
  11130. *(ht(m + 1) + ht(m)))/(4*(ht(m + 1) + ht(m))*hx) = 0
  11131. (4*(v(j,m + 1) - v(j,m) - v(j + 1,m) + v(j + 1,m + 1))*hx*ro
  11132. + ((eta(j + 1,m + 1) + eta(j,m + 1))
  11133. *(p(j + 1,m + 1) - p(j,m + 1))
  11134. + (eta(j + 1,m) + eta(j,m))*(p(j + 1,m) - p(j,m)))
  11135. *(ht(m + 1) + ht(m)))/(4*(ht(m + 1) + ht(m))*hx*ro) = 0
  11136. (4*(eps(j,m + 1) - eps(j,m) - eps(j + 1,m)
  11137. + eps(j + 1,m + 1))*hx*ro + ((
  11138. eta(j + 1,m + 1)*p(j + 1,m + 1)
  11139. + eta(j,m + 1)*p(j,m + 1))
  11140. *(v(j + 1,m + 1) - v(j,m + 1)) +
  11141. (eta(j + 1,m)*p(j + 1,m) + eta(j,m)*p(j,m))
  11142. *(v(j + 1,m) - v(j,m)))*(ht(m + 1) + ht(m)))/(4
  11143. *(ht(m + 1) + ht(m))*hx*ro) = 0
  11144. clear a;
  11145. clearsame;
  11146. cleargiven;
  11147. \end{verbatim}}
  11148. \chapter[FPS: Formal power series]%
  11149. {FPS: Automatic calculation of formal power series}
  11150. \label{FPS}
  11151. \typeout{[FPS: Formal power series]}
  11152. {\footnotesize
  11153. \begin{center}
  11154. Wolfram Koepf and Winfried Neun\\
  11155. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  11156. Takustra\"se 7 \\
  11157. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  11158. e--mail: Koepf@zib.de and Neun@zib.de
  11159. \end{center}
  11160. }
  11161. \ttindex{FPS}
  11162. This package can expand functions of certain type into
  11163. their corresponding Laurent-Puiseux series as a sum of terms of the form
  11164. \begin{displaymath}
  11165. \sum_{k=0}^{\infty} a_{k} (x-x_{0})^{k/n + s}
  11166. \end{displaymath}
  11167. where $s$ is the `shift number', $n$ is the `Puiseux number',
  11168. and $x_0$ is the `point of development'. The following types are
  11169. supported:
  11170. \begin{itemize}
  11171. \item
  11172. {\bf functions of `rational type'}, which are either rational or have a
  11173. rational derivative of some order;
  11174. \item
  11175. {\bf functions of `hypergeometric type'} where $a_{k+m}/a_k$ is a rational
  11176. function for some integer $m$, the `symmetry number';
  11177. \item
  11178. {\bf functions of `exp-like type'} which satisfy a linear homogeneous
  11179. differential equation with constant coefficients.
  11180. \end{itemize}
  11181. {\tt FPS(f,x,x0)}\ttindex{FPS} tries to find a formal power
  11182. series expansion for {\tt f} with respect to the variable {\tt x}
  11183. at the point of development {\tt x0}.
  11184. It also works for formal Laurent (negative exponents) and Puiseux series
  11185. (fractional exponents). If the third
  11186. argument is omitted, then {\tt x0:=0} is assumed.
  11187. Example: {\tt FPS(asin(x)\verb+^+2,x)} results in
  11188. {\small\begin{verbatim}
  11189. 2*k 2*k 2 2
  11190. x *2 *factorial(k) *x
  11191. infsum(----------------------------,k,0,infinity)
  11192. factorial(2*k + 1)*(k + 1)
  11193. \end{verbatim}}
  11194. If possible, the output is given using factorials. In some cases, the
  11195. use of the Pochhammer symbol {\tt pochhammer(a,k)}$:=a(a+1)\cdots(a+k-1)$
  11196. is necessary.
  11197. {\tt SimpleDE(f,x)} tries to find a homogeneous linear differential
  11198. equation with polynomial coefficients for $f$ with respect to $x$.
  11199. Make sure that $y$ is not a used variable.
  11200. The setting {\tt factor df;} is recommended to receive a nicer output form.
  11201. Examples: {\tt SimpleDE(asin(x)\verb+^+2,x)} then results in
  11202. {\small\begin{verbatim}
  11203. 2
  11204. df(y,x,3)*(x - 1) + 3*df(y,x,2)*x + df(y,x)
  11205. \end{verbatim}}
  11206. The depth for the search of a differential equation for {\tt f} is
  11207. controlled by the variable {\tt
  11208. fps\verb+_+search\verb+_+depth};\ttindex{fps\_search\_depth} higher
  11209. values for {\tt fps\verb+_+search\verb+_+depth} will increase the
  11210. chance to find the solution, but increases the complexity as well. The
  11211. default value for {\tt fps\verb+_+search\verb+_+depth} is 5. For {\tt
  11212. FPS(sin(x\verb+^+(1/3)),x)}, or {\tt SimpleDE(sin(x\verb+^+(1/3)),x)}
  11213. {\em e.g.}, a setting {\tt fps\verb+_+search\verb+_+depth:=6} is necessary.
  11214. The output of the FPS package can be influenced by the\ttindex{TRACEFPS}
  11215. switch {\tt tracefps}. Setting {\tt on tracefps} causes various
  11216. prints of intermediate results.
  11217. \chapter{GENTRAN: A code generation package}
  11218. \label{GENTRAN}
  11219. \typeout{{GENTRAN: A code generation package}}
  11220. {\footnotesize
  11221. \begin{center}
  11222. Barbara L. Gates \\
  11223. RAND \\
  11224. Santa Monica CA 90407-2138 \\
  11225. U.S.A. \\[0.1in]
  11226. Michael C. Dewar \\
  11227. School of Mathematical Sciences, The University of Bath \\
  11228. Bath BA2 7AY, England \\[0.05in]
  11229. e--mail: mcd@maths.bath.ac.uk
  11230. \end{center}
  11231. }
  11232. \ttindex{GENTRAN}
  11233. GENTRAN is an automatic code GENerator and TRANslator which runs under
  11234. \REDUCE. It constructs complete numerical programs based on sets of
  11235. algorithmic specifications and symbolic expressions. Formatted
  11236. FORTRAN, RATFOR, PASCAL or C code can be generated through a series of
  11237. interactive commands or under the control of a template processing
  11238. routine. Large expressions can be automatically segmented into
  11239. subexpressions of manageable size, and a special file-handling
  11240. mechanism maintains stacks of open I/O channels to allow output to be
  11241. sent to any number of files simultaneously and to facilitate recursive
  11242. invocation of the whole code generation process. GENTRAN provides the
  11243. flexibility necessary to handle most code generation applications. It
  11244. is designed to work with the SCOPE code optimiser.
  11245. GENTRAN is a large system with a great many options. This section
  11246. will only describe the FORTRAN generation facilities, and in broad
  11247. outline only. The full manual is available as part of the \REDUCE\
  11248. documentation.
  11249. \section{Simple Use}
  11250. A substantial subset of all expressions and statements in the \REDUCE{}
  11251. programming language can be translated directly into numerical code.
  11252. The {\bf GENTRAN} command takes a \REDUCE\ expression, statement, or
  11253. procedure definition, and translates it into code in the target
  11254. language.
  11255. \begin{describe}{Syntax:}
  11256. {\bf GENTRAN} {\it stmt} [ {\bf OUT} {\it f1,f2,\dots\ ,fn} ]{\it ;}
  11257. \end{describe}
  11258. {\it stmt} is any \REDUCE\ expression, statement (simple, compound, or
  11259. group), or procedure definition that can be translated by GENTRAN into the
  11260. target language.
  11261. {\it stmt} may contain any number of calls
  11262. to the special functions {\bf EVAL}, {\bf DECLARE}, and {\bf LITERAL}.
  11263. {\it f1,f2,\dots\ ,fn } is an optional argument list containing one or more
  11264. {\it f}'s, where each {\it f} is one of:
  11265. \par
  11266. \begin{tabular}{lll}
  11267. {\it an atom} &= &an output file\\
  11268. {\bf T} &= &the terminal\\
  11269. {\bf NIL} &= &the current output file(s)\\
  11270. \ttindex{ALL"!*} {\bf ALL!*} &= &all files currently open for output \\
  11271. & & by GENTRAN (see section~\ref{GENTRAN:output})\\
  11272. \end{tabular}
  11273. If the optional part of the command is not given, generated code is simply
  11274. written to the current output file. However, if it is
  11275. given, then the current output file is temporarily overridden. Generated
  11276. code is written to each file represented by
  11277. {\it f1,f2,\dots\ ,fn} for this command only. Files which were open prior
  11278. to the call to {\bf GENTRAN} will remain open after the call, and files
  11279. which did not exist prior to the call will be created, opened, written to,
  11280. and closed. The output stack will be exactly the same both before and
  11281. after the call.
  11282. {\bf GENTRAN} returns the name(s) of the file(s) to which code was
  11283. written.
  11284. \index{GENTRAN package ! example}
  11285. {\small\begin{verbatim}
  11286. 1: GENTRANLANG!* := 'FORTRAN$
  11287. 2: GENTRAN
  11288. 2: FOR I:=1:N DO
  11289. 2: V(I) := 0$
  11290. DO 25001 I=1,N
  11291. V(I)=0.0
  11292. 25001 CONTINUE
  11293. \end{verbatim}}
  11294. \section{Precision}
  11295. \label{precision}
  11296. \index{precision}\index{DOUBLE switch}
  11297. By default {\bf GENTRAN} generates constants and type declarations in
  11298. single precision form. If the user requires double precision output
  11299. then the switch {\bf DOUBLE} must be set {\bf ON}.
  11300. \index{PRECISION command}\index{PRINT"!-PRECISION command}
  11301. To ensure the correct number of floating point digits are
  11302. generated it may be necessary to use either the {\bf PRECISION} or
  11303. {\bf PRINT!-PRECISION} commands. The former alters the number of
  11304. digits \REDUCE\ calculates, the latter only the number of digits
  11305. \REDUCE\ prints. Each takes an integer argument. It is not possible to set
  11306. the printed precision higher than the actual precision. Calling {\bf
  11307. PRINT!-PRECISION} with a negative argument causes the printed
  11308. precision to revert to the actual precision.
  11309. \subsection{The EVAL Function}
  11310. \label{eval}
  11311. \begin{describe}{Syntax:}
  11312. {\bf EVAL} {\it exp}
  11313. \end{describe}\ttindex{EVAL}
  11314. \begin{describe}{Argument:}
  11315. {\it exp} is any \REDUCE\ expression or statement which, after evaluation
  11316. by \REDUCE, results in an expression that can be translated by
  11317. GENTRAN into the target language.
  11318. \end{describe}
  11319. When {\bf EVAL} is called on an expression which is to be translated, it
  11320. tells {\bf GENTRAN} to give the expression to \REDUCE\ for evaluation
  11321. first, and then to translate the result of that evaluation.
  11322. {\small\begin{verbatim}
  11323. f;
  11324. 2
  11325. 2*X - 5*X + 6
  11326. \end{verbatim}}
  11327. We wish to generate an assignment statement for the quotient
  11328. of F and its derivative.
  11329. {\small\begin{verbatim}
  11330. 1: GENTRAN
  11331. 1: Q := EVAL(F)/EVAL(DF(F,X))$
  11332. Q=(2.0*X**2-(5.0*X)+6.0)/(4.0*X-5.0)
  11333. \end{verbatim}}
  11334. \subsection{The :=: Operator}
  11335. \index{:=:}
  11336. \label{rsetq}\index{GENTRAN ! preevaluation}\index{rsetq operator}
  11337. In many applications, assignments must be generated in which the
  11338. left-hand side is some known variable name, but the
  11339. right-hand side is an expression that must be evaluated. For
  11340. this reason, a special operator is provided to indicate that the expression
  11341. on the right-hand side is to be evaluated prior to translation. This
  11342. special operator is {\bf :=:} ({\em i.e.} the usual \REDUCE\ assignment operator
  11343. with an extra ``:'' on the right).
  11344. \begin{describe}{\example}
  11345. {\small\begin{verbatim}
  11346. 1: GENTRAN
  11347. 1: DERIV :=: DF(X^4-X^3+2*x^2+1,X)$
  11348. DERIV=4.0*X**3-(3.0*X**2)+4.0*X
  11349. \end{verbatim}}
  11350. \end{describe}
  11351. \subsection{The ::= Operator}
  11352. \label{lsetq}
  11353. \index{matrices ! in GENTRAN}
  11354. When assignments to matrix or array elements must be generated, many
  11355. times the indices of the element must be evaluated first. The special
  11356. operator\index{::=}\index{lsetq operator}
  11357. {\bf ::=} can be used within a call to {\bf GENTRAN}
  11358. to indicate that the indices of the matrix or
  11359. array element on the left-hand side of the assignment are to
  11360. be evaluated prior to translation. (This is the usual \REDUCE{}
  11361. assignment operator with an extra ``:'' on the left.)
  11362. \begin{describe}{\example}
  11363. We wish to generate assignments which assign zeros to all elements
  11364. on the main diagonal of M, an n x n matrix.
  11365. {\small\begin{verbatim}
  11366. 10: FOR j := 1 : 8 DO
  11367. 10: GENTRAN
  11368. 10: M(j,j) ::= 0$
  11369. M(1,1)=0.0
  11370. M(2,2)=0.0
  11371. :
  11372. :
  11373. M(8,8)=0.0
  11374. \end{verbatim}}
  11375. \end{describe}
  11376. {\bf LSETQ} may be used interchangeably with {\bf ::=} on input.\ttindex{LSETQ}
  11377. \subsection{The ::=: Operator}
  11378. \label{lrsetq}
  11379. \index{::=:} \index{lrsetq operator}
  11380. In applications in which evaluated expressions are to be assigned to
  11381. array elements with evaluated subscripts, the {\bf ::=:} operator can be
  11382. used. It is a combination of the {\bf ::=} and {\bf :=:} operators described
  11383. in sections~\ref{rsetq} and ~\ref{lsetq}.
  11384. \index{matrices ! in GENTRAN}
  11385. \begin{describe}{\example}
  11386. The following matrix, M, has been derived symbolically:
  11387. \newpage
  11388. {\small\begin{verbatim}
  11389. ( A 0 -1 1)
  11390. ( )
  11391. ( 0 B 0 0)
  11392. ( )
  11393. ( -1 0 C -1)
  11394. ( )
  11395. ( 1 0 -1 D)
  11396. \end{verbatim}}
  11397. We wish to generate assignment statements for those elements
  11398. on the main diagonal of the matrix.
  11399. {\small\begin{verbatim}
  11400. 10: FOR j := 1 : 4 DO
  11401. 10: GENTRAN
  11402. 10: M(j,j) ::=: M(j,j)$
  11403. M(1,1)=A
  11404. M(2,2)=B
  11405. M(3,3)=C
  11406. M(4,4)=D
  11407. \end{verbatim}}
  11408. \end{describe}
  11409. The alternative alphanumeric identifier associated with {\bf ::=:} is
  11410. {\bf LRSETQ}.\ttindex{LRSETQ}
  11411. \section{Explicit Type Declarations}
  11412. \label{explicit:type}
  11413. Type declarations are automatically generated each time a subprogram
  11414. heading is generated. Type declarations are constructed
  11415. from information stored in the GENTRAN symbol table. The user
  11416. can place entries into the symbol table explicitly through calls
  11417. to the special GENTRAN function {\bf DECLARE}.\index{DECLARE function}
  11418. \begin{describe}{Syntax:}
  11419. {\bf \ \ DECLARE} {\it v1,v2,\dots\ ,vn} {\bf :} {\it type;}
  11420. or
  11421. \begin{tabular}{ll}
  11422. {\bf DECLARE}\\
  11423. {\bf $<$$<$}\\
  11424. &{\it v11,v12,\dots\ ,v1n} {\bf :} {\it type1;}\\
  11425. &{\it v21,v22,\dots\ ,v2n} {\bf :} {\it type2;}\\
  11426. & :\\
  11427. & :\\
  11428. &{\it vn1,vnn,\dots\ ,vnn} {\bf :} {\it typen;}\\
  11429. {\bf $>$$>$}{\it ;}
  11430. \end{tabular}
  11431. \end{describe}
  11432. \begin{describe}{Arguments:}
  11433. Each {\it v1,v2,\dots\ ,vn} is a list of one or more variables
  11434. (optionally subscripted to indicate array dimensions), or
  11435. variable ranges (two letters separated by a ``-''). {\it v}'s are
  11436. not evaluated unless given as arguments to {\bf EVAL}.
  11437. Each {\it type} is a variable type in the target language. Each
  11438. must be an atom, optionally preceded by the atom {\bf IMPLICIT}.
  11439. \index{IMPLICIT option}
  11440. {\it type}'s are not evaluated unless given as arguments to {\bf EVAL}.
  11441. \end{describe}
  11442. The {\bf DECLARE} statement can also be used to declare subprogram
  11443. types ({\em i.e.\ } {\bf SUBROUTINE} or {\bf FUNCTION}) for
  11444. \index{SUBROUTINE}\index{FUNCTION} FORTRAN and RATFOR code, and
  11445. function types for all four languages.
  11446. \section{Expression Segmentation}
  11447. \label{segmentation}\index{segmenting expressions}
  11448. Symbolic derivations can easily produce formulas that can be anywhere
  11449. from a few lines to several pages in length. Such formulas
  11450. can be translated into numerical assignment statements, but unless they
  11451. are broken into smaller pieces they may be too long for a compiler
  11452. to handle. (The maximum number of continuation lines for one statement
  11453. allowed by most FORTRAN compilers is only 19.) Therefore GENTRAN
  11454. \index{continuation lines}
  11455. contains a segmentation facility which automatically {\it segments},
  11456. or breaks down unreasonably large expressions.
  11457. The segmentation facility generates a sequence of assignment
  11458. statements, each of which assigns a subexpression to an automatically
  11459. generated temporary variable. This sequence is generated in such a
  11460. way that temporary variables are re-used as soon as possible, thereby
  11461. keeping the number of automatically generated variables to a minimum.
  11462. The facility can be turned on or off by setting the mode
  11463. \index{GENTRANSEG switch} switch {\bf GENTRANSEG} accordingly ({\em
  11464. i.e.\ }by calling the \REDUCE\ function {\bf ON} or {\bf OFF} on it). The user
  11465. can control the maximum allowable expression size by setting the
  11466. \ttindex{MAXEXPPRINTLEN"!*}
  11467. variable {\bf MAXEXPPRINTLEN!*} to the maximum number of characters
  11468. allowed in an expression printed in the target language (excluding
  11469. spaces automatically printed by the formatter). The {\bf GENTRANSEG}
  11470. switch is on initially, and {\bf MAXEXPPRINTLEN!*} is initialised to
  11471. 800.
  11472. \section{Template Processing}\label{GENTRAN:template}
  11473. \index{GENTRAN ! templates}\index{templates}\index{code templates}
  11474. In some code generation applications pieces of the target numerical
  11475. program are known in advance. A {\it template} file containing a
  11476. program outline is supplied by the user, and formulas are derived in
  11477. \REDUCE, converted to numerical code, and inserted in the corresponding
  11478. places in the program outline to form a complete numerical program. A
  11479. template processor is provided by GENTRAN for use in these
  11480. applications.
  11481. \label{templates}\index{GENTRANIN command}
  11482. \begin{describe}{Syntax:}
  11483. {\bf GENTRANIN} {\it f1,f2,\dots\ ,fm} [{\bf OUT} {\it f1,f2,\dots\
  11484. ,fn\/}]{\it ;}
  11485. \end{describe}
  11486. \begin{describe}{Arguments:}
  11487. {\it f1,f2,\dots\ ,fm\/} is an argument list containing one or more
  11488. {\it f\/}'s,
  11489. where each {\it f\/} is one of:
  11490. \begin{center}
  11491. \begin{tabular}{lll}
  11492. {\it an atom}& = &a template (input) file\\
  11493. {\bf T}& = &the terminal\\
  11494. \end{tabular}
  11495. \end{center}
  11496. {\it f1,f2,\dots\ ,fn\/} is an optional argument list containing one or more
  11497. {\it f\/}'s, where each {\it f\/} is one of:
  11498. \begin{center}
  11499. \begin{tabular}{lll}
  11500. {\it an atom}& = &an output file\\
  11501. {\bf T}& = &the terminal\\
  11502. {\bf NIL}& = &the current output file(s)\\
  11503. {\bf ALL!*}& = &all files currently open for output \\
  11504. & & by GENTRAN (see section~\ref{GENTRAN:output}) \\
  11505. \end{tabular}
  11506. \end{center}
  11507. \end{describe}
  11508. {\bf GENTRANIN} processes each template file {\it f1,f2,\dots\ ,fm}
  11509. sequentially.
  11510. A template file may contain any number of parts, each of which
  11511. is either an active or an inactive part. All active parts start with
  11512. the character sequence {\bf ;BEGIN;} and end with {\bf ;END;}. The end
  11513. of the template file is indicated by an extra {\bf ;END;} character
  11514. sequence.\index{;BEGIN; marker} \index{;END; marker}
  11515. Inactive parts of template files are assumed to contain code in the
  11516. target language. All inactive parts are
  11517. copied to the output.
  11518. Active parts may contain any number of \REDUCE\ expressions, statements,
  11519. and commands. They are not copied directly to the output. Instead,
  11520. they are given to \REDUCE\ for evaluation in algebraic mode. All output
  11521. generated by each evaluation is sent to the output file(s). Returned
  11522. values are only printed on the terminal.\index{GENTRAN ! preevaluation}
  11523. Active parts will most likely contain calls to {\bf GENTRAN} to
  11524. generate code. This means that the result of processing a
  11525. template file will be the original template file with all active
  11526. parts replaced by generated code.
  11527. If {\bf OUT} {\it f1,f2,\dots\ ,fn} is not given, generated code is simply
  11528. written to the current-output file.
  11529. However, if {\bf OUT} {\it f1,f2,\dots\ ,fn}
  11530. is given, then the current-output file
  11531. is temporarily overridden. Generated code is written to each file
  11532. represented by {\it f1,f2,\dots\ ,fn} for this command only. Files
  11533. which were open prior to the call to {\bf GENTRANIN} will remain open
  11534. after the call, and files which did not exist prior to the call will
  11535. be created, opened, written to, and closed. The output-stack will be
  11536. exactly the same both before and after the call.
  11537. {\bf GENTRANIN} returns the names of all files written to by this
  11538. command.
  11539. \newpage
  11540. \begin{describe}{\example}
  11541. Suppose we wish to generate a FORTRAN subprogram to compute the
  11542. determinant of a 3 x 3 matrix. We can construct a template
  11543. file with an outline of the FORTRAN subprogram and \REDUCE\ and
  11544. GENTRAN commands to fill it in:
  11545. \index{matrices ! in GENTRAN}
  11546. Contents of file {\tt det.tem}:
  11547. \end{describe}
  11548. {\small\begin{verbatim}
  11549. REAL FUNCTION DET(M)
  11550. REAL M(3,3)
  11551. ;BEGIN;
  11552. OPERATOR M$
  11553. MATRIX MM(3,3)$
  11554. MM := MAT( (M(1,1),M(1,2),M(1,3)),
  11555. (M(2,1),M(2,2),M(2,3)),
  11556. (M(3,1),M(3,2),M(3,3)) )$
  11557. GENTRAN DET :=: DET(MM)$
  11558. ;END;
  11559. RETURN
  11560. END
  11561. ;END;
  11562. \end{verbatim}}
  11563. \begin{describe}{}
  11564. Now we can generate a FORTRAN subprogram with the following
  11565. \REDUCE\ session:
  11566. {\small\begin{verbatim}
  11567. 1: GENTRANLANG!* := 'FORTRAN$
  11568. 2: GENTRANIN
  11569. 2: "det.tem"
  11570. 2: OUT "det.f"$
  11571. \end{verbatim}}
  11572. Contents of file det.f:
  11573. \end{describe}
  11574. {\small\begin{verbatim}
  11575. REAL FUNCTION DET(M)
  11576. REAL M(3,3)
  11577. DET=M(3,3)*M(2,2)*M(1,1)-(M(3,3)*M(2,1)*M(1,2))-(M(3,2)
  11578. . *M(2,3)*M(1,1))+M(3,2)*M(2,1)*M(1,3)+M(3,1)*M(2,3)*M(1
  11579. . ,2)-(M(3,1)*M(2,2)*M(1,3))
  11580. RETURN
  11581. END
  11582. \end{verbatim}}
  11583. \section{Output Redirection}\label{GENTRAN:output}
  11584. \index{GENTRAN ! file output}
  11585. \index{GENTRANOUT command}\index{GENTRANSHUT command}
  11586. The {\bf GENTRANOUT} and {\bf GENTRANSHUT} commands are identical to
  11587. the \REDUCE\ {\bf OUT} and {\bf SHUT} commands with the following
  11588. exceptions:
  11589. \begin{itemize}
  11590. \item {\bf GENTRANOUT} and {\bf GENTRANSHUT} redirect {\it only\/}
  11591. code which is printed as a side effect of GENTRAN commands.
  11592. \item {\bf GENTRANOUT} allows more than one file name to be given
  11593. to indicate that generated code is to be sent to two or more
  11594. files. (It is particularly convenient to be able to
  11595. have generated code sent to
  11596. the terminal screen and one or more file simultaneously.)
  11597. \item {\bf GENTRANOUT} does not automatically erase existing files; it
  11598. prints a warning message on the terminal and asks the user whether the
  11599. existing file should be erased or the whole command be aborted.
  11600. \end{itemize}
  11601. \chapter[GEOMETRY: Plane geometry]%
  11602. {GEOMETRY: Mechanized (Plane) Geometry Manipulations}
  11603. \label{GEOMETRY}
  11604. \typeout{{GEOMETRY: Mechanized (Plane) Geometry Manipulations}}
  11605. \newcommand{\xxyy}[2] {\noindent{\f{#1}} \\\hspace*{1cm}
  11606. \parbox[t]{9cm}{#2} \\[6pt]}
  11607. \newcommand{\geo}{{\sc Geometry}}
  11608. \newenvironment{code}{\tt \begin{tabbing}
  11609. \hspace*{1cm}\=\hspace*{1cm}\=\hspace*{1cm}\=
  11610. \hspace*{1cm}\=\hspace*{1cm}\=\kill}{\end{tabbing}}
  11611. {\footnotesize
  11612. \begin{center}
  11613. Hans-Gert Gr\"abe \\
  11614. Universit\"at Leipzig, Germany \\
  11615. e-mail: graebe@informatik.uni-leipzig.de \\
  11616. \end{center}
  11617. }
  11618. \ttindex{GEOMETRY}
  11619. %\markboth{CHAPTER \ref{GEOMETRY}. GEOMETRY: (PLANE) GEOMETRY MANIPULATIONS}{}
  11620. %\thispagestyle{myheadings}
  11621. \section{Introduction}
  11622. This package provides tools for formulation and mechanized proofs of
  11623. geometry statements in the spirit of the ``Chinese Prover'' of
  11624. W.-T. Wu \cite{Wu:94} and the fundamental book \cite{Chou:88} of
  11625. S.-C. Chou who proved 512 geometry theorems with this mechanized
  11626. method, see also \cite{Chou:84}, \cite{Chou:90}, \cite{Wu:84a},
  11627. \cite{Wu:84b}.
  11628. The general idea behind this approach is an algebraic reformulation of
  11629. geometric conditions using generic coordinates. A (mathematically
  11630. strong) proof of the geometry statement then may be obtained from
  11631. appropriate manipulations of these algebraic expressions. A CAS as,
  11632. e.g., Reduce is well suited to mechanize these manipulations.
  11633. For a more detailed introduction to the topic see the accompanying
  11634. file {\tt geometry.tex} in \$REDUCEPATH/packages/geometry/.
  11635. \section{Basic Data Types and Constructors}
  11636. The basic data types in this package are {\tt Scalar, Point, Line, Circle1
  11637. and Circle}. \\
  11638. The function \f{POINT($a,b$)} creates a {\tt Point} in the plane with
  11639. the $(x,y)$-coordinates $(a,b)$.
  11640. A {\tt Line} is created with the function \f{LINE($a,b,c$)} and
  11641. fulfills the equation $ ax + by + c = 0$.
  11642. For circles there are two constructors. You can use
  11643. \f{CIRCLE($c_1,c_2,c_3,c_4$)} to create a {\tt Circle} where
  11644. the scalar variables solve the equation $c_1(x^2+y^2) + c_2x + c_3y + c_4 = 0$.
  11645. Note that lines are a subset of the circles with $c_1=0$. The other way
  11646. to create a {\tt Circle} is the function \f{CIRCLE1($M,s$)}.
  11647. The variable $M$ here denotes a {\tt Point} and $s$ the squared
  11648. radius. Please note that this package mostly uses the squared distances and
  11649. radiuses.
  11650. There are various functions whose return type is {\tt Scalar}.
  11651. Booleans are represented as extended booleans, i.e.\ the
  11652. procedure returns a {\tt Scalar} that is zero iff the condition is fulfilled.
  11653. For example, the function call \f{POINT\_ON\_CIRCLE(P,c)} returns zero if
  11654. the {\tt Point} $P$ is on the circle, otherwise $P$ is not on the circle.
  11655. In some cases also a non zero result has a geometric meaning. For example,
  11656. \f{COLLINEAR(A,B,C)} returns the signed area of the corresponding
  11657. parallelogram.
  11658. \section{Procedures}
  11659. This section contains a short description of all procedures available
  11660. in \geo. Per convention distances and radiuses of circles are squared.
  11661. \bigskip
  11662. \xxyy{ANGLE\_SUM(a,b:Scalar):Scalar \ttindex{ANGLE\_SUM}}
  11663. {Returns $\tan(\alpha+\beta)$, if $a=\tan(\alpha), b=\tan(\beta)$.}
  11664. \xxyy{ALTITUDE(A,B,C:Point):Line \ttindex{ALTITUDE}}
  11665. {The altitude from $A$ onto $g(BC)$. }
  11666. \xxyy{C1\_CIRCLE(M:Point,sqr:Scalar):Circle \ttindex{C1\_CIRCLE}}
  11667. {The circle with given center and sqradius.}
  11668. \xxyy{CC\_TANGENT(c1,c2:Circle):Scalar \ttindex{CC\_TANGENT}}
  11669. {Zero iff $c_1$ and $c_2$ are tangent.}
  11670. \xxyy{CHOOSE\_PC(M:Point,r,u):Point \ttindex{CHOOSE\_PC}}
  11671. {Chooses a point on the circle around $M$ with radius $r$ using its rational
  11672. parametrization with parameter $u$.}
  11673. \xxyy{CHOOSE\_PL(a:Line,u):Point \ttindex{CHOOSE\_PL}}
  11674. {Chooses a point on $a$ using parameter $u$.}
  11675. \xxyy{CIRCLE(c1,c2,c3,c4:Scalar):Circle \ttindex{CIRCLE}}
  11676. {The {\tt Circle} constructor.}
  11677. \xxyy{CIRCLE1(M:Point,sqr:Scalar):Circle1 \ttindex{CIRCLE1}}
  11678. {The {\tt Circle1} constructor. }
  11679. \xxyy{CIRCLE\_CENTER(c:Circle):Point \ttindex{CIRCLE\_CENTER}}
  11680. {The center of $c$.}
  11681. \xxyy{CIRCLE\_SQRADIUS(c:Circle):Scalar \ttindex{CIRCLE\_SQRADIUS}}
  11682. {The sqradius of $c$.}
  11683. \xxyy{CL\_TANGENT(c:Circle,l:Line):Scalar \ttindex{CL\_TANGENT}}
  11684. {Zero iff $l$ is tangent to $c$.}
  11685. \xxyy{COLLINEAR(A,B,C:Point):Scalar \ttindex{COLLINEAR}}
  11686. {Zero iff $A,B,C$ are on a common line. In general the signed area of the
  11687. parallelogram spanned by $\vec{AB}$ and $\vec{AC}$. }
  11688. \xxyy{CONCURRENT(a,b,c:Line):Scalar \ttindex{CONCURRENT}}
  11689. {Zero iff $a,b,c$ have a common point.}
  11690. \xxyy{INTERSECTION\_POINT(a,b:Line):Point \ttindex{INTERSECTION\_POINT}}
  11691. {The intersection point of the lines $a,b$. }
  11692. \xxyy{L2\_ANGLE(a,b:Line):Scalar \ttindex{L2\_ANGLE}}
  11693. {Tangens of the angle between $a$ and $b$. }
  11694. \xxyy{LINE(a,b,c:Scalar):Line \ttindex{LINE}}
  11695. {The {\tt Line} constructor.}
  11696. \xxyy{LOT(P:Point,a:Line):Line \ttindex{LOT}}
  11697. {The perpendicular from $P$ onto $a$.}
  11698. \xxyy{MEDIAN(A,B,C:Point):Line \ttindex{MEDIAN}}
  11699. {The median line from $A$ to $BC$.}
  11700. \xxyy{MIDPOINT(A,B:Point):Point \ttindex{MIDPOINT}}
  11701. {The midpoint of $AB$. }
  11702. \xxyy{MP(B,C:Point):Line \ttindex{MP}}
  11703. {The midpoint perpendicular of $BC$.}
  11704. \xxyy{ORTHOGONAL(a,b:Line):Scalar \ttindex{ORTHOGONAL}}
  11705. {zero iff the lines $a,b$ are orthogonal. }
  11706. \xxyy{OTHER\_CC\_POINT(P:Point,c1,c2:Circle):Point \ttindex{OTHER\_CC\_POINT}}
  11707. { $c_1$ and $c_2$ intersect at $P$. The procedure returns the second
  11708. intersection point. }
  11709. \xxyy{OTHER\_CL\_POINT(P:Point,c:Circle,l:Line):Point \ttindex{OTHER\_CL\_POINT}}
  11710. {$c$ and $l$ intersect at $P$. The procedure returns the second intersection
  11711. point.}
  11712. \xxyy{P3\_ANGLE(A,B,C:Point):Scalar \ttindex{P3\_ANGLE}}
  11713. {Tangens of the angle between $\vec{BA}$ and $\vec{BC}$. }
  11714. \xxyy{P3\_CIRCLE(A,B,C:Point):Circle\ \ttindex{P3\_CIRCLE} {\rm or\ }\\
  11715. P3\_CIRCLE1(A,B,C:Point):Circle1\ttindex{P3\_CIRCLE1} }
  11716. {The circle through 3 given points. }
  11717. \xxyy{P4\_CIRCLE(A,B,C,D:Point):Scalar \ttindex{P4\_CIRCLE}}
  11718. {Zero iff four given points are on a common circle. }
  11719. \xxyy{PAR(P:Point,a:Line):Line \ttindex{PAR}}
  11720. {The line through $P$ parallel to $a$. }
  11721. \xxyy{PARALLEL(a,b:Line):Scalar \ttindex{PARALLEL}}
  11722. {Zero iff the lines $a,b$ are parallel. }
  11723. \xxyy{PEDALPOINT(P:Point,a:Line):Point \ttindex{PEDALPOINT}}
  11724. {The pedal point of the perpendicular from $P$ onto $a$.}
  11725. \xxyy{POINT(a,b:Scalar):Point \ttindex{POINT}}
  11726. {The {\tt Point} constructor.}
  11727. \xxyy{POINT\_ON\_BISECTOR(P,A,B,C:Point):Scalar \ttindex{POINT\_ON\_BISECTOR}}
  11728. {Zero iff $P$ is a point on the (inner or outer) bisector of the
  11729. angle $\angle\,ABC$.}
  11730. \xxyy{POINT\_ON\_CIRCLE(P:Point,c:Circle):Scalar\ \ttindex{POINT\_ON\_CIRCLE}
  11731. {\rm or\ }\\
  11732. POINT\_ON\_CIRCLE1(P:Point,c:Circle1):Scalar \ttindex{POINT\_ON\_CIRCLE1}}
  11733. {Zero iff $P$ is on the circle $c$.}
  11734. \xxyy{POINT\_ON\_LINE(P:Point,a:Line):Scalar \ttindex{POINT\_ON\_LINE}}
  11735. {Zero iff $P$ is on the line $a$. }
  11736. \xxyy{PP\_LINE(A,B:Point):Line \ttindex{PP\_LINE}}
  11737. {The line through $A$ and $B$.}
  11738. \xxyy{SQRDIST(A,B:Point):Scalar \ttindex{SQRDIST}}
  11739. {Square of the distance between $A$ and $B$.}
  11740. \xxyy{SYMPOINT(P:Point,l:Line):Point \ttindex{SYMPOINT}}
  11741. {The point symmetric to $P$ wrt.\ the line $l$.}
  11742. \xxyy{SYMLINE(a:Line,l:Line):Line \ttindex{SYMLINE}}
  11743. {The line symmetric to $a$ wrt.\ the line $l$.}
  11744. \xxyy{VARPOINT(A,B:Point,u):Point \ttindex{VARPOINT}}
  11745. {The point $D=u\cdot A+(1-u)\cdot B$. }
  11746. \noindent \geo \ supplies as additional tools the functions
  11747. \bigskip
  11748. \xxyy{EXTRACTMAT(polys,vars) \ttindex{EXTRACTMAT}}
  11749. {Returns the coefficient matrix of the list of equations $polys$ that are
  11750. linear in the variables $vars$. }
  11751. \xxyy{RED\_HOM\_COORDS(u:\{Line,Circle\}) \ttindex{RED\_HOM\_COORDS}}
  11752. {Returns the reduced homogeneous coordinates of $u$, i.e., divides out the
  11753. content. }
  11754. \newpage
  11755. \section{Examples}
  11756. \example
  11757. Create three points as the vertices of a generic triangle. \\
  11758. {\tt A:=Point(a1,a2); B:=Point(b1,b2); C:=Point(c1,c2);} \\
  11759. \noindent The midpoint perpendiculars of $\Delta\,ABC$ pass through
  11760. a common point since
  11761. \begin{code}\+\>
  11762. concurrent(mp(A,B),mp(B,C),mp(C,A));
  11763. \end{code}
  11764. simplifies to zero.
  11765. \medskip
  11766. \example
  11767. \noindent The intersection point of the midpoint perpendiculars
  11768. \begin{code}\+\>
  11769. M:=intersection\_point(mp(A,B),mp(B,C));
  11770. \end{code}
  11771. is the center of the circumscribed circle since
  11772. \begin{code}\+\>
  11773. sqrdist(M,A) - sqrdist(M,B);
  11774. \end{code}
  11775. simplifies to zero.
  11776. \medskip
  11777. \example
  11778. \noindent {\em Euler's line}:
  11779. \begin{quote}
  11780. The center $M$ of the circumscribed circle, the orthocenter $H$ and
  11781. the barycenter $S$ are collinear and $S$ divides $MH$ with ratio 1:2.
  11782. \end{quote}
  11783. Compute the coordinates of the corresponding points
  11784. \begin{code}\+\>
  11785. M:=intersection\_point(mp(a,b,c),mp(b,c,a));\\
  11786. H:=intersection\_point(altitude(a,b,c),altitude(b,c,a));\\
  11787. S:=intersection\_point(median(a,b,c),median(b,c,a));
  11788. \end{code}
  11789. and then prove that
  11790. \begin{code}\+\>
  11791. collinear(M,H,S);\\
  11792. sqrdist(S,varpoint(M,H,2/3));
  11793. \end{code}
  11794. both simplify to zero.
  11795. \medskip
  11796. \chapter[GNUPLOT: Plotting Functions]%
  11797. {GNUPLOT: Display of functions and surfaces}
  11798. \label{GNUPLOT}
  11799. \typeout{{GNUPLOT: Display of functions and surfaces}}
  11800. {\footnotesize
  11801. \begin{center}
  11802. Herbert Melenk \\
  11803. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  11804. Takustra\"se 7 \\
  11805. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  11806. e--mail: melenk@zib.de
  11807. \end{center}
  11808. }
  11809. \ttindex{GNUPLOT}
  11810. The {\bf gnuplot} system provides easy to use graphics output for
  11811. curves or surfaces which are defined by formulas and/or data sets.
  11812. The \REDUCE\ GNUPLOT package lets one use the GNUPLOT graphical output
  11813. directly from inside \REDUCE, either for the interactive display of
  11814. curves/surfaces or for the production of pictures on paper.
  11815. For a full understanding of use of the \REDUCE\ GNUPLOT package it is
  11816. best to be familiar with {\bf gnuplot}.
  11817. The main command is {\tt PLOT}\ttindex{PLOT}. It accepts an arbitrary
  11818. list of arguments which are either an expression to be plotted, a
  11819. range expressions or an option.
  11820. {\small\begin{verbatim}
  11821. load_package gnuplot;
  11822. plot(w=sin(a),a=(0 .. 10),xlabel="angle",ylabel="sine");
  11823. \end{verbatim}}
  11824. The expression can be in one or two unknowns, or a list of two
  11825. functions for the x and y values. It can also be an implicit equation
  11826. in 2-dimensional space.
  11827. {\small\begin{verbatim}
  11828. plot(x**3+x*y**3-9x=0);
  11829. \end{verbatim}}
  11830. The dependent and independent variables can be limited to a range with
  11831. the syntax shown in the first example. If omitted the independent
  11832. variables range from -10 to 10 and the dependent variable is limited
  11833. only by the precision of the IEEE floating point arithmetic.
  11834. There are a great deal of options, either as keywords or as
  11835. {\tt variable=string}. Options include:
  11836. {\tt title}\ttindex{title}: assign a heading (default: empty)
  11837. {\tt xlabel}\ttindex{xlabel}: set label for the x axis
  11838. {\tt ylabel}\ttindex{ylabel}: set label for the y axis
  11839. {\tt zlabel}\ttindex{zlabel}: set label for the z axis
  11840. {\tt terminal}\ttindex{terminal}: select an output device
  11841. {\tt size}\ttindex{size}: rescale the picture
  11842. {\tt view}\ttindex{view}: set a viewpoint
  11843. {\tt (no)}{\tt contour}\ttindex{contour}: 3d: add contour lines
  11844. {\tt (no)}{\tt surface}\ttindex{surface}: 3d: draw surface (default: yes)
  11845. {\tt (no)}{\tt hidden3d}\ttindex{hidden3d}: 3d: remove hidden lines (default: no)
  11846. The command {\tt PLOTRESET}\ttindex{PLOTRESET} closes the current
  11847. GNUPLOT windows. The next call to {\tt PLOT} will create a new
  11848. one.
  11849. GNUPLOT is controlled by a number of switches.
  11850. Normally all intermediate data sets are deleted after terminating
  11851. a plot session. If the switch {\tt PLOTKEEP}\ttindex{PLOTKEEP} is set on,
  11852. the data sets are kept for eventual post processing independent
  11853. of \REDUCE.
  11854. In general {\tt PLOT} tries to generate smooth pictures by evaluating
  11855. the functions at interior points until the distances are fine enough.
  11856. This can require a lot of computing time if the single function
  11857. evaluation is expensive. The refinement is controlled by the switch
  11858. {\tt PLOTREFINE}\ttindex{PLOTREFINE} which is on by default. When you
  11859. turn it off the functions will be evaluated only at the basic points.
  11860. The integer value of the global variable {\tt
  11861. PLOT\_XMESH}\ttindex{PLOT\_XMESH} defines the number of initial
  11862. function evaluations in x direction for \f{PLOT}. For 2d graphs
  11863. additional points will be used as long as {\tt
  11864. plotrefine}\ttindex{plotrefine} is on. For 3d graphs this number
  11865. defines also the number of mesh lines orthogonal to the x axis. {\tt
  11866. PLOT\_YMESH}\ttindex{PLOT\_YMESH} defines for 3d plots the number of
  11867. function evaluations in the y direction and the number of mesh lines
  11868. orthogonal to the y axis.
  11869. The grid for localising an implicitly defined curve in \f{PLOT}
  11870. consists of triangles. These are computed initially equally
  11871. distributed over the x-y plane controlled by {\tt PLOT\_XMESH}. The
  11872. grid is refined adaptively in several levels. The final grid can be
  11873. visualised by setting on the switch {\tt
  11874. SHOW\_GRID}\ttindex{SHOW\_GRID}.
  11875. \chapter{GROEBNER: A Gr\"obner basis package}
  11876. \label{GROEBNER}
  11877. \typeout{{GROEBNER: A Gr\"obner basis package}}
  11878. {\footnotesize
  11879. \begin{center}
  11880. Herbert Melenk \& Winfried Neun \\
  11881. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  11882. Takustra\"se 7 \\
  11883. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  11884. e--mail: melenk@zib.de \\[0.05in]
  11885. and \\[0.05in]
  11886. H.M. M\"oller \\
  11887. Fernuniversit\"at Hagen FB Math und Informatik\\
  11888. Postfach 940 \\
  11889. D--58084 Hagen, Germany\\[0.05in]
  11890. e--mail: Michael.Moeller@fernuni-hagen.de
  11891. \end{center}
  11892. }
  11893. \ttindex{GROEBNER}
  11894. Gr\"obner bases are a valuable tool for solving problems in
  11895. connection with multivariate polynomials, such as solving systems of
  11896. algebraic equations and analysing polynomial ideals.
  11897. \index{GROEBNER package}\index{Buchberger's Algorithm}
  11898. The GROEBNER package calculates Gr\"obner bases using the
  11899. Buchberger algorithm. It can be used over a variety of different
  11900. coefficient domains, and for different variable and term orderings.
  11901. \section{}
  11902. \subsection{Term Ordering} \par
  11903. In the theory of Gr\"obner bases, the terms of polynomials are
  11904. considered as ordered. Several order modes are available in
  11905. the current package, including the basic modes:
  11906. \index{LEX ! term order}\index{GRADLEX ! term order}
  11907. \index{REVGRADLEX ! term order}
  11908. \begin{center}
  11909. LEX, GRADLEX, REVGRADLEX
  11910. \end{center}
  11911. All orderings are based on an ordering among the variables. For each
  11912. pair of variables $(a,b)$ an order relation must be defined, {\em
  11913. e.g.\ } ``$ a\gg b $''. The greater sign $\gg$ does not represent a
  11914. numerical relation among the variables; it can be interpreted only in
  11915. terms of formula representation: ``$a$'' will be placed in front of
  11916. ``$b$'' or ``$a$'' is more complicated than ``$b$''.
  11917. The sequence of variables constitutes this order base. So the notion
  11918. of
  11919. \[
  11920. \{x1,x2,x3\}
  11921. \]
  11922. as a list of variables at the same time means
  11923. \[
  11924. x1 \gg x2 \gg x3
  11925. \]
  11926. with respect to the term order.
  11927. If terms (products of powers of variables) are compared with LEX,
  11928. that term is chosen which has a greater variable or a higher degree
  11929. if the greatest variable is the first in both. With GRADLEX the sum of
  11930. all exponents (the total degree) is compared first, and if that does
  11931. not lead to a decision, the LEX method is taken for the final decision.
  11932. The REVGRADLEX method also compares the total degree first, but
  11933. afterward it uses the LEX method in the reverse direction; this is the
  11934. method originally used by Buchberger.
  11935. Note that the LEX ordering is identical to the standard \REDUCE{}
  11936. kernel ordering, when KORDER is set explicitly to the sequence of
  11937. variables.
  11938. \index{default ! term order}
  11939. LEX is the default term order mode in the GROEBNER package.
  11940. \section{The Basic Operators}
  11941. \subsection{Term Ordering Mode}
  11942. \begin{description}
  11943. \ttindex{TORDER}
  11944. \item [{\it TORDER}]($vl$,$m$,$[p_1,p_2,\ldots]$);
  11945. where $vl$ is a variable list (or the empty list if
  11946. no variables are declared explicitly),
  11947. $m$ is the name of a term ordering mode LEX, GRADLEX,
  11948. REV\-GRAD\-LEX (or another implemented mode) and
  11949. $[p_1,p_2,\ldots]$ are additional parameters for the
  11950. term ordering mode (not needed for the basic modes).
  11951. TORDER sets variable set and the term ordering mode.
  11952. The default mode is LEX. The previous description is returned
  11953. as a list with corresponding elements. Such a list can
  11954. alternatively passed as sole argument to TORDER.
  11955. If the variable list is empty or if the TORDER declaration
  11956. is omitted, the automatic variable extraction is activated.
  11957. \ttindex{GVARS}
  11958. \item[{\it GVARS}] ({\it\{exp$1$, exp$2$, $ \ldots$, exp$n$\}});
  11959. where $\{exp1, exp2, \ldots , expn\}$ is a list of expressions or
  11960. equations.
  11961. GVARS extracts from the expressions $\{exp1, exp2, \ldots , expn\}$
  11962. the kernels, which can play the role of variables for a Gr\"obner
  11963. calculation. This can be used {\em e.g.\ } in a TORDER declaration.
  11964. \end{description}
  11965. \subsection{GROEBNER: Calculation of a Gr\"obner Basis}
  11966. \begin{description}
  11967. \ttindex{GROEBNER}
  11968. \item[{\it GROEBNER}] $\{exp1, exp2, \ldots , expm\}; $
  11969. where $\{exp1, exp2, \ldots , expm\}$ is a list of
  11970. expressions or equations.
  11971. GROEBNER calculates the Gr\"obner basis of the given set of
  11972. expressions with respect to the current TORDER setting.
  11973. The Gr\"obner basis $\{1\}$ means that the ideal generated by the
  11974. input polynomials is the whole polynomial ring, or equivalently, that
  11975. the input polynomials have no zeros in common.
  11976. As a side effect, the sequence of variables is stored as a \REDUCE\ list
  11977. in the shared variable \ttindex{gvarslast}{\tt gvarslast}.
  11978. \end{description}
  11979. \example \index{GROEBNER package ! example}
  11980. {\small\begin{verbatim}
  11981. torder({},lex)$
  11982. groebner{3*x**2*y + 2*x*y + y + 9*x**2 + 5*x - 3,
  11983. 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x + 3,
  11984. x**3*y + x**2*y + 3*x**3 + 2*x**2 };
  11985. 2
  11986. {8*X - 2*Y + 5*Y + 3,
  11987. 3 2
  11988. 2*Y - 3*Y - 16*Y + 21}
  11989. \end{verbatim}}
  11990. The operation of GROEBNER can be controlled by the following
  11991. switches:
  11992. \begin{description}
  11993. \ttindex{GROEBOPT}
  11994. \item[GROEBOPT] -- If set ON, the sequence of variables is optimized
  11995. with respect to execution speed; note that the final list of variables
  11996. is available in\ttindex{GVARSLAST} GVARSLAST.
  11997. An explicitly declared dependency supersedes the
  11998. variable optimization.
  11999. By default GROEBOPT is off, conserving the original variable
  12000. sequence.
  12001. \ttindex{GROEBFULLREDUCTION}
  12002. \item[GROEBFULLREDUCTION] -- If set off, the reduction steps during
  12003. the \linebreak[4] GROEBNER operation are limited to the pure head
  12004. term reduction; subsequent terms are reduced otherwise.
  12005. By default GROEBFULLREDUCTION is on.
  12006. \ttindex{GLTBASIS}
  12007. \item[GLTBASIS] -- If set on, the leading terms of the result basis are
  12008. extracted. They are collected in a basis of monomials, which is
  12009. available as value of the global variable with the name GLTB.
  12010. \end{description}
  12011. \subsection{GZERODIM?: Test of $\dim = 0$}
  12012. \begin{description}
  12013. \ttindex{GZERODIM?}
  12014. \item[{\it GZERODIM}!?] $bas$ \\
  12015. where {\it bas} is a Gr\"obner basis in the current setting.
  12016. The result is {\it NIL}, if {\it bas} is the basis of an ideal of
  12017. polynomials with more than finitely many common zeros.
  12018. If the ideal is zero dimensional, {\em i.e.\ } the polynomials of the
  12019. ideal have only finitely many zeros in common, the result is an
  12020. integer $k$ which is the number of these common zeros (counted with
  12021. multiplicities).
  12022. \end{description}
  12023. \subsection{GDIMENSION, GINDEPENDENT\_SETS}
  12024. The following operators can be used to compute the dimension
  12025. and the independent variable sets of an ideal which has the
  12026. Gr\"obner basis {\it bas} with arbitrary term order:
  12027. \begin{description}
  12028. \ttindex{GDIMENSION}\ttindex{GINDEPENDENT\_SETS}
  12029. \ttindex{ideal dimension}\ttindex{independent sets}
  12030. \item[Gdimension]$bas$
  12031. \item[Gindependent\_sets]$bas$
  12032. {\it Gindependent\_sets} computes the maximal
  12033. left independent variable sets of the ideal, that are
  12034. the variable sets which play the role of free parameters in the
  12035. current ideal basis. Each set is a list which is a subset of the
  12036. variable list. The result is a list of these sets. For an
  12037. ideal with dimension zero the list is empty.
  12038. {\it GDimension} computes the dimension of the ideal,
  12039. which is the maximum length of the independent sets.
  12040. \end{description}
  12041. \subsection{GLEXCONVERT: Conversion to a Lexical Base}
  12042. \begin{description}
  12043. \ttindex{GLEXCONVERT}
  12044. \item[{\it GLEXCONVERT}] $ \left(\{exp,\ldots , expm\} \left[,\{var1
  12045. \ldots , varn\}\right]\right.$ \\
  12046. $\left. \left[,MAXDEG=mx\right] \left[,NEWVARS=\{nv1, \ldots , nvk\}\right]\right) $ \\
  12047. where $\{exp1, \ldots , expm\}$ is a Gr\"obner basis with
  12048. $\{var1, \ldots , varn\}$ as variables in the current term order mode,
  12049. $mx$ is an integer, and
  12050. $\{nv1, \ldots , nvk\}$ is a subset of the basis variables.
  12051. For this operator the source and target variable sets must be specified
  12052. explicitly.
  12053. \end{description}
  12054. GLEXCONVERT converts a basis of a zero-dimensional ideal (finite number
  12055. of isolated solutions) from arbitrary ordering into a basis under {\it
  12056. lex} ordering. During the call of GLEXCONVERT the original ordering of
  12057. the input basis must be still active.
  12058. NEWVARS defines the new variable sequence. If omitted, the
  12059. original variable sequence is used. If only a subset of variables is
  12060. specified here, the partial ideal basis is evaluated. For the
  12061. calculation of a univariate polynomial, NEW\-VARS should be a list
  12062. with one element.
  12063. MAXDEG is an upper limit for the degrees. The algorithm stops with
  12064. an error message, if this limit is reached.
  12065. A warning occurs if the ideal is not zero dimensional.
  12066. GLEXCONVERT is an implementation of the FLGM algorithm. Often, the
  12067. calculation of a Gr\"obner basis
  12068. with a graded ordering and subsequent conversion to {\it lex} is
  12069. faster than a direct {\it lex} calculation. Additionally, GLEXCONVERT
  12070. can be used to transform a {\it lex} basis into one with different
  12071. variable sequence, and it supports the calculation of a univariate
  12072. polynomial. If the latter exists, the algorithm is even applicable in
  12073. the non zero-dimensional case, if such a polynomial exists.
  12074. {\small\begin{verbatim}
  12075. torder({{w,p,z,t,s,b},gradlex)
  12076. g := groebner { f1 := 45*p + 35*s -165*b -36,
  12077. 35*p + 40*z + 25*t - 27*s, 15*w + 25*p*s +30*z -18*t
  12078. -165*b**2, -9*w + 15*p*t + 20*z*s,
  12079. w*p + 2*z*t - 11*b**3, 99*w - 11*s*b +3*b**2,
  12080. b**2 + 33/50*b + 2673/10000};
  12081. G := {60000*W + 9500*B + 3969,
  12082. 1800*P - 3100*B - 1377,
  12083. 18000*Z + 24500*B + 10287,
  12084. 750*T - 1850*B + 81,
  12085. 200*S - 500*B - 9,
  12086. 2
  12087. 10000*B + 6600*B + 2673}
  12088. glexconvert(g,{w,p,z,t,s,b},maxdeg=5,newvars={w});
  12089. 2
  12090. 100000000*W + 2780000*W + 416421
  12091. glexconvert(g,{w,p,z,t,s,b},maxdeg=5,newvars={p});
  12092. 2
  12093. 6000*P - 2360*P + 3051
  12094. \end{verbatim}}
  12095. \subsection{GROEBNERF: Factorizing Gr\"obner Bases}
  12096. If Gr\"obner bases are computed in order to solve systems of equations
  12097. or to find the common roots of systems of polynomials, the factorizing
  12098. version of the Buchberger algorithm can be used. The theoretical
  12099. background is simple: if a polynomial $p$ can be represented as a
  12100. product of two (or more) polynomials, {\em e.g.\ } $h= f*g$, then $h$
  12101. vanishes if and only if one of the factors vanishes. So if during the
  12102. calculation of a Gr\"obner basis $h$ of the above form is detected,
  12103. the whole problem can be split into two (or more) disjoint branches.
  12104. Each of the branches is simpler than the complete problem; this saves
  12105. computing time and space. The result of this type of computation is a
  12106. list of (partial) Gr\"obner bases; the solution set of the original
  12107. problem is the union of the solutions of the partial problems,
  12108. ignoring the multiplicity of an individual solution. If a branch
  12109. results in a basis $\{1\}$, then there is no common zero, {\em i.e.\ }no
  12110. additional solution for the original problem, contributed by this
  12111. branch.
  12112. \subsubsection{GROEBNERF Call}
  12113. \ttindex{GROEBNERF}
  12114. The syntax of GROEBNERF is the same as for GROEBNER.
  12115. \[
  12116. \mbox{\it GROEBNERF}(\{exp1, exp2, \ldots , expm\}
  12117. [,\{\},\{nz1, \ldots nzk\});
  12118. \]
  12119. where $\{exp1, exp2, \ldots , expm\} $ is a given list of expressions or
  12120. equations, and $\{nz1, \ldots nzk\}$ is
  12121. an optional list of polynomials known to be non-zero.
  12122. GROEBNERF tries to separate polynomials into individual factors and
  12123. to branch the computation in a recursive manner (factorisation tree).
  12124. The result is a list of partial Gr\"obner bases. If no factorisation can
  12125. be found or if all branches but one lead to the trivial basis $\{1\}$,
  12126. the result has only one basis; nevertheless it is a list of lists of
  12127. polynomials. If no solution is found, the result will be $\{\{1\}\}$.
  12128. Multiplicities (one factor with a higher power, the same partial basis
  12129. twice) are deleted as early as possible in order to speed up the
  12130. calculation. The factorising is controlled by some switches.
  12131. As a side effect, the sequence of variables is stored as a \REDUCE\ list in
  12132. the shared variable
  12133. \begin{center}
  12134. gvarslast .
  12135. \end{center}
  12136. If GLTBASIS is on, a corresponding list of leading term bases is
  12137. also produced and is available in the variable GLTB.
  12138. The third parameter of GROEBNERF allows one to declare some polynomials
  12139. nonzero. If any of these is found in a branch of the calculation
  12140. the branch is cancelled. This can be used to save a substantial amount
  12141. of computing time. The second parameter must be included as an
  12142. empty list if the third parameter is to be used.
  12143. {\small\begin{verbatim}
  12144. torder({x,y},lex)$
  12145. groebnerf { 3*x**2*y + 2*x*y + y + 9*x**2 + 5*x = 3,
  12146. 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x = -3,
  12147. x**3*y + x**2*y + 3*x**3 + 2*x**2 };
  12148. {{Y - 3,X},
  12149. 2
  12150. {2*Y + 2*X - 1,2*X - 5*X - 5}}
  12151. \end{verbatim}}
  12152. %}
  12153. It is obvious here that the solutions of the equations can be read
  12154. off immediately.
  12155. All switches from GROEBNER are valid for GROEBNERF as well:
  12156. \ttindex{GROEBOPT} \ttindex{GLTBASIS}
  12157. \ttindex{GROEBFULLREDUCTION}\ttindex{GROEBSTAT}\ttindex{TRGROEB}
  12158. \ttindex{TRGROEBS}\ttindex{TRGROEB1}
  12159. \begin{center}
  12160. \begin{tabular}{l}
  12161. GROEBOPT \\
  12162. GLTBASIS \\
  12163. GROEBFULLREDUCTION \\
  12164. GROEBSTAT \\
  12165. TRGROEB \\
  12166. TRGROEBS \\
  12167. TRGROEB1
  12168. \end{tabular}
  12169. \end{center}
  12170. \subsubsection{Restriction of the Solution Space}
  12171. In some applications only a subset of the complete solution set
  12172. of a given set of equations is relevant, {\em e.g.\ } only
  12173. nonnegative values or positive definite values for the variables.
  12174. A significant amount of computing time can be saved if
  12175. nonrelevant computation branches can be terminated early.
  12176. Positivity: If a polynomial has no (strictly) positive zero, then
  12177. every system containing it has no nonnegative or strictly positive
  12178. solution. Therefore, the Buchberger algorithm tests the coefficients of
  12179. the polynomials for equal sign if requested. For example, in $13*x +
  12180. 15*y*z $ can be zero with real nonnegative values for $x, y$ and $z$
  12181. only if $x=0$ and $y=0$ or $ z=0$; this is a sort of ``factorization by
  12182. restriction''. A polynomial $13*x + 15*y*z + 20$ never can vanish
  12183. with nonnegative real variable values.
  12184. Zero point: If any polynomial in an ideal has an absolute term, the ideal
  12185. cannot have the origin point as a common solution.
  12186. By setting the shared variable
  12187. \ttindex{GROEBRESTRICTION}
  12188. \begin{center} GROEBRESTRICTION \end{center}
  12189. GROEBNERF is informed of the type of restriction the user wants to
  12190. impose on the solutions:
  12191. \begin{center}
  12192. \begin{tabular}{l}
  12193. {\it GROEBRESTRICTION:=NONEGATIVE;} \\
  12194. \hspace*{+.5cm} only nonnegative real solutions are of
  12195. interest\vspace*{4mm} \\
  12196. {\it GROEBRESTRICTION:=POSITIVE;} \\
  12197. \hspace*{+.5cm}only nonnegative and nonzero solutions are of
  12198. interest\vspace*{4mm} \\
  12199. {\it GROEBRESTRICTION:=ZEROPOINT;} \\
  12200. \hspace*{+.5cm}only solution sets which contain the point
  12201. $\{0,0,\ldots,0\}$ are or interest.
  12202. \end{tabular}
  12203. \end{center}
  12204. If GROEBNERF detects a polynomial which formally conflicts with the
  12205. restriction, it either splits the calculation into separate branches, or,
  12206. if a violation of the restriction is determined, it cancels the actual
  12207. calculation branch.
  12208. \subsection{GREDUCE, PREDUCE: Reduction of Polynomials}
  12209. \subsubsection{Background} \label{GROEBNER:background}
  12210. Reduction of a polynomial ``p'' modulo a given sets of polynomials
  12211. ``B'' is done by the reduction algorithm incorporated in the
  12212. Buchberger algorithm.
  12213. % Subsection 3.5.2
  12214. \subsubsection{Reduction via Gr\"obner Basis Calculation}
  12215. \ttindex{GREDUCE}
  12216. \[
  12217. \mbox{\it GREDUCE}(exp, \{exp1, exp2, \ldots , expm\}]);
  12218. \]
  12219. where {\it exp} is an expression, and $\{exp1, exp2,\ldots , expm\}$ is
  12220. a list of any number of expressions or equations.
  12221. GREDUCE first converts the list of expressions $\{exp1, \ldots ,
  12222. expn\}$ to a Gr\"obner basis, and then reduces the given expression
  12223. modulo that basis. An error results if the list of expressions is
  12224. inconsistent. The returned value is an expression representing the
  12225. reduced polynomial. As a side effect, GREDUCE sets the variable {\it
  12226. gvarslast} in the same manner as GROEBNER does.
  12227. \subsubsection{Reduction with Respect to Arbitrary Polynomials}
  12228. \ttindex{PREDUCE}
  12229. \[
  12230. PREDUCE(exp, \{exp1, exp2,\ldots , expm\});
  12231. \]
  12232. where $ exp $ is an expression, and $\{exp1, exp2, \ldots ,
  12233. expm \}$ is a list of any number of expressions or equations.
  12234. PREDUCE reduces the given expression modulo the set $\{exp1,
  12235. \ldots , expm\}$. If this set is a Gr\"obner basis, the obtained reduced
  12236. expression is uniquely determined. If not, then it depends on the
  12237. subsequence of the single reduction steps
  12238. (see~\ref{GROEBNER:background}). PREDUCE does not check whether
  12239. $\{exp1, exp2, \ldots , expm\}$ is a Gr\"obner basis in the actual
  12240. order. Therefore, if the expressions are a Gr\"obner basis calculated
  12241. earlier with a variable sequence given explicitly or modified by
  12242. optimisation, the proper variable sequence and term order must
  12243. be activated first.
  12244. \example (PREDUCE called with a Gr\"obner basis):
  12245. {\small\begin{verbatim}
  12246. torder({x,y},lex);
  12247. gb:=groebner{3*x**2*y + 2*x*y + y + 9*x**2 + 5*x - 3,
  12248. 2*x**3*y - x*y - y + 6*x**3 - 2*x**2 - 3*x + 3,
  12249. x**3*y + x**2*y + 3*x**3 + 2*x**2}$
  12250. preduce (5*y**2 + 2*x**2*y + 5/2*x*y + 3/2*y
  12251. + 8*x**2 + 3/2*x - 9/2, gb);
  12252. 2
  12253. Y
  12254. \end{verbatim}}
  12255. \section{Ideal Decomposition \& Equation System Solving}
  12256. Based on the elementary Gr\"obner operations, the GROEBNER package offers
  12257. additional operators, which allow the decomposition of an ideal or of a
  12258. system of equations down to the individual solutions. Details of the
  12259. operators\ttindex{GROESOLVE}\ttindex{GROEBNERF}
  12260. \ttindex{IDEALQUOTIENT}GROESOLVE, GROEBNERF and IDEALQUOTIENT can be
  12261. found in the full documentation, with associated functions.
  12262. \chapter{IDEALS: Arithmetic for polynomial ideals}
  12263. \label{IDEALS}
  12264. \typeout{{IDEALS: Arithmetic for polynomial ideals}}
  12265. {\footnotesize
  12266. \begin{center}
  12267. Herbert Melenk \\
  12268. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  12269. Takustra\"se 7 \\
  12270. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  12271. e--mail: melenk@zib.de
  12272. \end{center}
  12273. }
  12274. \ttindex{IDEALS}
  12275. This package implements the basic arithmetic for polynomial ideals
  12276. by exploiting the Gr\"obner bases package of \REDUCE.
  12277. In order to save computing time all intermediate Gr\"obner bases
  12278. are stored internally such that time consuming repetitions
  12279. are inhibited. A uniform setting facilitates the access.
  12280. \section{Initialization}
  12281. Prior to any computation the set of variables has to be declared
  12282. by calling the operator $I\_setting$ . For example in order to initiate
  12283. computations in the polynomial ring $Q[x,y,z]$ call
  12284. {\small\begin{verbatim}
  12285. I_setting(x,y,z);
  12286. \end{verbatim}}
  12287. A subsequent call to $I\_setting$ allows one to select another set
  12288. of variables; at the same time the internal data structures
  12289. are cleared in order to free memory resources.
  12290. \section{Bases}
  12291. An ideal is represented by a basis (set of polynomials) tagged
  12292. with the symbol $I$, {\em e.g.\ }
  12293. {\small\begin{verbatim}
  12294. u := I(x*z-y**2, x**3-y*z);
  12295. \end{verbatim}}
  12296. Alternatively a list of polynomials can be used as input basis; however,
  12297. all arithmetic results will be presented in the above form. The
  12298. operator $ideal2list$ allows one to convert an ideal basis into a
  12299. conventional \REDUCE\ list.
  12300. \subsection{Operators}
  12301. Because of syntactical restrictions in \REDUCE, special operators
  12302. have to be used for ideal arithmetic:
  12303. {\small\begin{verbatim}
  12304. .+ ideal sum (infix)
  12305. .* ideal product (infix)
  12306. .: ideal quotient (infix)
  12307. ./ ideal quotient (infix)
  12308. .= ideal equality test (infix)
  12309. subset ideal inclusion test (infix)
  12310. intersection ideal intersection (prefix,binary)
  12311. member test for membership in an ideal
  12312. (infix: polynomial and ideal)
  12313. gb Groebner basis of an ideal (prefix, unary)
  12314. ideal2list convert ideal basis to polynomial list
  12315. (prefix,unary)
  12316. \end{verbatim}}
  12317. Example:
  12318. {\small\begin{verbatim}
  12319. I(x+y,x^2) .* I(x-z);
  12320. 2 2 2
  12321. I(X + X*Y - X*Z - Y*Z,X*Y - Y *Z)
  12322. \end{verbatim}}
  12323. Note that ideal equality cannot be tested with the \REDUCE\ equal sign:
  12324. {\small\begin{verbatim}
  12325. I(x,y) = I(y,x) is false
  12326. I(x,y) .= I(y,x) is true
  12327. \end{verbatim}}
  12328. \chapter{INEQ: Support for solving inequalities}
  12329. \label{INEQ}
  12330. \typeout{{INEQ: Support for solving inequalities}}
  12331. {\footnotesize
  12332. \begin{center}
  12333. Herbert Melenk \\
  12334. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  12335. Takustra\"se 7 \\
  12336. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  12337. e--mail: melenk@zib.de
  12338. \end{center}
  12339. }
  12340. \ttindex{INEQ}
  12341. This package supports the operator {\bf ineq\_solve} that
  12342. tries to solves single inequalities and sets of coupled inequalities.
  12343. The following types of systems are supported
  12344. \footnote{For linear optimization problems please use the operator
  12345. {\bf simplex} of the {\bf linalg} package (section~\ref{simplex}}:
  12346. \begin{itemize}
  12347. \item only numeric coefficients (no parametric system),
  12348. \item a linear system of mixed equations and $<=$ -- $>=$
  12349. inequalities, applying the method of Fourier and Motzkin,
  12350. \item a univariate inequality with $<=$, $>=$, $>$ or $<$ operator
  12351. and polynomial or rational left--hand and right--hand sides,
  12352. or a system of such inequalities with only one variable.
  12353. \end{itemize}
  12354. Syntax:
  12355. \begin{center}
  12356. {\tt INEQ\_SOLVE($<$expr$>$ [,$<$vl$>$])}
  12357. \end{center}
  12358. where $<$expr$>$ is an inequality or a list of coupled inequalities
  12359. and equations, and the optional argument $<$vl$>$ is a single
  12360. variable (kernel) or a list of variables (kernels). If not
  12361. specified, they are extracted automatically from $<$expr$>$.
  12362. For multivariate input an explicit variable list specifies the
  12363. elimination sequence: the last member is the most specific one.
  12364. An error message occurs if the input cannot be processed by the
  12365. current algorithms.
  12366. The result is a list. It is empty if the system has no feasible
  12367. solution. Otherwise the result presents the admissible ranges as set
  12368. of equations where each variable is equated to one expression or to an
  12369. interval. The most specific variable is the first one in the result
  12370. list and each form contains only preceding variables (resolved form).
  12371. The interval limits can be formal {\bf max} or {\bf min} expressions.
  12372. Algebraic numbers are encoded as rounded number approximations.
  12373. \noindent
  12374. {\bf Examples}:
  12375. {\small\begin{verbatim}
  12376. ineq_solve({(2*x^2+x-1)/(x-1) >= (x+1/2)^2, x>0});
  12377. {x=(0 .. 0.326583),x=(1 .. 2.56777)}
  12378. reg:=
  12379. {a + b - c>=0, a - b + c>=0, - a + b + c>=0, 0>=0, 2>=0,
  12380. 2*c - 2>=0, a - b + c>=0, a + b - c>=0, - a + b + c - 2>=0,
  12381. 2>=0, 0>=0, 2*b - 2>=0, k + 1>=0, - a - b - c + k>=0,
  12382. - a - b - c + k + 2>=0, - 2*b + k>=0,
  12383. - 2*c + k>=0, a + b + c - k>=0,
  12384. 2*b + 2*c - k - 2>=0, a + b + c - k>=0}$
  12385. ineq_solve (reg,{k,a,b,c});
  12386. {c=(1 .. infinity),
  12387. b=(1 .. infinity),
  12388. a=(max( - b + c,b - c) .. b + c - 2),
  12389. k=a + b + c}
  12390. \end{verbatim}}
  12391. \chapter[INVBASE: Involutive Bases]%
  12392. {INVBASE: A package for computing involutive bases}
  12393. \label{INVBASE}
  12394. \typeout{{INVBASE: A package for computing involutive bases}}
  12395. {\footnotesize
  12396. \begin{center}
  12397. A.Yu.Zharkov, Yu.A.Blinkov\\
  12398. Saratov University\\
  12399. Astrakhanskaya 83\\
  12400. 410071 Saratov, Russia\\[0.05in]
  12401. e--mail: postmaster@scnit.saratov.su
  12402. \end{center}
  12403. }
  12404. \ttindex{INVBASE}
  12405. Involutive bases are a new tool for solving problems in connection
  12406. with multivariate polynomials, such as solving systems of polynomial
  12407. equations and analysing polynomial ideals. An involutive basis of
  12408. polynomial ideal is a special form of a redundant Gr\"obner basis.
  12409. The construction of involutive bases reduces the problem of solving
  12410. polynomial systems to simple linear algebra.
  12411. The INVBASE package can be seen as an alternative to Buchberger's
  12412. algorithm.
  12413. \section{The Basic Operators}
  12414. \subsection{Term Ordering}
  12415. The term order modes available
  12416. are\ttindex{REVGRADLEX}\ttindex{GRADLEX}\ttindex{LEX}
  12417. {\tt REVGRADLEX}, {\tt GRADLEX} and {\tt LEX}.
  12418. These modes have the same meaning as for the GROEBNER package.
  12419. All orderings are based on an ordering among the variables.
  12420. For each pair of variables an order relation $\gg$ must be defined.
  12421. The term ordering mode as well as the order of variables
  12422. are set by the operator\ttindex{INVTORDER}
  12423. {\tt INVTORDER} {\it mode},$\{x_1,...,x_n\}$
  12424. where {\it mode} is one of the term order modes listed above.
  12425. The notion of $\{x_1,...,x_n\}$ as a list of variables
  12426. at the same time means $x_1\gg \ldots \gg x_n$.
  12427. \subsection{Computing Involutive Bases}
  12428. To compute the involutive basis of ideal generated by the set of
  12429. polynomials $\{p_1,...,p_m\}$ one should type the command
  12430. \ttindex{INVBASE}
  12431. \noindent{\tt INVBASE} $\{p_1,...,p_m\} $
  12432. where $p_i$ are polynomials in variables listed in the
  12433. {\tt INVTORDER} operator. If some kernels in $p_i$ were not listed
  12434. previously in the {\tt INVTORDER} operator they are considered as
  12435. parameters, {\em i.e.\ }they are considered part of the coefficients of
  12436. polynomials. If {\tt INVTORDER} was omitted, all the kernels
  12437. in $p_i$ are considered as variables with the default \REDUCE{}
  12438. kernel order.
  12439. The coefficients of polynomials $p_i$ may be integers as well as
  12440. rational numbers (or, accordingly, polynomials and rational functions
  12441. in the parametric case). The computations modulo prime numbers are
  12442. also available. For this purpose one should type the \REDUCE\ commands
  12443. {\small\begin{verbatim}
  12444. ON MODULAR; SETMOD p;
  12445. \end{verbatim}}
  12446. where $p$ is a prime number.
  12447. The value of the \f{INVBASE} function is a list of integer polynomials
  12448. $\{g_1,...,g_n\}$ representing an involutive basis of a given ideal.
  12449. {\small\begin{verbatim}
  12450. INVTORDER REVGRADLEX, {x,y,z};
  12451. g:= INVBASE {4*x**2 + x*y**2 - z + 1/4,
  12452. 2*x + y**2*z + 1/2,
  12453. x**2*z - 1/2*x - y**2};
  12454. 3 2 3 2
  12455. g := {8*x*y*z - 2*x*y*z + 4*y - 4*y*z + 16*x*y + 17*y*z - 4*y,
  12456. 4 2 2 2
  12457. 8*y - 8*x*z - 256*y + 2*x*z + 64*z - 96*x + 20*z - 9,
  12458. 3
  12459. 2*y *z + 4*x*y + y,
  12460. 3 2 2 2
  12461. 8*x*z - 2*x*z + 4*y - 4*z + 16*x + 17*z - 4,
  12462. 3 3 2
  12463. - 4*y*z - 8*y + 6*x*y*z + y*z - 36*x*y - 8*y,
  12464. 2 2 2
  12465. 4*x*y + 32*y - 8*z + 12*x - 2*z + 1,
  12466. 2
  12467. 2*y *z + 4*x + 1,
  12468. 3 2 2
  12469. - 4*z - 8*y + 6*x*z + z - 36*x - 8,
  12470. 2 2 2
  12471. 8*x - 16*y + 4*z - 6*x - z}
  12472. \end{verbatim}}
  12473. To convert it into a lexicographical Gr\"obner basis one should type
  12474. {\small\begin{verbatim}
  12475. h := INVLEX g;
  12476. 6 5 4 3
  12477. h := {3976*x + 37104*z - 600*z + 2111*z + 122062*z
  12478. 2
  12479. + 232833*z - 680336*z + 288814,
  12480. 2 6 5 4 3
  12481. 1988*y - 76752*z + 1272*z - 4197*z - 251555*z
  12482. 2
  12483. - 481837*z + 1407741*z - 595666,
  12484. 7 6 5 4 3 2
  12485. 16*z - 8*z + z + 52*z + 75*z - 342*z + 266*z
  12486. - 60}
  12487. \end{verbatim}}
  12488. \chapter[LAPLACE: Laplace transforms etc.]%
  12489. {LAPLACE: Laplace and inverse Laplace transforms}
  12490. \label{LAPLACE}
  12491. \typeout{{LAPLACE: Laplace and inverse Laplace transforms}}
  12492. {\footnotesize
  12493. \begin{center}
  12494. C. Kazasov, M. Spiridonova, V. Tomov \\
  12495. Sofia, Bulgaria %%\\[0.05in]
  12496. %%e--mail:
  12497. \end{center}
  12498. }
  12499. \ttindex{LAPLACE}
  12500. The LAPLACE package provides both Laplace Transforms and Inverse
  12501. Laplace Transforms, with the two operators
  12502. \noindent{\tt LAPLACE(exp, s\_var, t\_var)}\ttindex{LAPLACE} \\
  12503. {\tt INVLAP(exp, s\_var, t\_var)}\ttindex{INVLAP}
  12504. The action is to transform the expression from the {\tt s\_var} or
  12505. source variable into the {\tt t\_var} or target variable. If {\tt
  12506. t\_var} is omitted, the package uses an internal variable {\tt lp!\&} or
  12507. {\tt il!\&} respectively.
  12508. Three switches control the transformations. If {\tt
  12509. lmon}\ttindex{lpon} is on then sine, cosine, hyperbolic sine and
  12510. hyperbolic cosines are converted by LAPLACE into exponentials. If
  12511. {\tt lhyp} is on then exponential functions are converted into
  12512. hyperbolic form. The last switch {\tt ltrig}\ttindex{ltrig} has the
  12513. same effect except it uses trigonometric functions.
  12514. The system can be extended by adding Laplace transformation rules for
  12515. single functions by rules or rule sets. In such a rule the source
  12516. variable {\bf must} be free, the target variable {\bf must} be {\tt
  12517. il!\&} for LAPLACE and {\tt lp!\&} for INVLAP, with the third parameter
  12518. omitted. Also rules for transforming derivatives are entered in such
  12519. a form. For example
  12520. {\small\begin{verbatim}
  12521. let {laplace(log(~x),x) => -log(gam * il!&)/il!&,
  12522. invlap(log(gam * ~x)/x,x) => -log(lp!&)};
  12523. operator f;
  12524. let {
  12525. laplace(df(f(~x),x),x) => il!&*laplace(f(x),x) - sub(x=0,f(x)),
  12526. laplace(df(f(~x),x,~n),x) => il!&**n*laplace(f(x),x) -
  12527. for i:=n-1 step -1 until 0 sum
  12528. sub(x=0, df(f(x),x,n-1-i)) * il!&**i
  12529. when fixp n,
  12530. laplace(f(~x),x) = f(il!&)
  12531. };
  12532. \end{verbatim}}
  12533. The LAPLACE system knows about the functions {\tt DELTA} and {\tt
  12534. GAMMA}, and used the operator {\tt ONE} for the unit step function and
  12535. {\tt INTL} stands for the parameterised integral function, for
  12536. instance {\tt intl(2*y**2,y,0,x)} stands for $\int^x_0 2 y^2 dx$.
  12537. {\small\begin{verbatim}
  12538. load_package laplace;
  12539. laplace(sin(17*x),x,p);
  12540. 17
  12541. ----------
  12542. 2
  12543. p + 289
  12544. on lmon;
  12545. laplace(-1/4*e**(a*x)*(x-k)**(-1/2), x, p);
  12546. 1 a*k
  12547. - ---*sqrt(pi)*e
  12548. 4
  12549. ----------------------
  12550. k*p
  12551. e *sqrt( - a + p)
  12552. invlap(c/((p-a)*(p-b)), p, t);
  12553. a*t b*t
  12554. c*(e - e )
  12555. -----------------
  12556. a - b
  12557. invlap(p**(-7/3), p, t);
  12558. 1/3
  12559. t *t
  12560. ------------
  12561. 7
  12562. gamma(---)
  12563. 3
  12564. \end{verbatim}}
  12565. \chapter[LIE: Classification of Lie algebras]%
  12566. {LIE: Functions for the classification of real n-dimensional Lie algebras}
  12567. \label{LIE}
  12568. \typeout{{LIE: Functions for the classification of real n-dimensional
  12569. Lie algebras}}
  12570. {\footnotesize
  12571. \begin{center}
  12572. Carsten and Franziska Sch\"obel\\
  12573. The Leipzig University, Computer Science Department \\
  12574. Augustusplatz 10/11, \\
  12575. O-7010 Leipzig, Germany \\[0.05in]
  12576. e--mail: cschoeb@aix550.informatik.uni-leipzig.de
  12577. \end{center}
  12578. }
  12579. \ttindex{LIE}
  12580. {\bf LIE} is a package of functions for the classification of real
  12581. n-dimensional Lie algebras. It consists of two modules: {\bf liendmc1}
  12582. and {\bf lie1234}.
  12583. \section{liendmc1}
  12584. With the help of the functions in this module real n-dimensional Lie
  12585. algebras $L$ with a derived algebra $L^{(1)}$ of dimension 1 can be
  12586. classified. $L$ has to be defined by its structure constants
  12587. $c_{ij}^k$ in the basis $\{X_1,\ldots,X_n\}$ with
  12588. $[X_i,X_j]=c_{ij}^k X_k$. The user must define an ARRAY
  12589. LIENSTRUCIN($n,n,n$) with n being
  12590. the dimension of the Lie algebra $L$. The structure constants
  12591. LIENSTRUCIN($i,j,k$):=$c_{ij}^k$ for $i<j$ should be given. Then the
  12592. procedure LIENDIMCOM1 can be called. Its syntax is:\ttindex{LIENDIMCOM1}
  12593. {\small\begin{verbatim}
  12594. LIENDIMCOM1(<number>).
  12595. \end{verbatim}}
  12596. {\tt <number>} corresponds to the dimension $n$. The procedure simplifies
  12597. the structure of $L$ performing real linear transformations. The returned
  12598. value is a list of the form
  12599. {\small\begin{verbatim}
  12600. (i) {LIE_ALGEBRA(2),COMMUTATIVE(n-2)} or
  12601. (ii) {HEISENBERG(k),COMMUTATIVE(n-k)}
  12602. \end{verbatim}}
  12603. with $3\leq k\leq n$, $k$ odd.
  12604. The returned list is also stored as\ttindex{LIE\_LIST}{\tt
  12605. LIE\_LIST}. The matrix LIENTRANS gives the transformation from the
  12606. given basis $\{X_1,\ldots ,X_n\}$ into the standard basis
  12607. $\{Y_1,\ldots ,Y_n\}$: $Y_j=($LIENTRANS$)_j^k X_k$.
  12608. \section{lie1234}
  12609. This part of the package classifies real low-dimensional Lie algebras $L$
  12610. of the dimension $n:={\rm dim}\,L=1,2,3,4$. $L$ is also given by its
  12611. structure constants $c_{ij}^k$ in the basis $\{X_1,\ldots,X_n\}$ with
  12612. $[X_i,X_j]=c_{ij}^k X_k$. An ARRAY
  12613. LIESTRIN($n,n,n$) has to be defined and LIESTRIN($i,j,k$):=$c_{ij}^k$ for
  12614. $i<j$ should be given. Then the procedure LIECLASS can be performed
  12615. whose syntax is:\ttindex{LIECLASS}
  12616. {\small\begin{verbatim}
  12617. LIECLASS(<number>).
  12618. \end{verbatim}}
  12619. {\tt <number>} should be the dimension of the Lie algebra $L$. The
  12620. procedure stepwise simplifies the commutator relations of $L$ using
  12621. properties of invariance like the dimension of the centre, of the
  12622. derived algebra, unimodularity {\em etc.} The returned value has the form:
  12623. {\small\begin{verbatim}
  12624. {LIEALG(n),COMTAB(m)},
  12625. \end{verbatim}}
  12626. where the value $m$ corresponds to the number of the standard form (basis:
  12627. $\{Y_1, \ldots ,Y_n\}$) in an enumeration scheme.
  12628. This returned value is also stored as LIE\_CLASS. The linear
  12629. transformation from the basis $\{X_1,\ldots,X_n\}$ into the basis of
  12630. the standard form $\{Y_1,\ldots,Y_n\}$ is given by the matrix LIEMAT:
  12631. $Y_j=($LIEMAT$)_j^k X_k$.
  12632. \chapter{LIMITS: A package for finding limits}
  12633. \label{LIMITS}
  12634. \typeout{{LIMITS: A package for finding limits}}
  12635. {\footnotesize
  12636. \begin{center}
  12637. Stanley L. Kameny \\
  12638. Los Angeles, U.S.A.
  12639. \end{center}
  12640. }
  12641. \ttindex{LIMITS}
  12642. LIMITS is a fast limit package for \REDUCE\ for functions which are
  12643. continuous except for computable poles and singularities, based on some
  12644. earlier work by Ian Cohen and John P. Fitch.
  12645. The Truncated Power Series
  12646. package is used for non-critical points, at which the value of the
  12647. function is the constant term in the expansion around that point.
  12648. \index{l'H\^opital's rule}
  12649. l'H\^opital's rule is used in critical cases, with preprocessing of
  12650. $\infty - \infty$ forms and reformatting of product forms in order
  12651. to apply l'H\^opital's rule. A limited amount of bounded arithmetic
  12652. is also employed where applicable.
  12653. \section{Normal entry points}
  12654. \ttindex{LIMIT}
  12655. \vspace{.1in}
  12656. \noindent {\tt LIMIT}(EXPRN:{\em algebraic}, VAR:{\em kernel},
  12657. LIMPOINT:{\em algebraic}):{\em algebraic}
  12658. \vspace{.1in}
  12659. This is the standard way of calling limit, applying all of the
  12660. methods. The result is the limit of EXPRN as VAR approaches LIMPOINT.
  12661. \section{Direction-dependent limits}
  12662. \ttindex{LIMIT+}\ttindex{LIMIT-}
  12663. \vspace{.1in}
  12664. \noindent {\tt LIMIT!+}(EXPRN:{\em algebraic}, VAR:{\em kernel},
  12665. LIMPOINT:{\em algebraic}):{\em algebraic} \\
  12666. \noindent {\tt LIMIT!-}(EXPRN:{\em algebraic}, VAR:{\em kernel},
  12667. LIMPOINT:{\em algebraic}):{\em algebraic}
  12668. \vspace{.1in}
  12669. If the limit depends upon the direction of approach to the {\tt
  12670. LIMPOINT}, the functions {\tt LIMIT!+} and {\tt LIMIT!-} may be used.
  12671. They are defined by:
  12672. \vspace{.1in}
  12673. \noindent{\tt LIMIT!+} (EXP,VAR,LIMPOINT) $\rightarrow$
  12674. \hspace*{2em}{\tt LIMIT}(EXP*,$\epsilon$,0) \\
  12675. where EXP* = sub(VAR=VAR+$\epsilon^2$,EXP)
  12676. and
  12677. \noindent{\tt LIMIT!-} (EXP,VAR,LIMPOINT) $\rightarrow$
  12678. \hspace*{2em}{\tt LIMIT}(EXP*,$\epsilon$,0) \\
  12679. where EXP* = sub(VAR=VAR-$\epsilon^2$,EXP)
  12680. Examples:
  12681. {\small\begin{verbatim}
  12682. load_package misc;
  12683. limit(sin(x)/x,x,0);
  12684. 1
  12685. limit((a^x-b^x)/x,x,0);
  12686. log(a) - log(b)
  12687. limit(x/(e**x-1), x, 0);
  12688. 1
  12689. limit!-(sin x/cos x,x,pi/2);
  12690. infinity
  12691. limit!+(sin x/cos x,x,pi/2);
  12692. - infinity
  12693. limit(x^log(1/x),x,infinity);
  12694. 0
  12695. limit((x^(1/5) + 3*x^(1/4))^2/(7*(sqrt(x + 9) - 3 - x/6))^(1/5),x,0);
  12696. 3/5
  12697. - 6
  12698. ---------
  12699. 1/5
  12700. 7
  12701. \end{verbatim}}
  12702. \chapter{LINALG: Linear algebra package}
  12703. \label{LINALG}
  12704. \typeout{{LINALG: Linear algebra package}}
  12705. {\footnotesize
  12706. \begin{center}
  12707. Matt Rebbeck \\
  12708. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  12709. Takustra\"se 7 \\
  12710. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  12711. \end{center}
  12712. }
  12713. \ttindex{LINALG}
  12714. \section{Introduction}
  12715. This package provides a selection of functions that are useful
  12716. in the world of linear algebra. They can be classified into four
  12717. sections:
  12718. \subsection{Basic matrix handling}
  12719. \begin{center}
  12720. \begin{tabular}{l l l l}
  12721. add\_columns\ttindex{ADD\_COLUMNS} &
  12722. add\_rows\ttindex{ADD\_ROWS} &
  12723. add\_to\_columns\ttindex{ADD\_TO\_COLUMNS} &
  12724. add\_to\_rows\ttindex{ADD\_TO\_ROWS} \\
  12725. augment\_columns\ttindex{AUGMENT\_COLUMNS} &
  12726. char\_poly\ttindex{CHAR\_POLY} &
  12727. column\_dim\ttindex{COLUMN\_DIM} &
  12728. copy\_into\ttindex{COPY\_INTO} \\
  12729. diagonal\ttindex{DIAGONAL} &
  12730. extend\ttindex{EXTEND} &
  12731. find\_companion\ttindex{FIND\_COMPANION} &
  12732. get\_columns\ttindex{GET\_COLUMNS} \\
  12733. get\_rows\ttindex{GET\_ROWS} &
  12734. hermitian\_tp\ttindex{HERMITIAN\_TP} &
  12735. matrix\_augment\ttindex{MATRIX\_AUGMENT} &
  12736. matrix\_stack\ttindex{MATRIX\_STACK} \\
  12737. minor\ttindex{MINOR} &
  12738. mult\_columns\ttindex{MULT\_COLUMNS} &
  12739. mult\_rows\ttindex{MULT\_ROWS} &
  12740. pivot\ttindex{PIVOT} \\
  12741. remove\_columns\ttindex{REMOVE\_COLUMNS} &
  12742. remove\_rows\ttindex{REMOVE\_ROWS} &
  12743. row\_dim\ttindex{ROW\_DIM} &
  12744. rows\_pivot\ttindex{ROWS\_PIVOT} \\
  12745. stack\_rows\ttindex{STACK\_ROWS} &
  12746. sub\_matrix\ttindex{SUB\_MATRIX} &
  12747. swap\_columns\ttindex{SWAP\_COLUMNS} &
  12748. swap\_entries\ttindex{SWAP\_ENTRIES} \\
  12749. swap\_rows\ttindex{SWAP\_ROWS} & & &
  12750. \end{tabular}
  12751. \end{center}
  12752. \subsection{Constructors}
  12753. Functions that create matrices.
  12754. \begin{center}
  12755. \begin{tabular}{l l l l}
  12756. band\_matrix\ttindex{BAND\_MATRIX} &
  12757. block\_matrix\ttindex{BLOCK\_MATRIX} &
  12758. char\_matrix\ttindex{CHAR\_MATRIX} &
  12759. coeff\_matrix\ttindex{COEFF\_MATRIX} \\
  12760. companion\ttindex{COMPANION} &
  12761. hessian\ttindex{HESSIAN} &
  12762. hilbert\ttindex{HILBERT} &
  12763. jacobian\ttindex{JACOBIAN} \\
  12764. jordan\_block\ttindex{JORDAN\_BLOCK} &
  12765. make\_identity\ttindex{MAKE\_IDENTITY} &
  12766. random\_matrix\ttindex{RANDOM\_MATRIX} &
  12767. toeplitz\ttindex{TOEPLITZ} \\
  12768. vandermonde\ttindex{VANDERMONDE} &
  12769. Kronecker\_Product\ttindex{KRONECKER\_PRODUCT} &
  12770. \end{tabular}
  12771. \end{center}
  12772. \subsection{High level algorithms}
  12773. \begin{center}
  12774. \begin{tabular}{l l l l}
  12775. char\_poly\ttindex{CHAR\_POLY} &
  12776. cholesky\ttindex{CHOLESKY} &
  12777. gram\_schmidt\ttindex{GRAM\_SCHMIDT} &
  12778. lu\_decom\ttindex{LU\_DECOM} \\
  12779. pseudo\_inverse\ttindex{PSEUDO\_INVERSE} &
  12780. simplex\ttindex{SIMPLEX} &
  12781. svd\ttindex{SVD} &
  12782. triang\_adjoint\ttindex{TRIANG\_ADJOINT} \\
  12783. \end{tabular}
  12784. \end{center}
  12785. \vspace*{5mm}
  12786. There is a separate {\small NORMFORM} package (chapter~\ref{NORMFORM})
  12787. for computing the matrix normal forms smithex, smithex\_int,
  12788. frobenius, ratjordan, jordansymbolic and jordan in \REDUCE.
  12789. \subsection{Predicates}
  12790. \begin{center}
  12791. \begin{tabular}{l l l}
  12792. matrixp\ttindex{MATRIXP} &
  12793. squarep\ttindex{SQUAREP} &
  12794. symmetricp\ttindex{SYMMETRICP}
  12795. \end{tabular}
  12796. \end{center}
  12797. \section{Explanations}
  12798. In the examples the matrix ${\cal A}$ will be
  12799. \begin{flushleft}
  12800. \begin{math}
  12801. {\cal A} = \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  12802. \end{array} \right)
  12803. \end{math}
  12804. \end{flushleft}
  12805. Throughout ${\cal I}$ is used to indicate the identity matrix and
  12806. ${\cal A}^T$ to indicate the transpose of the matrix ${\cal A}$.
  12807. Many of the functions have a fairly obvious meaning. Others need a
  12808. little explanation.
  12809. \section{Basic matrix handling}
  12810. The functions \f{ADD\_COLUMNS}\ttindex{ADD\_COLUMNS} and \f{ADD\_ROWS}
  12811. provide basic operations between rows and columns. The form is
  12812. \noindent {\tt add\_columns(${\cal A}$,c1,c2,expr);}
  12813. and it replaces column c2 of the matix by expr $*$ column(${\cal
  12814. A}$,c1) $+$ column(${\cal A}$,c2).
  12815. \f{ADD\_TO\_COLUMNS}\ttindex{ADD\_TO\_COLUMNS} and
  12816. \f{ADD\_TO\_ROWS}\ttindex{ADD\_TO\_ROWS} do a similar task, adding an
  12817. expression to each of a number of columns (or rows) specified by a
  12818. list.
  12819. \begin{math}
  12820. \begin{array}{ccc}
  12821. {\tt add\_to\_columns}({\cal A},\{1,2\},10) & = &
  12822. \left( \begin{array}{ccc} 11 & 12 & 3 \\ 14 & 15 & 6 \\ 17 & 18 & 9
  12823. \end{array} \right)
  12824. \end{array}
  12825. \end{math}
  12826. The functions \f{MULT\_COLUMNS}\ttindex{MULT\_COLUMNS} and
  12827. \f{MULT\_ROW}\ttindex{MULT\_ROW} are equivalent to multiply columns
  12828. and rows.
  12829. \f{COLUMN\_DIM}\ttindex{COLUMN\_DIM} and
  12830. \f{ROW\_DIM}\ttindex{ROW\_DIM} find the column dimension and row
  12831. dimension of their argument.
  12832. Parts of a matrix can be replaced from another by using
  12833. \f{COPY\_INTO}\ttindex{COPY\_INTO}; the last two arguments are row and
  12834. column counters for to where to copy the matrix.
  12835. \begin{flushleft}
  12836. \hspace*{0.175in}
  12837. \begin{math}
  12838. {\cal G} = \left( \begin{array}{cccc} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\
  12839. 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0
  12840. \end{array} \right)
  12841. \end{math}
  12842. \end{flushleft}
  12843. \begin{flushleft}
  12844. \hspace*{0.1in}
  12845. \begin{math}
  12846. \begin{array}{ccc}
  12847. {\tt copy\_into}({\cal A,G},1,2) & = &
  12848. \left( \begin{array}{cccc} 0 & 1 & 2 & 3 \\ 0 & 4 & 5 & 6 \\ 0 & 7 & 8
  12849. & 9 \\ 0 & 0 & 0 & 0
  12850. \end{array} \right)
  12851. \end{array}
  12852. \end{math}
  12853. \end{flushleft}
  12854. A diagonal matrix can be created with \f{DIAGONAL}\ttindex{DIAGONAL}.
  12855. The argument is a list of expressions of matrices which form the
  12856. diagonal.
  12857. An existing matrix can be extended; the call \f{EXTEND}(A,r,c,exp)\ttindex{EXTEND}
  12858. returns the matrix A extended by r rows and c columns, with the new
  12859. entries all exp.
  12860. The function \f{GET\_COLUMNS}\ttindex{GET\_COLUMNS} extracts from a
  12861. matrix a list of the specified columns as matrices.
  12862. \f{GET\_ROWS}\ttindex{GET\_ROWS} does the equivalent for rows.
  12863. \begin{flushleft}
  12864. \hspace*{0.1in}
  12865. \begin{math}
  12866. \begin{array}{ccc}
  12867. {\tt get\_columns}({\cal A},\{1,3\}) & = &
  12868. \left\{
  12869. \left( \begin{array}{c} 1 \\ 4 \\ 7 \end{array} \right),
  12870. \left( \begin{array}{c} 3 \\ 6 \\ 9 \end{array} \right)
  12871. \right\}
  12872. \end{array}
  12873. \end{math}
  12874. \end{flushleft}
  12875. The Hermitian transpose, that is a matrix in which the (i,$\,$j) entry is the conjugate of
  12876. the (j,$\,$i) entry of the input is returned by \f{HERMITIAN\_TP}\ttindex{HERMITIAN\_TP}.
  12877. \f{MATRIX\_AUGMENT}(\{mat$_{1}$,mat$_{2}$, \ldots ,mat$_{n}$\})\ttindex{MATRIX\_AUGMENT}
  12878. produces a new matrix from the list joined as new columns.
  12879. \ttindex{MATRIX\_STACK}\f{MATRIX\_STACK} joins a list of matrices by
  12880. stacking them.
  12881. \begin{flushleft}
  12882. \hspace*{0.1in}
  12883. \begin{math}
  12884. \begin{array}{ccc}
  12885. {\tt matrix\_stack}(\{{\cal A,A}\}) & = &
  12886. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  12887. \\ 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  12888. \end{array} \right)
  12889. \end{array}
  12890. \end{math}
  12891. \end{flushleft}
  12892. \f{MINOR}(A,r,c)\ttindex{MINOR} calculates the (r,c) minor of A.
  12893. \f{PIVOT}\ttindex{PIVOT} pivots a matrix about its (r,c) entry.
  12894. To do this, multiples of the $r^{th}$ row are added to every other row in
  12895. the matrix. This means that the $c^{th}$ column will be 0 except for
  12896. the (r,c) entry.
  12897. A variant on this operation is provided by
  12898. \f{ROWS\_PIVOT}\ttindex{ROWS\_PIVOT}. It applies the pivot only to the
  12899. rows specified as the last argument.
  12900. A sub matrix can be extracted, giving a list or the rows and columns
  12901. to keep.
  12902. \begin{flushleft}
  12903. \hspace*{0.1in}
  12904. \begin{math}
  12905. \begin{array}{ccc}
  12906. {\tt sub\_matrix}({\cal A},\{1,3\},\{2,3\}) & = &
  12907. \left( \begin{array}{cc} 2 & 3 \\ 8 & 9
  12908. \end{array} \right)
  12909. \end{array}
  12910. \end{math}
  12911. \end{flushleft}
  12912. The basic operation of swapping rows or columns is provided by
  12913. \f{SWAP\_ROWS}\ttindex{SWAP\_ROWS} and
  12914. \f{SWAP\_COLUMNS}\ttindex{SWAP\_COLUMNS}. Individual entries can be
  12915. swapped with \f{SWAP\_ENTRIES}\ttindex{SWAP\_ENTRIES}.
  12916. \begin{flushleft}
  12917. \hspace*{0.1in}
  12918. \begin{math}
  12919. \begin{array}{ccc}
  12920. {\tt swap\_columns}({\cal A},2,3) & = &
  12921. \left( \begin{array}{ccc} 1 & 3 & 2 \\ 4 & 6 & 5 \\ 7 & 9 & 8
  12922. \end{array} \right)
  12923. \end{array}
  12924. \end{math}
  12925. \end{flushleft}
  12926. \begin{flushleft}
  12927. \hspace*{0.1in}
  12928. \begin{math}
  12929. \begin{array}{ccc}
  12930. {\tt swap\_entries}({\cal A},\{1,1\},\{3,3\}) & = &
  12931. \left( \begin{array}{ccc} 9 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 1
  12932. \end{array} \right)
  12933. \end{array}
  12934. \end{math}
  12935. \end{flushleft}
  12936. \section{Constructors}
  12937. \f{AUGMENT\_COLUMNS}\ttindex{AUGMENT\_COLUMNS} allows just specified
  12938. columns to be selected; \f{STACK\_ROWS}\ttindex{STACK\_ROWS} does
  12939. a similar job for rows.
  12940. \begin{math}
  12941. \begin{array}{ccc}
  12942. {\tt stack\_rows}({\cal A},\{1,3\}) & = &
  12943. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 7 & 8 & 9
  12944. \end{array} \right)
  12945. \end{array}
  12946. \end{math}
  12947. Rows or columns can be removed with
  12948. \f{REMOVE\_COLUMNS}\ttindex{REMOVE\_COLUMNS} and
  12949. \f{REMOVE\_ROWS}\ttindex{REMOVE\_ROWS}.
  12950. \begin{flushleft}
  12951. \hspace*{0.1in}
  12952. \begin{math}
  12953. \begin{array}{ccc}
  12954. {\tt remove\_columns}({\cal A},2) & = &
  12955. \left( \begin{array}{cc} 1 & 3 \\ 4 & 6 \\ 7 & 9
  12956. \end{array} \right)
  12957. \end{array}
  12958. \end{math}
  12959. \end{flushleft}
  12960. {\tt BAND\_MATRIX}\ttindex{BAND\_MATRIX} creates a square matrix of
  12961. dimension its second argument. The diagonal consists of the middle
  12962. expressions of the first argument, which is an expression list. The
  12963. expressions to the left of this fill the required number of
  12964. sub\_diagonals and the expressions to the right the super\_diagonals.
  12965. \begin{math}
  12966. \begin{array}{ccc}
  12967. {\tt band\_matrix}(\{x,y,z\},6) & = &
  12968. \left( \begin{array}{cccccc} y & z & 0 & 0 & 0 & 0 \\ x & y & z & 0 & 0
  12969. & 0 \\ 0 & x & y & z & 0 & 0 \\ 0 & 0 & x & y & z & 0 \\ 0 & 0 & 0 & x &
  12970. y & z \\ 0 & 0 & 0 & 0 & x & y
  12971. \end{array} \right)
  12972. \end{array}
  12973. \end{math}
  12974. Related to the band matrix is a block matrix, which can be created by
  12975. \noindent {\tt BLOCK\_MATRIX(r,c,matrix\_list)}.\ttindex{BLOCK\_MATRIX}
  12976. The resulting matrix consists of r by c matrices filled from the
  12977. matrix\_list row wise.
  12978. \begin{flushleft}
  12979. \hspace*{0.1in}
  12980. \begin{math}
  12981. \begin{array}{ccc}
  12982. {\cal B} = \left( \begin{array}{cc} 1 & 0 \\ 0 & 1
  12983. \end{array} \right), &
  12984. {\cal C} = \left( \begin{array}{c} 5 \\ 5
  12985. \end{array} \right), &
  12986. {\cal D} = \left( \begin{array}{cc} 22 & 33 \\ 44 & 55
  12987. \end{array} \right)
  12988. \end{array}
  12989. \end{math}
  12990. \end{flushleft}
  12991. \vspace*{0.175in}
  12992. \begin{flushleft}
  12993. \hspace*{0.1in}
  12994. \begin{math}
  12995. \begin{array}{ccc}
  12996. {\tt block\_matrix}(2,3,\{{\cal B,C,D,D,C,B}\}) & = &
  12997. \left( \begin{array}{ccccc} 1 & 0 & 5 & 22 & 33 \\ 0 & 1 & 5 & 44 & 55
  12998. \\
  12999. 22 & 33 & 5 & 1 & 0 \\ 44 & 55 & 5 & 0 & 1
  13000. \end{array} \right)
  13001. \end{array}
  13002. \end{math}
  13003. \end{flushleft}
  13004. Characteristic polynomials and characteristic matrices are created by
  13005. the functions
  13006. {\tt CHAR\_POLY}\ttindex{CHAR\_POLY} and
  13007. \f{CHAR\_MATRIX}\ttindex{CHAR\_MATRIX}.
  13008. A set of linear equations can be turned into the associated
  13009. coefficient matrix and vector of unknowns and the righthandside.
  13010. \f{COEFF\_MATRIX} returns a list \{${\cal C,X,B}$\} such that ${\cal
  13011. CX} = {\cal B}$.
  13012. \begin{math}
  13013. \hspace*{0.175in}
  13014. {\tt coeff\_matrix}(\{x+y+4*z=10,y+x-z=20,x+y+4\}) =
  13015. \end{math}
  13016. \vspace*{0.1in}
  13017. \begin{flushleft}
  13018. \hspace*{0.175in}
  13019. \begin{math}
  13020. \left\{ \left( \begin{array}{ccc} 4 & 1 & 1 \\ -1 & 1 & 1 \\ 0 & 1 & 1
  13021. \end{array} \right), \left( \begin{array}{c} z \\ y \\ x \end{array}
  13022. \right), \left( \begin{array}{c} 10 \\ 20 \\ -4
  13023. \end{array} \right) \right\}
  13024. \end{math}
  13025. \end{flushleft}
  13026. \f{COMPANION}(poly,x) creates the companion matrix ${\cal C}$ of a
  13027. polynomial. That is the square matrix of dimension n, where n is the
  13028. degree of polynomial with respect to x, and the entries of ${\cal C}$ are:
  13029. ${\cal C}$(i,n) = -coeffn(poly,x,i-1) for i = 1 \ldots n, ${\cal
  13030. C}$(i,i-1) = 1 for i = 2 \ldots n and the rest are 0.
  13031. \begin{flushleft}
  13032. \hspace*{0.1in}
  13033. \begin{math}
  13034. \begin{array}{ccc}
  13035. {\tt companion}(x^4+17*x^3-9*x^2+11,x) & = &
  13036. \left( \begin{array}{cccc} 0 & 0 & 0 & -11 \\ 1 & 0 & 0 & 0 \\
  13037. 0 & 1 & 0 & 9 \\ 0 & 0 & 1 & -17
  13038. \end{array} \right)
  13039. \end{array}
  13040. \end{math}
  13041. \end{flushleft}
  13042. The polynomial associated with a companion matrix can be recovered by
  13043. calling \f{FIND\_COMPANION}\ttindex{FIND\_COMPANION}.
  13044. \f{HESSIAN}(expr, var\_list)\ttindex{HESSIAN} calculates the Hessian
  13045. matrix of the expressions with respect to the variables in the list,
  13046. or the single variable. That is the matrix with the (i,$\,$j) element
  13047. the $j^{th}$ derivative of the expressions with respect to the
  13048. $i^{th}$ variable.
  13049. \begin{flushleft}
  13050. \hspace*{0.1in}
  13051. \begin{math}
  13052. \begin{array}{ccc}
  13053. {\tt hessian}(x*y*z+x^2,\{w,x,y,z\}) & = &
  13054. \left( \begin{array}{cccc} 0 & 0 & 0 & 0 \\ 0 & 2 & z & y \\ 0 & z & 0
  13055. & x \\ 0 & y & x & 0
  13056. \end{array} \right)
  13057. \end{array}
  13058. \end{math}
  13059. \end{flushleft}
  13060. Hilbert's matrix, that is where the (i,$\,$j) element is $1/(i+j-x)$
  13061. is constructed by \f{HILBERT}(n,x)\ttindex{HILBERT}.
  13062. The Jacobian of an expression list with respect to a variable list is
  13063. calculated by
  13064. \f{JACOBIAN}(expr\_list,variable\_list)\ttindex{JACOBIAN}. This is a
  13065. matrix whose (i,$\,$j) entry is df(expr\_list(i),variable\_list(j)).
  13066. The square Jordan block matrix of dimension $n$ is calculated by the
  13067. function \f{JORDAN\_BLOCK}(exp,n).\ttindex{JORDAN\_BLOCK} The entries
  13068. of the Jordan\_block matrix are ${\cal J}$(i,i) = expr for i=1 \ldots
  13069. n, ${\cal J}$(i,i+1) = 1 for i=1 \ldots n-1, and all other entries are 0.
  13070. \begin{flushleft}
  13071. \hspace*{0.1in}
  13072. \begin{math}
  13073. \begin{array}{ccc}
  13074. {\tt jordan\_block(x,5)} & = &
  13075. \left( \begin{array}{ccccc} x & 1 & 0 & 0 & 0 \\ 0 & x & 1 & 0 & 0 \\ 0
  13076. & 0 & x & 1 & 0 \\ 0 & 0 & 0 & x & 1 \\ 0 & 0 & 0 & 0 & x
  13077. \end{array} \right)
  13078. \end{array}
  13079. \end{math}
  13080. \end{flushleft}
  13081. \f{MAKE\_IDENTITY}(n)\ttindex{MAKE\_IDENTITY} generates the $n \times
  13082. n$ identity matrix.
  13083. \f{RANDOM\_MATRIX}(r,c,limit)\ttindex{RANDOM\_MATRIX} generates and $r
  13084. \times c$ matrix with random values limited by {\tt limit}. The type
  13085. of entries is controlled by a number of switches.
  13086. \begin{description}
  13087. \item[{\tt IMAGINARY}]\ttindex{IMAGINARY}
  13088. If on then matrix entries are $x+i*y$ where $-limit < x,y < limit$.
  13089. \item[{\tt NOT\_NEGATIVE}]\ttindex{NOT\_NEGATIVE}
  13090. If on then $0 < entry < limit$. In the imaginary case we have $0 < x,y
  13091. < limit$.
  13092. \item[{\tt ONLY\_INTEGER}]\ttindex{ONLY\_INTEGER}
  13093. If on then each entry is an integer. In the imaginary case $x$ and $y$ are
  13094. integers. If off the values are rounded.
  13095. \item[{\tt SYMMETRIC}]\ttindex{SYMMETRIC}
  13096. If on then the matrix is symmetric.
  13097. \item[{\tt UPPER\_MATRIX}]\ttindex{UPPER\_MATRIX}
  13098. If on then the matrix is upper triangular.
  13099. \item[{\tt LOWER\_MATRIX}]\ttindex{LOWER\_MATRIX}
  13100. If on then the matrix is lower triangular.
  13101. \end{description}
  13102. \begin{flushleft}
  13103. \hspace*{0.1in}
  13104. \begin{math}
  13105. \begin{array}{ccc}
  13106. {\tt random\_matrix}(3,3,10) & = &
  13107. \left( \begin{array}{ccc} -4.729721 & 6.987047 & 7.521383 \\
  13108. - 5.224177 & 5.797709 & - 4.321952 \\
  13109. - 9.418455 & - 9.94318 & - 0.730980
  13110. \end{array} \right)
  13111. \end{array}
  13112. \end{math}
  13113. \end{flushleft}
  13114. \vspace*{0.2in}
  13115. \hspace*{0.165in}
  13116. {\tt on only\_integer, not\_negative, upper\_matrix, imaginary;}
  13117. \begin{flushleft}
  13118. %\hspace*{0.12in}
  13119. \begin{math}
  13120. \begin{array}{ccc}
  13121. {\tt random\_matrix}(4,4,10) & = &
  13122. \left( \begin{array}{cccc} 2*i+5 & 3*i+7 & 7*i+3 & 6 \\ 0 & 2*i+5 &
  13123. 5*i+1 & 2*i+1 \\ 0 & 0 & 8 & i \\ 0 & 0 & 0& 5*i+9
  13124. \end{array} \right)
  13125. \end{array}
  13126. \end{math}
  13127. \end{flushleft}
  13128. {\tt TOEPLITZ}\ttindex{TOEPLITZ} creates the Toeplitz matrix from the
  13129. given expression list. This is a square symmetric matrix in which the
  13130. first expression is placed on the diagonal and the $i^{th}$
  13131. expression is placed on the $(i-1)^{th}$ sub- and super-diagonals.
  13132. It has dimension equal to the number of expressions.
  13133. \begin{flushleft}
  13134. \begin{math}
  13135. \begin{array}{ccc}
  13136. {\tt toeplitz}(\{w,x,y,z\}) & = &
  13137. \left( \begin{array}{cccc} w & x & y & z \\ x & w & x & y \\
  13138. y & x & w & x \\ z & y & x & w
  13139. \end{array} \right)
  13140. \end{array}
  13141. \end{math}
  13142. \end{flushleft}
  13143. \f{VANDERMONDE}\ttindex{VANDERMONDE} creates the Vandermonde matrix
  13144. from the expression list; the square matrix in which the (i,$\,$j)
  13145. entry is expr\_list(i) $^{(j-1)}$.
  13146. \begin{flushleft}
  13147. \hspace*{0.1in}
  13148. \begin{math}
  13149. \begin{array}{ccc}
  13150. {\tt vandermonde}(\{x,2*y,3*z\}) & = &
  13151. \left( \begin{array}{ccc} 1 & x & x^2 \\ 1 & 2*y & 4*y^2 \\ 1
  13152. & 3*z & 9*z^2
  13153. \end{array} \right)
  13154. \end{array}
  13155. \end{math}
  13156. \end{flushleft}
  13157. The direct product\index{direct product} (or tensor
  13158. product\index{tensor product}) is created by the
  13159. \f{KRONECKER\_PRODUCT}\ttindex{KRONECKER\_PRODUCT} function.
  13160. {\small\begin{verbatim}
  13161. a1 := mat((1,2),(3,4),(5,6))$
  13162. a2 := mat((1,1,1),(2,z,2),(3,3,3))$
  13163. kronecker_product(a1,a2);
  13164. \end{verbatim}}
  13165. \begin{flushleft}
  13166. \hspace*{0.1in}
  13167. \begin{math}
  13168. \begin{array}{ccc}
  13169. \left( \begin{array}{cccccc} 1 & 1 & 1 & 2 & 2 & 2 \\
  13170. 2 & z & 2 & 4 &2*z &4 \\
  13171. 3 & 3 & 3 & 6 & 6 &6 \\
  13172. 3 & 3 & 3 & 4 & 4 &4 \\
  13173. 6 & 3*z& 6 & 8 &4*z &8 \\
  13174. 9 & 9 & 9 & 12 &12 &12\\
  13175. 5 & 5 & 5 & 6 & 6 &6 \\
  13176. 10 &5*z& 10& 12 &6*z &12 \\
  13177. 15 &15 & 15& 18 &18 &18 \end{array} \right)
  13178. \end{array}
  13179. \end{math}
  13180. \end{flushleft}
  13181. \section{Higher Algorithms}
  13182. The Cholesky decomposition of a matrix can be
  13183. calculated with the function \f{CHOLESKY}. It returns \{${\cal
  13184. L,U}$\} where ${\cal L}$ is a lower matrix, ${\cal U}$ is an upper
  13185. matrix, and ${\cal A} = {\cal LU}$, and ${\cal U} = {\cal L}^T$.
  13186. Gram--Schmidt orthonormalisation can be calculated by
  13187. \f{GRAM\_SCHMIDT}\ttindex{GRAM\_SCHMIDT}. It accepts a list of
  13188. linearly independent vectors, written as lists, and returns a list of
  13189. orthogonal normalised vectors.
  13190. {\small\begin{verbatim}
  13191. gram_schmidt({{1,0,0},{1,1,0},{1,1,1}});
  13192. {{1,0,0},{0,1,0},{0,0,1}}
  13193. gram_schmidt({{1,2},{3,4}});
  13194. 1 2 2*sqrt(5) - sqrt(5)
  13195. {{---------,---------},{-----------,------------}}
  13196. sqrt(5) sqrt(5) 5 5
  13197. \end{verbatim}}
  13198. The LU decomposition of a real or imaginary matrix with numeric
  13199. entries is performed by {\tt LU\_DECOM(${\cal A}$)}.\ttindex{LU\_DECOM}
  13200. It returns \{${\cal L,U}$\} where ${\cal L}$ is a lower diagonal
  13201. matrix, ${\cal U}$ an upper diagonal matrix and ${\cal A} = {\cal LU}$.
  13202. Note: the algorithm used can swap the rows of ${\cal A}$ during
  13203. the calculation. This means that ${\cal LU}$ does not equal ${\cal
  13204. A}$ but a row equivalent of it. Due to this, {\tt lu\_decom} returns
  13205. \{${\cal L,U}$,vec\}. The call {\tt CONVERT(${\cal
  13206. A}$,vec)}\ttindex{CONVERT} will return the matrix that has been
  13207. decomposed, {\em i.e.\ } ${\cal LU} = $ {\tt convert(${\cal A}$,vec)}.
  13208. \begin{flushleft}
  13209. \hspace*{0.175in}
  13210. \begin{math}
  13211. {\cal K} = \left( \begin{array}{ccc} 1 & 3 & 5 \\ -4 & 3 & 7 \\ 8 & 6 &
  13212. 4
  13213. \end{array} \right)
  13214. \end{math}
  13215. \end{flushleft}
  13216. \begin{flushleft}
  13217. %\hspace*{0.1in}
  13218. \begin{math}
  13219. \begin{array}{cccc}
  13220. $% {\tt lu} :=
  13221. {\tt lu\_decom}$({\cal K}) & = &
  13222. \left\{
  13223. \left( \begin{array}{ccc} 8 & 0 & 0 \\ -4 & 6 & 0 \\ 1 & 2.25 &
  13224. 1.125 1 \end{array} \right),
  13225. \left( \begin{array}{ccc} 1 & 0.75 & 0.5 \\ 0 & 1 & 1.5 \\ 0 &
  13226. 0 & 1 \end{array} \right),
  13227. [\; 3 \; 2 \; 3 \; ]
  13228. \right\}
  13229. \end{array}
  13230. \end{math}
  13231. \end{flushleft}
  13232. {\tt PSEUDO\_INVERSE}\ttindex{PSEUDO\_INVERSE}, also known as the
  13233. Moore--Penrose inverse\index{Moore--Penrose inverse}, computes
  13234. the pseudo inverse of ${\cal A}$.
  13235. Given the singular value decomposition of ${\cal A}$, {\em i.e.\ }
  13236. ${\cal A} = {\cal U} \sum {\cal V}^T$, then the pseudo inverse ${\cal
  13237. A}^{-1}$ is defined by ${\cal A}^{-1} = {\cal V}^T \sum^{-1} {\cal U}$.
  13238. Thus ${\cal A}$ $ * $ {\tt pseudo\_inverse}$({\cal A}) = {\cal I}$.
  13239. \begin{flushleft}
  13240. \hspace*{0.1in}
  13241. \begin{math}
  13242. \begin{array}{ccc}
  13243. {\tt pseudo\_inverse}({\cal A}) & = &
  13244. \left( \begin{array}{cc} -0.2 & 0.1 \\ -0.05 & 0.05 \\ 0.1 & 0
  13245. \\ 0.25 & -0.05
  13246. \end{array} \right)
  13247. \end{array}
  13248. \end{math}
  13249. \end{flushleft}
  13250. \label{simplex}
  13251. The simplex linear programming algorithm\index{Simplex Algorithm} for
  13252. maximising or minimising a function subject to lineal inequalities can
  13253. be used with the function \f{SIMPLEX}\ttindex{SIMPLEX}. It requires
  13254. three arguments, the first indicates where the action is to maximising
  13255. or minimising, the second is the test expressions, and the last is a
  13256. list of linear inequalities.
  13257. It returns \{optimal value,\{ values of variables at this optimal\}\}.
  13258. The algorithm implies that all the variables are non-negative.
  13259. \begin{addtolength}{\leftskip}{0.22in}
  13260. %\begin{math}
  13261. {\tt simplex($max,x+y,\{x>=10,y>=20,x+y<=25\}$);}
  13262. %\end{math}
  13263. {\tt ***** Error in simplex: Problem has no feasible solution.}
  13264. \vspace*{0.2in}
  13265. \parbox[t]{0.96\linewidth}{\tt simplex($max,10x+5y+5.5z,\{5x+3z<=200,
  13266. x+0.1y+0.5z<=12$,\\
  13267. \hspace*{0.55in} $0.1x+0.2y+0.3z<=9, 30x+10y+50z<=1500\}$);}
  13268. \vspace*{0.1in}
  13269. {\tt $\{525.0,\{x=40.0,y=25.0,z=0\}$\}}
  13270. \end{addtolength}
  13271. {\tt SVD}\ttindex{SVD} computes the singular value decomposition of
  13272. ${\cal A}$ with numeric entries. It returns \{${\cal U},\sum,{\cal V}$\} where ${\cal A} = {\cal U}
  13273. \sum {\cal V}^T$ and $\sum = diag(\sigma_{1}, \ldots ,\sigma_{n}). \;
  13274. \sigma_{i}$ for $i= (1 \ldots n)$ are the singular values of ${\cal A}$.
  13275. The singular values of ${\cal A}$ are the non-negative square roots of
  13276. the eigenvalues of ${\cal A}^T {\cal A}$.
  13277. ${\cal U}$ and ${\cal V}$ are such that ${\cal UU}^T = {\cal VV}^T =
  13278. {\cal V}^T {\cal V} = {\cal I}_n$.
  13279. \begin{flushleft}
  13280. \hspace*{0.175in}
  13281. \begin{math}
  13282. {\cal Q} = \left( \begin{array}{cc} 1 & 3 \\ -4 & 3
  13283. \end{array} \right)
  13284. \end{math}
  13285. \end{flushleft}
  13286. \begin{eqnarray}
  13287. \hspace*{0.1in}
  13288. {\tt svd({\cal Q})} & = &
  13289. \left\{
  13290. \left( \begin{array}{cc} 0.289784 & 0.957092 \\ -0.957092 &
  13291. 0.289784 \end{array} \right), \left( \begin{array}{cc} 5.149162 & 0 \\
  13292. 0 & 2.913094 \end{array} \right), \right. \nonumber \\ & & \left. \: \;
  13293. \, \left( \begin{array}{cc} -0.687215 & 0.726453 \\ -0.726453 &
  13294. -0.687215 \end{array} \right)
  13295. \right\} \nonumber
  13296. \end{eqnarray}
  13297. {\tt TRIANG\_ADJOINT}\ttindex{TRIANG\_ADJOINT} computes the trianglarizing adjoint of
  13298. the given matrix. The triangularizing adjoint is a lower triangular matrix. The
  13299. multiplication of the triangularizing adjoint with the given matrix results in an
  13300. upper triangular matrix. The i-th entry in the diagonal of this matrix is the
  13301. determinant of the principal i-th minor of the given matrix.
  13302. \begin{flushleft}
  13303. \hspace*{0.1in}
  13304. \begin{math}
  13305. \begin{array}{ccc}
  13306. {\tt triang\_adjoint}({\cal A}) & = &
  13307. \left( \begin{array}{ccc} 1 & 0 & 0 \\ -4 & 1 & 0 \\ -3 & 6 & -3
  13308. \end{array} \right)
  13309. \end{array}
  13310. \end{math}
  13311. \end{flushleft}
  13312. The multiplication of this matrix with ${\cal A}$ results in an upper triangular matrix.
  13313. \begin{flushleft}
  13314. \hspace*{0.1in}
  13315. \begin{math}
  13316. \begin{array}{cccc}
  13317. \left( \begin{array}{ccc} 1 & 0 & 0 \\ -4 & 1 & 0 \\ -3 & 6 & -3
  13318. \end{array} \right) &
  13319. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  13320. \end{array} \right)
  13321. & = &
  13322. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 0 & -3 & -6 \\ 0 & 0 & 0
  13323. \end{array} \right)
  13324. \end{array}
  13325. \end{math}
  13326. \end{flushleft}
  13327. \section{Fast Linear Algebra}
  13328. By turning the {\tt FAST\_LA}\ttindex{FAST\_LA} switch on, the speed
  13329. of the following functions will be increased:
  13330. \begin{tabular}{l l l l}
  13331. add\_columns & add\_rows & augment\_columns & column\_dim \\
  13332. copy\_into & make\_identity & matrix\_augment & matrix\_stack\\
  13333. minor & mult\_column & mult\_row & pivot \\
  13334. remove\_columns & remove\_rows & rows\_pivot & squarep \\
  13335. stack\_rows & sub\_matrix & swap\_columns & swap\_entries\\
  13336. swap\_rows & symmetricp
  13337. \end{tabular}
  13338. The increase in speed will be insignificant unless you are making a
  13339. thousands of calls. When using this switch,
  13340. error checking is minimised, and thus illegal input may give strange
  13341. error messages.
  13342. \chapter{MATHML : MathML Interface for REDUCE }
  13343. \label{MATHML}
  13344. \typeout{{MATHML : MathML Interface for REDUCE}}
  13345. {\footnotesize
  13346. \begin{center}
  13347. Luis Alvarez-Sobreviela \\
  13348. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin \\
  13349. Takustra\"se 7 \\
  13350. D-14195 Berlin-Dahlem, Germany \\
  13351. \end{center}
  13352. }
  13353. \ttindex{MATHML}
  13354. MathML is intended to facilitate the use and re-use of mathematical and
  13355. scientific content on the Web, and for other applications such as computer
  13356. algebra systems. \\
  13357. This package contains the MathML-{\REDUCE}\ interface.
  13358. This interface provides an easy to use series of commands,
  13359. allowing to evaluate and output MathML.
  13360. The principal features of this package can be resumed as:
  13361. \begin{itemize}
  13362. \item Evaluation of MathML code. Allows {\REDUCE}\ to parse MathML expressions
  13363. and evaluate them.
  13364. \item Generation of MathML compliant code. Provides the printing of REDUCE
  13365. expressions in MathML source code, to be used directly in web page
  13366. production.
  13367. \end{itemize}
  13368. We assume that the reader is familiar with MathML. If not, the
  13369. specification\footnote{This specification is subject to change, since it is
  13370. not yet a final draft. During the two month period in which this package was
  13371. developed, the specification changed, forcing a review of the code. This
  13372. package is based on the Nov 98 version.}
  13373. is available at: \qquad {\tt http://www.w3.org/TR/WD-math/ }
  13374. The MathML-{\REDUCE} interface package is loaded by supplying {\tt load mathml;}.
  13375. \subsubsection{Switches}
  13376. There are two switches which can be used alternatively and incrementally.
  13377. These are {\tt MATHML} and {\tt BOTH}. Their use can be described as
  13378. follows:
  13379. \begin{description}
  13380. \item[{\tt mathml}:]\ttindex{MATHML} All output will be printed in MathML.
  13381. \item[{\tt both}:]\ttindex{BOTH} All output will be printed in both MathML and normal
  13382. REDUCE.
  13383. \item[{\tt web}:]\ttindex{WEB} All output will be printed within an HTML $<$embed$>$ tag.
  13384. This is for direct use in an HTML web page. Only works when {\tt mathml} is on.
  13385. \end{description}
  13386. MathML has often been said to be too verbose. If {\tt BOTH} is on, an easy
  13387. interpretation of the results is possible, improving MathML readability.
  13388. \subsubsection{Operators of Package MathML}
  13389. \begin{description}
  13390. \item[\f{mml}(filename):]\ttindex{MML} This function opens and reads the file filename
  13391. containing the MathML.
  13392. \item[\f{parseml}():]\ttindex{PARSEML} To introduce a series of valid mathml tokens you
  13393. can use this function. It takes no arguments and will prompt you to enter mathml tags
  13394. stating with $<$mathml$>$ and ending with $<$/mathml$>$. It returns an expression resulting
  13395. from evaluating the input.
  13396. \end{description}
  13397. {\bf Example}
  13398. {\small\begin{verbatim}
  13399. 1: load mathml;
  13400. 3: on both;
  13401. 3: int(2*x+1,x);;
  13402. x*(x + 1)
  13403. <mathml>
  13404. <apply><plus/>
  13405. <apply><power/>
  13406. <ci>x</ci>
  13407. <cn type="integer">2</cn>
  13408. </apply>
  13409. <ci>x</ci>
  13410. </apply>
  13411. </mathml>
  13412. 4:
  13413. \end{verbatim}}
  13414. \chapter{MODSR: Modular solve and roots}
  13415. \label{MODSR}
  13416. \typeout{{MODSR: Modular solve and roots}}
  13417. {\footnotesize
  13418. \begin{center}
  13419. Herbert Melenk \\
  13420. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  13421. Takustra\"se 7 \\
  13422. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13423. e--mail: melenk@zib.de
  13424. \end{center}
  13425. }
  13426. \ttindex{MODSR}
  13427. This package supports solve (\f{M\_SOLVE}\ttindex{M\_SOLVE}) and roots
  13428. (\f{M\_ROOTS}\ttindex{M\_ROOTS}) operators for modular polynomials and
  13429. modular polynomial systems. The moduli need not be primes. {\tt
  13430. M\_SOLVE} requires a modulus to be set. {\tt M\_ROOTS} takes the
  13431. modulus as a second argument. For example:
  13432. {\small\begin{verbatim}
  13433. on modular; setmod 8;
  13434. m_solve(2x=4); -> {{X=2},{X=6}}
  13435. m_solve({x^2-y^3=3});
  13436. -> {{X=0,Y=5}, {X=2,Y=1}, {X=4,Y=5}, {X=6,Y=1}}
  13437. m_solve({x=2,x^2-y^3=3}); -> {{X=2,Y=1}}
  13438. off modular;
  13439. m_roots(x^2-1,8); -> {1,3,5,7}
  13440. m_roots(x^3-x,7); -> {0,1,6}
  13441. \end{verbatim}}
  13442. \chapter[MRVLIMIT: Limits of ``exp-log'' functions]%
  13443. {MRVLIMIT: Package for Computing Limits of "Exp-Log" Functions}
  13444. \label{MRVLIMIT}
  13445. \typeout{{MRVLIMIT: Package for Computing Limits of "Exp-Log" Functions}}
  13446. {\footnotesize
  13447. \begin{center}
  13448. Neil Langmead \\
  13449. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin (ZIB) \\
  13450. Takustra\"se 7 \\
  13451. D - 14195 Berlin-Dahlem, Germany \\
  13452. \end{center}
  13453. }
  13454. \ttindex{MRVLIMIT}
  13455. %\markboth{CHAPTER \ref{MRVLIMIT}. MRVLIMIT: LIMITS OF ``EXP-LOG'' FUNCTIONS}{}
  13456. %\thispagestyle{myheadings}
  13457. Using the LIMITS package to compute the limits of functions containing
  13458. exponential and logarithmic expressions may raise a problem. For the computation
  13459. of indefinite forms (such as $0/0$,or $\frac{\infty}{\infty}$) L'Hospital's
  13460. rule may only be applied a finite number of times in a CAS. In REDUCE it is
  13461. applied 3 times. This algorithm of Dominik Gruntz of the ETH Z\"urich
  13462. solves this particular problem, and enables the computation of many more
  13463. limit calculations in REDUCE.
  13464. {\small\begin{verbatim}
  13465. 1: load limits;
  13466. 2: limit(x^7/e^x,x,infinity);
  13467. 7
  13468. x
  13469. limit(----,x,infinity)
  13470. x
  13471. e
  13472. 3: load mrvlimit;
  13473. 4: mrv_limit(x^7/e^x,x,infinity);
  13474. 0
  13475. \end{verbatim}}
  13476. For this example, the MRVLIMIT package is able to compute the correct limit. \\
  13477. \ttindex{MRV\_LIMIT}
  13478. \vspace{.1in}
  13479. \noindent {\tt MRV\_LIMIT}(EXPRN:{\em algebraic}, VAR:{\em kernel},
  13480. LIMPOINT:{\em algebraic}):{\em algebraic} \ttindex{MRV\_LIMIT} \par
  13481. The result is the limit of EXPRN as VAR approaches LIMPOINT.
  13482. \vspace{.1in}
  13483. A switch {\tt TRACELIMIT} is available to inform the user about the computed
  13484. Taylor expansion, all recursive calls and the return value of the
  13485. internally called function {\tt MRV}. \\
  13486. \\
  13487. {\bf Examples}:
  13488. \\
  13489. {\small\begin{verbatim}
  13490. 5: b:=e^x*(e^(1/x-e^-x)-e^(1/x));
  13491. -1 - x
  13492. x + x - e
  13493. b:= e *(e - 1)
  13494. 6: mrv_limit(b,x,infinity);
  13495. -1
  13496. -1
  13497. 7: ex:= - log(log(log(log(x))) + log(x)) *log(x)
  13498. *(log(log(x)) - log(log(log(x)) + log(x)));
  13499. - log(x)*(log(log(x)) - log(log(log(x)) + log(x)))
  13500. ex:= -----------------------------------------------------
  13501. log(log(log(log(x))) + log(x))
  13502. 8: off mcd;
  13503. 9: mrv_limit(ex,x,infinity);
  13504. 1
  13505. \end{verbatim}}
  13506. \chapter[NCPOLY: Ideals in non--comm case]%
  13507. {NCPOLY: Non--commutative polynomial ideals}
  13508. \label{NCPOLY}
  13509. \typeout{{NCPOLY: Non--commutative polynomial ideals}}
  13510. {\footnotesize
  13511. \begin{center}
  13512. Herbert Melenk\\
  13513. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  13514. Takustra\"se 7 \\
  13515. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13516. e--mail: melenk@zib.de \\[0.1in]
  13517. Joachim Apel\\
  13518. Institut f\"ur Informatik, Universit\"at Leipzig \\
  13519. Augustusplatz 10--11\\
  13520. D--04109 Leipzig, Germany \\[0.05in]
  13521. e--mail: apel@informatik.uni--leipzig.de
  13522. \end{center}
  13523. }
  13524. \ttindex{NCPOLY}\index{Groebner Bases}
  13525. \REDUCE\ supports a very general mechanism for computing with objects
  13526. under a non--commutative multiplication, where commutator relations
  13527. must be introduced explicitly by rule sets when needed. The package
  13528. {\bf NCPOLY} allows the user to set up automatically a consistent
  13529. environment for computing in an algebra where the non--commutativity
  13530. is defined by Lie-bracket commutators. The package uses the \REDUCE\
  13531. {\bf noncom} mechanism for elementary polynomial arithmetic; the
  13532. commutator rules are automatically computed from the Lie brackets.
  13533. Polynomial arithmetic may be performed directly, including {\bf
  13534. division} and {\bf factorisation}. Additionally {\bf NCPOLY} supports
  13535. computations in a one sided ideal (left or right), especially one
  13536. sided {\bf Gr\"obner} bases and {\bf polynomial reduction}.
  13537. \section{Setup, Cleanup}
  13538. Before the computations can start the environment for a
  13539. non--commutative computation must be defined by a
  13540. call to {\tt nc\_setup}:\ttindex{nc\_setup}
  13541. {\small\begin{verbatim}
  13542. nc_setup(<vars>[,<comms>][,<dir>]);
  13543. \end{verbatim}}
  13544. where
  13545. $<vars>$ is a list of variables; these must include the
  13546. non--commutative quantities.
  13547. $<comms>$ is a list of equations \verb&<u>*<v> - <v>*<u>=<rh>&
  13548. where $<u>$ and $<v>$ are members of $<vars>$, and $<rh>$ is
  13549. a polynomial.
  13550. $<dir>$ is either $left$ or $right$ selecting a left or a
  13551. right one sided ideal. The initial direction is $left$.
  13552. {\tt nc\_setup} generates from $<comms>$ the necessary
  13553. rules to support an algebra where all monomials are
  13554. ordered corresponding to the given variable sequence.
  13555. All pairs of variables which are not explicitly covered in
  13556. the commutator set are considered as commutative and the
  13557. corresponding rules are also activated.
  13558. The second parameter in {\tt nc\_setup} may be
  13559. omitted if the operator is called for the second time,
  13560. {\em e.g.\ } with a reordered variable sequence. In such a case
  13561. the last commutator set is used again.
  13562. Remarks: \begin{itemize}
  13563. \item The variables need not be declared {\bf noncom} -
  13564. {\bf nc\_setup} performs all necessary declarations.
  13565. \item The variables need not be formal operator expressions;
  13566. {\bf nc\_setup} encapsulates a variable $x$ internally
  13567. as \verb+nc!*(!_x)+ expressions anyway where the operator $nc!*$
  13568. keeps the noncom property.
  13569. \item The commands {\bf order} and {\bf korder} should be avoided
  13570. because {\bf nc\_setup} sets these such that the computation
  13571. results are printed in the correct term order.
  13572. \end{itemize}
  13573. Example:
  13574. {\small\begin{verbatim}
  13575. nc_setup({KK,NN,k,n},
  13576. {NN*n-n*NN= NN, KK*k-k*KK= KK});
  13577. NN*N; -> NN*N
  13578. N*NN; -> NN*N - NN
  13579. nc_setup({k,n,KK,NN});
  13580. NN*N - NN -> N*NN;
  13581. \end{verbatim}}
  13582. Here $KK,NN,k,n$ are non--commutative variables where
  13583. the commutators are described as $[NN,n]=NN$, $[KK,k]=KK$.
  13584. The current term order must be compatible with the commutators:
  13585. the product $<u>*<v>$ must precede all terms on the right hand
  13586. side $<rh>$ under the current term order. Consequently
  13587. \begin{itemize}
  13588. \item the maximal degree of $<u>$ or $<v>$ in $<rh>$ is 1,
  13589. \item in a total degree ordering the total degree of $<rh>$ may be not
  13590. higher than 1,
  13591. \item in an elimination degree order ({\em e.g.\ }$lex$) all variables in
  13592. $<rh>$ must be below the minimum of $<u>$ and $<v>$.
  13593. \item If $<rh>$ does not contain any variables or has at most $<u>$ or
  13594. $<v>$, any term order can be selected.
  13595. \end{itemize}
  13596. To use the non--commutative variables or results from
  13597. non--commutative computations later in commutative operations
  13598. it might be necessary to switch off the non--commutative
  13599. evaluation mode because not
  13600. all operators in \REDUCE\ are prepared for that environment. In
  13601. such a case use the command\ttindex{nc\_cleanup}
  13602. {\small\begin{verbatim}
  13603. nc_cleanup;
  13604. \end{verbatim}}
  13605. without parameters. It removes all internal rules and definitions
  13606. which {\tt nc\_setup} had introduced. To reactive non--commutative
  13607. call {\tt nc\_setup} again.
  13608. \section{Left and right ideals}
  13609. A (polynomial) left ideal $L$ is defined by the axioms
  13610. $u \in L, v \in L \Longrightarrow u+v \in L$
  13611. $u \in L \Longrightarrow k*u \in L$ for an arbitrary polynomial $k$
  13612. where ``*'' is the non--commutative multiplication. Correspondingly,
  13613. a right ideal $R$ is defined by
  13614. $u \in R, v \in R \Longrightarrow u+v \in R$
  13615. $u \in R \Longrightarrow u*k \in R$ for an arbitrary polynomial $k$
  13616. \section{Gr\"obner bases}
  13617. When a non--commutative environment has been set up
  13618. by {\tt nc\_setup}, a basis for a left or right polynomial ideal
  13619. can be transformed into a Gr\"obner basis by the operator
  13620. {\tt nc\_groebner}\ttindex{nc\_groebner}
  13621. {\small\begin{verbatim}
  13622. nc_groebner(<plist>);
  13623. \end{verbatim}}
  13624. Note that the variable set and variable sequence must be
  13625. defined before in the {\tt nc\_setup} call. The term order
  13626. for the Gr\"obner calculation can be set by using the
  13627. {\tt torder} declaration.
  13628. For details about {\tt torder}
  13629. see the {\bf \REDUCE\ GROEBNER} manual, or chapter~\ref{GROEBNER}.
  13630. {\small\begin{verbatim}
  13631. 2: nc_setup({k,n,NN,KK},{NN*n-n*NN=NN,KK*k-k*KK=KK},left);
  13632. 3: p1 := (n-k+1)*NN - (n+1);
  13633. p1 := - k*nn + n*nn - n + nn - 1
  13634. 4: p2 := (k+1)*KK -(n-k);
  13635. p2 := k*kk + k - n + kk
  13636. 5: nc_groebner ({p1,p2});
  13637. {k*nn - n*nn + n - nn + 1,
  13638. k*kk + k - n + kk,
  13639. n*nn*kk - n*kk - n + nn*kk - kk - 1}
  13640. \end{verbatim}}
  13641. Important: Do not use the operators of the GROEBNER
  13642. package directly as they would not consider the non--commutative
  13643. multiplication.
  13644. \section{Left or right polynomial division}
  13645. The operator {\tt nc\_divide}\ttindex{nc\_divide} computes the one
  13646. sided quotient and remainder of two polynomials:
  13647. {\small\begin{verbatim}
  13648. nc_divide(<p1>,<p2>);
  13649. \end{verbatim}}
  13650. The result is a list with quotient and remainder.
  13651. The division is performed as a pseudo--division, multiplying
  13652. $<p1>$ by coefficients if necessary. The result $\{<q>,<r>\}$
  13653. is defined by the relation
  13654. $<c>*<p1>=<q>*<p2> + <r>$ for direction $left$ and
  13655. $<c>*<p1>=<p2>*<q> + <r>$ for direction $right$,
  13656. where $<c>$ is an expression that does not contain any of the
  13657. ideal variables, and the leading term of $<r>$ is lower than
  13658. the leading term of $<p2>$ according to the actual term order.
  13659. \section{Left or right polynomial reduction}
  13660. For the computation of the one sided remainder of a polynomial
  13661. modulo a given set of other polynomials the operator
  13662. {\tt nc\_preduce} may be used:\ttindex{nc\_preduce}
  13663. {\small\begin{verbatim}
  13664. nc_preduce(<polynomial>,<plist>);
  13665. \end{verbatim}}
  13666. The result of the reduction is unique (canonical) if
  13667. and only if $<plist>$ is a one sided Gr\"obner basis.
  13668. Then the computation is at the same time an ideal
  13669. membership test: if the result is zero, the
  13670. polynomial is member of the ideal, otherwise not.
  13671. \section{Factorisation}
  13672. Polynomials in a non--commutative ring cannot be factored
  13673. using the ordinary {\tt factorize} command of \REDUCE.
  13674. Instead one of the operators of this section must be
  13675. used:\ttindex{nc\_factorize}
  13676. {\small\begin{verbatim}
  13677. nc_factorize(<polynomial>);
  13678. \end{verbatim}}
  13679. The result is a list of factors of $<polynomial>$. A list
  13680. with the input expression is returned if it is irreducible.
  13681. As non--commutative factorisation is not unique, there is
  13682. an additional operator which computes all possible
  13683. factorisations\ttindex{nc\_factorize\_all}
  13684. {\small\begin{verbatim}
  13685. nc_factorize_all(<polynomial>);
  13686. \end{verbatim}}
  13687. The result is a list of factor decompositions of $<polynomial>$.
  13688. If there are no factors at all the result list has only one
  13689. member which is a list containing the input polynomial.
  13690. \section{Output of expressions}
  13691. It is often desirable to have the commutative parts (coefficients)
  13692. in a non--commutative operation condensed by factorisation. The
  13693. operator\ttindex{nc\_compact}
  13694. {\small\begin{verbatim}
  13695. nc_compact(<polynomial>)
  13696. \end{verbatim}}
  13697. collects the coefficients to the powers of the lowest possible
  13698. non-commutative variable.
  13699. {\small\begin{verbatim}
  13700. load_package ncpoly;
  13701. nc_setup({n,NN},{NN*n-n*NN=NN})$
  13702. p1 := n**4 + n**2*nn + 4*n**2 + 4*n*nn + 4*nn + 4;
  13703. 4 2 2
  13704. p1 := n + n *nn + 4*n + 4*n*nn + 4*nn + 4
  13705. nc_compact p1;
  13706. 2 2 2
  13707. (n + 2) + (n + 2) *nn
  13708. \end{verbatim}}
  13709. \chapter[NORMFORM: matrix normal forms]%
  13710. {NORMFORM: Computation of matrix normal forms}
  13711. \label{NORMFORM}
  13712. \typeout{{NORMFORM: Computation of matrix normal forms}}
  13713. {\footnotesize
  13714. \begin{center}
  13715. Matt Rebbeck \\
  13716. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  13717. Takustra\"se 7 \\
  13718. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13719. \end{center}
  13720. }
  13721. \ttindex{NORMFORM}
  13722. This package contains routines for computing the following
  13723. normal forms of matrices:
  13724. \begin{itemize}
  13725. \item smithex\_int
  13726. \item smithex
  13727. \item frobenius
  13728. \item ratjordan
  13729. \item jordansymbolic
  13730. \item jordan.
  13731. \end{itemize}
  13732. By default all calculations are carried out in ${\cal Q}$ (the rational
  13733. numbers). For {\tt smithex}, {\tt frobenius}, {\tt ratjordan},
  13734. {\tt jordansymbolic}, and {\tt jordan}, this field can be extended to
  13735. an algebraic number field using ARNUM (chapter~\ref{ARNUM}).
  13736. The {\tt frobenius}, {\tt ratjordan}, and {\tt jordansymbolic} normal
  13737. forms can also be computed in a modular base.
  13738. \section{Smithex}
  13739. \ttindex{smithex}
  13740. {\tt Smithex}(${\cal A},\, x$) computes the Smith normal form ${\cal S}$
  13741. of the matrix ${\cal A}$.
  13742. It returns \{${\cal S}, {\cal P}, {\cal P}^{-1}$\} where ${\cal S},
  13743. {\cal P}$, and ${\cal P}^{-1}$ are such that
  13744. ${\cal P S P}^{-1} = {\cal A}$.
  13745. ${\cal A}$ is a rectangular matrix of univariate polynomials in $x$
  13746. where $x$ is the variable name.
  13747. {\tt load\_package normform;}
  13748. \begin{displaymath}
  13749. {\cal A} = \left( \begin{array}{cc} x & x+1 \\ 0 & 3*x^2 \end{array}
  13750. \right)
  13751. \end{displaymath}
  13752. \begin{displaymath}
  13753. \hspace{-0.5in}
  13754. \begin{array}{ccc}
  13755. {\tt smithex}({\cal A},\, x) & = &
  13756. \left\{ \left( \begin{array}{cc} 1 & 0 \\
  13757. 0 & x^3 \end{array} \right), \left( \begin{array}{cc} 1 & 0 \\ 3*x^2
  13758. & 1 \end{array} \right), \left( \begin{array}{cc} x & x+1 \\ -3 & -3
  13759. \end{array} \right) \right\} \end{array}
  13760. \end{displaymath}
  13761. \section{Smithex\_int}
  13762. \ttindex{smithex\_int}
  13763. Given an $n$ by $m$ rectangular matrix ${\cal A}$ that contains
  13764. {\it only} integer entries, {\tt smithex\_int}(${\cal A}$) computes the
  13765. Smith normal form ${\cal S}$ of ${\cal A}$.
  13766. It returns \{${\cal S}, {\cal P}, {\cal P}^{-1}$\} where ${\cal S},
  13767. {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P S P}^{-1} =
  13768. {\cal A}$.
  13769. {\tt load\_package normform;}
  13770. \begin{displaymath}
  13771. {\cal A} = \left( \begin{array}{ccc} 9 & -36 & 30 \\ -36 & 192 & -180 \\
  13772. 30 & -180 & 180 \end{array}
  13773. \right)
  13774. \end{displaymath}
  13775. {\tt smithex\_int}(${\cal A}$) =
  13776. \begin{center}
  13777. \begin{displaymath}
  13778. \left\{ \left( \begin{array}{ccc} 3 & 0 & 0 \\ 0 & 12 & 0 \\ 0 & 0 & 60
  13779. \end{array} \right), \left( \begin{array}{ccc} -17 & -5 & -4 \\ 64 & 19
  13780. & 15 \\ -50 & -15 & -12 \end{array} \right), \left( \begin{array}{ccc}
  13781. 1 & -24 & 30 \\ -1 & 25 & -30 \\ 0 & -1 & 1 \end{array} \right) \right\}
  13782. \end{displaymath}
  13783. \end{center}
  13784. \section{Frobenius}
  13785. \ttindex{frobenius}
  13786. {\tt Frobenius}(${\cal A}$) computes the Frobenius normal form
  13787. ${\cal F}$ of the matrix ${\cal A}$.
  13788. It returns \{${\cal F}, {\cal P}, {\cal P}^{-1}$\} where ${\cal F},
  13789. {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P F P}^{-1} =
  13790. {\cal A}$.
  13791. ${\cal A}$ is a square matrix.
  13792. {\tt load\_package normform;}
  13793. \begin{displaymath}
  13794. {\cal A} = \left( \begin{array}{cc} \frac{-x^2+y^2+y}{y} &
  13795. \frac{-x^2+x+y^2-y}{y} \\ \frac{-x^2-x+y^2+y}{y} & \frac{-x^2+x+y^2-y}
  13796. {y} \end{array} \right)
  13797. \end{displaymath}
  13798. {\tt frobenius}(${\cal A}$) =
  13799. \begin{center}
  13800. \begin{displaymath}
  13801. \left\{ \left( \begin{array}{cc} 0 & \frac{x*(x^2-x-y^2+y)}{y} \\ 1 &
  13802. \frac{-2*x^2+x+2*y^2}{y} \end{array} \right), \left( \begin{array}{cc}
  13803. 1 & \frac{-x^2+y^2+y}{y} \\ 0 & \frac{-x^2-x+y^2+y}{y} \end{array}
  13804. \right), \left( \begin{array}{cc} 1 & \frac{-x^2+y^2+y}{x^2+x-y^2-y} \\
  13805. 0 & \frac{-y}{x^2+x-y^2-y} \end{array} \right) \right\}
  13806. \end{displaymath}
  13807. \end{center}
  13808. \section{Ratjordan}
  13809. \ttindex{ratjordan}
  13810. {\tt Ratjordan}(${\cal A}$) computes the rational Jordan normal form
  13811. ${\cal R}$ of the matrix ${\cal A}$.
  13812. It returns \{${\cal R}, {\cal P}, {\cal P}^{-1}$\} where ${\cal R},
  13813. {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P R P}^{-1} =
  13814. {\cal A}$.
  13815. ${\cal A}$ is a square matrix.
  13816. {\tt load\_package normform;}
  13817. \begin{displaymath}
  13818. {\cal A} = \left( \begin{array}{cc} x+y & 5 \\ y & x^2 \end{array}
  13819. \right)
  13820. \end{displaymath}
  13821. {\tt ratjordan}(${\cal A}$) =
  13822. \begin{center}
  13823. \begin{displaymath}
  13824. \left\{ \left( \begin{array}{cc} 0 & -x^3-x^2*y+5*y \\ 1 &
  13825. x^2+x+y \end{array} \right), \left( \begin{array}{cc}
  13826. 1 & x+y \\ 0 & y \end{array} \right), \left( \begin{array}{cc} 1 &
  13827. \frac{-(x+y)}{y} \\ 0 & \hspace{0.2in} \frac{1}{y} \end{array} \right)
  13828. \right\}
  13829. \end{displaymath}
  13830. \end{center}
  13831. \section{Jordansymbolic}
  13832. \ttindex{jordansymbolic}
  13833. {\tt Jordansymbolic}(${\cal A}$) \hspace{0in} computes the Jordan
  13834. normal form ${\cal J}$of the matrix ${\cal A}$.
  13835. It returns \{${\cal J}, {\cal L}, {\cal P}, {\cal P}^{-1}$\}, where
  13836. ${\cal J}, {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P J P}^
  13837. {-1} = {\cal A}$. ${\cal L}$ = \{~{\it ll},~$\xi$~\}, where $\xi$ is
  13838. a name and {\it ll} is a list of irreducible factors of ${\it p}(\xi)$.
  13839. ${\cal A}$ is a square matrix.
  13840. {\tt load\_package normform;}\\
  13841. \begin{displaymath}
  13842. {\cal A} = \left( \begin{array}{cc} 1 & y \\ y^2 & 3 \end{array}
  13843. \right)
  13844. \end{displaymath}
  13845. {\tt jordansymbolic}(${\cal A}$) =
  13846. \begin{eqnarray}
  13847. & & \left\{ \left( \begin{array}{cc} \xi_{11} & 0 \\ 0 & \xi_{12}
  13848. \end{array} \right) ,
  13849. \left\{ \left\{ -y^3+\xi^2-4*\xi+3 \right\}, \xi \right\}, \right.
  13850. \nonumber \\ & & \hspace{0.1in} \left. \left( \begin{array}{cc}
  13851. \xi_{11} -3 & \xi_{12} -3 \\ y^2 & y^2
  13852. \end{array} \right), \left( \begin{array}{cc} \frac{\xi_{11} -2}
  13853. {2*(y^3-1)} & \frac{\xi_{11} + y^3 -1}{2*y^2*(y^3+1)} \\
  13854. \frac{\xi_{12} -2}{2*(y^3-1)} & \frac{\xi_{12}+y^3-1}{2*y^2*(y^3+1)}
  13855. \end{array} \right) \right\} \nonumber
  13856. \end{eqnarray}
  13857. \vspace{0.2in}
  13858. \begin{flushleft}
  13859. \begin{math}
  13860. {\tt solve(-y^3+xi^2-4*xi+3,xi)}${\tt ;}$
  13861. \end{math}
  13862. \end{flushleft}
  13863. \vspace{0.1in}
  13864. \begin{center}
  13865. \begin{math}
  13866. \{ \xi = \sqrt{y^3+1} + 2,\, \xi = -\sqrt{y^3+1}+2 \}
  13867. \end{math}
  13868. \end{center}
  13869. \vspace{0.1in}
  13870. \begin{math}
  13871. {\tt {\cal J} = sub}{\tt (}{\tt \{ xi(1,1)=sqrt(y^3+1)+2,\, xi(1,2) =
  13872. -sqrt(y^3+1)+2\},}
  13873. \end{math}
  13874. \\ \hspace*{0.29in} {\tt first jordansymbolic (${\cal A}$));}
  13875. \vspace{0.2in}
  13876. \begin{displaymath}
  13877. {\cal J} = \left( \begin{array}{cc} \sqrt{y^3+1} + 2 & 0 \\ 0 &
  13878. -\sqrt{y^3+1} + 2 \end{array} \right)
  13879. \end{displaymath}
  13880. \section{Jordan}
  13881. \ttindex{jordan}
  13882. {\tt Jordan}(${\cal A}$) computes the Jordan normal form
  13883. ${\cal J}$ of the matrix ${\cal A}$.
  13884. It returns \{${\cal J}, {\cal P}, {\cal P}^{-1}$\}, where
  13885. ${\cal J}, {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P J P}^
  13886. {-1} = {\cal A}$.
  13887. ${\cal A}$ is a square matrix.
  13888. {\tt load\_package normform;}
  13889. \begin{displaymath}
  13890. {\cal A} = \left( \begin{array}{cccccc} -9 & -21 & -15 & 4 & 2 & 0 \\
  13891. -10 & 21 & -14 & 4 & 2 & 0 \\ -8 & 16 & -11 & 4 & 2 & 0 \\ -6 & 12 & -9
  13892. & 3 & 3 & 0 \\ -4 & 8 & -6 & 0 & 5 & 0 \\ -2 & 4 & -3 & 0 & 1 & 3
  13893. \end{array} \right)
  13894. \end{displaymath}
  13895. \begin{flushleft}
  13896. {\tt ${\cal J}$ = first jordan$({\cal A})$;}
  13897. \end{flushleft}
  13898. \begin{displaymath}
  13899. {\cal J} = \left( \begin{array}{cccccc} 3 & 0 & 0 & 0 & 0 & 0 \\ 0 & 3
  13900. & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\
  13901. 0 & 0 & 0 & 0 & i+2 & 0 \\ 0 & 0 & 0 & 0 & 0 & -i+2
  13902. \end{array} \right)
  13903. \end{displaymath}
  13904. \chapter{NUMERIC: Solving numerical problems}
  13905. \label{NUMERIC}
  13906. \typeout{{NUMERIC: Solving numerical problems}}
  13907. {\footnotesize
  13908. \begin{center}
  13909. Herbert Melenk \\
  13910. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  13911. Takustra\"se 7 \\
  13912. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13913. e--mail: melenk@zib.de
  13914. \end{center}
  13915. }
  13916. \ttindex{NUMERIC}
  13917. \ttindex{NUM\_SOLVE}\index{Newton's method}\ttindex{NUM\_ODESOLVE}
  13918. \ttindex{BOUNDS}\index{Chebyshev fit}
  13919. \ttindex{NUM\_MIN}\index{Minimum}\ttindex{NUM\_INT}\index{Quadrature}
  13920. The {\small NUMERIC} package implements some numerical (approximative)
  13921. algorithms for \REDUCE\, based on the \REDUCE\ rounded mode
  13922. arithmetic. These algorithms are implemented for standard cases. They
  13923. should not be called for ill-conditioned problems; please use standard
  13924. mathematical libraries for these.
  13925. \section{Syntax}
  13926. \subsection{Intervals, Starting Points}
  13927. Intervals are generally coded as lower bound and
  13928. upper bound connected by the operator \verb+`..'+, usually
  13929. associated to a variable in an
  13930. equation.\index{Interval}
  13931. {\small\begin{verbatim}
  13932. x= (2.5 .. 3.5)
  13933. \end{verbatim}}
  13934. means that the variable x is taken in the range from 2.5 up to
  13935. 3.5. Note, that the bounds can be algebraic
  13936. expressions, which, however, must evaluate to numeric results.
  13937. In cases where an interval is returned as the result, the lower
  13938. and upper bounds can be extracted by the \verb+PART+ operator
  13939. as the first and second part respectively.
  13940. A starting point is specified by an equation with a numeric
  13941. righthand side,
  13942. {\small\begin{verbatim}
  13943. x=3.0
  13944. \end{verbatim}}
  13945. If for multivariate applications several coordinates must be
  13946. specified by intervals or as a starting point, these
  13947. specifications can be collected in one parameter (which is then
  13948. a list) or they can be given as separate parameters
  13949. alternatively. The list form is more appropriate when the
  13950. parameters are built from other \REDUCE\ calculations in an
  13951. automatic style, while the flat form is more convenient
  13952. for direct interactive input.
  13953. \subsection{Accuracy Control}
  13954. The keyword parameters $accuracy=a$ and $iterations=i$, where
  13955. $a$ and $i$ must be positive integer numbers, control the
  13956. iterative algorithms: the iteration is continued until
  13957. the local error is below $10^{-a}$; if that is impossible
  13958. within $i$ steps, the iteration is terminated with an
  13959. error message. The values reached so far are then returned
  13960. as the result.
  13961. \section{Minima}
  13962. The function to be minimised must have continuous partial derivatives
  13963. with respect to all variables. The starting point of the search can
  13964. be specified; if not, random values are taken instead. The steepest
  13965. descent algorithms in general find only local minima.
  13966. Syntax:\ttindex{NUM\_MIN}
  13967. \begin{description}
  13968. \item[NUM\_MIN] $(exp, var_1[=val_1] [,var_2[=val_2] \ldots]$
  13969. $ [,accuracy=a][,iterations=i]) $
  13970. or
  13971. \item[NUM\_MIN] $(exp, \{ var_1[=val_1] [,var_2[=val_2] \ldots] \}$
  13972. $ [,accuracy=a][,iterations=i]) $
  13973. where $exp$ is a function expression,
  13974. $var_1, var_2, \ldots$ are the variables in $exp$ and
  13975. $val_1,val_2, \ldots$ are the (optional) start values.
  13976. NUM\_MIN tries to find the next local minimum along the descending
  13977. path starting at the given point. The result is a list
  13978. with the minimum function value as first element followed by a list
  13979. of equations, where the variables are equated to the coordinates
  13980. of the result point.
  13981. \end{description}
  13982. Examples:
  13983. {\small\begin{verbatim}
  13984. num_min(sin(x)+x/5, x);
  13985. {4.9489585606,{X=29.643767785}}
  13986. num_min(sin(x)+x/5, x=0);
  13987. { - 1.3342267466,{X= - 1.7721582671}}
  13988. % Rosenbrock function (well known as hard to minimize).
  13989. fktn := 100*(x1**2-x2)**2 + (1-x1)**2;
  13990. num_min(fktn, x1=-1.2, x2=1, iterations=200);
  13991. {0.00000021870228295,{X1=0.99953284494,X2=0.99906807238}}
  13992. \end{verbatim}}
  13993. \section{Roots of Functions/ Solutions of Equations}
  13994. An adaptively damped Newton iteration is used to find an approximative
  13995. zero of a function, a function vector or the solution of an equation
  13996. or an equation system. The expressions must have continuous
  13997. derivatives for all variables. A starting point for the iteration can
  13998. be given. If not given, random values are taken instead. If the number
  13999. of forms is not equal to the number of variables, the Newton method
  14000. cannot be applied. Then the minimum of the sum of absolute squares is
  14001. located instead.
  14002. With {\tt ON COMPLEX} solutions with imaginary parts can be
  14003. found, if either the expression(s) or the starting point
  14004. contain a nonzero imaginary part.
  14005. Syntax:\ttindex{NUM\_SOLVE}
  14006. \begin{description}
  14007. \item[NUM\_SOLVE] $(exp_1, var_1[=val_1][,accuracy=a][,iterations=i])$
  14008. or
  14009. \item[NUM\_SOLVE] $(\{exp_1,\ldots,exp_n\},
  14010. var_1[=val_1],\ldots,var_1[=val_n]$
  14011. \item[\ \ \ \ \ \ \ \ ]$[,accuracy=a][,iterations=i])$
  14012. or
  14013. \item[NUM\_SOLVE] $(\{exp_1,\ldots,exp_n\},
  14014. \{var_1[=val_1],\ldots,var_1[=val_n]\}$
  14015. \item[\ \ \ \ \ \ \ \ ]$[,accuracy=a][,iterations=i])$
  14016. where $exp_1, \ldots,exp_n$ are function expressions,
  14017. $var_1, \ldots, var_n$ are the variables,
  14018. $val_1, \ldots, val_n$ are optional start values.
  14019. NUM\_SOLVE tries to find a zero/solution of the expression(s).
  14020. Result is a list of equations, where the variables are
  14021. equated to the coordinates of the result point.
  14022. The Jacobian matrix is stored as a side effect in the shared
  14023. variable JACOBIAN.\ttindex{JACOBIAN}
  14024. \end{description}
  14025. Example:
  14026. {\small\begin{verbatim}
  14027. num_solve({sin x=cos y, x + y = 1},{x=1,y=2});
  14028. {X= - 1.8561957251,Y=2.856195584}
  14029. jacobian;
  14030. [COS(X) SIN(Y)]
  14031. [ ]
  14032. [ 1 1 ]
  14033. \end{verbatim}}
  14034. \section{Integrals}
  14035. Numerical integration uses a polyalgorithm, explained in the full
  14036. documentation.\ttindex{NUM\_INT}
  14037. \begin{description}
  14038. \item[NUM\_INT] $(exp,var_1=(l_1 .. u_1)[,var_2=(l_2 .. u_2)\ldots]$
  14039. \item[\ \ \ \ \ \ ]$[,accuracy=a][,iterations=i])$
  14040. where $exp$ is the function to be integrated,
  14041. $var_1, var_2 , \ldots$ are the integration variables,
  14042. $l_1, l_2 , \ldots$ are the lower bounds,
  14043. $u_1, u_2 , \ldots$ are the upper bounds.
  14044. Result is the value of the integral.
  14045. \end{description}
  14046. Example:
  14047. {\small\begin{verbatim}
  14048. num_int(sin x,x=(0 .. pi));
  14049. 2.0000010334
  14050. \end{verbatim}}
  14051. \section{Ordinary Differential Equations}
  14052. A Runge-Kutta method of order 3 finds an approximate graph for
  14053. the solution of a ordinary differential equation
  14054. real initial value problem.
  14055. Syntax:\ttindex{NUM\_ODESOLVE}
  14056. \begin{description}
  14057. \item[NUM\_ODESOLVE]($exp$,$depvar=dv$,$indepvar$=$(from .. to)$
  14058. $ [,accuracy=a][,iterations=i]) $
  14059. where
  14060. $exp$ is the differential expression/equation,
  14061. $depvar$ is an identifier representing the dependent variable
  14062. (function to be found),
  14063. $indepvar$ is an identifier representing the independent variable,
  14064. $exp$ is an equation (or an expression implicitly set to zero) which
  14065. contains the first derivative of $depvar$ wrt $indepvar$,
  14066. $from$ is the starting point of integration,
  14067. $to$ is the endpoint of integration (allowed to be below $from$),
  14068. $dv$ is the initial value of $depvar$ in the point $indepvar=from$.
  14069. The ODE $exp$ is converted into an explicit form, which then is
  14070. used for a Runge-Kutta iteration over the given range. The
  14071. number of steps is controlled by the value of $i$
  14072. (default: 20).
  14073. If the steps are too coarse to reach the desired
  14074. accuracy in the neighbourhood of the starting point, the number is
  14075. increased automatically.
  14076. Result is a list of pairs, each representing a point of the
  14077. approximate solution of the ODE problem.
  14078. \end{description}
  14079. Example:
  14080. {\small\begin{verbatim}
  14081. num_odesolve(df(y,x)=y,y=1,x=(0 .. 1), iterations=5);
  14082. {{0.0,1.0},{0.2,1.2214},{0.4,1.49181796},{0.6,1.8221064563},
  14083. {0.8,2.2255208258},{1.0,2.7182511366}}
  14084. \end{verbatim}}
  14085. \section{Bounds of a Function}
  14086. Upper and lower bounds of a real valued function over an
  14087. interval or a rectangular multivariate domain are computed
  14088. by the operator \f{BOUNDS}. Some knowledge
  14089. about the behaviour of special functions like ABS, SIN, COS, EXP, LOG,
  14090. fractional exponentials etc. is integrated and can be evaluated
  14091. if the operator BOUNDS is called with rounded mode on
  14092. (otherwise only algebraic evaluation rules are available).
  14093. If BOUNDS finds a singularity within an interval, the evaluation
  14094. is stopped with an error message indicating the problem part
  14095. of the expression.
  14096. \newpage
  14097. Syntax:\ttindex{BOUNDS}
  14098. \begin{description}
  14099. \item[BOUNDS]$(exp,var_1=(l_1 .. u_1) [,var_2=(l_2 .. u_2) \ldots])$
  14100. \item[{\it BOUNDS}]$(exp,\{var_1=(l_1 .. u_1) [,var_2=(l_2 .. u_2)\ldots]\})$
  14101. where $exp$ is the function to be investigated,
  14102. $var_1, var_2 , \ldots$ are the variables of exp,
  14103. $l_1, l_2 , \ldots$ and $u_1, u_2 , \ldots$ specify the area (intervals).
  14104. {\tt BOUNDS} computes upper and lower bounds for the expression in the
  14105. given area. An interval is returned.
  14106. \end{description}
  14107. Example:
  14108. {\small\begin{verbatim}
  14109. bounds(sin x,x=(1 .. 2));
  14110. {-1,1}
  14111. on rounded;
  14112. bounds(sin x,x=(1 .. 2));
  14113. 0.84147098481 .. 1
  14114. bounds(x**2+x,x=(-0.5 .. 0.5));
  14115. - 0.25 .. 0.75
  14116. \end{verbatim}}
  14117. \section{Chebyshev Curve Fitting}
  14118. The operator family $Chebyshev\_\ldots$ implements approximation
  14119. and evaluation of functions by the Chebyshev method.
  14120. The operator {\tt Chebyshev\_fit}\ttindex{Chebyshev\_fit} computes
  14121. this approximation and returns a list, which has as first element the
  14122. sum expressed as a polynomial and as second element the sequence of
  14123. Chebyshev coefficients ${c_i}$. {\tt
  14124. Chebyshev\_df}\ttindex{Chebyshev\_df} and {\tt
  14125. Chebyshev\_int}\ttindex{Chebyshev\_int} transform a Chebyshev
  14126. coefficient list into the coefficients of the corresponding derivative
  14127. or integral respectively. For evaluating a Chebyshev approximation at
  14128. a given point in the basic interval the operator {\tt
  14129. Chebyshev\_eval}\ttindex{Chebyshev\_eval} can be used. Note that {\tt
  14130. Chebyshev\_eval} is based on a recurrence relation which is in general
  14131. more stable than a direct evaluation of the complete polynomial.
  14132. \begin{description}
  14133. \item[CHEBYSHEV\_FIT] $(fcn,var=(lo .. hi),n)$
  14134. \item[CHEBYSHEV\_EVAL] $(coeffs,var=(lo .. hi),var=pt)$
  14135. \item[CHEBYSHEV\_DF] $(coeffs,var=(lo .. hi))$
  14136. \item[CHEBYSHEV\_INT] $(coeffs,var=(lo .. hi))$
  14137. where $fcn$ is an algebraic expression (the function to be
  14138. fitted), $var$ is the variable of $fcn$, $lo$ and $hi$ are
  14139. numerical real values which describe an interval ($lo < hi$),
  14140. $n$ is the approximation order,an integer $>0$, set to 20 if missing,
  14141. $pt$ is a numerical value in the interval and $coeffs$ is
  14142. a series of Chebyshev coefficients, computed by one of
  14143. $CHEBYSHEV\_COEFF$, $\_DF$ or $\_INT$.
  14144. \end{description}
  14145. Example:
  14146. {\small\begin{verbatim}
  14147. on rounded;
  14148. w:=chebyshev_fit(sin x/x,x=(1 .. 3),5);
  14149. 3 2
  14150. w := {0.03824*x - 0.2398*x + 0.06514*x + 0.9778,
  14151. {0.8991,-0.4066,-0.005198,0.009464,-0.00009511}}
  14152. chebyshev_eval(second w, x=(1 .. 3), x=2.1);
  14153. 0.4111
  14154. \end{verbatim}}
  14155. \section{General Curve Fitting}
  14156. The operator {\tt NUM\_FIT}\ttindex{NUM\_FIT} finds for a set of
  14157. points the linear combination of a given set of
  14158. functions (function basis) which approximates the
  14159. points best under the objective of the least squares
  14160. criterion (minimum of the sum of the squares of the deviation).
  14161. The solution is found as zero of the
  14162. gradient vector of the sum of squared errors.
  14163. Syntax:
  14164. \begin{description}
  14165. \item[NUM\_FIT] $(vals,basis,var=pts)$
  14166. where $vals$ is a list of numeric values,
  14167. $var$ is a variable used for the approximation,
  14168. $pts$ is a list of coordinate values which correspond to $var$,
  14169. $basis$ is a set of functions varying in $var$ which is used
  14170. for the approximation.
  14171. \end{description}
  14172. The result is a list containing as first element the
  14173. function which approximates the given values, and as
  14174. second element a list of coefficients which were used
  14175. to build this function from the basis.
  14176. Example:
  14177. {\small\begin{verbatim}
  14178. % approximate a set of factorials by a polynomial
  14179. pts:=for i:=1 step 1 until 5 collect i$
  14180. vals:=for i:=1 step 1 until 5 collect
  14181. for j:=1:i product j$
  14182. num_fit(vals,{1,x,x**2},x=pts);
  14183. 2
  14184. {14.571428571*X - 61.428571429*X + 54.6,{54.6,
  14185. - 61.428571429,14.571428571}}
  14186. num_fit(vals,{1,x,x**2,x**3,x**4},x=pts);
  14187. 4 3
  14188. {2.2083333234*X - 20.249999879*X
  14189. 2
  14190. + 67.791666154*X - 93.749999133*X
  14191. + 44.999999525,
  14192. {44.999999525, - 93.749999133,67.791666154,
  14193. - 20.249999879,2.2083333234}}
  14194. \end{verbatim}}
  14195. \section{Function Bases}
  14196. The following procedures compute sets of functions
  14197. for example to be used for approximation.
  14198. All procedures have
  14199. two parameters, the expression to be used as $variable$
  14200. (an identifier in most cases) and the
  14201. order of the desired system.
  14202. The functions are not scaled to a specific interval, but
  14203. the $variable$ can be accompanied by a scale factor
  14204. and/or a translation
  14205. in order to map the generic interval of orthogonality to another
  14206. ({\em e.g.\ }$(x- 1/2 ) * 2 pi$).
  14207. The result is a function list with ascending order, such that
  14208. the first element is the function of order zero and (for
  14209. the polynomial systems) the function of order $n$ is the $n+1$-th
  14210. element.
  14211. \ttindex{monomial\_base}\ttindex{trigonometric\_base}\ttindex{Bernstein\_base}
  14212. \ttindex{Legendre\_base}\ttindex{Laguerre\_base}\ttindex{Hermite\_base}
  14213. \ttindex{Chebyshev\_base\_T}\ttindex{Chebyshev\_base\_U}
  14214. {\small\begin{verbatim}
  14215. monomial_base(x,n) {1,x,...,x**n}
  14216. trigonometric_base(x,n) {1,sin x,cos x,sin(2x),cos(2x)...}
  14217. Bernstein_base(x,n) Bernstein polynomials
  14218. Legendre_base(x,n) Legendre polynomials
  14219. Laguerre_base(x,n) Laguerre polynomials
  14220. Hermite_base(x,n) Hermite polynomials
  14221. Chebyshev_base_T(x,n) Chebyshev polynomials first kind
  14222. Chebyshev_base_U(x,n) Chebyshev polynomials second kind
  14223. \end{verbatim}}
  14224. Example:
  14225. {\small\begin{verbatim}
  14226. Bernstein_base(x,5);
  14227. 5 4 3 2
  14228. { - X + 5*X - 10*X + 10*X - 5*X + 1,
  14229. 4 3 2
  14230. 5*X*(X - 4*X + 6*X - 4*X + 1),
  14231. 2 3 2
  14232. 10*X *( - X + 3*X - 3*X + 1),
  14233. 3 2
  14234. 10*X *(X - 2*X + 1),
  14235. 4
  14236. 5*X *( - X + 1),
  14237. 5
  14238. X }
  14239. \end{verbatim}}
  14240. \chapter[ODESOLVE: Ordinary differential eqns]%
  14241. {ODESOLVE: \protect\\ Ordinary differential equations solver}
  14242. \label{ODESOLVE}
  14243. \typeout{[ODESOLVE: Ordinary differential equations solver]}
  14244. {\footnotesize
  14245. \begin{center}
  14246. Malcolm A.H. MacCallum \\
  14247. School of Mathematical Sciences, Queen Mary and Westfield College \\
  14248. University of London \\
  14249. Mile End Road \\
  14250. London E1 4NS, England \\[0.05in]
  14251. e--mail: mm@maths.qmw.ac.uk
  14252. \end{center}
  14253. }
  14254. \ttindex{ODESOLVE}
  14255. \index{ordinary differential equations}
  14256. The ODESOLVE package is a solver for ordinary differential equations.
  14257. At the present time it has very limited capabilities,
  14258. \begin{enumerate}
  14259. \item it can handle only a single scalar equation presented as an
  14260. algebraic expression or equation, and
  14261. \item it can solve only first-order equations of simple types,
  14262. linear equations with constant coefficients and Euler equations.
  14263. \end{enumerate}
  14264. \noindent These solvable types are exactly those for
  14265. which Lie symmetry techniques give no useful information.
  14266. \section{Use}
  14267. The only top-level function the user should normally invoke is:
  14268. \ttindex{ODESOLVE}
  14269. \vspace{.1in}
  14270. \begin{tabbing}
  14271. {\tt ODESOLVE}(\=EXPRN:{\em expression, equation}, \\
  14272. \>VAR1:{\em variable}, \\
  14273. \>VAR2:{\em variable}):{\em list-algebraic}
  14274. \end{tabbing}
  14275. \vspace{.1in}
  14276. \noindent {\tt ODESOLVE} returns a list containing an equation (like solve):
  14277. \begin{description}
  14278. \item[EXPRN] is a single scalar expression such that EXPRN = 0 is the
  14279. ordinary differential equation (ODE for short) to be solved,
  14280. or is an equivalent equation.
  14281. \item[VAR1] is the name of the dependent variable.
  14282. \item[VAR2] is the name of the independent variable
  14283. \end{description}
  14284. \noindent (For simplicity these will be called y and x in the sequel)
  14285. The returned value is a list containing the equation giving the
  14286. general solution of the ODE (for simultaneous equations this will be a
  14287. list of equations eventually). It will contain occurrences of the
  14288. \index{ARBCONST operator}
  14289. operator {\tt ARBCONST} for the arbitrary constants in the general
  14290. solution. The arguments of {\tt ARBCONST} should be new, as with {\tt
  14291. ARBINT} etc. in SOLVE. A counter {\tt !!ARBCONST} is used to arrange
  14292. this (similar to the way {\tt ARBINT} is implemented).
  14293. Some other top-level functions may be of use elsewhere, especially:
  14294. \ttindex{SORTOUTODE}
  14295. \vspace{.1in}
  14296. \noindent{\tt SORTOUTODE}(EXPRN:{\em algebraic}, Y:{\em var}, X:{\em var}):
  14297. {\em expression}
  14298. \vspace{.1in}
  14299. \noindent which finds the order and degree of the EXPRN as a
  14300. differential equation for Y with respect to Y and sets the linearity
  14301. and highest derivative occurring in reserved variables ODEORDER,
  14302. ODEDEGREE,\ttindex{ODEORDER}\ttindex{ODEDEGREE}\ttindex{ODELINEARITY}\ttindex{HIGHESTDERIV}ODELINEARITY
  14303. and HIGHESTDERIV. An expression equivalent to the ODE is
  14304. returned, or zero if EXPRN (equated to 0) is not an ODE in the
  14305. given variables.
  14306. \section{Commentary}
  14307. The methods used by this package are described in detail in the full
  14308. documentation, which should be inspected together with the examples
  14309. file.
  14310. \chapter[ORTHOVEC: scalars and vectors]%
  14311. {ORTHOVEC: Three-dimensional vector analysis}
  14312. \label{ORTHOVEC}
  14313. \typeout{{ORTHOVEC: Three-dimensional vector analysis}}
  14314. {\footnotesize
  14315. \begin{center}
  14316. James W.~Eastwood \\
  14317. AEA Technology, Culham Laboratory \\
  14318. Abingdon \\
  14319. Oxon OX14 3DB, England \\[0.05in]
  14320. e--mail: jim\_eastwood@aeat.co.uk
  14321. \end{center}
  14322. }
  14323. \ttindex{ORTHOVEC}
  14324. The ORTHOVEC package is a collection of \REDUCE\ procedures and
  14325. operations which provide a simple to use environment for the
  14326. manipulation of scalars and vectors. Operations include addition,
  14327. subtraction, dot and cross products, division, modulus, div, grad,
  14328. curl, laplacian, differentiation, integration, ${\bf a \cdot \nabla}$
  14329. and Taylor expansion.
  14330. \section{Initialisation}\label{vstart}
  14331. \ttindex{VSTART}
  14332. The procedure \f{START} initialises ORTHOVEC. VSTART provides a
  14333. menu of standard coordinate systems:-
  14334. \begin{enumerate}
  14335. \index{cartesian coordinates}
  14336. \item cartesian $(x, y, z) = $ {\tt (x, y, z)}
  14337. \index{cylindrical coordinates}
  14338. \item cylindrical $(r, \theta, z) = $ {\tt (r, th, z)}
  14339. \index{spherical coordinates}
  14340. \item spherical $(r, \theta, \phi) = $ {\tt (r, th, ph) }
  14341. \item general $( u_1, u_2, u_3 ) = $ {\tt (u1, u2, u3) }
  14342. \item others
  14343. \end{enumerate}
  14344. which the user selects by number. Selecting options (1)-(4)
  14345. automatically sets up the coordinates and scale factors. Selection
  14346. option (5) shows the user how to select another coordinate system. If
  14347. VSTART is not called, then the default cartesian coordinates are used.
  14348. ORTHOVEC may be re-initialised to a new coordinate system at any time
  14349. during a given \REDUCE\ session by typing
  14350. {\small\begin{verbatim}
  14351. VSTART $.
  14352. \end{verbatim}}
  14353. \section{Input-Output}
  14354. ORTHOVEC assumes all quantities are either scalars or 3 component
  14355. vectors. To define a vector $a$ with components $(c_1, c_2, c_3)$ use
  14356. the procedure SVEC:\ttindex{SVEC}
  14357. {\small\begin{verbatim}
  14358. a := svec(c1, c2, c3);
  14359. \end{verbatim}}
  14360. The procedure\ttindex{VOUT} \f{VOUT} (which returns the value of its
  14361. argument) can be used to give labelled output of components
  14362. in algebraic form:
  14363. {\small\begin{verbatim}
  14364. b := svec (sin(x)**2, y**2, z)$
  14365. vout(b)$
  14366. \end{verbatim}}
  14367. The operator {\tt \_} can be used to select a particular
  14368. component (1, 2 or 3) for output {\em e.g.}
  14369. {\small\begin{verbatim}
  14370. b_1 ;
  14371. \end{verbatim}}
  14372. \section{Algebraic Operations}
  14373. Six infix operators, sum, difference, quotient, times, exponentiation
  14374. and cross product, and four prefix
  14375. operators, plus, minus, reciprocal
  14376. and modulus are defined in ORTHOVEC. These operators can take suitable
  14377. combinations of scalar and vector arguments,
  14378. and in the case of scalar arguments reduce to the usual definitions of
  14379. $ +, -, *, /, $ etc.
  14380. The operators are represented by symbols
  14381. \index{+ ! 3-D vector}\index{- ! 3-D vector}\index{/ ! 3-D vector}
  14382. \index{* ! 3-D vector}\index{* ! 3-D vector}\index{"\^{} ! 3-D vector}
  14383. \index{$><$ ! 3-D vector}
  14384. {\small\begin{verbatim}
  14385. +, -, /, *, ^, ><
  14386. \end{verbatim}}
  14387. \index{$><$ ! diphthong} The composite {\tt ><} is an
  14388. attempt to represent the cross product symbol
  14389. $\times$ in ASCII characters.
  14390. If we let ${\bf v}$ be a vector and $s$ be a scalar, then
  14391. valid combinations of arguments of the
  14392. procedures and operators and the type of the result
  14393. are as summarised below. The notation used is\\
  14394. {\em result :=procedure(left argument, right argument) } or\\
  14395. {\em result :=(left operand) operator (right operand) } . \\
  14396. \underline{Vector Addition} \\
  14397. \ttindex{VECTORPLUS}\ttindex{VECTORADD}\index{vector ! addition}
  14398. \begin{tabular}{rclcrcl}
  14399. {\bf v} &:=& VECTORPLUS({\bf v}) &{\rm or}& {\bf v} &:=& + {\bf v} \\
  14400. s &:=& VECTORPLUS(s) &{\rm or} & s &:=& + s \\
  14401. {\bf v} &:=& VECTORADD({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  14402. {\bf v} + {\bf v} \\
  14403. s &:=& VECTORADD(s,s) &{\rm or }& s &:=& s + s \\
  14404. \end{tabular} \\
  14405. \underline{Vector Subtraction} \\
  14406. \ttindex{VECTORMINUS}\ttindex{VECTORDIFFERENCE}\index{vector ! subtraction}
  14407. \begin{tabular}{rclcrcl}
  14408. {\bf v} &:=& VECTORMINUS({\bf v}) &{\rm or}&
  14409. {\bf v} &:=& - {\bf v} \\
  14410. s &:=& VECTORMINUS(s) &{\rm or} & s &:=& - s \\
  14411. {\bf v} &:=& VECTORDIFFERENCE({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  14412. {\bf v} - {\bf v} \\
  14413. s &:=& VECTORDIFFERENCE(s,s) &{\rm or }& s &:=& s - s \\
  14414. \end{tabular} \\
  14415. \underline{Vector Division}\\
  14416. \ttindex{VECTORRECIP}\ttindex{VECTORQUOTIENT}\index{vector ! division}
  14417. \begin{tabular}{rclcrcl}
  14418. {\bf v} &:=& VECTORRECIP({\bf v}) &{\rm or}& {\bf v} &:=& /
  14419. {\bf v} \\
  14420. s &:=& VECTORRECIP(s) &{\rm or} & s &:=& / s \\
  14421. {\bf v} &:=& VECTORQUOTIENT({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  14422. {\bf v} / {\bf v} \\
  14423. {\bf v} &:=& VECTORQUOTIENT({\bf v}, s ) &{\rm or }& {\bf v} &:=&
  14424. {\bf v} / s \\
  14425. {\bf v} &:=& VECTORQUOTIENT( s ,{\bf v}) &{\rm or }& {\bf v} &:=&
  14426. s / {\bf v} \\
  14427. s &:=& VECTORQUOTIENT(s,s) &{\rm or }& s &:=& s / s
  14428. \\
  14429. \end{tabular} \\
  14430. \underline{Vector Multiplication}\\
  14431. \ttindex{VECTORTIMES}\index{vector ! multiplication}
  14432. \begin{tabular}{rclcrcl}
  14433. {\bf v} &:=& VECTORTIMES( s ,{\bf v}) &{\rm or }& {\bf v} &:=&
  14434. s * {\bf v} \\
  14435. {\bf v} &:=& VECTORTIMES({\bf v}, s ) &{\rm or }& {\bf v} &:=& {\bf
  14436. v} * s \\
  14437. s &:=& VECTORTIMES({\bf v},{\bf v}) &{\rm or }& s &:=& {\bf
  14438. v} * {\bf v} \\
  14439. s &:=& VECTORTIMES( s , s ) &{\rm or }& s &:=&
  14440. s * s \\
  14441. \end{tabular} \\
  14442. \underline{Vector Cross Product} \\
  14443. \ttindex{VECTORCROSS}\index{cross product}\index{vector ! cross product}
  14444. \begin{tabular}{rclcrcl}
  14445. {\bf v} &:=& VECTORCROSS({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=& {\bf
  14446. v} $\times$ {\bf v} \\
  14447. \end{tabular} \\
  14448. \underline{Vector Exponentiation}\\
  14449. \ttindex{VECTOREXPT}\index{vector ! exponentiation}
  14450. \begin{tabular}{rclcrcl}
  14451. s &:=& VECTOREXPT ({\bf v}, s ) &{\rm or }& s &:=& {\bf
  14452. v} \^{} s \\
  14453. s &:=& VECTOREXPT ( s , s ) &{\rm or }& s &:=& s
  14454. \^{} s \\
  14455. \end{tabular} \\
  14456. \underline{Vector Modulus}\\
  14457. \ttindex{VMOD}\index{vector ! modulus}
  14458. \begin{tabular}{rcl}
  14459. s &:=& VMOD (s)\\
  14460. s &:=& VMOD ({\bf v}) \\
  14461. \end{tabular} \\
  14462. All other combinations of operands for these operators lead to error
  14463. messages being issued. The first two instances of vector
  14464. multiplication are scalar multiplication of vectors, the third is the
  14465. \index{vector ! dot product}\index{vector ! inner product}
  14466. \index{inner product}\index{dot product}
  14467. product of two scalars and the last is the inner (dot) product. The
  14468. prefix operators {\tt +, -, /} can take either scalar or vector
  14469. arguments and return results of the same type as their arguments.
  14470. VMOD returns a scalar.
  14471. In compound expressions, parentheses may be used to specify the order of
  14472. combination. If parentheses are omitted the ordering of the
  14473. operators, in increasing order of precedence is
  14474. {\small\begin{verbatim}
  14475. + | - | dotgrad | * | >< | ^ | _
  14476. \end{verbatim}}
  14477. and these are placed in the precedence list defined in \REDUCE{}
  14478. after $<$.
  14479. Vector divisions are defined as follows: If ${\bf a}$ and ${\bf b}$ are
  14480. vectors and $c$ is a scalar, then
  14481. \begin{eqnarray*}
  14482. {\bf a} / {\bf b} & = & \frac{{\bf a} \cdot {\bf b}}{ \mid {\bf b}
  14483. \mid^2}\\
  14484. c / {\bf a} & = & \frac{c {\bf a} }{ \mid {\bf a} \mid^2}
  14485. \end{eqnarray*}
  14486. Both scalar multiplication and dot products are given by the same symbol,
  14487. braces are advisable to ensure the correct
  14488. precedences in expressions such as $({\bf a} \cdot {\bf b})
  14489. ({\bf c} \cdot {\bf d})$.
  14490. Vector exponentiation is defined as the power of the modulus:\\
  14491. ${\bf a}^n \equiv {\rm VMOD}(a)^n = \mid {\bf a} \mid^n$
  14492. \section{Differential Operations}
  14493. Differential operators provided are div, grad, curl, delsq, and dotgrad.
  14494. \index{div operator}\index{grad operator}\index{curl operator}
  14495. \index{delsq operator}\index{dotgrad operator}
  14496. All but the last of these are prefix operators having a single
  14497. vector or scalar argument as appropriate. Valid combinations of
  14498. operator and argument, and the type of the result are shown in
  14499. table~\ref{vvecttable}.
  14500. \begin{table}
  14501. \begin{center}
  14502. \begin{tabular}{rcl}
  14503. s & := & div ({\bf v}) \\
  14504. {\bf v} & := & grad(s) \\
  14505. {\bf v} & := & curl({\bf v}) \\
  14506. {\bf v} & := & delsq({\bf v}) \\
  14507. s & := & delsq(s) \\
  14508. {\bf v} & := & {\bf v} dotgrad {\bf v} \\
  14509. s & := & {\bf v} dotgrad s
  14510. \end{tabular}
  14511. \end{center}
  14512. \caption{ORTHOVEC valid combinations of operator and argument}\label{vvecttable}
  14513. \end{table}
  14514. All other combinations of operator and argument type cause error
  14515. messages to be issued. The differential operators have their usual
  14516. meanings. The coordinate system used by these operators is
  14517. set by invoking VSTART (cf. Sec.~\ref{vstart}). The names {\tt h1},
  14518. {\tt h2} and {\tt h3 } are
  14519. reserved for the scale factors, and {\tt u1}, {\tt u2} and {\tt u3} are
  14520. used for the coordinates.
  14521. A vector extension, VDF, of the \REDUCE\ procedure DF allows the
  14522. differentiation of a vector (scalar) with respect to a scalar to be
  14523. performed. Allowed forms are\ttindex{VDF}
  14524. VDF({\bf v}, s) $\rightarrow$ {\bf v} and
  14525. VDF(s, s) $\rightarrow$ s ,
  14526. where, for example\\
  14527. \begin{eqnarray*}
  14528. {\tt vdf( B,x)} \equiv \frac{\partial {\bf B}}{\partial x}
  14529. \end{eqnarray*}
  14530. The standard \REDUCE\ procedures DEPEND and NODEPEND have been redefined
  14531. to allow dependences of vectors to be compactly
  14532. defined. For example\index{DEPEND statement}\index{NODEPEND statement}
  14533. {\small\begin{verbatim}
  14534. a := svec(a1,a2,a3)$;
  14535. depend a,x,y;
  14536. \end{verbatim}}
  14537. causes all three components {\tt a1},{\tt a2} and {\tt a3} of {\tt a}
  14538. to be treated as functions of {\tt x} and {\tt y}.
  14539. Individual component dependences can still be defined if desired.
  14540. {\small\begin{verbatim}
  14541. depend a3,z;
  14542. \end{verbatim}}
  14543. The procedure VTAYLOR gives truncated Taylor series expansions of scalar
  14544. or vector functions:-\ttindex{VTAYLOR}
  14545. {\small\begin{verbatim}
  14546. vtaylor(vex,vx,vpt,vorder);
  14547. \end{verbatim}}
  14548. returns the series expansion of the expression
  14549. VEX with respect to variable VX\ttindex{VORDER}
  14550. about point VPT to order VORDER. Valid
  14551. combinations of argument types are shown in table~\ref{ORTHOVEC:validexp}. \\
  14552. \begin{table}
  14553. \begin{center}
  14554. \begin{tabular}{cccc}
  14555. VEX & VX & VPT & VORDER \\[2ex]
  14556. {\bf v} & {\bf v} & {\bf v} & {\bf v}\\
  14557. {\bf v} & {\bf v} & {\bf v} & s\\
  14558. {\bf v} & s & s & s \\
  14559. s & {\bf v} & {\bf v} & {\bf v} \\
  14560. s & {\bf v} & {\bf v} & s\\
  14561. s & s & s & s\\
  14562. \end{tabular}
  14563. \end{center}
  14564. \caption{ORTHOVEC valid combination of argument types.}\label{ORTHOVEC:validexp}
  14565. \end{table}
  14566. Any other combinations cause error messages to be issued. Elements of
  14567. VORDER must be non-negative integers, otherwise error messages are
  14568. issued. If scalar VORDER is given for a vector expansion, expansions
  14569. in each component are truncated at the same order, VORDER.
  14570. The new version of Taylor expansion applies\index{l'H\^opital's rule}
  14571. l'H\^opital's rule in evaluating coefficients, so handle cases such as
  14572. $\sin(x) / (x) $ , etc. which the original version of ORTHOVEC could
  14573. not. The procedure used for this is LIMIT,\ttindex{LIMIT} which can
  14574. be used directly to find the limit of a scalar function {\tt ex} of
  14575. variable {\tt x} at point {\tt pt}:-
  14576. {\small\begin{verbatim}
  14577. ans := limit(ex,x,pt);
  14578. \end{verbatim}}
  14579. \section{Integral Operations}
  14580. Definite and indefinite vector, volume and scalar line integration
  14581. procedures are included in ORTHOVEC. They are defined as follows:
  14582. \ttindex{VINT}\ttindex{DVINT}
  14583. \ttindex{VOLINT}\ttindex{DVOLINT}\ttindex{LINEINT}\ttindex{DLINEINT}
  14584. \begin{eqnarray*}
  14585. {\rm VINT} ({\bf v},x) & = & \int {\bf v}(x)dx\\
  14586. %
  14587. {\rm DVINT} ({\bf v},x, a, b) & = & \int^b_a {\bf v} (x) dx\\
  14588. %
  14589. {\rm VOLINT} ({\bf v}) & = & \int {\bf v} h_1 h_2 h_3 du_1 du_2 du_3\\
  14590. %
  14591. {\rm DVOLINT}({\bf v},{\bf l},{\bf u},n) & = & \int^{\bf u}_{\bf l}
  14592. {\bf v} h_1 h_2 h_3 du_1 du_2 du_3\\
  14593. %
  14594. {\rm LINEINT} ({\bf v, \omega}, t) & = & \int {\bf v} \cdot {\bf dr}
  14595. \equiv \int v_i h_i \frac{\partial \omega_i}{\partial t} dt\\
  14596. %
  14597. {\rm DLINEINT} ({\bf v, \omega} t, a, b) & = & \int^b_a v_i h_i
  14598. \frac{\partial \omega_i}{\partial t} dt\\
  14599. \end{eqnarray*}
  14600. In the vector and volume integrals, ${\bf v}$ are vector or scalar,
  14601. $a, b,x$ and $n$ are scalar. Vectors ${\bf l}$ and ${\bf u}$ contain
  14602. expressions for lower and upper bounds to the integrals. The integer
  14603. index $n$ defines the order in which the integrals over $u_1, u_2$ and
  14604. $u_3$ are performed in order to allow for functional dependencies in
  14605. the integral bounds:
  14606. \begin{center}
  14607. \begin{tabular}{ll}
  14608. n & order\\ 1 & $u_1~u_2~u_3$\\
  14609. %
  14610. 2 & $u_3~u_1~u_2$\\
  14611. %
  14612. 3 & $u_2~u_3~u_1$\\
  14613. %
  14614. 4 & $u_1~u_3~u_2$\\
  14615. %
  14616. 5 & $u_2~u_1~u_3$\\ otherwise & $u_3~u_2~u_1$\\
  14617. \end{tabular}
  14618. \end{center}
  14619. The vector ${\bf \omega}$ in the line integral's arguments contain
  14620. explicit parameterisation of the coordinates $u_1, u_2, u_3$ of the
  14621. line ${\bf u}(t)$ along which the integral is taken.
  14622. \chapter[PHYSOP: Operator Calculus]%
  14623. {PHYSOP: Operator calculus in quantum theory}
  14624. \label{PHYSOP}
  14625. \typeout{{PHYSOP: Operator calculus in quantum theory}}
  14626. {\footnotesize
  14627. \begin{center}
  14628. Mathias Warns \\
  14629. Physikalisches Institut der Universit\"at Bonn \\
  14630. Endenicher Allee 11--13 \\
  14631. D--5300 BONN 1, Germany \\[0.05in]
  14632. e--mail: UNP008@DBNRHRZ1.bitnet
  14633. \end{center}
  14634. }
  14635. \ttindex{PHYSOP}
  14636. The package PHYSOP has been designed to meet the requirements of
  14637. theoretical physicists looking for a
  14638. computer algebra tool to perform complicated calculations
  14639. in quantum theory
  14640. with expressions containing operators. These operations
  14641. consist mainly in the calculation of commutators between operator
  14642. expressions and in the evaluations of operator matrix elements
  14643. in some abstract space.
  14644. \section{The NONCOM2 Package}
  14645. The package NONCOM2 redefines some standard \REDUCE\ routines
  14646. in order to modify the way noncommutative operators are handled by the
  14647. system. It redefines the \f{NONCOM}\ttindex{NONCOM} statement in
  14648. a way more suitable for calculations in physics. Operators have now to
  14649. be declared noncommutative pairwise, {\em i.e.\ }coding: \\
  14650. {\small\begin{verbatim}
  14651. NONCOM A,B;
  14652. \end{verbatim}}
  14653. declares the operators \f{A} and \f{B} to be noncommutative but allows them
  14654. to commute with any other (noncommutative or not) operator present in
  14655. the expression. In a similar way if one wants {\em e.g.\ }\f{A(X)} and
  14656. \f{A(Y)} not to commute, one has now to code:
  14657. {\small\begin{verbatim}
  14658. NONCOM A,A;
  14659. \end{verbatim}}
  14660. A final example should make
  14661. the use of the redefined \f{NONCOM} statement clear:
  14662. {\small\begin{verbatim}
  14663. NONCOM A,B,C;
  14664. \end{verbatim}}
  14665. declares \f{A} to be noncommutative with \f{B} and \f{C},
  14666. \f{B} to be noncommutative
  14667. with \f{A} and \f{C} and \f{C} to be noncommutative
  14668. with \f{A} and \f{B}.
  14669. Note that after these declaration
  14670. {\em e.g.\ }\f{A(X)} and \f{A(Y)}
  14671. are still commuting kernels.
  14672. Finally to keep the compatibility with standard \REDUCE\, declaring a
  14673. \underline{single} identifier using the \f{NONCOM} statement has the same
  14674. effect as in
  14675. standard \REDUCE.
  14676. From the user's point of view there are no other
  14677. new commands implemented by the package.
  14678. \section{The PHYSOP package}
  14679. The package PHYSOP implements a new \REDUCE\ data type to perform
  14680. calculations with physical operators. The noncommutativity of
  14681. operators is
  14682. implemented using the NONCOM2 package so this file should be loaded
  14683. prior to the use of PHYSOP.
  14684. \subsection{Type declaration commands}
  14685. The new \REDUCE\ data type PHYSOP implemented by the package allows the
  14686. definition of a new kind of operators ({\em i.e.\ }kernels carrying
  14687. an arbitrary
  14688. number of arguments). Throughout this manual, the name
  14689. ``operator''
  14690. will refer, unless explicitly stated otherwise, to this new data type.
  14691. This data type is in turn
  14692. divided into 5 subtypes. For each of this subtype, a declaration command
  14693. has been defined:
  14694. \begin{description}
  14695. \item[\f{SCALOP A;} ]\ttindex{SCALOP} declares \f{A} to be a scalar
  14696. operator. This operator may
  14697. carry an arbitrary number of arguments; after the
  14698. declaration: \f{ SCALOP A; }
  14699. all kernels of the form
  14700. \f{A(J), A(1,N), A(N,L,M)}
  14701. are recognised by the system as being scalar operators.
  14702. \item[\f{VECOP V;} ]\ttindex{VECOP} declares \f{V} to be a vector operator.
  14703. As for scalar operators, the vector operators may carry an arbitrary
  14704. number of arguments. For example \f{V(3)} can be used to represent
  14705. the vector operator $\vec{V}_{3}$. Note that the dimension of space
  14706. in which this operator lives is \underline{arbitrary}.
  14707. One can however address a specific component of the
  14708. vector operator by using a special index declared as \f{PHYSINDEX} (see
  14709. below). This index must then be the first in the argument list
  14710. of the vector operator.
  14711. \item[\f{TENSOP C(3);} ] \ttindex{TENSOP}
  14712. declares \f{C} to be a tensor operator of rank 3. Tensor operators
  14713. of any fixed integer rank larger than 1 can be declared.
  14714. Again this operator may carry an arbitrary number of arguments
  14715. and the space dimension is not fixed.
  14716. The tensor
  14717. components can be addressed by using special \f{PHYSINDEX} indices
  14718. (see below) which have to be placed in front of all other
  14719. arguments in the argument list.
  14720. \item[\f{STATE U;} ]\ttindex{STATE} declares \f{U} to be a state, {\em i.e.\ }an
  14721. object on
  14722. which operators have a certain action. The state U can also carry an
  14723. arbitrary number of arguments.
  14724. \item[\f{PHYSINDEX X;} ]\ttindex{PHYSINDEX} declares \f{X} to be a special
  14725. index which will be used
  14726. to address components of vector and tensor operators.
  14727. \end{description}
  14728. A command \f{CLEARPHYSOP}\ttindex{CLEARPHYSOP}
  14729. removes
  14730. the PHYSOP type from an identifier in order to use it for subsequent
  14731. calculations. However it should be
  14732. remembered that \underline{no}
  14733. substitution rule is cleared by this function. It
  14734. is therefore left to the user's responsibility to clear previously all
  14735. substitution rules involving the identifier from which the PHYSOP type
  14736. is removed.
  14737. \subsection{Ordering of operators in an expression}
  14738. The ordering of kernels in an expression is performed according to
  14739. the following rules: \\
  14740. 1. \underline{Scalars} are always ordered ahead of
  14741. PHYSOP operators in an expression.
  14742. The \REDUCE\ statement \f{KORDER}\ttindex{KORDER} can be used to control the
  14743. ordering of scalars but has no
  14744. effect on the ordering of operators.
  14745. 2. The default ordering of operators follows the
  14746. order in which they have been declared (not the alphabetical one).
  14747. This ordering scheme can be changed using the command \f{OPORDER}.
  14748. \ttindex{OPORDER}
  14749. Its syntax is similar to the \f{KORDER} statement, {\em i.e.\ }coding:
  14750. \f{OPORDER A,V,F;}
  14751. means that all occurrences of the operator \f{A} are ordered ahead of
  14752. those of \f{V} etc. It is also possible to include operators
  14753. carrying
  14754. indices (both normal and special ones) in the argument list of
  14755. \f{OPORDER}. However including objects \underline{not}
  14756. defined as operators ({\em i.e.\ }scalars or indices) in the argument list
  14757. of the \f{OPORDER} command leads to an error.
  14758. 3. Adjoint operators are placed by the declaration commands just
  14759. after the original operators on the \f{OPORDER} list. Changing the
  14760. place of an operator on this list means \underline{not} that the
  14761. adjoint operator is moved accordingly. This adjoint operator can
  14762. be moved freely by including it in the argument list of the
  14763. \f{OPORDER} command.
  14764. \subsection{Arithmetic operations on operators}
  14765. The following arithmetic operations are possible with
  14766. operator expressions: \\
  14767. 1. Multiplication or division of an operator by a scalar.
  14768. 2. Addition and subtraction of operators of the \underline{same}
  14769. type.
  14770. 3. Multiplication of operators is only defined between two
  14771. \underline{scalar} operators.
  14772. 4. The scalar product of two VECTOR operators is implemented
  14773. with a new function \f{DOT}\ttindex{DOT}. The system expands
  14774. the product of
  14775. two vector operators into an ordinary product of the components of these
  14776. operators by inserting a special index generated by the program.
  14777. To give an example, if one codes:
  14778. {\small\begin{verbatim}
  14779. VECOP V,W;
  14780. V DOT W;
  14781. \end{verbatim}}
  14782. the system will transform the product into:
  14783. {\small\begin{verbatim}
  14784. V(IDX1) * W(IDX1)
  14785. \end{verbatim}}
  14786. where \f{IDX1} is a \f{PHYSINDEX} generated by the system (called a
  14787. DUMMY INDEX in the following) to express the summation over the
  14788. components. The identifiers \f{IDXn} (\f{n} is a nonzero integer) are
  14789. reserved variables for this purpose and should not be used for other
  14790. applications. The arithmetic operator
  14791. \f{DOT} can be used both in infix and prefix form with two arguments.
  14792. 5. Operators (but not states) can only be raised to an
  14793. \underline{integer} power. The system expands this power
  14794. expression into a product of the corresponding number of terms
  14795. inserting dummy indices if necessary. The following examples explain
  14796. the transformations occurring on power expressions (system output
  14797. is indicated with an \f{-->}):
  14798. {\small\begin{verbatim}
  14799. SCALOP A; A**2;
  14800. --> A*A
  14801. VECOP V; V**4;
  14802. --> V(IDX1)*V(IDX1)*V(IDX2)*V(IDX2)
  14803. TENSOP C(2); C**2;
  14804. --> C(IDX3,IDX4)*C(IDX3,IDX4)
  14805. \end{verbatim}}
  14806. Note in particular the way how the system interprets powers of
  14807. tensor operators which is different from the notation used in matrix
  14808. algebra.
  14809. 6. Quotients of operators are only defined between
  14810. scalar operator expressions.
  14811. The system transforms the quotient of 2 scalar operators into the
  14812. product of the first operator times the inverse of the second one.
  14813. {\small\begin{verbatim}
  14814. SCALOP A,B; A / B;
  14815. -1
  14816. A *( B )
  14817. \end{verbatim}}
  14818. 7. Combining the last 2 rules explains the way how the system
  14819. handles negative powers of operators:
  14820. \noindent
  14821. {\small\begin{verbatim}
  14822. SCALOP B;
  14823. B**(-3);
  14824. -1 -1 -1
  14825. --> (B )*(B )*(B )
  14826. \end{verbatim}}
  14827. The method of inserting dummy indices and expanding powers of
  14828. operators has been chosen to facilitate the handling of
  14829. complicated operator
  14830. expressions and particularly their application on states.
  14831. However it may be useful to get rid of these
  14832. dummy indices in order to enhance the readability of the
  14833. system's final output.
  14834. For this purpose the switch \f{CONTRACT}\ttindex{CONTRACT} has to
  14835. be turned on (\f{CONTRACT} is normally set to \f{OFF}).
  14836. The system in this case contracts over dummy indices reinserting the
  14837. \f{DOT} operator and reassembling the expanded powers. However due to
  14838. the predefined operator ordering the system may not remove all the
  14839. dummy indices introduced previously.
  14840. %%file).
  14841. \subsection{Special functions}
  14842. \subsubsection{Commutation relations}
  14843. If two PHYSOPs have been declared noncommutative using the (redefined)
  14844. \f{NONCOM}\ttindex{NONCOM} statement, it is possible to introduce in the environment
  14845. elementary (anti-) commutation relations between them. For
  14846. this purpose,
  14847. two scalar operators \f{COMM}\ttindex{COMM} and
  14848. \f{ANTICOMM}\ttindex{ANTICOMM} are available.
  14849. These operators are used in conjunction with \f{LET} statements.
  14850. Example:
  14851. {\small\begin{verbatim}
  14852. SCALOP A,B,C,D;
  14853. LET COMM(A,B)=C;
  14854. FOR ALL N,M LET ANTICOMM(A(N),B(M))=D;
  14855. VECOP U,V,W; PHYSINDEX X,Y,Z;
  14856. FOR ALL X,Y LET COMM(V(X),W(Y))=U(Z);
  14857. \end{verbatim}}
  14858. Note that if special indices are used as dummy variables in
  14859. \f{FOR ALL ... LET} constructs then these indices should have been
  14860. declared previously using the \f{PHYSINDEX} command.\ttindex{PHYSINDEX}
  14861. Every time the system
  14862. encounters a product term involving two
  14863. noncommutative operators which have to be reordered on account of the
  14864. given operator ordering, the list of available (anti-) commutators is
  14865. checked in the following way: First the system looks for a
  14866. \underline{commutation} relation which matches the product term. If it
  14867. fails then the defined \underline{anticommutation} relations are
  14868. checked. If there is no successful match the product term
  14869. \f{A*B} is replaced by: \\
  14870. {\small\begin{verbatim}
  14871. A*B;
  14872. --> COMM(A,B) + B*A
  14873. \end{verbatim}}
  14874. so that the user may introduce the commutation relation later on.
  14875. The user may want to force the system to look for
  14876. \underline{anticommutators} only; for this purpose a switch \f{ANTICOM}
  14877. \ttindex{ANTICOM}
  14878. is defined which has to be turned on ( \f{ANTICOM} is normally set to
  14879. \f{OFF}). In this case, the above example is replaced by:
  14880. {\small\begin{verbatim}
  14881. ON ANTICOM;
  14882. A*B;
  14883. --> ANTICOMM(A,B) - B*A
  14884. \end{verbatim}}
  14885. For the calculation of (anti-) commutators between complex
  14886. operator
  14887. expressions, the functions \f{COMMUTE}\ttindex{COMMUTE} and
  14888. \f{ANTICOMMUTE}\ttindex{ANTICOMMUTE} have been defined.
  14889. {\small\begin{verbatim}
  14890. VECOP P,A,K;
  14891. PHYSINDEX X,Y;
  14892. FOR ALL X,Y LET COMM(P(X),A(Y))=K(X)*A(Y);
  14893. COMMUTE(P**2,P DOT A);
  14894. \end{verbatim}}
  14895. \subsubsection{Adjoint expressions}
  14896. As has been already mentioned, for each operator and state defined
  14897. using the declaration commands, the system
  14898. generates automatically the corresponding adjoint operator. For the
  14899. calculation of the adjoint representation of a complicated
  14900. operator expression, a function \f{ADJ}\ttindex{ADJ} has been defined.
  14901. {\small\begin{verbatim}
  14902. SCALOP A,B;
  14903. ADJ(A*B);
  14904. + +
  14905. --> (A )*(B )
  14906. \end{verbatim}}
  14907. \subsubsection{Application of operators on states}
  14908. A function \f{OPAPPLY}\ttindex{OPAPPLY} has been
  14909. defined for the application of operators to states.
  14910. It has two arguments and is used in the following combinations:
  14911. {\bf (i)} \f{LET OPAPPLY(}{\it operator, state}\f{) =} {\it state};
  14912. This is to define a elementary
  14913. action of an operator on a state in analogy to the way
  14914. elementary commutation relations are introduced to the system.
  14915. {\small\begin{verbatim}
  14916. SCALOP A; STATE U;
  14917. FOR ALL N,P LET OPAPPLY((A(N),U(P))= EXP(I*N*P)*U(P);
  14918. \end{verbatim}}
  14919. {\bf (ii)} \f{LET OPAPPLY(}{\it state, state}\f{) =} {\it scalar exp.};
  14920. This form is to define scalar products between states and normalisation
  14921. conditions.
  14922. {\small\begin{verbatim}
  14923. STATE U;
  14924. FOR ALL N,M LET OPAPPLY(U(N),U(M)) = IF N=M THEN 1 ELSE 0;
  14925. \end{verbatim}}
  14926. {\bf (iii)} {\it state} \f{:= OPAPPLY(}{\it operator expression, state});
  14927. In this way, the action of an operator expression on a given state
  14928. is calculated using elementary relations defined as explained in {\bf
  14929. (i)}. The result may be assigned to a different state vector.
  14930. {\bf (iv)} \f{OPAPPLY(}{\it state}\f{, OPAPPLY(}{\it operator expression,
  14931. state}\f{))}; This is the way how to calculate matrix elements of
  14932. operator
  14933. expressions. The system proceeds in the following way: first the
  14934. rightmost operator is applied on the right state, which means that the
  14935. system tries
  14936. to find an elementary relation which match the application of the
  14937. operator on the state. If it fails
  14938. the system tries to apply the leftmost operator of the expression on the
  14939. left state using the adjoint representations. If this fails also,
  14940. the system prints out a warning message and stops the evaluation.
  14941. Otherwise the next operator occuring in the expression is
  14942. taken and so on until the complete expression is applied. Then the
  14943. system
  14944. looks for a relation expressing the scalar product of the two
  14945. resulting states and prints out the final result. An example of such
  14946. a calculation is given in the test file.
  14947. The infix version of the \f{OPAPPLY} function is the vertical bar
  14948. $\mid$. It is \underline{right} associative and placed in the
  14949. precedence
  14950. list just above the minus ($-$) operator.
  14951. \chapter{PM: A REDUCE pattern matcher}
  14952. \label{PM}
  14953. \typeout{{PM: A REDUCE pattern matcher}}
  14954. {\footnotesize
  14955. \begin{center}
  14956. Kevin McIsaac \\
  14957. The University of Western Australia \\
  14958. Australia\\[0.05in]
  14959. e--mail: kevin@wri.com
  14960. \end{center}
  14961. }
  14962. \ttindex{PM}
  14963. PM is a general pattern matcher similar in style to those found in systems
  14964. such as SMP and Mathematica.
  14965. A template is any expression composed of literal elements ({\em e.g.\ }{\tt
  14966. 5}, {\tt a} or {\tt a+1}) and specially denoted pattern variables
  14967. ({\em e.g.\ }{\tt ?a} or {\tt ??b}). Atoms
  14968. beginning with `?' are called generic variables and match any expression.
  14969. Atoms beginning with `??' are called multi-generic variables and match any
  14970. expression or any sequence of expressions including the null or empty
  14971. sequence. A sequence is an expression of the form `[a1, a2,...]'. When
  14972. placed in a function argument list the brackets are removed, {\em
  14973. i.e.\ }f([a,1]) $\rightarrow$ f(a,1) and f(a,[1,2],b) $\rightarrow$ f(a,1,2,b).
  14974. A template is said to match an expression if the template is literally
  14975. equal to the expression or if by replacing any of the generic or
  14976. multi-generic symbols occurring in the template, the template can be made
  14977. to be literally equal to the expression. These replacements are called the
  14978. bindings for the generic variables. A replacement is an expression of the
  14979. form {\tt exp1 -> exp2}, which means exp1 is replaced by exp2, or
  14980. {\tt exp1 --> exp2}, which is the same except exp2 is not simplified
  14981. until after the
  14982. substitution for exp1 is made. If the expression has any of the
  14983. properties; associativity, commutativity, or an identity element, they are
  14984. used to determine if the expressions match. If an attempt to match the
  14985. template to the expression fails the matcher backtracks, unbinding generic
  14986. variables, until it reached a place were it can make a different choice.
  14987. The matcher also supports semantic matching. Briefly, if a subtemplate
  14988. does not match the corresponding subexpression because they have different
  14989. structures then the two are equated and the matcher continues matching the
  14990. rest of the expression until all the generic variables in the subexpression
  14991. are bound. The equality is then checked. This is controlled by the switch
  14992. \ttindex{SEMANTIC}{\tt semantic}. By default it is on.
  14993. \section{The Match Function}
  14994. {\tt M(exp,template)}\ttindex{M}
  14995. The template is matched against the expression. If the template is
  14996. literally equal to the expression {\tt T} is returned. If the
  14997. template is literally equal to the expression after replacing the
  14998. generic variables by their bindings then the set of bindings is
  14999. returned as a set of replacements. Otherwise {\tt NIL} is returned.
  15000. {\small\begin{verbatim}
  15001. OPERATOR F;
  15002. M(F(A),F(A));
  15003. T
  15004. M(F(A,B),F(A,?A));
  15005. {?A->B}
  15006. M(F(A,B),F(??A));
  15007. {??A->[A,B]}
  15008. m(a+b+c,c+?a+?b);
  15009. {?a->a,?b->b}
  15010. m(a+b+c,b+?a);
  15011. {?a->a + c}
  15012. \end{verbatim}}
  15013. This example shows the effects of semantic matching, using the
  15014. associativity and commutativity of {\tt +}.
  15015. \section {Qualified Matching}
  15016. A template may be qualified by the use of the conditional operator
  15017. {\tt \_=',}\ttindex{\_=} standing for {\bf such that}. When a
  15018. such-that condition is encountered in a template it is held until all
  15019. generic variables appearing in logical-exp are bound. On the binding
  15020. of the last generic variable logical-exp is simplified and if the
  15021. result is not {\tt T} the condition fails and the pattern matcher
  15022. backtracks. When the template has been fully parsed any remaining
  15023. held such-that conditions are evaluated and compared to {\tt T}.
  15024. {\small\begin{verbatim}
  15025. load_package pm;
  15026. operator f;
  15027. if (m(f(a,b),f(?a,?b_=(?a=?b)))) then write "yes" else write"no";
  15028. no
  15029. m(f(a,a),f(?a,?b_=(?a=?b)));
  15030. {?B->A,?A->A}
  15031. \end{verbatim}}
  15032. {\typeout {This is not true}}
  15033. \section{Substituting for replacements}
  15034. The operator {\tt S}\ttindex{S} substitutes the replacements in an
  15035. expression.
  15036. {\tt S(exp,{temp1->sub1,temp2->sub2,...},rept, depth);}
  15037. will do the substitutions for a maximum of {\tt rept} and to a depth of
  15038. {\tt depth}, using a breadth-first search and replace. {\tt rept} and
  15039. {\tt depth} may be omitted when they default to 1 and infinity.
  15040. {\tt SI(exp,{temp1->sub1,temp2->sub2,...}, depth)}\ttindex{SI}
  15041. will substitute infinitely many times until expression stops
  15042. changing.
  15043. {\tt SD(exp,{temp1->sub1,temp2->sub2,...},rept, depth)}\ttindex{SD}
  15044. is a depth-first version of {\tt S}.
  15045. {\small\begin{verbatim}
  15046. s(f(a,b),f(a,?b)->?b^2);
  15047. 2
  15048. b
  15049. s(a+b,a+b->a*b);
  15050. a*b
  15051. operator nfac;
  15052. s(nfac(3),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)});
  15053. 3*nfac(2)
  15054. s(nfac(3),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)},2);
  15055. 6*nfac(1)
  15056. si(nfac(4),{nfac(0)->1,nfac(?x)->?x*nfac(?x-1)});
  15057. 24
  15058. s(a+b+f(a+b),a+b->a*b,inf,0);
  15059. f(a + b) + a*b
  15060. \end{verbatim}}
  15061. \section{Programming with Patterns}
  15062. There are also facilities to use this pattern-matcher as a programming
  15063. language. The operator {\tt :-}\ttindex{:-} can be used to declare
  15064. that while simplifying all matches of a template should be replaced by
  15065. some expression. The operator {\tt ::-} is the same except that the
  15066. left hand side is not simplified.
  15067. {\small\begin{verbatim}
  15068. operator fac, gamma;
  15069. fac(?x_=Natp(?x)) ::- ?x*fac(?x-1);
  15070. HOLD(FAC(?X-1)*?X)
  15071. fac(0) :- 1;
  15072. 1
  15073. fac(?x) :- Gamma(?x+1);
  15074. GAMMA(?X + 1)
  15075. fac(3);
  15076. 6
  15077. fac(3/2);
  15078. GAMMA(5/2)
  15079. \end{verbatim}}
  15080. \chapter[QSUM: {\slshape q}-hypergeometric sums]%
  15081. {QSUM : Package for {\slshape q}-hypergeometric sums}
  15082. \label{QSUM}
  15083. \typeout{{QSUM : Package for summation of
  15084. $q$-hypergeometric terms}}
  15085. \newcommand{\funkdef}[3]{\left\{\!\!\!\begin{array}{cc}
  15086. #1 & \!\!\!\mbox{\rm{if} $#2$ } \\
  15087. #3 & \!\!\!\mbox{\rm{otherwise}}
  15088. \end{array}
  15089. \right.}
  15090. \newcommand{\funkdefff}[6]{\left\{\begin{array}{ccc}
  15091. #1 && \mbox{{if} $#2$ } \\
  15092. #3 && \mbox{{if} $#4$ } \\
  15093. #5 && \mbox{{if} $#6$ }
  15094. \end{array}
  15095. \right.}
  15096. \newcommand{\qphihyp}[5]{{}_{#1}\phi_{#2}\left.\left[\begin{array}{c}
  15097. #3 \\ #4 \end{array}\right|q,#5\right]}
  15098. \newcommand{\qpsihyp}[5]{{}_{#1}\psi_{#2}\left.\left[\begin{array}{c}
  15099. #3 \\ #4 \end{array}\right|q,#5\right]}
  15100. \newcommand{\hyp}[5]{{}_{#1}F_{#2}\left.\left[\begin{array}{c}
  15101. #3 \\ #4 \end{array}\right|#5\right]}
  15102. \newcommand{\fcn}[2]{{\mathrm #1}(#2)}
  15103. \newcommand{\ifcn}[3]{{\mathrm #1}_{#2}(#3)}
  15104. \newcommand{\qgosper}{$q$-Gosper\ }
  15105. \newcommand{\qgosperalg}{\qgosper algorithm\ }
  15106. \newcommand{\qzeilalg}{$q$-Zeilberger algorithm\ }
  15107. \newcommand{\qfac}[2]{\left(#1;\,q\right)_{#2}}
  15108. \newcommand{\qatom}[1]{\left(#1;\,q\right)_{\infty}}
  15109. %\newcommand{\qbinomial}[2]{\left(\begin{array}{c}#1\\#2\end{array}\right)_q}
  15110. %\newcommand{\binomial}[2]{\left(\begin{array}{c}#1\\#2\end{array}\right)}
  15111. \newcommand{\binomial}[2]{{#1 \choose #2}}
  15112. \newcommand{\qbinomial}[2]{{{#1 \choose #2}\!}_q}
  15113. \newcommand{\qfactorial}[2]{}
  15114. \newcounter{redprompt}
  15115. {\setcounter{redprompt}{0}}
  15116. \newcommand{\redprompt}{\stepcounter{redprompt}\theredprompt:}
  15117. \newenvironment{redoutput}{\small\begin{alltt}}{\end{alltt}\noindent{}}
  15118. {\footnotesize
  15119. \begin{center}
  15120. Harald B\"oing \\
  15121. Wolfram Koepf \\
  15122. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin \\
  15123. Takustra\"se 7 \\
  15124. D-14195 Berlin-Dahlem \\
  15125. e-mail: koepf@zib.de
  15126. \end{center}
  15127. }
  15128. \ttindex{QSUM}
  15129. %\markboth{CHAPTER \ref{QSUM}. QSUM: SUMMATION OF Q-HYPERGEOMETRIC TERMS}{}
  15130. %\thispagestyle{myheadings}
  15131. This package is an implementation of the $q$-analogues of Gosper's
  15132. and Zeilberger's
  15133. %
  15134. \footnote{The {\tt ZEILBERG} package (Chap. \ref{ZEILBERG}
  15135. p. \pageref{ZEILBERG}, see also \cite{Koepf:95})
  15136. contains the hypergeometric versions.}
  15137. %
  15138. algorithm for indefinite and definite summation of
  15139. $q$-hypergeometric terms, respectively.
  15140. An expression $a_k$ is called a {\sl $q$-hypergeometric term}, if
  15141. $a_{k}/a_{k-1}$ is a rational function with respect to $q^k$. Most
  15142. $q$-terms are based on the {\sl $q$-shifted factorial} or
  15143. {\sl qpochhammer}. Other typical $q$-hypergeometric terms are ratios
  15144. of products of powers, $q$-factorials, $q$-binomial coefficients, and
  15145. $q$-shifted factorials that are integer-linear in their arguments. \\
  15146. The package is loaded with {\tt load\_package qsum}.
  15147. \section{Elementary {\slshape q}-Functions}
  15148. The package supports the input of the following elementary
  15149. {\slshape q}-functions:
  15150. \begin{itemize}
  15151. \item {\verb@qpochhammer(a,q,infinity)@}
  15152. \ttindex{QPOCHHAMMER}
  15153. \[ \qfac{a}{\infty}:= \prod_{j=0}^{\infty}{\left(1-a\,q^j\right)} \]
  15154. \item {\verb@qpochhammer(a,q,k)@}
  15155. \[ \qfac{a}{k}:= \funkdefff{\prod_{j=0}^{k-1}{\left(1-a\,q^j\right)}}%
  15156. {k>0}{1}{k=0}{\prod_{j=1}^{k}{\left(1-a\,q^{-j}\right)^{-1}}}{k<0}
  15157. \]
  15158. \item {\verb@qbrackets(k,q)@}
  15159. \ttindex{QBRACKETS}
  15160. \[ {}[q,k]:=\frac{q^k-1}{q-1} \]
  15161. \item {\verb@qfactorial(k,q)@}
  15162. \ttindex{QFACTORIAL}
  15163. \[ {}[k]_q!:= \frac{\qfac{q}{k}}{(1-q)^k} \]
  15164. \item {\verb@qbinomial(n,k,q)@}
  15165. \ttindex{QBINOMIAL}
  15166. \[ \qbinomial{n}{k}:=
  15167. \frac{\qfac{q}{n}}{\qfac{q}{k}\cdot\qfac{q}{n-k}} \]
  15168. \item {\protect\verb@qphihyperterm({a1,a2,...,ar},{b1,b2,...,bs},q,z,k)@}
  15169. \ttindex{QPHIHYPERTERM}
  15170. \[ \sum_{k=0}^{\infty}{\frac{\qfac{a_1,a_2,\ldots,a_r}{k}}
  15171. {\qfac{b_1,b_2,\ldots,b_s}{k}}
  15172. \,\frac{z^k}{\qfac{q}{k}}\,\left[(-1)^k\,
  15173. q^{\binomial{k}{2}}\right]^{1+s-r}} \]
  15174. \item {\protect\verb@qpsihyperterm({a1,a2,...,ar},{b1,b2,...,bs},q,z,k)@}
  15175. \ttindex{QPSIHYPERTERM}
  15176. \[\sum_{k=-\infty}^{\infty}{\frac{\qfac{a_1,a_2,\ldots,a_r}{k}}
  15177. {\qfac{b_1,b_2,\ldots,b_s}{k}}\,z^k\,
  15178. \left[(-1)^k\,q^{\binomial{k}{2}}\right]^{s-r}} \]
  15179. \end{itemize}
  15180. where $\qfac{a_1,a_2,\ldots,a_r}{k}$ stands for the
  15181. product $\prod_{j=1}^r{\qfac{a_j}{k}}$.
  15182. \section{The {\ttfamily QGOSPER} operator}
  15183. The {\tt qgosper} operator is an implementation of the $q$-Gosper
  15184. algorithm \cite{Koornwinder:93}.
  15185. \begin{itemize}
  15186. \item {\verb@qgosper(a,q,k)@} determines a $q$-hypergeometric
  15187. antidifference. (By default it returns a {\sl downward}
  15188. antidifference, which may be changed by the switch
  15189. {\verb@qgosper_down@}.)
  15190. If it does not return a \textsl{q}-hypergeometric antidifference,
  15191. then such an antidifference does not exist.
  15192. \item {\verb@qgosper(a,q,k,m,n)@} determines a closed formula
  15193. for the definite sum \[\sum\limits_{k=m}^n a_k\] using the
  15194. $q$-analogue of Gosper's algorithm.
  15195. This is only successful if \textsl{q}-Gosper's algorithm applies.
  15196. \end{itemize}
  15197. {\bf Example:}
  15198. {\small\begin{verbatim}
  15199. 1: qgosper(qpochhammer(a,q,k)*q^k/qpochhammer(q,q,k),q,k);
  15200. k
  15201. (q *a - 1)*qpochhammer(a,q,k)
  15202. -------------------------------
  15203. (a - 1)*qpochhammer(q,q,k)
  15204. \end{verbatim}}
  15205. \section{The {\ttfamily QSUMRECURSION} operator}
  15206. \label{QSUMRECURSION}
  15207. The \f{QSUMRECURSION\ttindex{QSUMRECURSION}} operator is an implementation
  15208. of the $q$-Zeilberger algorithm \cite{Koornwinder:93}.
  15209. It tries to determine a homogeneous recurrence equation for
  15210. $\fcn{summ}{n}$ wrt. $n$ with polynomial coefficients (in $n$), where
  15211. \[
  15212. \fcn{summ}{n}:= \sum_{k=-\infty}^{\infty}{\fcn{f}{n,k}}.
  15213. \]
  15214. There are three different ways to pass a summand $\fcn{f}{n,k}$
  15215. to {\verb@qsumrecursion@}:
  15216. \begin{itemize}
  15217. \item {\verb@qsumrecursion(f,q,k,n)@}, where {\tt f} is a
  15218. $q$-hypergeometric term wrt. {\tt k} and {\tt n},
  15219. {\tt k} is the summation variable and {\tt n} the recursion
  15220. variable, {\tt q} is a symbol.
  15221. \item {\verb@qsumrecursion(upper,lower,q,z,n)@} is a shortcut for \\
  15222. {\verb@qsumrecursion(qphihyperterm(upper,lower,q,z,k),q,k,n)@}
  15223. \item {\verb@qsumrecursion(f,upper,lower,q,z,n)@} is a similar
  15224. shortcut for\\
  15225. {\verb@qsumrecursion(f*qphihyperterm(upper,lower,q,z,k),q,k,n)@},
  15226. \end{itemize}
  15227. i.\,e.\ {\tt upper} and {\tt lower} are lists of upper and lower
  15228. parameters of the generalized $q$-hypergeometric function.
  15229. The third form is handy if you have any additional factors.
  15230. For all three instances it is possible to pass the order, if known
  15231. in advance, as additional argument at the end of the parameter sequence.
  15232. You can also specifiy a range by a list of two positive integers, the first
  15233. one specifying the lowest and the second one the highest order. By default
  15234. \f{QSUMRECURSION} will search for recurrences of order from 1 to 5. Usually
  15235. it uses {\tt summ} as name for the summ-function. If you want to change this
  15236. behaviour then use the following syntax: \f{QSUMRECURSION(f,q,k,s(n))}.
  15237. {\small\begin{verbatim}
  15238. 2: qsumrecursion(qpochhammer(q^(-n),q,k)*z^k /
  15239. qpochhammer(q,q,k),q,k,n);
  15240. n n
  15241. - ((q - z)*summ(n - 1) - q *summ(n))
  15242. \end{verbatim}}
  15243. \section{Global Variables and Switches}
  15244. There are several switches defined in the \f{QSUM} package. Please take a
  15245. look in the accompanying documentation file {\tt qsum.tex} in
  15246. \$REDUCEPATH/packages/. \\
  15247. The most important switches are:
  15248. \begin{itemize}
  15249. \item \verb@qgosper_down@, default setting is on. It determines
  15250. whether \verb@qgosper@ returns a downward or an upward
  15251. antidifference $g_k$ for the input term $a_k$,
  15252. .\,e.\ $a_k=g_k-g_{k-1}$ or $a_k=g_{k+1}-g_k$ respectively.
  15253. \item \verb@qsumrecursion_certificate@, default off.
  15254. As Zeilberger's algorithm
  15255. delivers a recurrence equation for a $q$-hypergeometric term
  15256. $\mathrm{f}(n,k)$ this switch is used to get all necessary
  15257. informations for proving this recurrence equation.
  15258. If it is set on, instead of simply returning the
  15259. resulting recurrence equation (for the sum)---if one
  15260. exists---\verb@qsumrecursion@ returns
  15261. a list \verb@{rec,cert,f,k,dir}@ with
  15262. five items: The first entry contains the
  15263. recurrence equation, while the other items enable you to
  15264. prove the recurrence a posteriori by rational arithmetic.
  15265. If we denote by \verb@r@ the recurrence
  15266. \verb@rec@ where we substituted the \verb@summ@-function
  15267. by the input term \verb@f@ (with the corresponding shifts
  15268. in \verb@n@) then the following equation is valid:
  15269. \[ \verb@r = cert*f - sub(k=k-1,cert*f)@ \]
  15270. or
  15271. \[ \verb@r = sub(k=k+1,cert*f) - cert*f@ \]
  15272. if \verb@dir=downward_antidifference@ or
  15273. \verb@dir=upward_antidifference@ respectively.
  15274. \end{itemize}
  15275. There is one global variable:
  15276. \begin{itemize}
  15277. \item \verb@qsumrecursion_recrange!*@ controls for
  15278. which recursion orders the procedure \verb@qsumrecursion@ looks.
  15279. It has to be a list with two entries, the first one representing
  15280. the lowest and the second one the highest order of a recursion
  15281. to search for. By default it is set to \verb@{1,5}@.
  15282. \end{itemize}
  15283. \chapter[RANDPOLY: Random polynomials]%
  15284. {RANDPOLY: A random polynomial generator}
  15285. \label{RANDPOLY}
  15286. \typeout{{RANDPOLY: A random polynomial generator}}
  15287. {\footnotesize
  15288. \begin{center}
  15289. Francis J. Wright \\
  15290. School of Mathematical Sciences, Queen Mary and Westfield College \\
  15291. University of London \\
  15292. Mile End Road \\
  15293. London E1 4NS, England \\[0.05in]
  15294. e--mail: F.J.Wright@QMW.ac.uk
  15295. \end{center}
  15296. }
  15297. \ttindex{RANDPOLY}
  15298. The operator {\tt RANDPOLY}\ttindex{RANDPOLY} requires at least one
  15299. argument corresponding to the polynomial variable or variables, which
  15300. must be either a single expression or a list of expressions.
  15301. In effect, {\tt RANDPOLY} replaces each input expression by an
  15302. internal variable and then substitutes the input expression for the
  15303. internal variable in the generated polynomial (and by default expands
  15304. the result as usual). The rest of this document
  15305. uses the term ``variable'' to refer to a general input expression or
  15306. the internal variable used to represent it, and all references to the
  15307. polynomial structure, such as its degree, are with respect to these
  15308. internal variables. The actual degree of a generated polynomial might
  15309. be different from its degree in the internal variables.
  15310. By default, the polynomial generated has degree 5 and contains 6
  15311. terms. Therefore, if it is univariate it is dense whereas if it is
  15312. multivariate it is sparse.
  15313. \section{Optional arguments}
  15314. Other arguments can optionally be specified, in any order, after the
  15315. first compulsory variable argument. All arguments receive full
  15316. algebraic evaluation, subject to the current switch settings etc. The
  15317. arguments are processed in the order given, so that if more than one
  15318. argument relates to the same property then the last one specified
  15319. takes effect. Optional arguments are either keywords or equations
  15320. with keywords on the left.
  15321. In general, the polynomial is sparse by default, unless the keyword
  15322. {\tt dense}\index{randpoly ! {\tt dense}} is specified as an optional
  15323. argument. (The keyword {\tt sparse}\index{randpoly ! {\tt sparse}} is
  15324. also accepted, but is the default.) The default degree can be changed
  15325. by specifying an optional argument of the form\index{randpoly
  15326. ! {\tt degree}}
  15327. \begin{center}
  15328. {\tt degree = {\it natural number}}.
  15329. \end{center}
  15330. In the multivariate case this is the total degree, {\em i.e.\ }the sum of
  15331. the degrees with respect to the individual variables.
  15332. More complicated monomial degree bounds can be constructed by using
  15333. the coefficient function described below to return a monomial or
  15334. polynomial coefficient expression. Moreover, {\tt randpoly} respects
  15335. internally the \REDUCE\ ``asymptotic'' commands {\tt let}, {\tt weight}
  15336. {\em etc.\ }described in section~\ref{sec-asymp}, which can be used
  15337. to exercise additional control over the polynomial generated.
  15338. In the sparse case (only), the default maximum number of terms
  15339. generated can be changed by specifying an optional argument of the
  15340. form\index{randpoly ! {\tt terms}}
  15341. \begin{center}
  15342. {\tt terms = {\it natural number}}.
  15343. \end{center}
  15344. The actual number of terms generated will be the minimum of the value
  15345. of {\tt terms} and the number of terms in a dense polynomial of the
  15346. specified degree, number of variables, {\em etc.}
  15347. \section{Advanced use of RANDPOLY}
  15348. The default order (or minimum or trailing degree) can be changed by
  15349. specifying an optional argument of the form\index{randpoly ! {\tt ord}}
  15350. \begin{center}
  15351. {\tt ord = {\it natural number}}.
  15352. \end{center}
  15353. The order normally defaults to 0.
  15354. The input expressions to {\tt randpoly} can also be
  15355. equations, in which case the order defaults to 1 rather than 0. Input
  15356. equations are converted to the difference of their two sides before
  15357. being substituted into the generated polynomial. This makes it easy
  15358. to generate polynomials with a specified zero -- for example
  15359. \begin{center}\tt
  15360. randpoly(x = a);
  15361. \end{center}
  15362. generates a polynomial that is guaranteed to vanish at $x = a$, but is
  15363. otherwise random.
  15364. The operator {\tt randpoly} accepts two further optional arguments in
  15365. the form of equations with the keywords {\tt coeffs}
  15366. \index{randpoly ! {\tt coeffs}} and {\tt expons}\index{randpoly ! {\tt expons}}
  15367. on the left. The right sides of each of these equations must evaluate
  15368. to objects that can be applied as functions of no variables. These
  15369. functions should be normal algebraic procedures; the {\tt coeffs}
  15370. procedure may return any algebraic expression, but the {\tt expons}
  15371. procedure must return an integer. The values returned by
  15372. the functions should normally be random, because it is the randomness
  15373. of the coefficients and, in the sparse case, of the exponents that
  15374. makes the constructed polynomial random.
  15375. A convenient special case is to use the function {\tt rand} on the
  15376. right of one or both of these equations; when called with a single
  15377. argument {\tt rand} returns an anonymous function of no variables that
  15378. generates a random integer. The single argument of {\tt rand} should
  15379. normally be an integer range in the form $a~..~b$, where $a$, $b$ are
  15380. integers such that $a < b$. For example, the {\tt expons} argument might
  15381. take the form
  15382. \begin{center}\tt
  15383. expons = rand(0~..~n)
  15384. \end{center}
  15385. where {\tt n} will be the maximum degree with respect to each variable
  15386. {\em independently}. In the case of {\tt coeffs} the lower limit will
  15387. often be the negative of the upper limit to give a balanced
  15388. coefficient range, so that the {\tt coeffs} argument might take the
  15389. form
  15390. \begin{center}\tt
  15391. coeffs = rand(-n~..~n)
  15392. \end{center}
  15393. which will generate random integer coefficients in the range $[-n,n]$.
  15394. Further information on the the auxiliary functions of RANDPOLY can be
  15395. found in the extended documentation and examples.
  15396. \section{Examples}
  15397. \label{sec:Examples}
  15398. {\small\begin{verbatim}
  15399. randpoly(x);
  15400. 5 4 3 2
  15401. - 54*x - 92*x - 30*x + 73*x - 69*x - 67
  15402. randpoly({x, y}, terms = 20);
  15403. 5 4 4 3 2 3 3
  15404. 31*x - 17*x *y - 48*x - 15*x *y + 80*x *y + 92*x
  15405. 2 3 2 2 4 3 2
  15406. + 86*x *y + 2*x *y - 44*x + 83*x*y + 85*x*y + 55*x*y
  15407. 5 4 3 2
  15408. - 27*x*y + 33*x - 98*y + 51*y - 2*y + 70*y - 60*y - 10
  15409. \end{verbatim}}
  15410. \newpage
  15411. {\small\begin{verbatim}
  15412. randpoly({x, sin(x), cos(x)});
  15413. 4 3 3
  15414. sin(x)*( - 4*cos(x) - 85*cos(x) *x + 50*sin(x)
  15415. 2
  15416. - 20*sin(x) *x + 76*sin(x)*x + 96*sin(x))
  15417. \end{verbatim}}
  15418. \chapter[RATAPRX: Rational Approximations]%
  15419. {RATAPRX : Rational Approximations Package}
  15420. \label{RATAPRX}
  15421. \typeout{{RATAPRX : Rational Approximations Package}}
  15422. {\footnotesize
  15423. \begin{center}
  15424. Lisa Temme\\
  15425. Wolfram Koepf\\
  15426. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin\\
  15427. Takustra\"se 7 \\
  15428. D-14195 Berlin-Dahlem, Germany \\
  15429. e-mail: koepf@zib.de
  15430. \end{center}
  15431. }
  15432. \ttindex{RATAPRX}
  15433. This package provides functions to
  15434. \begin{itemize}
  15435. \item convert rational numbers in their periodic representation and vice versa,
  15436. \item to compute continued fractions and
  15437. \item to compute the Pad\'{e} approximant of a function.
  15438. \end{itemize}
  15439. The package can be loaded using {\tt load\_package rataprx;} it supersedes
  15440. the {\tt contfr} package.
  15441. \section{}
  15442. \subsection{Periodic Representation}
  15443. The function \f{rational2periodic(n)\ttindex{RATIONAL2PERIODIC}}
  15444. converts a rational number {\tt n} in its periodic representation.
  15445. For example $59/70$ is converted to $0.8\overline{428571}$. \\
  15446. Depending on the print function of your \REDUCE\ system, calling the
  15447. function \f{rational2periodic} might result in an expression of
  15448. the form {\tt periodic(\{a,b\},\{c$_1$,...,c$_n$\})\ttindex{PERIODIC}}.
  15449. {\tt a} and {\tt b} is the non-periodic part of the rational number
  15450. {\tt n} and {\tt c$_1$,...,c$_n$} are the digits of the periodic part.
  15451. In this case $59/70$ would result in {\tt periodic(\{8,10\},\{4,2,8,5,7,1\})}. \\
  15452. The function \f{periodic2rational(periodic(\{a,b\},\{c$_1$,...,c$_n$\}))
  15453. \ttindex{PERIODIC2RATIONAL}} is the
  15454. inverse function and computes the rational expression for a periodic one.
  15455. Note that {\tt b} is 1,-1 or a integer multiple of 10. If {\tt a} is zero,
  15456. then the input number {\tt b} indicates how many places after the decimal
  15457. point the period occurs.
  15458. {\small\begin{verbatim}
  15459. rational2periodic(6/17);
  15460. periodic({0,1},{3,5,2,9,4,1,1,7,6,4,7,0,5,8,8,2})
  15461. periodic2rational(ws);
  15462. 6
  15463. ----
  15464. 17
  15465. \end{verbatim}}
  15466. \subsection{Continued Fractions}
  15467. A continued fraction (see \cite{Baker:81a} \S 4.2) has the general form
  15468. \[b_0 + \frac{a_1}{b_1 +
  15469. \frac{a_2}{b_2+
  15470. \frac{a_3}{b_3 + \ldots
  15471. }}}
  15472. \;.\]
  15473. A more compact way of writing this is as
  15474. \[b_0 + \frac{a_1|}{|b_1} + \frac{a_2|}{|b_2} + \frac{a_3|}{|b_3} + \ldots\,.\]
  15475. \\
  15476. This is represented in \REDUCE\ as
  15477. \[{\tt
  15478. contfrac({\mbox{\sl Rational\hspace{2mm} approximant}},
  15479. \{b_0, \{a_1,b_1\}, \{a_2,b_2\},.....\}).\ttindex{CONTFRAC}
  15480. }\]
  15481. There are four different functions to determine the continued fractions
  15482. for real numbers and functions {\tt f} in the variable {\tt var}:
  15483. \begin{center}
  15484. {\tt
  15485. \begin{tabular}{l l}
  15486. cfrac(number); & cfrac(number,length); \\
  15487. cfrac(f, var); & cfrac(f, var, length);
  15488. \end{tabular}} \\[1mm]
  15489. \end{center}
  15490. \ttindex{CFRAC}
  15491. The {\tt length} argument is optional and specifies the number of
  15492. ordered pairs $\{a_i,b_i\}$ to be returned. It's default value is five.
  15493. {\small\begin{verbatim}
  15494. cfrac pi;
  15495. 1146408
  15496. contfrac(---------),
  15497. 364913
  15498. {3,{1,7},{1,15},{1,1},{1,292},{1,1},{1,1},{1,1},
  15499. {1,2},{1,1}})
  15500. \end{verbatim}}
  15501. \newpage
  15502. {\small\begin{verbatim}
  15503. cfrac((x+2/3)^2/(6*x-5),x);
  15504. 2
  15505. 9*x + 12*x + 4 6*x + 13 24*x - 20
  15506. contfrac(-----------------,{----------,{1,-----------}})
  15507. 54*x - 45 36 9
  15508. cfrac(e^x,x);
  15509. 3 2
  15510. x + 9*x + 36*x + 60
  15511. contfrac(-----------------------,
  15512. 2
  15513. 3*x - 24*x + 60
  15514. {1,{x,1},{ - x,2},{x,3},{ - x,2},{x,5}})
  15515. \end{verbatim}}
  15516. \subsection{Pad\'{e} Approximation}
  15517. The Pad\'{e} approximant represents a function by the ratio of two
  15518. polynomials. The coefficients of the powers occuring in the polynomials
  15519. are determined by the coefficients in the Taylor series
  15520. expansion of the function (see \cite{Baker:81a}). Given a power series
  15521. \[ f(x) = c_0 + c_1 (x-h) + c_2 (x-h)^2 \ldots \]
  15522. and the degree of numerator, $n$, and of the denominator, $d$,
  15523. the {\tt pade} function finds the unique coefficients
  15524. $a_i,\, b_i$ in the Pad\'{e} approximant
  15525. \[ \frac{a_0+a_1 x+ \cdots + a_n x^n}{b_0+b_1 x+ \cdots + b_d x^d} \; .\]
  15526. The function \f{pade(f, x, h ,n ,d)\ttindex{PAD\'{E}}} takes as input the
  15527. function {\tt f} in the variable {\tt x} to be approximated , where
  15528. {\tt h} is the point at which the approximation is evaluated. {\tt n}
  15529. and {\tt d} are the (specified) degrees of the numerator and the denominator.
  15530. It returns the Pad\'{e} Approximant, ie. a rational function. \par
  15531. Error Messages may occur in the following different cases:
  15532. \begin{itemize}
  15533. \item The Taylor series expansion for the function {\tt f} has not yet been
  15534. implemented in the \REDUCE\ Taylor Package.
  15535. \item A Pad\'{e} Approximant of this function does not exist.
  15536. \item A Pad\'{e} Approximant of this order (ie. the specified numerator and
  15537. denominator orders) does not exist. Please note, there might exist an
  15538. approximant of a different order.
  15539. \end{itemize}
  15540. \newpage
  15541. {\small\begin{verbatim}
  15542. pade(sin(x),x,0,3,3);
  15543. 2
  15544. x*( - 7*x + 60)
  15545. ------------------
  15546. 2
  15547. 3*(x + 20)
  15548. pade(tanh(x),x,0,5,5);
  15549. 4 2
  15550. x*(x + 105*x + 945)
  15551. -----------------------
  15552. 4 2
  15553. 15*(x + 28*x + 63)
  15554. pade(exp(1/x),x,0,5,5);
  15555. ***** no Pade Approximation exists
  15556. pade(factorial(x),x,1,3,3);
  15557. ***** not yet implemented
  15558. 30: pade(sin(x)/x^2,x,0,10,0);
  15559. ***** Pade Approximation of this order does not exist
  15560. 31: pade(sin(x)/x^2,x,0,10,2);
  15561. 10 8 6 4 2
  15562. - x + 110*x - 7920*x + 332640*x - 6652800*x + 39916800
  15563. --------------------------------------------------------------
  15564. 39916800*x
  15565. \end{verbatim}}
  15566. \chapter[REACTEQN: Chemical reaction equations]%
  15567. {REACTEQN: Support for chemical reaction equations}
  15568. \label{REACTEQN}
  15569. \typeout{{REACTEQN: Support for chemical reaction equations}}
  15570. {\footnotesize
  15571. \begin{center}
  15572. Herbert Melenk \\
  15573. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  15574. Takustra\"se 7 \\
  15575. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  15576. e--mail: melenk@zib.de
  15577. \end{center}
  15578. }
  15579. \ttindex{REACTEQN}
  15580. The \REDUCE\ package REACTEQN allows one to transform chemical reaction
  15581. systems into ordinary differential equation systems corresponding to
  15582. the laws of pure mass action.
  15583. It provides the single function
  15584. {\small\begin{verbatim}
  15585. reac2ode { <reaction> [,<rate> [,<rate>]]
  15586. [,<reaction> [,<rate> [,<rate>]]]
  15587. ....
  15588. };
  15589. \end{verbatim}}
  15590. A rate is any \REDUCE\ expression, and two rates are applicable only
  15591. for forward and backward reactions. A reaction is coded as a linear
  15592. sum of the series variables, with the operator $->$ for forward
  15593. reactions and $<>$ for two-way reactions.
  15594. The result is a system of explicit ordinary differential equations
  15595. with polynomial righthand sides. As side effect the following
  15596. variables are set:
  15597. \newpage
  15598. \begin{description}
  15599. \item[{\tt rates}]
  15600. \index{reacteqn ! {\tt rates}} A list of the rates in the system.
  15601. \item[{\tt species}]
  15602. \index{reacteqn ! {\tt species}} A list of the species in the system.
  15603. \item[{\tt inputmat}]
  15604. \index{reacteqn ! {\tt inputmat}} A matrix of the input coefficients.
  15605. \item[{\tt outputmat}]
  15606. \index{reacteqn ! {\tt outputmat}} A matrix of the output coefficients.
  15607. \end{description}
  15608. In the matrices the row number corresponds to the input reaction
  15609. number, while the column number corresponds to the species index.
  15610. If the rates are numerical values, it will be in most cases
  15611. appropriate to select a \REDUCE\ evaluation mode for floating point numbers.
  15612. {\tt Inputmat} and {\tt outputmat} can be used for linear algebra type
  15613. investigations of the reaction system. The classical reaction
  15614. matrix is the difference of these matrices; however, the two
  15615. matrices contain more information than their differences because
  15616. the appearance of a species on both sides is not reflected by
  15617. the reaction matrix.
  15618. \chapter{REDLOG: Logic System}
  15619. \label{REDLOG}
  15620. \typeout{{REDLOG: Logic System}}
  15621. {\footnotesize
  15622. \begin{center}
  15623. Andreas Dolzmann \\
  15624. Thomas Sturm \\
  15625. University of Passau, Germany \\
  15626. e-mail: dolzmann@uni-passau.de, sturm@uni-passau.de
  15627. \end{center}
  15628. }
  15629. \ttindex{REDLOG}
  15630. \section{Introduction}
  15631. This package extends \REDUCE\ to a computer logic system implementing
  15632. symbolic algorithms on first-order formulas wrt.~temporarily fixed
  15633. first-order languages and theories.
  15634. \subsection{Contexts}
  15635. REDLOG is designed for working with several languages and theories in
  15636. the sense of first-order logic. Both a language and a theory make up a
  15637. context. There are the following contexts available:
  15638. \begin{description}
  15639. \item[\textsc{OFSF}]
  15640. \textsc{OF} stands for \emph{ordered fields}, which is a little imprecise.
  15641. The quantifier elimination actually requires the more restricted class
  15642. of \emph{real closed fields}, while most of the tool-like algorithms
  15643. are generally correct for ordered fields. One usually has in mind real
  15644. numbers with ordering when using \textsc{OFSF}.
  15645. \item[\textsc{DVFSF}]
  15646. \emph{Discretely valued fields}. This is for computing with formulas
  15647. over classes of $p$-adic valued extension fields of the rationals,
  15648. usually the fields of $p$-adic numbers for some prime $p$.
  15649. \item[\textsc{ACFSF}]
  15650. \emph{Algebraically closed fields} such as the complex numbers.
  15651. \end{description}
  15652. \subsection{Overview}
  15653. REDLOG origins from the implementation of quantifier elimination
  15654. procedures. Successfully applying such methods to both academic and
  15655. real-world problems, the authors have developed over the time a large
  15656. set of formula-manipulating tools, many of which are meanwhile
  15657. interesting in their own right:
  15658. \begin{itemize}
  15659. \item
  15660. Numerous tools for comfortably inputing, decomposing, and analyzing
  15661. formulas.
  15662. \item
  15663. Several techniques for the \emph{simplification} of formulas.
  15664. \item
  15665. Various \emph{normal form computations}. The
  15666. \emph{\textsc{CNF}/\textsc{DNF}} computation includes both Boolean and
  15667. algebraic simplification strategies. The \emph{prenex normal form}
  15668. computation minimizes the number of quantifier changes.
  15669. \item
  15670. \emph{Quantifier elimination} computes quantifier-free equivalents for
  15671. given first-order formulas. For \textsc{OFSF} and \textsc{DVFSF} the
  15672. formulas have to obey certain degree restrictions.
  15673. \item
  15674. The context \textsc{OFSF} allows a variant of quantifier elimination
  15675. called \emph{generic quantifier elimination}: There are certain
  15676. non-degeneracy assumptions made on the parameters, which considerably
  15677. speeds up the elimination.
  15678. \item
  15679. The contexts \textsc{OFSF} and \textsc{DVFSF} provide variants of
  15680. (generic) quantifier elimination that additionally compute
  15681. \emph{answers} such as satisfying sample points for existentially
  15682. quantified formulas.
  15683. \item
  15684. \textsc{OFSF}
  15685. includes linear \emph{optimization} techniques based on quantifier
  15686. elimination.
  15687. \end{itemize}
  15688. To avoid ambiguities with other packages, all \textsc{REDLOG} functions and
  15689. switches are prefixed by ``\texttt{RL}''.
  15690. The package is loaded by typing: \qquad {\tt load\_package redlog;} \\
  15691. It is recommended to read the documentation which comes with this
  15692. package. This manual chapter gives an overview on the features of
  15693. \textsc{REDLOG}, which is by no means complete.
  15694. \section{Context Selection}
  15695. The context to be used has to be selected explicitly. One way
  15696. to do this is using the command \f{RLSET}\ttindex{RLSET}. As argument it takes one
  15697. of the
  15698. valid choices \f{ACFSF}\ttindex{ACFSF} (algebraically closed fields
  15699. standard form),
  15700. \f{OFSF}\ttindex{OFSF} (ordered fields standard form), and
  15701. \f{DVFSF}\ttindex{DVFSF}
  15702. (discretely valued fields standard form). By default, \f{DVFSF}\ttindex{DVFSF}
  15703. computes
  15704. uniformly over the class of all $p$-adic valued fields. For the sake
  15705. of efficiency, this can be restricted by means of an extra
  15706. \f{RLSET}\ttindex{RLSET} argument.
  15707. \f{RLSET}\ttindex{RLSET} returns the old setting as a list.
  15708. \section{Format and Handling of Formulas}
  15709. \subsection{First-order Operators}
  15710. REDLOG knows the following operators for constructing Boolean
  15711. combinations and quantifications of atomic formulas:
  15712. \begin{center}
  15713. \begin{tabular}{llll}
  15714. \f{NOT}\ttindex{NOT}: Unary &
  15715. \f{AND}\ttindex{AND}: N-ary Infix &
  15716. \f{OR}\ttindex{OR}: N-ary Infix &
  15717. \f{IMPL}\ttindex{IMPL}: Binary Infix \\
  15718. \f{REPL}\ttindex{REPL}: Binary Infix &
  15719. \f{EQUIV}\ttindex{EQUIV}: Binary Infix &
  15720. \f{EX}\ttindex{EX}: Binary \\
  15721. \f{ALL}\ttindex{ALL}: Binary &
  15722. \f{TRUE}\ttindex{TRUE}: Variable &
  15723. \f{FALSE}\ttindex{FALSE}: Variable &
  15724. \end{tabular}
  15725. \end{center}
  15726. The \f{EX} and the \f{ALL} operators are the quantifiers. Their first
  15727. argument is the quantified variable, the second one a matrix formula.
  15728. There are operators \f{MKAND}\ttindex{MKAND} and
  15729. \f{MKOR}\ttindex{MKOR} for the construction of large systematic
  15730. conjunctions/disjunctions via for loops available. They are used in
  15731. the style of \f{SUM} and \f{COLLECT}.
  15732. \vspace{0.5cm}
  15733. {\bf Example:}
  15734. {\small\begin{verbatim}
  15735. 1: load_package redlog;
  15736. 2: rlset ofsf;
  15737. {}
  15738. 3: g := for i:=1:3 mkand
  15739. for j:=1:3 mkor
  15740. if j<>i then mkid(x,i) + mkid(x,j)=0;
  15741. true and (false or false or x1 + x2 = 0 or x1 + x3 = 0)
  15742. and (false or x1 + x2 = 0 or false or x2 + x3 = 0)
  15743. and (false or x1 + x3 = 0 or x2 + x3 = 0 or false)
  15744. \end{verbatim}}
  15745. \subsection{OFSF Operators}
  15746. The \f{OFSF}\ttindex{OFSF} context implements {\it ordered fields}
  15747. over the language of {\it ordered rings}. There are the following
  15748. binary operators available:
  15749. \begin{center}
  15750. \begin{tabular}{llllllll}
  15751. \f{EQUAL}\ttindex{EQUAL} &
  15752. \f{NEQ}\ttindex{NEQ} &
  15753. \f{LEQ}\ttindex{LEQ} &
  15754. \f{GEQ}\ttindex{GEQ} &
  15755. \f{LESSP}\ttindex{LESSP} &
  15756. \f{GREATERP}\ttindex{GREATERP}
  15757. \end{tabular}
  15758. \end{center}
  15759. They can also be written as \f{=}, \f{<>}, \f{<=}, \f{>=}, \f{<}, and
  15760. \f{>}.
  15761. For {\sc OFSF}
  15762. there is specified that all right hand sides must be zero. Non-zero right
  15763. hand sides are immediately subtracted.
  15764. \subsection{DVFSF Operators}\ttindex{DVFSF}
  15765. Discretely valued fields are implemented as a one-sorted language
  15766. using in addition to \f{=} and \f{<>} the
  15767. binary operators \f{|}, \f{||}, \f{\~{}}, and \f{/\~{}}, which encode
  15768. $\leq$, $<$, $=$, and $\neq$ in the
  15769. value group, respectively.
  15770. \begin{center}
  15771. \begin{tabular}{llllll}
  15772. \f{EQUAL}\ttindex{EQUAL} &
  15773. \f{NEQ}\ttindex{NEQ} &
  15774. \f{DIV}\ttindex{DIV} &
  15775. \f{SDIV}\ttindex{SDIV} &
  15776. \f{ASSOC}\ttindex{ASSOC} &
  15777. \f{NASSOC}\ttindex{NASSOC} \\
  15778. \end{tabular}
  15779. \end{center}
  15780. \subsection{ACFSF Operators}\ttindex{ACFSF}
  15781. For algebraically closed fields there are only equations and
  15782. inequalities allowed:
  15783. \begin{center}
  15784. \begin{tabular}{ll}
  15785. \f{EQUAL}\ttindex{EQUAL} &
  15786. \f{NEQ}\ttindex{NEQ}
  15787. \end{tabular}
  15788. \end{center}
  15789. As in \textsc{OFSF}, they can be conveniently written as \f{=} and
  15790. \f{<>}, respectively. All right hand sides are zero.
  15791. \subsection{Extended Built-in Commands}
  15792. The operators
  15793. \f{SUB}\ttindex{SUB},
  15794. \f{PART}\ttindex{PART},
  15795. and \f{LENGTH}\ttindex{LENGTH} work on formulas in a reasonable way.
  15796. \subsection{Global Switches}
  15797. The switch \f{RLSIMPL}\ttindex{RLSIMPL} causes the function
  15798. \f{RLSIMPL} to be automatically applied at the expression evaluation stage.
  15799. The switch \f{RLREALTIME}\ttindex{RLREALTIME} protocols the wall clock
  15800. time needed for {\sc REDLOG} commands in seconds.
  15801. The switch \f{RLVERBOSE}\ttindex{RLVERBOSE} toggles verbosity output
  15802. with some {\sc REDLOG} procedures.
  15803. \section{Simplification}
  15804. {\sc REDLOG} knows three types of simplifiers to reduce the size of a
  15805. given first-order formula: the standard simplifier, tableau
  15806. simplifiers, and Gr\"obner simplifiers.
  15807. \subsection{Standard Simplifier}
  15808. The standard simplifier \f{RLSIMPL}\ttindex{RLSIMPL} returns a
  15809. simplified equivalent of its argument formula. It is much faster
  15810. though less powerful than the other simplifiers.
  15811. As an optional argument there can be a \emph{theory} passed. This is a
  15812. list of atomic formulas assumed to hold. Simplification is then
  15813. performed on the basis of these assumptions.
  15814. \vspace{0.5cm}
  15815. {\bf Example:}
  15816. {\small\begin{verbatim}
  15817. 4: rlsimpl g;
  15818. (x1 + x2 = 0 or x1 + x3 = 0) and (x1 + x2 = 0 or x2 + x3 = 0)
  15819. and (x1 + x3 = 0 or x2 + x3 = 0)
  15820. \end{verbatim}}
  15821. \subsection{Tableau Simplifier}
  15822. The standard simplifier preserves the basic Boolean structure of a formula. The
  15823. tableau methods, in contrast, provide a technique for changing the Boolean
  15824. structure of a formula by constructing case distinctions.
  15825. The function \f{RLATAB}\ttindex{RLATAB} automatically finds a suitable
  15826. case distinction. Based on \f{RLATAB}, the function
  15827. \f{RLITAB}\ttindex{RLITAB} iterates this process until no further
  15828. simplification can be detected. There is a more fundamental entry
  15829. point \f{RLTAB}\ttindex{RLTAB} for manually entering case
  15830. distinctions.
  15831. \subsection{Gr\"obner Simplifier}
  15832. The Gr\"obner simplifier considers algebraic simplification rules
  15833. between the atomic formulas of the input formula. The usual procedure
  15834. called for Gr\"obner simplification is \f{RLGSN}\ttindex{RLGSN}.
  15835. Similar to the standard simplifier, there is an optional theory
  15836. argument.
  15837. \begin{samepage}
  15838. \vspace{0.5cm}
  15839. {\bf Example:}
  15840. {\small\begin{verbatim}
  15841. 5: rlgsn(x*y+1<>0 or y*z+1<>0 or x-z=0);
  15842. true
  15843. \end{verbatim}}
  15844. \end{samepage}
  15845. \section{Normal Forms}
  15846. \subsection{Boolean Normal Forms}
  15847. \f{RLCNF}\ttindex{RLCNF} and \f{RLDNF}\ttindex{RLDNF} compute conjunctive
  15848. resp.~disjunctive normal forms of their formula arguments. Subsumption
  15849. and cut strategies are applied to decrease the number of clauses.
  15850. \subsection{Miscellaneous Normal Forms}
  15851. \f{RLNNF}\ttindex{RLNNF} computes a
  15852. negation normal form. This is an {\tt and}-\texttt{or}-combination of
  15853. atomic formulas.
  15854. \f{RLPNF}\ttindex{RLPNF} computes a prenex normal form of its
  15855. argument. That is, all quantifiers are moved outside such that they
  15856. form a block in front of a quantifier-free matrix formula.
  15857. \section{Quantifier Elimination and Variants}
  15858. Quantifier elimination computes quantifier-free equivalents for given
  15859. first-order formulas. For \textsc{OFSF} and \textsc{DVFSF}, REDLOG
  15860. uses a technique based on elimination set ideas. The \textsc{OFSF}
  15861. implementation is restricted to at most quadratic occurrences of the
  15862. quantified variables, but includes numerous heuristic strategies for
  15863. coping with higher degrees. The \textsc{DVFSF} implementation is
  15864. restricted to formulas that are linear in the quantified variables.
  15865. The \textsc{ACFSF} quantifier elimination is based on comprehensive
  15866. Gr\"obner basis computation; there are no degree restrictions for this
  15867. context
  15868. \subsection{Quantifier Elimination}
  15869. \f{RLQE}\ttindex{RLQE} performs quantifier elimination on its argument
  15870. formula. There is an optional theory argument in the style of
  15871. \f{RLSIMPL} supported.
  15872. \begin{samepage}
  15873. \vspace{0.5cm}
  15874. {\bf Example:}
  15875. {\small\begin{verbatim}
  15876. 6: rlqe(ex(x,a*x**2+b*x+c>0),{a<0});
  15877. 2
  15878. 4*a*c - b < 0
  15879. \end{verbatim}}
  15880. \end{samepage}
  15881. For \textsc{OFSF} and \textsc{DVFSF} there is a variant
  15882. \f{RLQEA}\ttindex{RLQEA} available. It returns instead of a
  15883. quantifier-free equivalent, a list of condition-solution pairs
  15884. containing, e.g., satisfying sample points for outermost existential
  15885. quantifier blocks.
  15886. \begin{samepage}
  15887. \vspace{0.5cm}
  15888. {\bf Example:}
  15889. {\small\begin{verbatim}
  15890. 7: rlqea(ex(x,a*x**2+b*x+c>0),{a<0});
  15891. 2
  15892. {{4*a*c - b < 0,
  15893. 2
  15894. - sqrt( - 4*a*c + b ) - 2*a*epsilon1 - b
  15895. {x = -------------------------------------------}}}
  15896. 2*a
  15897. \end{verbatim}}
  15898. \end{samepage}
  15899. \subsection{Generic Quantifier Elimination}
  15900. \textsc{OFSF} allows generic quantifier elimination
  15901. \f{RLGQE}\ttindex{RLGQE}, which enlarges the theory by disequations,
  15902. i.e.~\f{<>}-atomic formulas, wherever this supports the quantifier
  15903. elimination. There is also generic quantifier elimination with answer
  15904. available: \f{RLGQEA}\ttindex{RLGQEA}.
  15905. \begin{samepage}
  15906. \vspace{0.5cm}
  15907. {\bf Example:}
  15908. {\small\begin{verbatim}
  15909. 8: rlgqe ex(x,a*x**2+b*x+c>0);
  15910. {{a <> 0},
  15911. 2
  15912. 4*a*c - b < 0 or a >= 0}
  15913. \end{verbatim}}
  15914. \end{samepage}
  15915. \subsection{Linear Optimization}
  15916. \f{RLOPT}\ttindex{RLOPT} uses quantifier elimination for linear
  15917. optimization. It takes as arguments a list of constraints and the
  15918. target function. The target function is minimized subject to the
  15919. constraints.
  15920. \chapter{RESET: Reset REDUCE to its initial state}
  15921. \label{RESET}
  15922. \typeout{{RESET: Code to reset REDUCE to its initial state}}
  15923. {\footnotesize
  15924. \begin{center}
  15925. J. P. Fitch \\
  15926. School of Mathematical Sciences, University of Bath\\
  15927. BATH BA2 7AY, England \\[0.05in]
  15928. e--mail: jpff@cs.bath.ac.uk
  15929. \end{center}
  15930. }
  15931. \ttindex{RESET}
  15932. This package defines a command {\tt RESETREDUCE}
  15933. \ttindex{RESETREDUCE} that works through the history of previous
  15934. commands, and clears any values which have been assigned, plus any
  15935. rules, arrays and the like. It also sets the various switches to
  15936. their initial values. It is not complete, but does work for most
  15937. things that cause a gradual loss of space.
  15938. \chapter{RESIDUE: A residue package}
  15939. \label{RESIDUE}
  15940. \typeout{{RESIDUE: A residue package}}
  15941. {\footnotesize
  15942. \begin{center}
  15943. Wolfram Koepf\\
  15944. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  15945. Takustra\"se 7 \\
  15946. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  15947. e--mail: Koepf@zib.de
  15948. \end{center}
  15949. }
  15950. \ttindex{RESIDUE}
  15951. \def\Res{\mathop{\rm Res}\limits}
  15952. \newcommand{\C}{{\rm {\mbox{C{\llap{{\vrule height1.52ex}\kern.4em}}}}}}
  15953. This package supports the calculation of residues. The residue
  15954. $\Res_{z=a} f(z)$ of a function $f(z)$ at the point $a\in\C$ is defined
  15955. as
  15956. \[
  15957. \Res_{z=a} f(z)=
  15958. \frac{1}{2 \pi i}\oint f(z)\,dz
  15959. \;,
  15960. \]
  15961. with integration along a closed curve around $z=a$ with winding number 1.
  15962. It contains two \REDUCE\ operators:
  15963. \begin{itemize}
  15964. \item
  15965. {\tt residue(f,z,a)}\ttindex{residue} determines the residue of $f$ at
  15966. the point $z=a$ if $f$ is meromorphic at $z=a$. The calculation of
  15967. residues at essential singularities of $f$ is not supported.
  15968. \item
  15969. {\tt poleorder(f,z,a)}\ttindex{poleorder} determines the pole order
  15970. of $f$ at the point $z=a$ if $f$ is meromorphic at $z=a$.
  15971. \end{itemize}
  15972. Note that both functions use the {\tt TAYLOR} package (chapter~\ref{TAYLOR}).
  15973. {\small\begin{verbatim}
  15974. load_package residue;
  15975. residue(x/(x^2-2),x,sqrt(2));
  15976. 1
  15977. ---
  15978. 2
  15979. poleorder(x/(x^2-2),x,sqrt(2));
  15980. 1
  15981. residue(sin(x)/(x^2-2),x,sqrt(2));
  15982. sqrt(2)*sin(sqrt(2))
  15983. ----------------------
  15984. 4
  15985. poleorder(sin(x)/(x^2-2),x,sqrt(2));
  15986. 1
  15987. residue((x^n-y^n)/(x-y)^2,x,y);
  15988. n
  15989. y *n
  15990. ------
  15991. y
  15992. poleorder((x^n-y^n)/(x-y)^2,x,y);
  15993. 1
  15994. \end{verbatim}}
  15995. \chapter{RLFI: REDUCE LaTeX formula interface}
  15996. \label{RLFI}
  15997. \typeout{{RLFI: REDUCE LaTeX formula interface}}
  15998. {\footnotesize
  15999. \begin{center}
  16000. Richard Liska, Ladislav Drska\\
  16001. Computational Physics Group \\
  16002. Faculty of Nuclear Sciences and Physical Engineering\\
  16003. Czech Technical University in Prague, Brehova 7, 115 19 Prague 1 \\
  16004. Czech Republic\\[0.05in]
  16005. e--mail: liska@siduri.fjfi.cvut.cz
  16006. \end{center}
  16007. }
  16008. \ttindex{RLFI}
  16009. The RLFI package provides the printing of \REDUCE\ expressions in
  16010. \LaTeX\ format, so it can be used directly for document production.
  16011. Various mathematical
  16012. constructions are supported by the interface including subscripts,
  16013. superscripts, font changing, Greek letters, divide-bars, integral and
  16014. sum signs, derivatives etc.
  16015. The interface is connected to \REDUCE\ by three new switches and
  16016. several statements. To activate the \LaTeX\ output mode the switch {\tt
  16017. latex}\ttindex{latex} must be set {\tt on}. This switch causes all
  16018. outputs to be written in the \LaTeX\ syntax of formulas. The switch
  16019. {\tt VERBATIM}\ttindex{VERBATIM} is used for input printing control.
  16020. If it is {\tt on} input to \REDUCE{} system is typeset in \LaTeX{}
  16021. verbatim environment after the line containing the string {\tt REDUCE Input:}.
  16022. The switch {\tt lasimp}\ttindex{lasimp} controls the algebraic
  16023. evaluation of input
  16024. formulas. If it is {\tt on} every formula is evaluated, simplified and
  16025. written in the form given by ordinary \REDUCE\ statements and switches
  16026. such as {\tt factor}, {\tt order}, {\tt rat} etc. In the case when the
  16027. {\tt lasimp} switch is {\tt off} evaluation, simplification or
  16028. reordering of formulas is not performed and \REDUCE\ acts only as a
  16029. formula parser and the form of the formula output is exactly the same as
  16030. that of the input, the only difference remains in the syntax. The mode
  16031. {\tt off lasimp} is designed especially for typesetting of formulas for
  16032. which the user needs preservation of their structure. This switch has
  16033. no meaning if the switch {\tt Latex} is {\tt off} and thus is working
  16034. only for \LaTeX\ output.
  16035. For every identifier used in the typeset \REDUCE\ formula
  16036. the following properties can be defined by the statement {\tt defid}:
  16037. \ttindex{defid}
  16038. \begin{itemize}
  16039. \item its printing symbol (Greek letters can be used).
  16040. \item the font in which the symbol will be typeset.
  16041. \item accent which will be typeset above the symbol.
  16042. \end{itemize}
  16043. Symbols with indexes are treated in \REDUCE\ as operators. Each index
  16044. corresponds to an argument of the operator. The meaning of operator
  16045. arguments (where one wants to typeset them) is declared by the
  16046. statement\ttindex{defindex}
  16047. {\tt defindex}. This statement causes the arguments to be typeset as
  16048. subscripts or superscripts (on left or right-hand side of the operator)
  16049. or as arguments of the operator.
  16050. The statement {\tt mathstyle}\ttindex{mathstyle} defines the style of
  16051. formula typesetting. The variable {\tt laline!*}\ttindex{laline"!*}
  16052. defines the length of output lines.
  16053. The fractions with horizontal divide bars are typeset by using the
  16054. new \REDUCE\ infix operator \verb+\+. This operator is not
  16055. algebraically simplified. During typesetting of powers the checking on
  16056. the form of the power base and exponent is performed to determine the
  16057. form of the typeset expression ({\em e.g.\ }sqrt symbol, using parentheses).
  16058. Some special forms can be typeset by using \REDUCE\ prefix operators.
  16059. These are as follows:
  16060. \begin{itemize}
  16061. \item {\tt int} - integral of an expression.
  16062. \item {\tt dint} - definite integral of an expression.
  16063. \item {\tt df} - derivative of an expression.
  16064. \item {\tt pdf} - partial derivative of an expression.
  16065. \item {\tt sum} - sum of expressions.
  16066. \item {\tt product} - product of expressions.
  16067. \item {\tt sqrt} - square root of expression.
  16068. \end{itemize}
  16069. There are still some problems unsolved in the present version of the
  16070. interface as follows:
  16071. \begin{itemize}
  16072. \item breaking the formulas which do not fit on one line.
  16073. \item automatic decision where to use divide bars in fractions.
  16074. \item distinction of two- or more-character identifiers from the product
  16075. of one-character symbols.
  16076. \item typesetting of matrices.
  16077. \end{itemize}
  16078. \chapter{ROOTS: A REDUCE root finding package}
  16079. \label{ROOTS}
  16080. \typeout{{ROOTS: A REDUCE root finding package}}
  16081. {\footnotesize
  16082. \begin{center}
  16083. Stanley L. Kameny \\
  16084. Los Angeles, U.S.A.
  16085. \end{center}
  16086. }
  16087. \ttindex{ROOTS}
  16088. The root finding package is designed so that it can be used as an
  16089. independent package, or it can be integrated with and called by {\tt
  16090. SOLVE}.\index{SOLVE package ! with ROOTS package}
  16091. \section{Top Level Functions}
  16092. The top level functions can be called either as symbolic operators from
  16093. algebraic mode, or they can be called directly from symbolic mode with
  16094. symbolic mode arguments. Outputs are expressed in forms that print out
  16095. correctly in algebraic mode.
  16096. \subsection{Functions that refer to real roots only}
  16097. The three functions \f{REALROOTS}, \f{ISOLATER} and \f{RLROOTNO} can
  16098. receive 1, 2 or 3 arguments.
  16099. The first argument is the polynomial p, that can be complex and can
  16100. have multiple or zero roots. If arg2 and arg3 are not present, all real
  16101. roots are found. If the additional arguments are present, they restrict
  16102. the region of consideration.
  16103. \begin{itemize}
  16104. \item If there are two arguments the second is either POSITIVE or NEGATIVE.
  16105. The function will only find positive or negative roots
  16106. \item If arguments are (p,arg2,arg3) then
  16107. \ttindex{EXCLUDE}\ttindex{POSITIVE}\ttindex{NEGATIVE}\ttindex{INFINITY}
  16108. Arg2 and Arg3 must be r (a real number) or EXCLUDE r, or a member of
  16109. the list POSITIVE, NEGATIVE, INFINITY, -INFINITY. EXCLUDE r causes the
  16110. value r to be excluded from the region. The order of the sequence
  16111. arg2, arg3 is unimportant. Assuming that arg2 $\leq$ arg3 when both are
  16112. numeric, then
  16113. \begin{tabular}{l c l}
  16114. \{-INFINITY,INFINITY\} & (or \{\}) & all roots; \\
  16115. \{arg2,NEGATIVE\} & represents & $-\infty < r < arg2$; \\
  16116. \{arg2,POSITIVE\} & represents & $arg2 < r < \infty$;
  16117. \end{tabular}
  16118. In each of the following, replacing an {\em arg} with EXCLUDE {\em arg}
  16119. converts the corresponding inclusive $\leq$ to the exclusive $<$
  16120. \begin{tabular}{l c l}
  16121. \{arg2,-INFINITY\} & represents & $-\infty < r \leq arg2$; \\
  16122. \{arg2,INFINITY\} & represents & $arg2 \leq r < \infty$; \\
  16123. \{arg2,arg3\} & represents & $arg2 \leq r \leq arg3$;
  16124. \end{tabular}
  16125. \item If zero is in the interval the zero root is included.
  16126. \end{itemize}
  16127. \begin{description}
  16128. \ttindex{REALROOTS}
  16129. \item[REALROOTS] finds the real roots of the polynomial
  16130. p. Precision of computation is guaranteed to be sufficient to
  16131. separate all real roots in the specified region. (cf. MULTIROOT for
  16132. treatment of multiple roots.)
  16133. \ttindex{ISOLATER}
  16134. \item[ISOLATER] produces a list of rational intervals, each
  16135. containing a single real root of the polynomial p, within the specified
  16136. region, but does not find the roots.
  16137. \ttindex{RLROOTNO}
  16138. \item[RLROOTNO] computes the number of real roots of p in
  16139. the specified region, but does not find the roots.
  16140. \end{description}
  16141. \subsection{Functions that return both real and complex roots}
  16142. \begin{description}
  16143. \ttindex{ROOTS}
  16144. \item[ROOTS p;] This is the main top level function of the roots package.
  16145. It will find all roots, real and complex, of the polynomial p to an
  16146. accuracy that is sufficient to separate them and which is a minimum of 6
  16147. decimal places. The value returned by ROOTS is a
  16148. list of equations for all roots. In addition, ROOTS stores separate lists
  16149. of real roots and complex roots in the global variables ROOTSREAL and
  16150. ROOTSCOMPLEX.\ttindex{ROOTSREAL}\ttindex{ROOTSCOMPLEX}
  16151. The output of ROOTS is normally sorted into a standard order:
  16152. a root with smaller real part precedes a root with larger real part; roots
  16153. with identical real parts are sorted so that larger imaginary part
  16154. precedes smaller imaginary part.
  16155. However, when a polynomial has been factored algebraically then the
  16156. root sorting is applied to each factor separately. This makes the
  16157. final resulting order less obvious.
  16158. \ttindex{ROOTS\_AT\_PREC}
  16159. \item[ROOTS\_AT\_PREC p;] Same as ROOTS except that roots values are
  16160. returned to a minimum of the number of decimal places equal to the current
  16161. system precision.
  16162. \ttindex{ROOT\_VAL}
  16163. \item[ROOT\_VAL p;] Same as ROOTS\_AT\_PREC, except that instead of
  16164. returning a list of equations for the roots, a list of the root value is
  16165. returned. This is the function that SOLVE calls.
  16166. \ttindex{NEARESTROOT}
  16167. \item[NEARESTROOT(p,s);] This top level function finds the root to
  16168. which the method converges given the initial starting origin s, which
  16169. can be complex. If there are several roots in the vicinity of s and s
  16170. is not significantly closer to one root than it is to all others, the
  16171. convergence could arrive at a root that is not truly the nearest root.
  16172. This function should therefore be used only when the user is certain
  16173. that there is only one root in the immediate vicinity of the
  16174. starting point s.
  16175. \ttindex{FIRSTROOT}
  16176. \item[FIRSTROOT p;] ROOTS is called, but only a single root is computed.
  16177. \end{description}
  16178. \subsection{Other top level functions}
  16179. \begin{description}
  16180. \ttindex{GETROOT}\ttindex{ROOTS}\ttindex{REALROOTS}\ttindex{NEARESTROOTS}
  16181. \item[GETROOT(n,rr);] If rr has the form of the output of ROOTS, REALROOTS,
  16182. or NEARESTROOTS; GETROOT returns the rational, real, or complex value of
  16183. the root equation. An error occurs if $n<1$ or $n>$ the number of roots in
  16184. rr.
  16185. \ttindex{MKPOLY}
  16186. \item[MKPOLY rr;] This function can be used to reconstruct a polynomial
  16187. whose root equation list is rr and whose denominator is 1. Thus one can
  16188. verify that if $rr := ROOTS~p$, and $rr1 := ROOTS~MKPOLY~rr$, then
  16189. $rr1 = rr$. (This will be true if {\tt MULTIROOT} and {\tt RATROOT} are ON,
  16190. and {\tt ROUNDED} is off.)
  16191. However, $MKPOLY~rr - NUM~p = 0$ will be true if and only if all roots of p
  16192. have been computed exactly.
  16193. \end{description}
  16194. \section{Switches Used in Input}
  16195. The input of polynomials in algebraic mode is sensitive to the switches
  16196. {\tt COMPLEX}, {\tt ROUNDED}, and {\tt ADJPREC}. The correct choice of
  16197. input method is important since incorrect choices will result in
  16198. undesirable truncation or rounding of the input coefficients.
  16199. Truncation or rounding may occur if {\tt ROUNDED} is on and
  16200. one of the following is true:
  16201. \begin{enumerate}
  16202. \item a coefficient is entered in floating point form or rational form.
  16203. \item {\tt COMPLEX} is on and a coefficient is imaginary or complex.
  16204. \end{enumerate}
  16205. Therefore, to avoid undesirable truncation or rounding, then:
  16206. \begin{enumerate}
  16207. \item {\tt ROUNDED} should be off and input should be
  16208. in integer or rational form; or
  16209. \item {\tt ROUNDED} can be on if it is acceptable to truncate or round
  16210. input to the current value of system precision; or both {\tt ROUNDED} and
  16211. {\tt ADJPREC} can be on, in which case system precision will be adjusted
  16212. to accommodate the largest coefficient which is input; or \item if the
  16213. input contains complex coefficients with very different magnitude for the
  16214. real and imaginary parts, then all three switches {\tt ROUNDED}, {\tt
  16215. ADJPREC} and {\tt COMPLEX} must be on.
  16216. \end{enumerate}
  16217. \begin{description}
  16218. \item[integer and complex modes] (off {\tt ROUNDED}) any real
  16219. polynomial can be input using integer coefficients of any size; integer or
  16220. rational coefficients can be used to input any real or complex polynomial,
  16221. independent of the setting of the switch {\tt COMPLEX}. These are the most
  16222. versatile input modes, since any real or complex polynomial can be input
  16223. exactly.
  16224. \item[modes rounded and complex-rounded] (on {\tt ROUNDED}) polynomials can be
  16225. input using
  16226. integer coefficients of any size. Floating point coefficients will be
  16227. truncated or rounded, to a size dependent upon the system. If complex
  16228. is on, real coefficients can be input to any precision using integer
  16229. form, but coefficients of imaginary parts of complex coefficients will
  16230. be rounded or truncated.
  16231. \end{description}
  16232. \section{Root Package Switches}
  16233. \begin{description}
  16234. \ttindex{RATROOT}
  16235. \item[RATROOT] (Default OFF) If {\tt RATROOT} is on all root equations are
  16236. output in rational form. Assuming that the mode is {\tt COMPLEX}
  16237. ({\em i.e.\ }
  16238. {\tt ROUNDED} is off,) the root equations are
  16239. guaranteed to be able to be input into \REDUCE\ without truncation or
  16240. rounding errors. (Cf. the function MKPOLY described above.)
  16241. \ttindex{MULTIROOT}
  16242. \item[MULTIROOT] (Default ON) Whenever the polynomial has complex
  16243. coefficients or has real coefficients and has multiple roots, as
  16244. \ttindex{SQFRF} determined by the Sturm function, the function {\tt SQFRF}
  16245. is called automatically to factor the polynomial into square-free factors.
  16246. If {\tt MULTIROOT} is on, the multiplicity of the roots will be indicated
  16247. in the output of ROOTS or REALROOTS by printing the root output
  16248. repeatedly, according to its multiplicity. If {\tt MULTIROOT} is off,
  16249. each root will be printed once, and all roots should be normally be
  16250. distinct. (Two identical roots should not appear. If the initial
  16251. precision of the computation or the accuracy of the output was
  16252. insufficient to separate two closely-spaced roots, the program attempts to
  16253. increase accuracy and/or precision if it detects equal roots. If,
  16254. however, the initial accuracy specified was too low, and it was not
  16255. possible to separate the roots, the program will abort.)
  16256. \end{description}
  16257. \chapter[RSOLVE: Rational polynomial solver]%
  16258. {RSOLVE: \protect\\ Rational/integer polynomial solvers}
  16259. \label{RSOLVE}
  16260. \typeout{[RSOLVE: Rational polynomial solver]}
  16261. {\footnotesize
  16262. \begin{center}
  16263. Francis J. Wright \\
  16264. School of Mathematical Sciences, Queen Mary and Westfield College \\
  16265. University of London \\
  16266. Mile End Road \\
  16267. London E1 4NS, England \\[0.05in]
  16268. e--mail: F.J.Wright@QMW.ac.uk
  16269. \end{center}
  16270. }
  16271. \ttindex{RSOLVE}
  16272. The exact rational zeros of a single univariate polynomial using fast
  16273. modular methods can be calculated.
  16274. The operator \verb|r_solve|\ttindex{R\_SOLVE} computes
  16275. all rational zeros and the operator \verb|i_solve|
  16276. \ttindex{I\_SOLVE} computes only
  16277. integer zeros in a way that is slightly more efficient than extracting
  16278. them from the rational zeros.
  16279. The first argument is either a univariate polynomial expression or
  16280. equation with integer, rational or rounded coefficients. Symbolic
  16281. coefficients are not allowed. The argument is simplified to a
  16282. quotient of integer polynomials and the denominator is silently
  16283. ignored.
  16284. Subsequent arguments are optional. If the polynomial variable is to
  16285. be specified then it must be the first optional argument. However,
  16286. since the variable in a non-constant univariate polynomial can be
  16287. deduced from the polynomial it is unnecessary to specify it
  16288. separately, except in the degenerate case that the first argument
  16289. simplifies to either 0 or $0 = 0$. In this case the result is
  16290. returned by \verb|i_solve| in terms of the operator \verb|arbint| and
  16291. by \verb|r_solve| in terms of the (new) analogous operator
  16292. \verb|arbrat|. The operator \verb|i_solve| will generally run
  16293. slightly faster than \verb|r_solve|.
  16294. The (rational or integer) zeros of the first argument are returned as
  16295. a list and the default output format is the same as that used by
  16296. \verb|solve|. Each distinct zero is returned in the form of an
  16297. equation with the variable on the left and the multiplicities of the
  16298. zeros are assigned to the variable \verb|root_multiplicities| as a
  16299. list. However, if the switch {\ttfamily multiplicities} is turned on then
  16300. each zero is explicitly included in the solution list the appropriate
  16301. number of times (and \verb|root_multiplicities| has no value).
  16302. \begin{sloppypar}
  16303. Optional keyword arguments acting as local switches allow other output
  16304. formats. They have the following meanings:
  16305. \begin{description}
  16306. \item[{\ttfamily separate}:] assign the multiplicity list to the global
  16307. variable \verb|root_multiplicities| (the default);
  16308. \item[{\ttfamily expand} or {\ttfamily multiplicities}:] expand the solution
  16309. list to include multiple zeros multiple times (the default if the
  16310. {\ttfamily multiplicities} switch is on);
  16311. \item[{\ttfamily together}:] return each solution as a list whose second
  16312. element is the multiplicity;
  16313. \item[{\ttfamily nomul}:] do not compute multiplicities (thereby saving
  16314. some time);
  16315. \item[{\ttfamily noeqs}:] do not return univariate zeros as equations but
  16316. just as values.
  16317. \end{description}
  16318. \end{sloppypar}
  16319. \section{Examples}
  16320. {\small\begin{verbatim}
  16321. r_solve((9x^2 - 16)*(x^2 - 9), x);
  16322. \end{verbatim}}
  16323. \[
  16324. \left\{x=\frac{-4}{3},x=3,x=-3,x=\frac{4}{3}\right\}
  16325. \]
  16326. {\small\begin{verbatim}
  16327. i_solve((9x^2 - 16)*(x^2 - 9), x);
  16328. \end{verbatim}}
  16329. \[
  16330. \{x=3,x=-3\}
  16331. \]
  16332. \chapter[SCOPE: Source code optimisation package]
  16333. {SCOPE: REDUCE source code optimisation package}
  16334. \label{SCOPE}
  16335. \typeout{{SCOPE: REDUCE source code optimisation package}}
  16336. {\footnotesize
  16337. \begin{center}
  16338. J.A. van Hulzen \\
  16339. University of Twente, Department of Computer Science \\
  16340. P.O. Box 217, 7500 AE Enschede \\
  16341. The Netherlands \\[0.05in]
  16342. e--mail: infhvh@cs.utwente.nl
  16343. \end{center}
  16344. }
  16345. SCOPE is a package to produce optimised versions of algebraic
  16346. expressions. It can be used in two distinct fashions, as an adjunct
  16347. to numerical code generation (using GENTRAN, described in
  16348. chapter~\ref{GENTRAN}) or as a stand alone way of investigating
  16349. structure in an expression.
  16350. When used with GENTRAN\ttindex{GENTRAN} it is sufficient to set the
  16351. switch {\tt GENTRANOPT}\ttindex{GENTRANOPT} on, and GENTRAN will then
  16352. use SCOPE internally. This is described in its internal detail in the
  16353. GENTRAN manual and the SCOPE documentation.
  16354. As a stand-alone package SCOPE provides the operator {\tt OPTIMIZE}.
  16355. \ttindex{OPTIMIZE}
  16356. A SCOPE application is easily performed and based on the use of
  16357. the following syntax:
  16358. {\small
  16359. \begin{flushleft}
  16360. \begin{tabular}{lcl}
  16361. $<$SCOPE\_application$>$ & $\Rightarrow$ & {\tt OPTIMIZE} $<$object\_seq$>$
  16362. [{\tt INAME} $<$cse\_prefix$>$]\\
  16363. $<$object\_seq$>$ & $\Rightarrow$ & $<$object$>$[,$<$object\_seq$>$]\\
  16364. $<$object$>$ & $\Rightarrow$ & $<$stat$>~\mid~<$alglist$>~\mid~<$alglist\_production$>$ \\
  16365. $<$stat$>$ & $\Rightarrow$ & $<$name$>~<$assignment operator$>~<$expression$>$\\
  16366. $<$assignment operator$>$ & $\Rightarrow$ & $:=~\mid~::=~\mid~::=:~\mid~:=:$\\
  16367. $<$alglist$>$ & $\Rightarrow$ & \{$<$eq\_seq$>$\}\\
  16368. $<$eq\_seq$>$ & $\Rightarrow$ & $<$name$>~=~<$expression$>$[,$<$eq\_seq$>$]\\
  16369. $<$alglist\_production$>$ & $\Rightarrow$ & $<$name$>~\mid~<$function\_application$>$\\
  16370. $<$name$>$ & $\Rightarrow$ & $<$id$>~\mid~<$id$>(<$a\_subscript\_seq$>)$\\
  16371. $<$a\_subscript\_seq$>$ & $\Rightarrow$ & $<$a\_subscript$>$[,$<$a\_subscript\_seq$>$]\\
  16372. $<$a\_subscript$>$ & $\Rightarrow$ & $<$integer$>~\mid~<$integer infix\_expression$>$\\
  16373. $<$cse\_prefix$>$ & $\Rightarrow$ & $<$id$>$
  16374. \end{tabular}
  16375. \end{flushleft}}
  16376. A SCOPE action can be applied on one assignment statement, or to a
  16377. sequence of such statements, separated by commas, or a list of expressions.
  16378. \index{SCOPE option ! {\tt INAME}}
  16379. The optional use of the {\tt INAME} extension in an {\tt OPTIMIZE}
  16380. command is introduced to allow the user to influence the generation of
  16381. cse-names. The cse\_prefix is an identifier, used to generate
  16382. cse-names, by extending it with an integer part. If the cse\_prefix
  16383. consists of letters only, the initially selected integer part is 0.
  16384. If the user-supplied cse\_prefix ends with an integer its value
  16385. functions as initial integer part.
  16386. {\small\begin{verbatim}
  16387. 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;
  16388. 2 2 2 6 2 2 4 2 6 2 2
  16389. z := a *b + 10*a *m + a *m + 2*a*b*m + 2*b *m + b *m
  16390. OPTIMIZE z:=:z ;
  16391. G0 := b*a
  16392. G4 := m*m
  16393. G1 := G4*b*b
  16394. G2 := G4*a*a
  16395. G3 := G4*G4
  16396. z := G1 + G2 + G0*(2*G3 + G0) + G3*(2*G1 + 10*G2)
  16397. \end{verbatim}}
  16398. it can be desirable
  16399. to rerun an optimisation request with a restriction on the minimal size of
  16400. the righthandsides. The command
  16401. \index{SCOPE function ! {\tt SETLENGTH}}
  16402. \hspace*{1cm} {\tt SETLENGTH} $<$integer$>$\$
  16403. can be used to produce rhs's with a minimal arithmetic complexity,
  16404. dictated by the value of
  16405. its integer argument. Statements, used to rename function applications, are
  16406. not affected by the {\tt SETLENGTH} command. The default setting is restored
  16407. with the command
  16408. \hspace*{1cm} {\tt RESETLENGTH}\$
  16409. \index{SCOPE function ! {\tt RESETLENGTH}}
  16410. {\em Example:}
  16411. {\small\begin{verbatim}
  16412. SETLENGTH 2$
  16413. OPTIMIZE z:=:z INAME s$
  16414. 2 2
  16415. s1 := b *m
  16416. 2 2
  16417. s2 := a *m
  16418. 4 4
  16419. z := (a*b + 2*m )*a*b + 2*(s1 + 5*s2)*m + s1 + s2
  16420. \end{verbatim}}
  16421. Details of the algorithm used is given in the Scope User's Manual.
  16422. \chapter{SETS: A basic set theory package}
  16423. \label{SETS}
  16424. \typeout{{SETS: A basic set theory package}}
  16425. {\footnotesize
  16426. \begin{center}
  16427. Francis J. Wright \\
  16428. School of Mathematical Sciences, Queen Mary and Westfield College \\
  16429. University of London \\
  16430. Mile End Road \\
  16431. London E1 4NS, England \\[0.05in]
  16432. e--mail: F.J.Wright@QMW.ac.uk
  16433. \end{center}
  16434. }
  16435. \ttindex{SETS}
  16436. The SETS package provides set theoretic operations on lists and represents
  16437. the results as normal algebraic-mode lists, so that all other \REDUCE{}
  16438. facilities that apply to lists can still be applied to lists that have
  16439. been constructed by explicit set operations.
  16440. \section{Infix operator precedence}
  16441. The set operators are currently inserted into the standard \REDUCE{}
  16442. precedence list (see section~\ref{sec-operators}) as follows:
  16443. {\small\begin{verbatim}
  16444. or and not member memq = set_eq neq eq >= > <= < subset_eq
  16445. subset freeof + - setdiff union intersection * / ^ .
  16446. \end{verbatim}}
  16447. \section{Explicit set representation and MKSET}
  16448. Explicit sets are represented by lists, and there is a need to convert
  16449. standard \REDUCE\ lists into a set by removing duplicates. The
  16450. package also orders the members of the set so the standard {\tt =}
  16451. predicate will provide set equality.\ttindex{MKSET}
  16452. {\small\begin{verbatim}
  16453. mkset {1,2,y,x*y,x+y};
  16454. {x + y,x*y,y,1,2}
  16455. \end{verbatim}}
  16456. The empty set is represented by the empty list \verb|{}|.
  16457. \section{Union and intersection}
  16458. The intersection operator has the name\ttindex{intersect} {\tt
  16459. intersect}, and set union is denotes by\ttindex{union}{\tt union}.
  16460. These operators will probably most commonly be used as binary infix
  16461. operators applied to explicit sets,
  16462. {\small\begin{verbatim}
  16463. {1,2,3} union {2,3,4};
  16464. {1,2,3,4}
  16465. {1,2,3} intersect {2,3,4};
  16466. {2,3}
  16467. \end{verbatim}}
  16468. \section{Symbolic set expressions}
  16469. If one or more of the arguments evaluates to an unbound identifier
  16470. then it is regarded as representing a symbolic implicit set, and the
  16471. union or intersection will evaluate to an expression that still
  16472. contains the union or intersection operator. These two operators are
  16473. symmetric, and so if they remain symbolic their arguments will be
  16474. sorted as for any symmetric operator. Such symbolic set expressions
  16475. are simplified, but the simplification may not be complete in
  16476. non-trivial cases. For example:
  16477. {\small\begin{verbatim}
  16478. a union b union {} union b union {7,3};
  16479. {3,7} union a union b
  16480. a intersect {};
  16481. {}
  16482. \end{verbatim}}
  16483. Intersection distributes over union, which is not applied by default
  16484. but is implemented as a rule list assigned to the variable {\tt
  16485. set\_distribution\_rule}, {\em e.g.}
  16486. {\small\begin{verbatim}
  16487. a intersect (b union c);
  16488. (b union c) intersection a
  16489. a intersect (b union c) where set_distribution_rule;
  16490. a intersection b union a intersection c
  16491. \end{verbatim}}
  16492. \section{Set difference}
  16493. The set difference operator is represented by the symbol \verb|\| and
  16494. is always output using this symbol, although it can also be input using
  16495. \ttindex{setdiff} {\tt setdiff}. It is a binary operator.
  16496. {\small\begin{verbatim}
  16497. {1,2,3} \ {2,4};
  16498. {1,3}
  16499. a \ {1,2};
  16500. a\{1,2}
  16501. a \ a;
  16502. {}
  16503. \end{verbatim}}
  16504. \section{Predicates on sets}
  16505. Set membership, inclusion or equality are all binary infix operators.
  16506. They can only be used within conditional statements or within the
  16507. argument of the {\tt evalb}\ttindex{evalb} operator provided by this
  16508. package, and they cannot remain symbolic -- a predicate that cannot be
  16509. evaluated to a Boolean value causes a normal \REDUCE\ error.
  16510. The {\tt evalb} operator provides a convenient shorthand for an {\tt
  16511. if} statement designed purely to display the value of any Boolean
  16512. expression (not only predicates defined in this package).
  16513. {\small\begin{verbatim}
  16514. if a = a then true else false;
  16515. true
  16516. evalb(a = a);
  16517. true
  16518. if a = b then true else false;
  16519. false
  16520. \end{verbatim}}
  16521. \subsection{Set membership}
  16522. Set membership is tested by the predicate \ttindex{member}{\tt member}.
  16523. Its left operand is regarded as a potential set element and
  16524. its right operand {\em must\/} evaluate to an explicit set. There is
  16525. currently no sense in which the right operand could be an implicit set.
  16526. {\small\begin{verbatim}
  16527. evalb(1 member {1,2,3});
  16528. true
  16529. evalb(2 member {1,2} intersect {2,3});
  16530. true
  16531. evalb(a member b);
  16532. ***** b invalid as list
  16533. \end{verbatim}}
  16534. \subsection{Set inclusion}
  16535. Set inclusion is tested by the predicate {\tt subset\_eq}
  16536. \ttindex{subset\_eq} where {\tt a subset\_eq b} is true if the set $a$
  16537. is either a subset of or equal to the set $b$; strict inclusion is
  16538. tested by the predicate {\tt subset}\ttindex{subset}
  16539. where {\tt a subset b} is true if the set $a$ is {\em strictly\/} a
  16540. subset of the set $b$ and is false is $a$ is equal to $b$. These
  16541. predicates provide some support for symbolic set expressions, but is
  16542. incomplete.
  16543. {\small\begin{verbatim}
  16544. evalb({1,2} subset_eq {1,2,3});
  16545. true
  16546. evalb({1,2} subset_eq {1,2});
  16547. true
  16548. evalb({1,2} subset {1,2});
  16549. false
  16550. evalb(a subset a union b);
  16551. true
  16552. \end{verbatim}}
  16553. \newpage
  16554. {\small\begin{verbatim}
  16555. evalb(a\b subset a);
  16556. true
  16557. \end{verbatim}}
  16558. An undecidable predicate causes a normal \REDUCE\ error, {\em e.g.\ }
  16559. {\small\begin{verbatim}
  16560. evalb(a subset_eq {b});
  16561. ***** Cannot evaluate a subset_eq {b} as Boolean-valued set
  16562. expression
  16563. \end{verbatim}}
  16564. \subsection{Set equality}
  16565. As explained above, equality of two sets in canonical form can be
  16566. reliably tested by the standard \REDUCE\ equality predicate ({\tt =}).
  16567. \chapter{SPARSE: Sparse Matrices}
  16568. \label{SPARSE MATRICES}
  16569. \typeout{{SPARSE: Sparse Matrices}}
  16570. {\footnotesize
  16571. \begin{center}
  16572. Stephen Scowcroft \\
  16573. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin \\
  16574. Takustra\"se 7 \\
  16575. D-14195 Berlin-Dahlem, Germany \\
  16576. \end{center}
  16577. }
  16578. \ttindex{SPARSE, Sparse matrices}
  16579. \ttindex{MATRIX, see also SPARSE}
  16580. \section{Introduction}
  16581. This package extends the available matrix feature to enable
  16582. calculations with sparse matrices. It also provides
  16583. a selection of functions that are useful in the world of linear
  16584. algebra with respect to sparse matrices. \\
  16585. The package is loaded by: {\tt load\_package sparse;}
  16586. \section{Sparse Matrix Calculations}
  16587. To extend the syntax of this class of calculations an expression type
  16588. {\tt sparse \ttindex{SPARSE}} is added. An identifier may be declared a
  16589. sparse variable by the declaration {\tt sparse}. The size of the
  16590. sparse matrix must be declared explicitly in the matrix declaration.
  16591. This declaration \f{SPARSE} is similar to the declaration \f{MATRIX}.
  16592. Once a matrix has been declared a sparse matrix all elements of the
  16593. matrix are treated as if they were initialized to 0. When printing out
  16594. a sparse matrix only the non-zero elements are printed due to the fact
  16595. that only the non-zero elements of the matrix are stored. To assign values
  16596. to the elements of the declared sparse matrix we use the same syntax as for
  16597. matrices.
  16598. {\small\begin{verbatim}
  16599. sparse aa(10,1),bb(200,200);
  16600. aa(1,1):=10;
  16601. bb(100,150):=a;
  16602. \end{verbatim}}
  16603. \section{Linear Algebra Package for Sparse Matrices}
  16604. Most of the functions of this package are related to the functions
  16605. of the linear algebra package \f{LINALG}. For further explanation and
  16606. examples of the various functions please refer to the \f{LINALG}
  16607. package.
  16608. \subsection{Basic matrix handling}
  16609. {\small\begin{tabular}{l l l l}
  16610. spadd\_columns \ttindex{SPADD\_COLUMNS} &
  16611. spadd\_rows \ttindex{SPADD\_ROWS} &
  16612. spadd\_to\_columns \ttindex{SPADD\_TO\_COLUMNS} &
  16613. spadd\_to\_rows \ttindex{SPADD\_TO\_ROWS} \\
  16614. spaugment\_columns \ttindex{SPAUGMENT\_COLUMNS} &
  16615. spchar\_poly \ttindex{SPCHAR\_POLY} &
  16616. spcol\_dim \ttindex{SPCOL\_DIM} &
  16617. spcopy\_into \ttindex{SPCOPY\_INTO} \\
  16618. spdiagonal \ttindex{SPDIAGONAL} &
  16619. spextend \ttindex{SPEXTEND} &
  16620. spfind\_companion \ttindex{SPFIND\_COMPANION} &
  16621. spget\_columns \ttindex{SPGET\_COLUMNS} \\
  16622. spget\_rows \ttindex{SPGET\_ROWS} &
  16623. sphermitian\_tp \ttindex{SPHERMITIAN\_TP} &
  16624. spmatrix\_augment \ttindex{SPMATRIX\_AUGMENT} &
  16625. spmatrix\_stack \ttindex{SPMATRIX\_STACK} \\
  16626. spminor \ttindex{SPMINOR} &
  16627. spmult\_columns \ttindex{SPMULT\_COLUMNS} &
  16628. spmult\_rows \ttindex{SPMULT\_ROWS} &
  16629. sppivot \ttindex{SPPIVOT} \\
  16630. spremove\_columns \ttindex{SPREMOVE\_COLUMNS} &
  16631. spremove\_rows \ttindex{SPREMOVE\_ROWS} &
  16632. sprow\_dim \ttindex{SPROW\_DIM} &
  16633. sprows\_pivot \ttindex{SPROWS\_PIVOT} \\
  16634. spstack\_rows \ttindex{SPSTACK\_ROWS} &
  16635. spsub\_matrix \ttindex{SPSUB\_MATRIX} &
  16636. spswap\_columns \ttindex{SPSWAP\_COLUMNS} &
  16637. spswap\_entries \ttindex{SPSWAP\_ENTRIES} \\
  16638. spswap\_rows \ttindex{SPSWAP\_ROWS}
  16639. \end{tabular}}
  16640. \subsection{Constructors}
  16641. Functions that create sparse matrices.
  16642. \begin{tabular}{l l l l}
  16643. spband\_matrix \ttindex{SPBAND\_MATRIX} &
  16644. spblock\_matrix \ttindex{SPBLOCK\_MATRIX} &
  16645. spchar\_matrix \ttindex{SPCHAR\_MATRIX} &
  16646. spcoeff\_matrix \ttindex{SPCOEFF\_MATRIX} \\
  16647. spcompanion \ttindex{SPCOMPANION} &
  16648. sphessian \ttindex{SPHESSIAN} &
  16649. spjacobian \ttindex{SPJACOBIAN} &
  16650. spjordan\_block \ttindex{SPJORDAN\_BLOCK} \\
  16651. spmake\_identity \ttindex{SPMAKE\_IDENTITY}
  16652. \end{tabular}
  16653. \subsection{High level algorithms}
  16654. \begin{tabular}{l l l l}
  16655. spchar\_poly \ttindex{SPCHAR\_POLY} &
  16656. spcholesky \ttindex{SPCHOLESKY} &
  16657. spgram\_schmidt \ttindex{SPGRAM\_SCHMIDT} &
  16658. splu\_decom \ttindex{SPLU\_DECOM} \\
  16659. sppseudo\_inverse \ttindex{SPPSEUDO\_INVERSE} &
  16660. svd \ttindex{SVD}
  16661. \end{tabular}
  16662. \subsection{Predicates}
  16663. \begin{tabular}{l l l l}
  16664. matrixp \ttindex{MATRIXP} &
  16665. sparsematp \ttindex{SPARSEMATP} &
  16666. squarep \ttindex{SQUAREP} &
  16667. symmetricp \ttindex{SYMMETRICP}
  16668. \end{tabular}
  16669. \chapter[SPDE: Symmetry groups of {PDE}'s]%
  16670. {SPDE: A package for finding symmetry groups of {PDE}'s}
  16671. \label{SPDE}
  16672. \typeout{{SPDE: A package for finding symmetry groups of {PDE}'s}}
  16673. {\footnotesize
  16674. \begin{center}
  16675. Fritz Schwarz \\
  16676. GMD, Institut F1 \\
  16677. Postfach 1240 \\
  16678. 5205 St. Augustin, Germany \\[0.05in]
  16679. e--mail: fritz.schwarz@gmd.de
  16680. \end{center}
  16681. }
  16682. \ttindex{SPDE}
  16683. The package SPDE provides a set of functions which may be applied
  16684. to determine the symmetry group of Lie- or point-symmetries of a
  16685. given system of partial differential equations. Preferably it is
  16686. used interactively on a computer terminal. In many cases the
  16687. determining system is solved completely automatically. In some
  16688. other cases the user has to provide some additional input
  16689. information for the solution algorithm to terminate.
  16690. \section{System Functions and Variables}
  16691. The symmetry analysis of partial differential equations logically
  16692. falls into three parts. Accordingly the most important functions
  16693. provided by the package are:
  16694. \begin{table}
  16695. \begin{center}
  16696. \begin{tabular}{| c | c | }\hline
  16697. Function name & Operation \\ \hline \hline
  16698. \ttindex{CRESYS}
  16699. CRESYS(\s{arguments}) & Constructs determining system \\ \hline
  16700. \ttindex{SIMPSYS}
  16701. SIMPSYS() & Solves determining system \\ \hline
  16702. \ttindex{RESULT}
  16703. RESULT() & Prints infinitesimal generators \\
  16704. & and commutator table \\ \hline
  16705. \end{tabular}
  16706. \end{center}
  16707. \caption{SPDE Functions}
  16708. \end{table}
  16709. Some other useful functions for obtaining various kinds of output
  16710. are:
  16711. \begin{table}
  16712. \begin{center}
  16713. \begin{tabular}{| c | c |} \hline
  16714. Function name & Operation \\ \hline \hline
  16715. \ttindex{PRSYS}
  16716. PRSYS() & Prints determining system \\ \hline
  16717. \ttindex{PRGEN}
  16718. PRGEN() & Prints infinitesimal generators \\ \hline
  16719. \ttindex{COMM}
  16720. COMM(U,V) & Prints commutator of generators U and V \\ \hline
  16721. \end{tabular}
  16722. \end{center}
  16723. \caption{SPDE Useful Output Functions}\label{spde:useful}
  16724. \end{table}
  16725. SPDE expects a system of differential equations to be defined as the
  16726. values of the operator {\tt deq} and other operators. A simple
  16727. example follows.
  16728. {\small\begin{verbatim}
  16729. load_package spde;
  16730. deq 1:=u(1,1)+u(1,2,2);
  16731. deq(1) := u(1,2,2) + u(1,1)
  16732. CRESYS deq 1;
  16733. PRSYS();
  16734. GL(1):=2*df(eta(1),u(1),x(2)) - df(xi(2),x(2),2) - df(xi(2),x(1))
  16735. GL(2):=df(eta(1),u(1),2) - 2*df(xi(2),u(1),x(2))
  16736. GL(3):=df(eta(1),x(2),2) + df(eta(1),x(1))
  16737. GL(4):=df(xi(2),u(1),2)
  16738. GL(5):=df(xi(2),u(1)) - df(xi(1),u(1),x(2))
  16739. GL(6):=2*df(xi(2),x(2)) - df(xi(1),x(2),2) - df(xi(1),x(1))
  16740. GL(7):=df(xi(1),u(1),2)
  16741. GL(8):=df(xi(1),u(1))
  16742. GL(9):=df(xi(1),x(2))
  16743. The remaining dependencies
  16744. xi(2) depends on u(1),x(2),x(1)
  16745. xi(1) depends on u(1),x(2),x(1)
  16746. eta(1) depends on u(1),x(2),x(1)
  16747. \end{verbatim}}
  16748. A detailed description can be found in the SPDE documentation and
  16749. examples.
  16750. \chapter{SPECFN: Package for special functions}
  16751. \label{SPECFN}
  16752. \typeout{{SPECFN: Package for special functions}}
  16753. {\footnotesize
  16754. \begin{center}
  16755. Chris Cannam \& Winfried Neun \\
  16756. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  16757. Takustra\"se 7 \\
  16758. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  16759. e--mail: neun@zib.de
  16760. \end{center}
  16761. }
  16762. \ttindex{SPECFN}
  16763. \index{Orthogonal polynomials}
  16764. This package is designed to provide algebraic and numeric manipulations of
  16765. several common special functions, namely:
  16766. \begin{itemize}
  16767. \item Bernoulli Numbers and Polynomials;
  16768. \item Euler numbers and Polynomials;
  16769. \item Fibonacci numbers and Polynomials;
  16770. \item Stirling Numbers;
  16771. \item Binomial Coefficients;
  16772. \item Pochhammer notation;
  16773. \item The Gamma function;
  16774. \item The Psi function and its derivatives;
  16775. \item The Riemann Zeta function;
  16776. \item The Bessel functions J and Y of the first and second kinds;
  16777. \item The modified Bessel functions I and K;
  16778. \item The Hankel functions H1 and H2;
  16779. \item The Kummer hypergeometric functions M and U;
  16780. \item The Beta function, and Struve, Lommel and Whittaker functions;
  16781. \item The Airy functions;
  16782. \item The Exponential Integral, the Sine and Cosine Integrals;
  16783. \item The Hyperbolic Sine and Cosine Integrals;
  16784. \item The Fresnel Integrals and the Error function;
  16785. \item The Dilog function;
  16786. \item The Polylogarithm and Lerch Phi function;
  16787. \item Hermite Polynomials;
  16788. \item Jacobi Polynomials;
  16789. \item Legendre Polynomials;
  16790. \item Associated Legendre Functions (Spherical and Solid Harmonics);
  16791. \item Laguerre Polynomials;
  16792. \item Chebyshev Polynomials;
  16793. \item Gegenbauer Polynomials;
  16794. \item Lambert's $\omega$ function;
  16795. \item Jacobi Elliptic Functions and Integrals;
  16796. \item 3j symbols, 6j symbols and Clebsch Gordan coefficients;
  16797. \item and some well-known constants.
  16798. \end{itemize}
  16799. \section{Simplification and Approximation}
  16800. All of the operators supported by this package have certain algebraic
  16801. simplification rules to handle special cases, poles, derivatives and so
  16802. on. Such rules are applied whenever they are appropriate. However, if
  16803. the {\tt ROUNDED} switch is on, numeric evaluation is also carried out.
  16804. Unless otherwise stated below, the result of an application of a special
  16805. function operator to real or complex numeric arguments in rounded mode
  16806. will be approximated numerically whenever it is possible to do so. All
  16807. approximations are to the current precision.
  16808. \section{Constants}
  16809. \ttindex{Euler\_Gamma}\ttindex{Khinchin}\ttindex{Golden\_Ratio}
  16810. \ttindex{Catalan}
  16811. Some well-known constants are defined in the special function package.
  16812. Important properties of these constants which can be used to define them
  16813. are also known. Numerical values are computed at arbitrary precision
  16814. if the switch ROUNDED is on.
  16815. \begin{itemize}
  16816. \item Euler\_Gamma : Euler's constants, also available as -$\psi(1)$;
  16817. \item Catalan : Catalan's constant;
  16818. \item Khinchin : Khinchin's constant;
  16819. \item Golden\_Ratio : $\frac{1 + \sqrt{5}}{2}$
  16820. \end{itemize}
  16821. \section{Functions}
  16822. The functions provided by this package are given in the following
  16823. tables.
  16824. %%\index{Spherical and Solid Harmonics}\ttindex{SphericalHarmonicY}
  16825. %%\ttindex{SolidHarmonicY}
  16826. %%\ttindex{Jacobiamplitude}
  16827. %%\ttindex{JacobiZeta}
  16828. \begin{center}
  16829. \fbox{
  16830. \begin{tabular}{r l}\\
  16831. Function & Operator \\\\
  16832. %\hline
  16833. $\left( { n \atop m } \right)$ & {\tt Binomial(n,m)}\ttindex{Binomial}\index{Binomial coefficients} \\
  16834. Motzkin($n$) & {\tt Motzkin(n)}\ttindex{Motzkin}\index{Motzkin} \\
  16835. Bernoulli($n$) or $ B_n $ & {\tt Bernoulli(n)}\ttindex{Bernoulli}\index{Bernoulli numbers} \\
  16836. Euler($n$) or $ E_n $ & {\tt Euler(n)}\ttindex{Euler}\index{Euler polynomials} \\
  16837. Fibonacci($n$) or $ F_n $ & {\tt Fibonacci(n)}\ttindex{Fibonacci}\index{Fibonacci} \\
  16838. $S_n^{(m)}$ & {\tt Stirling1(n,m)}\ttindex{Stirling1}\index{Stirling numbers} \\
  16839. ${\bf S}_n^{(m)}$ & {\tt Stirling2(n,m)}\ttindex{Stirling2} \\
  16840. $B(z,w)$ & {\tt Beta(z,w)}\ttindex{Beta}\index{Beta function} \\
  16841. $\Gamma(z)$ & {\tt Gamma(z)}\ttindex{Gamma}\index{Gamma function} \\
  16842. incomplete Beta $B_x(a,b)$ & {\tt iBeta(a,b,x)}\ttindex{iBeta}\index{incomplete Beta function} \\
  16843. incomplete Gamma $\Gamma(a,z)$ & {\tt iGamma(a,z)}\ttindex{iGamma}\index{incomplete Gamma function} \\
  16844. $(a)_k$ & {\tt Pochhammer(a,k)}\ttindex{Pochhammer}\index{Pochhammer's symbol} \\
  16845. $\psi(z)$ & {\tt Psi(z)}\ttindex{Psi}\index{Psi function} \\
  16846. $\psi^{(n)}(z)$ & {\tt Polygamma(n,z)}\ttindex{Polygamma}\index{Polygamma functions} \\
  16847. Riemann's $\zeta(z)$ & {\tt Zeta(z)}\ttindex{Zeta}\index{Zeta function (Riemann's)} \\
  16848. $J_\nu(z)$ & {\tt BesselJ(nu,z)}\ttindex{BesselJ}\index{Bessel functions}\\
  16849. $Y_\nu(z)$ & {\tt BesselY(nu,z)}\ttindex{BesselY}\\
  16850. $I_\nu(z)$ & {\tt BesselI(nu,z)}\ttindex{BesselI}\\
  16851. $K_\nu(z)$ & {\tt BesselK(nu,z)}\ttindex{BesselK}\\
  16852. $H^{(1)}_\nu(z)$ & {\tt Hankel1(nu,z)}\ttindex{Hankel1}\index{Hankel functions}\\
  16853. $H^{(2)}_\nu(z)$ & {\tt Hankel2(nu,z)}\ttindex{Hankel2}\\
  16854. $B(z,w)$ & {\tt Beta(z,w)}\ttindex{Beta}\index{Beta function}\\
  16855. \end{tabular}}
  16856. \end{center}
  16857. \begin{center}
  16858. \fbox{
  16859. \begin{tabular}{r l}\\
  16860. Function & Operator \\\\
  16861. %\hline
  16862. ${\bf H}_{\nu}(z)$ & {\tt StruveH(nu,z)}\ttindex{StruveH}\index{Struve functions}\\
  16863. ${\bf L}_{\nu}(z)$ & {\tt StruveL(nu,z)}\ttindex{StruveL}\\
  16864. $s_{a,b}(z)$ & {\tt Lommel1(a,b,z)}\ttindex{Lommel1}\index{Lommel functions}\\
  16865. $S_{a,b}(z)$ & {\tt Lommel2(a,b,z)}\ttindex{Lommel2}\\
  16866. $Ai(z)$ & {\tt Airy\_Ai(z)}\ttindex{Airy\_Ai}\index{Airy functions}\\
  16867. $Bi(z)$ & {\tt Airy\_Bi(z)}\ttindex{Airy\_Bi}\\
  16868. $Ai'(z)$ & {\tt Airy\_Aiprime(z)}\ttindex{Airy\_Aiprime}\\
  16869. $Bi'(z)$ & {\tt Airy\_Biprime(z)}\ttindex{Airy\_Biprime}\\
  16870. $M(a, b, z)$ or $_1F_1(a, b; z)$ or $\Phi(a, b; z)$ &
  16871. {\tt KummerM(a,b,z)}\ttindex{KummerM}\index{Kummer functions} \\
  16872. $U(a, b, z)$ or $z^{-a}{_2F_0(a, b; z)}$ or $\Psi(a, b; z)$ &
  16873. {\tt KummerU(a,b,z)}\ttindex{KummerU}\\
  16874. $M_{\kappa,\mu}(z)$ & {\tt WhittakerM(kappa,mu,z)}\ttindex{WhittakerM}\index{Whittaker functions}\\
  16875. $W_{\kappa,\mu}(z)$ & {\tt WhittakerW(kappa,mu,z)}\ttindex{WhittakerW}\\
  16876. $B_n(x)$ & {\tt BernoulliP(n,x)}\ttindex{BernoulliP}\index{Bernoulli polynomials} \\
  16877. $E_n(x)$ & {\tt EulerP(n,x)}\ttindex{EulerP} \\
  16878. Fibonacci Polynomials $F_n(x)$ & {\tt FibonacciP(n,x)}\ttindex{FibonacciP}\index{Fibonacci polynomials} \\
  16879. $C_n^{(\alpha)}(x)$ & {\tt GegenbauerP(n,alpha,x)}\ttindex{GegenbauerP}\index{Gegenbauer polynomials}\\
  16880. $H_n(x)$ & {\tt HermiteP(n,x)}\ttindex{HermiteP}\index{Hermite polynomials} \\
  16881. $L_n(x)$ & {\tt LaguerreP(n,x)}\ttindex{LaguerreP}\index{Laguerre polynomials}\\
  16882. $L_n^{(m)}(x)$ & {\tt LaguerreP(n,m,x)}\ttindex{LaguerreP}\\
  16883. $P_n(x)$ & {\tt LegendreP(n,x)}\ttindex{LegendreP}\index{Legendre polynomials}\\
  16884. $P_n^{(m)}(x)$ & {\tt LegendreP(n,m,x)}\ttindex{LegendreP}\\
  16885. $P_n^{(\alpha,\beta)} (x)$ & {\tt JacobiP(n,alpha,beta,x)}\ttindex{JacobiP}\index{Jacobi's polynomials} \\
  16886. $U_n(x)$ & {\tt ChebyshevU(n,x)}\ttindex{ChebyshevU}\index{Chebyshev polynomials} \\
  16887. $T_n(x)$ & {\tt ChebyshevT(n,x)}\ttindex{ChebyshevT}\\
  16888. \end{tabular}}
  16889. \end{center}
  16890. \begin{center}
  16891. \fbox{
  16892. \begin{tabular}{r l}\\
  16893. Function & Operator \\\\
  16894. %\hline
  16895. $Y_n^{m}(x,y,z,r2)$ & {\tt SolidHarmonicY(n,m,x,y,z,r2)}\ttindex{SolidHarmonicY}\\
  16896. $Y_n^{m}(\theta,\phi)$ & {\tt SphericalHarmonicY(n,m,theta,phi)}\ttindex{SphericalHarmonicY}\\
  16897. $\left( {j_1 \atop m_1} {j_2 \atop m_2}
  16898. {j_3 \atop m_3} \right)$ & {\tt ThreeJSymbol(\{j1,m1\},\{j2,m2\},\{j3,m3\})}\ttindex{ThreeJSymbol}\index{3j and 6j symbols}\\
  16899. $\left( {j_1m_1j_2m_2 | j_1j_2j_3 - m_3} \right)$ &
  16900. {\tt Clebsch\_Gordan(\{j1,m1\},\{j2,m2\},\{j3,m3\})}\ttindex{Clebsch\_Gordan}\index{Clebsch Gordan coefficients}\\
  16901. $\left\{ {j_1 \atop l_1} {j_2 \atop l_2}
  16902. {j_3 \atop l_3} \right\}$ & {\tt SixJSymbol(\{j1,j2,j3\},\{l1,l2,l3\})}\ttindex{SixJSymbol}\\
  16903. \end{tabular}}
  16904. \end{center}
  16905. \begin{center}
  16906. \fbox{
  16907. \begin{tabular}{r l}\\
  16908. Function & Operator \\\\
  16909. %\hline
  16910. $Si(z)$ & {\tt Si(z) }\ttindex{Si}\\
  16911. $si(z)$ & {\tt s\_i(z) }\ttindex{s\_i}\\
  16912. $Ci(z)$ & {\tt Ci(z) }\ttindex{Ci}\\
  16913. $Shi(z)$ & {\tt Shi(z) }\ttindex{Shi}\\
  16914. $Chi(z)$ & {\tt Chi(z) }\ttindex{Chi}\\
  16915. $erf(z)$ & {\tt erf(z) }\ttindex{erf}\\
  16916. $erfc(z)$ & {\tt erfc(z) }\ttindex{erfc}\\
  16917. $Ei(z)$ & {\tt Ei(z) }\ttindex{Ei}\\
  16918. $li(z)$ & {\tt li(z) }\ttindex{li}\\
  16919. $C(x)$ & {\tt Fresnel\_C(x)}\ttindex{Fresnel\_C} \\
  16920. $S(x)$ & {\tt Fresnel\_S(x)}\ttindex{Fresnel\_S} \\
  16921. \\
  16922. $dilog(z)$ & {\tt dilog(z)}\ttindex{dilog}\index{Dilogarithm function} \\
  16923. $Li_n(z)$ & {\tt Polylog(n,z)}\ttindex{Polylog}\index{Polylogarithm function} \\
  16924. Lerch $\Phi(z,s,a)$ & {\tt Lerch\_Phi(z,s,a)}\ttindex{Lerch\_Phi}\index{Lerch Phi function} \\
  16925. \\
  16926. $sn(u|m)$ & {\tt Jacobisn(u,m)}\ttindex{Jacobisn}\index{Jacobi Elliptic Functions and {Integrals}}\\
  16927. $dn(u|m)$ & {\tt Jacobidn(u,m)}\ttindex{Jacobidn}\\
  16928. $cn(u|m)$ & {\tt Jacobicn(u,m)}\ttindex{Jacobicn}\\
  16929. $cd(u|m)$ & {\tt Jacobicd(u,m)}\ttindex{Jacobicd}\\
  16930. $sd(u|m)$ & {\tt Jacobisd(u,m)}\ttindex{Jacobisd}\\
  16931. $nd(u|m)$ & {\tt Jacobind(u,m)}\ttindex{Jacobind}\\
  16932. $dc(u|m)$ & {\tt Jacobidc(u,m)}\ttindex{Jacobidc}\\
  16933. $nc(u|m)$ & {\tt Jacobinc(u,m)}\ttindex{Jacobinc}\\
  16934. $sc(u|m)$ & {\tt Jacobisc(u,m)}\ttindex{Jacobisc}\\
  16935. $ns(u|m)$ & {\tt Jacobins(u,m)}\ttindex{Jacobins}\\
  16936. $ds(u|m)$ & {\tt Jacobids(u,m)}\ttindex{Jacobids}\\
  16937. $cs(u|m)$ & {\tt Jacobics(u,m)}\ttindex{Jacobics}\\
  16938. $F(\phi|m)$ & {\tt EllipticF(phi,m)}\ttindex{EllipticF}\\
  16939. $K(m)$ & {\tt EllipticK(m)}\ttindex{EllipticK}\\
  16940. $E(\phi|m) or E(m)$ & {\tt EllipticE(phi,m) or}\\
  16941. ~ & {\tt EllipticE(m)}\ttindex{EllipticE}\\
  16942. $H(u|m), H_1(u|m), \Theta_1(u|m), \Theta(u|m)$ & {\tt EllipticTheta(a,u,m)}\ttindex{EllipticTheta}\\
  16943. $\theta_1(u|m), \theta_2(u|m), \theta_3(u|m), \theta_4(u|m)$
  16944. & {\tt EllipticTheta(a,u,m)}\ttindex{EllipticTheta}\\
  16945. $Z(u|m)$ & {\tt Zeta\_function(u,m)}\ttindex{Zeta\_function} \\
  16946. \\
  16947. Lambert $\omega(z)$ & {\tt Lambert\_W(z)}\ttindex{Lambert\_W}\index{Lambert $\omega$ function}
  16948. \end{tabular}}
  16949. \end{center}
  16950. \chapter{SPECFN2: Special special functions}
  16951. \label{SPECFN2}
  16952. \typeout{{SPECFN2: Package for special special functions}}
  16953. {\footnotesize
  16954. \begin{center}
  16955. Victor S. Adamchik \\
  16956. Byelorussian University \\
  16957. Minsk, Belorus \\[0.1in]
  16958. and\\[0.05in]
  16959. Winfried Neun \\
  16960. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  16961. Takustra\"se 7 \\
  16962. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  16963. e--mail: neun@zib.de
  16964. \end{center}
  16965. }
  16966. \ttindex{SPECFN2}
  16967. \index{Generalised Hypergeometric functions}
  16968. \index{Meijer's G function}
  16969. The (generalised) hypergeometric functions
  16970. \begin{displaymath}
  16971. _pF_q \left( {{a_1, \ldots , a_p} \atop {b_1, \ldots ,b_q}} \Bigg\vert z \right)
  16972. \end{displaymath}
  16973. are defined in textbooks on special functions.
  16974. \section{\REDUCE{} operator HYPERGEOMETRIC}
  16975. The operator {\tt hypergeometric} expects 3 arguments, namely the
  16976. list of upper parameters (which may be empty), the list of lower
  16977. parameters (which may be empty too), and the argument, e.g:
  16978. {\small\begin{verbatim}
  16979. hypergeometric ({},{},z);
  16980. Z
  16981. E
  16982. hypergeometric ({1/2,1},{3/2},-x^2);
  16983. ATAN(X)
  16984. ---------
  16985. X
  16986. \end{verbatim}}
  16987. \section{Enlarging the HYPERGEOMETRIC operator}
  16988. Since hundreds of particular cases for the generalised hypergeometric
  16989. functions can be found in the literature, one cannot expect that all
  16990. cases are known to the {\tt hypergeometric} operator.
  16991. Nevertheless the set of special cases can be augmented by adding
  16992. rules to the \REDUCE{} system, {\em e.g.}
  16993. {\small\begin{verbatim}
  16994. let {hypergeometric({1/2,1/2},{3/2},-(~x)^2) => asinh(x)/x};
  16995. \end{verbatim}}
  16996. \chapter{SUM: A package for series summation}
  16997. \label{SUM}
  16998. \typeout{{SUM: A package for series summation}}
  16999. {\footnotesize
  17000. \begin{center}
  17001. Fujio Kako \\
  17002. Department of Mathematics, Faculty of Science \\
  17003. Hiroshima University \\
  17004. Hiroshima 730, JAPAN \\[0.05in]
  17005. e--mail: kako@ics.nara-wu.ac.jp
  17006. \end{center}
  17007. }
  17008. \ttindex{SUM}
  17009. \index{Gosper's Algorithm}\index{SUM operator}\index{PROD operator}
  17010. This package implements the Gosper algorithm for the summation of series.
  17011. It defines operators SUM and PROD. The operator SUM returns the indefinite
  17012. or definite summation of a given expression, and the operator PROD returns
  17013. the product of the given expression. These are used with the syntax:
  17014. \vspace{.1in}
  17015. \noindent{\tt SUM}(EXPR:{\em expression}, K:{\em kernel},
  17016. [LOLIM:{\em expression} [, UPLIM:{\em expression}]]) \\
  17017. \noindent{\tt PROD}(EXPR:{\em expression}, K:{\em kernel},
  17018. [LOLIM:{\em expression} [, UPLIM:{\em expression}]])
  17019. If there is no closed form solution, these operators return the input
  17020. unchanged. UPLIM and LOLIM are optional parameters specifying the lower
  17021. limit and upper limit of the summation (or product), respectively. If UPLIM
  17022. is not supplied, the upper limit is taken as K (the summation variable
  17023. itself).
  17024. For example:
  17025. {\small\begin{verbatim}
  17026. sum(n**3,n);
  17027. sum(a+k*r,k,0,n-1);
  17028. sum(1/((p+(k-1)*q)*(p+k*q)),k,1,n+1);
  17029. prod(k/(k-2),k);
  17030. \end{verbatim}}
  17031. Gosper's algorithm succeeds whenever the ratio
  17032. \[ \frac{\sum_{k=n_0}^n f(k)}{\sum_{k=n_0}^{n-1} f(k)} \]
  17033. \noindent is a rational function of $n$. The function SUM!-SQ
  17034. handles basic functions such as polynomials, rational functions and
  17035. exponentials.\ttindex{SUM-SQ}
  17036. The trigonometric functions sin, cos, {\em etc.\ }are converted to exponentials
  17037. and then Gosper's algorithm is applied. The result is converted back into
  17038. sin, cos, sinh and cosh.
  17039. Summations of logarithms or products of exponentials are treated by the
  17040. formula:
  17041. \vspace{.1in}
  17042. \hspace*{2em} \[ \sum_{k=n_0}^{n} \log f(k) = \log \prod_{k=n_0}^n f(k) \]
  17043. \vspace{.1in}
  17044. \hspace*{2em} \[ \prod_{k=n_0}^n \exp f(k) = \exp \sum_{k=n_0}^n f(k) \]
  17045. \vspace{.1in}
  17046. Other functions can be summed by providing LET rules which must relate the
  17047. functions evaluated at $k$ and $k - 1$ ($k$ being the summation variable).
  17048. {\small\begin{verbatim}
  17049. operator f,gg; % gg used to avoid possible conflict with high energy
  17050. % physics operator.
  17051. for all n,m such that fixp m let
  17052. f(n+m)=if m > 0 then f(n+m-1)*(b*(n+m)**2+c*(n+m)+d)
  17053. else f(n+m+1)/(b*(n+m+1)**2+c*(n+m+1)+d);
  17054. for all n,m such that fixp m let
  17055. gg(n+m)=if m > 0 then gg(n+m-1)*(b*(n+m)**2+c*(n+m)+e)
  17056. else gg(n+m+1)/(b*(n+m+1)**2+c*(n+m+1)+e);
  17057. sum(f(n-1)/gg(n),n);
  17058. f(n)
  17059. ---------------
  17060. gg(n)*(d - e)
  17061. \end{verbatim}}
  17062. \chapter{SUSY2: Super Symmetry}
  17063. \label{SUSY2}
  17064. \typeout{{SUSY2: Super Symmetry}}
  17065. {\footnotesize
  17066. \begin{center}
  17067. Ziemowit Popowicz \\
  17068. Institute of Theoretical Physics, University of Wroclaw\\
  17069. pl. M. Borna 9 50-205 Wroclaw, Poland \\
  17070. e-mail: ziemek@ift.uni.wroc.pl
  17071. \end{center}
  17072. }
  17073. \ttindex{SUSY2}
  17074. This package deals with supersymmetric functions and with algebra
  17075. of supersymmetric operators in the extended N=2 as well as in the
  17076. nonextended N=1 supersymmetry. It allows us
  17077. to make the realization of SuSy algebra of differential operators,
  17078. compute the gradients of given SuSy Hamiltonians and to obtain
  17079. SuSy version of soliton equations using the SuSy Lax approach. There
  17080. are also many additional procedures encountered in the SuSy soliton
  17081. approach, as for example: conjugation of a given SuSy operator, computation
  17082. of general form of SuSy Hamiltonians (up to SuSy-divergence equivalence),
  17083. checking of the validity of the Jacobi identity for some SuSy
  17084. Hamiltonian operators.
  17085. To load the package, type \quad {\tt load susy2;} \\
  17086. \\
  17087. For full explanation and further examples, please refer to the
  17088. detailed documentation and the susy2.tst which comes with this package.
  17089. \section{Operators}
  17090. \subsection{Operators for constructing Objects}
  17091. The superfunctions are represented in this package by \f{BOS}(f,n,m) for superbosons
  17092. and \f{FER}(f,n,m) for superfermions. The first index denotes the name of the given
  17093. superobject, the second denotes the value of SuSy derivatives, and the last gives the
  17094. value of usual derivative. \\
  17095. In addition to the definitions of the superfunctions, also the inverse and the exponential
  17096. of superbosons can be defined (where the inverse is defined as \f{BOS}(f,n,m,-1)
  17097. with the property {\it bos(f,n,m,-1)*bos(f,n,m,1)=1}). The exponential of the superboson
  17098. function is \f{AXP}(\f{BOS}(f,0,0)). \\
  17099. The operator \f{FUN} and \f{GRAS} denote the classical and the Grassmann function. \\
  17100. Three different realizations of supersymmetric derivatives are implemented. To select
  17101. traditional realization declare \f{LET TRAD}. In order to select chiral or chiral1 algebra
  17102. declare \f{LET CHIRAL} or \f{LET CHIRAL1}. For usual differentiation the operator
  17103. \f{D}(1) stands for right and \f{D}(2) for left differentiation. SuSy derivatives are
  17104. denoted as {\it der} and {\it del}. \f{DER} and \f{DEL} are one component argument operations
  17105. and represent the left and right operators. The action of these operators on the
  17106. superfunctions depends on the choice of the supersymmetry algebra.
  17107. \flushleft
  17108. {\small\begin{center}
  17109. \begin{tabular}{ l l l l l l}
  17110. \f{BOS}(f,n,m)\ttindex{BOS} & \f{BOS}(f,n,m,k)\ttindex{BOS} &
  17111. \f{FER}(f,n,m)\ttindex{FER} & \f{AXP}(f)\ttindex{AXP} &
  17112. \f{FUN}(f,n)\ttindex{FUN} & \f{FUN}(f,n,m)\ttindex{FUN} \cr
  17113. \f{GRAS}(f,n)\ttindex{GRAS} & \f{AXX}(f)\ttindex{AXX} &
  17114. \f{D}(1)\ttindex{D} & \f{D}(2)\ttindex{D} &
  17115. \f{D}(3)\ttindex{D} & \f{D}(-1)\ttindex{D} \cr
  17116. \f{D}(-2)\ttindex{D} & \f{D}(-3)\ttindex{D} &
  17117. \f{D}(-4)\ttindex{D} & \f{DR}(-n)\ttindex{DR} &
  17118. \f{DER}(1)\ttindex{DER} & \f{DER}(2)\ttindex{DER} \cr
  17119. \f{DEL}(1)\ttindex{DEL} & \f{DEL}(2)\ttindex{DEL}
  17120. \end{tabular}
  17121. \end{center} }
  17122. \vspace{1cm}
  17123. {\bf Example}:
  17124. {\small\begin{verbatim}
  17125. 1: load susy2;
  17126. 2: bos(f,0,2,-2)*axp(fer(k,1,2))*del(1); %first susy derivative
  17127. 2*fer(f,1,2)*bos(f,0,2,-3)*axp(fer(k,1,2))
  17128. - bos(k,0,3)*bos(f,0,2,-2)*axp(fer(k,1,2))
  17129. + del(1)*bos(f,0,2,-2)*axp(fer(k,1,2))
  17130. 3: sub(del=der,ws);
  17131. bos(f,0,2,-2)*axp(fer(k,1,2))*der(1)
  17132. \end{verbatim}}
  17133. \subsection{Commands}
  17134. There are plenty of operators on superfunction objects. Some of them are introduced
  17135. here briefly.
  17136. \begin{itemize}
  17137. \item By using the operators \f{FPART}, \f{BPART}, \f{BFPART} and \f{BF\_PART}
  17138. it is possible to compute the coordinates of the arbitrary SuSy expressions.
  17139. \item With \f{W\_COMB}, \f{FCOMB} and \f{PSE\_ELE} there are three operators to be able to
  17140. construct different possible combinations of superfunctions and
  17141. super-pseudo-differential elements with the given conformal dimensions .
  17142. \item The three operators \f{S\_PART}, \f{D\_PART} and \f{SD\_PART} are implemented to
  17143. obtain the components of the (pseudo)-SuSy element.
  17144. \item \f{RZUT} is used to obtain the projection onto the invariant subspace (with respect
  17145. to commutator) of algebra of pseudo-SuSy-differential algebra.
  17146. \item To obtain the list of the same combinations of some superfunctions and (SuSy)
  17147. derivatives from some given operator-valued expression, the operators
  17148. \f{LYST}, \f{LYST1} and \f{LYST2} are constructed.
  17149. \end{itemize}
  17150. \begin{center}
  17151. \begin{tabular}{ l l}
  17152. \f{FPART}(expression)\ttindex{FPART} &
  17153. \f{BPART}(expression)\ttindex{BPART} \cr
  17154. \f{BF\_PART}(expression,n)\ttindex{BF\_PART} &
  17155. \f{B\_PART}(expression,n)\ttindex{B\_PART} \cr
  17156. \f{PR}(n,expression)\ttindex{PR} &
  17157. \f{PG}(n,expression)\ttindex{PG} \cr
  17158. \f{W\_COMB}(\{\{f,n,x\},...\},m,z,y)\ttindex{W\_COMB} &
  17159. \f{FCOMB}(\{\{f,n,x\},...\},m,z,y)\ttindex{FCOMB} \cr
  17160. \f{PSE\_ELE}(n,\{\{f,n\},...\},z)\ttindex{PSE\_ELE} \cr
  17161. \f{S\_PART}(expression,n)\ttindex{S\_PART} &
  17162. \f{D\_PART}(expression,n)\ttindex{D\_PART} \cr
  17163. \f{SD\_PART}(expression,n,m)\ttindex{SD\_PART} &
  17164. \f{CP}(expression)\ttindex{CP} \cr
  17165. \f{RZUT}(expression,n)\ttindex{RZUT} &
  17166. \f{LYST}(expression)\ttindex{LYST} \cr
  17167. \f{LYST1}(expression)\ttindex{LYST1} &
  17168. \f{LYST2}(expression)\ttindex{LYST2} \cr
  17169. \f{CHAN}(expression)\ttindex{CHAN} &
  17170. \f{ODWA}(expression)\ttindex{ODWA} \cr
  17171. \f{GRA}(expression,f)\ttindex{GRA} &
  17172. \f{DYW}(expression,f)\ttindex{DYW} \cr
  17173. \f{WAR}(expression,f)\ttindex{WAR} &
  17174. \f{DOT\_HAM}(equations,expression)\ttindex{DOT\_HAM} \cr
  17175. \f{N\_GAT}(operator,list)\ttindex{N\_GAT} &
  17176. \f{FJACOB}(operator,list)\ttindex{FJACOB} \cr
  17177. \f{JACOB}(operator,list,\{$\alpha,\beta,\gamma$\})\ttindex{JACOB} &
  17178. \f{MACIERZ}(expression,x,y)\ttindex{MACIERZ} \cr
  17179. \f{S\_INT}(number,expression,list)\ttindex{S\_INT}
  17180. \end{tabular}
  17181. \end{center}
  17182. \vspace{1cm}
  17183. {\bf Example}:
  17184. {\small\begin{verbatim}
  17185. 4: xxx:=fer(f,2,3);
  17186. xxx := fer(f,2,3)
  17187. 5: fpart(xxx); % all components
  17188. - fun(f0,4) + 2*fun(f1,3) gras(ff2,4)
  17189. {gras(ff2,3), ----------------------------,0, -------------}
  17190. 2 2
  17191. 6: bpart(xxx); % bosonic sector
  17192. - fun(f0,4) + 2*fun(f1,3)
  17193. {0,----------------------------,0,0}
  17194. 2
  17195. 9: b_part(xxx,1); %the given component in the bosonic sector
  17196. - fun(f0,4) + 2*fun(f1,3)
  17197. ----------------------------
  17198. 2
  17199. \end{verbatim}}
  17200. \section{Options}
  17201. The are several options defined in this package. Please note that they are
  17202. activated by typing \f{let $<$option$>$}. See also above. \\
  17203. The \f{TRAD}, \f{CHIRAL} and \f{CHIRAL1} select the different realizations of the
  17204. supersymmetric derivatives. By default traditional algebra is selected. \\
  17205. If the command {\tt LET INVERSE} is used, then three indices {\it bos} objects are
  17206. transformed onto four indices objects.
  17207. \begin{center}
  17208. \begin{tabular}{ l l l l l l }
  17209. \f{TRAD}\ttindex{TRAD} & \f{CHIRAL}\ttindex{CHIRAL} &
  17210. \f{CHIRAL1}\ttindex{CHIRAL1} & \f{INVERSE}\ttindex{INVERSE} &
  17211. \f{DRR}\ttindex{DRR} & \f{NODRR}\ttindex{NODRR}
  17212. \end{tabular}
  17213. \end{center}
  17214. \vspace{1cm}
  17215. {\bf Example}:
  17216. {\small\begin{verbatim}
  17217. 10: let inverse;
  17218. 11: bos(f,0,3)**3*bos(k,3,1)**40*bos(f,0,3,-2);
  17219. bos(k,3,1,40)*bos(f,0,3,1);
  17220. 12: clearrules inverse;
  17221. 13: xxx:=fer(f,1,2)*bos(k,0,2,-2);
  17222. xxx := fer(f,1,2)*bos(k,0,2,-2)
  17223. 14: pr(1,xxx); % first susy derivative
  17224. - 2*fer(k,1,2)*fer(f,1,2)*bos(k,0,2,-3) + bos(k,0,2,-2)*bos(f,0,3)
  17225. 15: pr(2,xxx); %second susy derivative
  17226. - 2*fer(k,2,2)*fer(f,1,2)*bos(k,0,2,-3) - bos(k,0,2,-2)*bos(f,3,2)
  17227. 16: clearrules trad;
  17228. 17: let chiral; % changing to chiral algebra
  17229. 18: pr(1,xxx);
  17230. - 2*fer(k,1,2)*fer(f,1,2)*bos(k,0,2,-3)
  17231. \end{verbatim}}
  17232. \chapter{SYMMETRY: Symmetric matrices}
  17233. \label{SYMMETRY}
  17234. \typeout{{SYMMETRY: Operations on symmetric matrices}}
  17235. {\footnotesize
  17236. \begin{center}
  17237. Karin Gatermann\\
  17238. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  17239. Takustra\"se 7 \\
  17240. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  17241. e--mail: gatermann@zib.de
  17242. \end{center}
  17243. }
  17244. \ttindex{SYMMETRY}
  17245. The SYMMETRY package provides procedures
  17246. that compute symmetry-adapted bases and block diagonal forms
  17247. of matrices which have the symmetry of a group.
  17248. \section{Operators for linear representations}
  17249. The data structure for a linear representation, a {\em
  17250. representation}, is a list consisting of the group identifier and
  17251. equations which assign matrices to the generators of the group.
  17252. {\bf Example:}
  17253. {\small\begin{verbatim}
  17254. rr:=mat((0,1,0,0),
  17255. (0,0,1,0),
  17256. (0,0,0,1),
  17257. (1,0,0,0));
  17258. sp:=mat((0,1,0,0),
  17259. (1,0,0,0),
  17260. (0,0,0,1),
  17261. (0,0,1,0));
  17262. representation:={D4,rD4=rr,sD4=sp};
  17263. \end{verbatim}}
  17264. For orthogonal (unitarian) representations the following operators
  17265. are available.
  17266. {\tt canonicaldecomposition(representation);}\ttindex{canonicaldecomposition}
  17267. returns an equation giving the canonical decomposition of the linear
  17268. representation.
  17269. {\tt character(representation);}\ttindex{character}
  17270. computes the character of the linear representation. The result is a list
  17271. of the group identifier and of lists consisting of a
  17272. list of group elements in one equivalence class and a real or complex number.
  17273. {\tt symmetrybasis(representation,nr);}\ttindex{symmetrybasis}
  17274. computes the basis of the isotypic component corresponding to the irreducible
  17275. representation of type nr. If the nr-th irreducible representation is
  17276. multidimensional, the basis is symmetry adapted. The output is a matrix.
  17277. {\tt symmetrybasispart(representation,nr);}\ttindex{symmetrybasispart}
  17278. is similar as {\tt symmetrybasis}, but for multidimensional
  17279. irreducible representations only the first part of the
  17280. symmetry adapted basis is computed.
  17281. {\tt allsymmetrybases(representation);}\ttindex{allsymmetrybases}
  17282. is similar as {\tt symmetrybasis} and {\tt symmetrybasispart},
  17283. but the bases of all
  17284. isotypic components are computed and thus a
  17285. complete coordinate transformation is returned.
  17286. {\tt diagonalize(matrix,representation);}\ttindex{diagonalize}
  17287. returns the block diagonal form of matrix which has the symmetry
  17288. of the given linear representation. Otherwise an error message occurs.
  17289. \section{Display Operators}
  17290. Access is provided to the information for a group, and for adding
  17291. knowledge for other groups. This is explained in detail in the
  17292. Symmetry on-line documentation.
  17293. \chapter{TAYLOR: Manipulation of Taylor series}
  17294. \label{TAYLOR}
  17295. \typeout{{TAYLOR: Manipulation of Taylor series}}
  17296. {\footnotesize
  17297. \begin{center}
  17298. Rainer Sch\"opf\\
  17299. Zentrum f\"ur Datenverarbeitung der Universit\"at Mainz\\
  17300. Anselm-Franz-von-Bentzel-Weg~12\\
  17301. D-55055 Mainz, Germany \\[0.05in]
  17302. e--mail: Schoepf@Uni-Mainz.DE
  17303. \end{center}
  17304. }
  17305. \ttindex{TAYLOR}\index{Taylor Series}\index{TAYLOR package}
  17306. \index{Laurent series}
  17307. The TAYLOR package of \REDUCE\ allow Taylor expansion in one or
  17308. several variables, and efficient manipulation of the resulting Taylor
  17309. series. Capabilities include basic operations (addition, subtraction,
  17310. multiplication and division), and also application of certain
  17311. algebraic and transcendental functions. To a certain extent, Laurent
  17312. and Puiseux expansions can be performed as well. In many cases,
  17313. separable singularities are detected and factored out.
  17314. \noindent {\tt TAYLOR}(EXP:{\em exprn}[,VAR:{\em kernel},
  17315. VAR$_0$:{\em exprn},ORDER:{\em integer}]\ldots):{\em exprn}
  17316. where EXP is the expression to be expanded. It can be any \REDUCE\
  17317. object, even an expression containing other Taylor kernels. VAR is
  17318. the kernel with respect to which EXP is to be expanded. VAR$_0$
  17319. denotes the point about which and ORDER the order up to which
  17320. expansion is to take place. If more than one (VAR, VAR0, ORDER) triple
  17321. is specified {\tt TAYLOR} will expand its first argument independently
  17322. with respect to each variable in turn. For example,
  17323. {\small\begin{verbatim}
  17324. taylor(e^(x^2+y^2),x,0,2,y,0,2);
  17325. \end{verbatim}}
  17326. will calculate the Taylor expansion up to order $X^{2}*Y^{2}$.
  17327. Note that once the expansion has been done it is not possible to
  17328. calculate higher orders.
  17329. Instead of a kernel, VAR may also
  17330. be a list of kernels. In this case expansion will take place in a way
  17331. so that the {\em sum\/} of the degrees of the kernels does not exceed
  17332. ORDER.
  17333. If VAR$_0$ evaluates to the special identifier \verb|INFINITY|
  17334. {\tt TAYLOR} tries to expand EXP in a series in 1/VAR.
  17335. The expansion is performed variable per variable, {\em i.e.\ }in the
  17336. example above by first expanding $\exp(x^{2}+y^{2})$ with respect
  17337. to $x$ and then expanding every coefficient with respect to $y$.
  17338. \index{IMPLICIT\_TAYLOR operator}\index{INVERSE\_TAYLOR} There are two
  17339. extra operators to compute the Taylor expansions of implicit and
  17340. inverse functions:
  17341. \noindent {\tt IMPLICIT\_TAYLOR}(F:{\em exprn},VAR1,VAR2:{\em kernel},\\
  17342. \hphantom{{\tt IMPLICIT\_TAYLOR}(}VAR1$_0$,VAR2$_0$:{\em exprn},
  17343. ORDER:{\em integer}):{\em exprn}
  17344. takes a function F depending on two variables VAR1 and VAR2 and
  17345. computes the Taylor series of the implicit function VAR2(VAR1)
  17346. given by the equation F(VAR1,VAR2) = 0. For example,
  17347. {\small\begin{verbatim}
  17348. implicit_taylor(x^2 + y^2 - 1,x,y,0,1,5);
  17349. \end{verbatim}}
  17350. \noindent {\tt INVERSE\_TAYLOR}(F:{\em exprn},VAR1,VAR2:{\em kernel},\\
  17351. \hphantom{{\tt INVERSE\_TAYLOR}(}VAR1$_0$:{\em exprn},
  17352. ORDER:{\em integer}):{\em exprn}
  17353. takes a function F depending on VAR1 and computes the Taylor series of
  17354. the inverse of F with respect to VAR2. For example,
  17355. {\small\begin{verbatim}
  17356. inverse_taylor(exp(x)-1,x,y,0,8);
  17357. \end{verbatim}}
  17358. \index{TAYLORPRINTTERMS variable}
  17359. When a Taylor kernel is printed, only a certain number of (non-zero)
  17360. coefficients are shown. If there are more, an expression of the form
  17361. \verb|(|$n$\verb| terms)| is printed to indicate how many non-zero
  17362. terms have been suppressed. The number of terms printed is given by
  17363. the value of the shared algebraic variable \verb|TAYLORPRINTTERMS|.
  17364. Allowed values are integers and the special identifier \verb|ALL|. The
  17365. latter setting specifies that all terms are to be printed. The default
  17366. setting is $5$.
  17367. \index{TAYLORKEEPORIGINAL switch}
  17368. If the switch \verb|TAYLORKEEPORIGINAL| is set to \verb|ON| the
  17369. original expression EXP is kept for later reference.
  17370. It can be recovered by means of the operator
  17371. \hspace*{2em} {\tt TAYLORORIGINAL}(EXP:{\em exprn}):{\em exprn}
  17372. An error is signalled if EXP is not a Taylor kernel or if the original
  17373. expression was not kept, {\em i.e.\ }if \verb|TAYLORKEEPORIGINAL| was
  17374. \verb|OFF| during expansion. The template of a Taylor kernel, {\em i.e.\ }
  17375. the list of all variables with respect to which expansion took place
  17376. together with expansion point and order can be extracted using
  17377. \ttindex{TAYLORTEMPLATE}
  17378. \hspace*{2em} {\tt TAYLORTEMPLATE}(EXP:{\em exprn}):{\em list}
  17379. This returns a list of lists with the three elements (VAR,VAR0,ORDER).
  17380. As with \verb|TAYLORORIGINAL|, an error is signalled if EXP is not a
  17381. Taylor kernel.
  17382. \hspace*{2em} {\tt TAYLORTOSTANDARD}(EXP:{\em exprn}):{\em exprn}
  17383. converts all Taylor kernels in EXP into standard form and
  17384. \ttindex{TAYLORTOSTANDARD} resimplifies the result.
  17385. \hspace*{2em} {\tt TAYLORSERIESP}(EXP:{\em exprn}):{\em boolean}
  17386. may be used to determine if EXP is a Taylor kernel.
  17387. \ttindex{TAYLORSERIESP} Note that this operator is subject to the same
  17388. restrictions as, {\em e.g.}, ORDP or NUMBERP, {\em i.e.\ }it may only be used in
  17389. boolean expressions in \verb|IF| or \verb|LET| statements. Finally
  17390. there is
  17391. \hspace*{2em} {\tt TAYLORCOMBINE}(EXP:{\em exprn}):{\em exprn}
  17392. which tries to combine all Taylor kernels found in EXP into one.
  17393. \ttindex{TAYLORCOMBINE}
  17394. Operations currently possible are:
  17395. \index{Taylor series ! arithmetic}
  17396. \begin{itemize}
  17397. \item Addition, subtraction, multiplication, and division.
  17398. \item Roots, exponentials, and logarithms.
  17399. \item Trigonometric and hyperbolic functions and their inverses.
  17400. \end{itemize}
  17401. Application of unary operators like \verb|LOG| and \verb|ATAN| will
  17402. nearly always succeed. For binary operations their arguments have to be
  17403. Taylor kernels with the same template. This means that the expansion
  17404. variable and the expansion point must match. Expansion order is not so
  17405. important, different order usually means that one of them is truncated
  17406. before doing the operation.
  17407. \ttindex{TAYLORKEEPORIGINAL}\ttindex{TAYLORCOMBINE}
  17408. If \verb|TAYLORKEEPORIGINAL| is set to \verb|ON| and if all Taylor
  17409. kernels in \verb|exp| have their original expressions kept
  17410. \verb|TAYLORCOMBINE| will also combine these and store the result
  17411. as the original expression of the resulting Taylor kernel.
  17412. \index{TAYLORAUTOEXPAND switch}
  17413. There is also the switch \verb|TAYLORAUTOEXPAND| (see below).
  17414. There are a few restrictions to avoid mathematically undefined
  17415. expressions: it is not possible to take the logarithm of a Taylor
  17416. kernel which has no terms ({\em i.e.\ }is zero), or to divide by such a
  17417. beast. There are some provisions made to detect singularities during
  17418. expansion: poles that arise because the denominator has zeros at the
  17419. expansion point are detected and properly treated, {\em i.e.\ }the Taylor
  17420. kernel will start with a negative power. (This is accomplished by
  17421. expanding numerator and denominator separately and combining the
  17422. results.) Essential singularities of the known functions (see above)
  17423. are handled correctly.
  17424. \index{Taylor series ! differentiation}
  17425. Differentiation of a Taylor expression is possible. Differentiating
  17426. with respect to one of the Taylor variables will decrease the order by one.
  17427. \index{Taylor series ! substitution}
  17428. Substitution is a bit restricted: Taylor variables can only be replaced
  17429. by other kernels. There is one exception to this rule: one can always
  17430. substitute a Taylor variable by an expression that evaluates to a
  17431. constant. Note that \REDUCE\ will not always be able to determine
  17432. that an expression is constant.
  17433. \index{Taylor series ! integration}
  17434. Only simple Taylor kernels can be integrated. More complicated
  17435. expressions that contain Taylor kernels as parts of themselves are
  17436. automatically converted into a standard representation by means of the
  17437. TAYLORTOSTANDARD operator. In this case a suitable warning is printed.
  17438. \index{Taylor series ! reversion} It is possible to revert a Taylor
  17439. series of a function $f$, {\em i.e.}, to compute the first terms of the
  17440. expansion of the inverse of $f$ from the expansion of $f$. This is
  17441. done by the operator
  17442. \hspace*{2em} {\tt TAYLORREVERT}(EXP:{\em exprn},OLDVAR:{\em kernel},
  17443. NEWVAR:{\em kernel}):{\em exprn}
  17444. EXP must evaluate to a Taylor kernel with OLDVAR being one of its
  17445. expansion variables. Example:
  17446. {\small\begin{verbatim}
  17447. taylor (u - u**2, u, 0, 5);
  17448. taylorrevert (ws, u, x);
  17449. \end{verbatim}}
  17450. This package introduces a number of new switches:
  17451. \begin{itemize}
  17452. \index{TAYLORAUTOCOMBINE switch}
  17453. \item If \verb|TAYLORAUTOCOMBINE| is set to \verb|ON| \REDUCE\
  17454. automatically combines Taylor expressions during the simplification
  17455. process. This is equivalent to applying \verb|TAYLORCOMBINE| to
  17456. every expression that contains Taylor kernels.
  17457. Default is \verb|ON|.
  17458. \index{TAYLORAUTOEXPAND switch}
  17459. \item \verb|TAYLORAUTOEXPAND| makes Taylor expressions ``contagious''
  17460. in the sense that \verb|TAYLORCOMBINE| tries to Taylor expand
  17461. all non-Taylor subexpressions and to combine the result with the
  17462. rest. Default is \verb|OFF|.
  17463. \index{TAYLORKEEPORIGINAL switch}
  17464. \item \verb|TAYLORKEEPORIGINAL|, if set to \verb|ON|, forces the
  17465. package to keep the original expression, {\em i.e.\ }the expression
  17466. that was Taylor expanded. All operations performed on the
  17467. Taylor kernels are also applied to this expression which can
  17468. be recovered using the operator \verb|TAYLORORIGINAL|.
  17469. Default is \verb|OFF|.
  17470. \index{TAYLORPRINTORDER switch}
  17471. \item \verb|TAYLORPRINTORDER|, if set to \verb|ON|, causes the
  17472. remainder to be printed in big-$O$ notation. Otherwise, three
  17473. dots are printed. Default is \verb|ON|.
  17474. \end{itemize}
  17475. \chapter{TPS: A truncated power series package}
  17476. \label{TPS}
  17477. \typeout{{TPS: A truncated power series package}}
  17478. {\footnotesize
  17479. \begin{center}
  17480. Alan Barnes \\
  17481. Dept. of Computer Science and Applied Mathematics \\
  17482. Aston University, Aston Triangle, \\
  17483. Birmingham B4 7ET, England \\[0.05in]
  17484. e--mail: barnesa@aston.ac.uk \\[0.1in]
  17485. and \\[0.1in]
  17486. Julian Padget \\
  17487. School of Mathematics, University of Bath \\
  17488. Bath, BA2 7AY, England \\[0.05in]
  17489. e--mail: jap@maths.bath.ac.uk
  17490. \end{center}
  17491. }
  17492. \ttindex{TPS}\ttindex{PS}
  17493. \index{power series}\index{truncated power series}
  17494. \index{Laurent series expansions}
  17495. This package implements formal Laurent series expansions in one
  17496. variable using the domain mechanism of \REDUCE. This means that power
  17497. series objects can be added, multiplied, differentiated {\em etc}. like other
  17498. first class objects in the system. A lazy evaluation scheme is used in
  17499. the package and thus terms of the series are not evaluated until they
  17500. are required for printing or for use in calculating terms in other
  17501. power series. The series are extendible giving the user the impression
  17502. that the full infinite series is being manipulated. The errors that
  17503. can sometimes occur using series that are truncated at some fixed depth
  17504. (for example when a term in the required series depends on terms of an
  17505. intermediate series beyond the truncation depth) are thus avoided.
  17506. \newpage
  17507. \section{Basic Truncated Power Series}
  17508. \subsection{PS Operator}
  17509. Syntax:
  17510. \noindent{\tt PS}(EXPRN:{\em algebraic},DEPVAR:{\em kernel},ABOUT:{\em algebraic}):{\em ps object}
  17511. \index{PS operator}
  17512. The {\tt PS} operator returns a power series object
  17513. representing the univariate formal power series expansion of EXPRN with
  17514. respect to the dependent variable DEPVAR about the expansion point
  17515. ABOUT. EXPRN may itself contain power series objects.
  17516. The algebraic expression ABOUT should simplify to an expression
  17517. which is independent of the dependent variable DEPVAR, otherwise
  17518. an error will result. If ABOUT is the identifier {\tt INFINITY}
  17519. then the power series expansion about DEPVAR = $\infty$ is
  17520. obtained in ascending powers of 1/DEPVAR.
  17521. \index{PSEXPLIM operator}
  17522. The power series object
  17523. representing EXPRN is compiled and then a number of terms of the
  17524. power series expansion are evaluated. The expansion is
  17525. carried out as far as the value specified by {\tt PSEXPLIM}. If,
  17526. subsequently, the value of {\tt PSEXPLIM} is increased, sufficient
  17527. information is stored in the power series object to enable the
  17528. additional terms to be calculated without recalculating the terms
  17529. already obtained.
  17530. If the function has a pole at the expansion point then the correct
  17531. Laurent series expansion will be produced.
  17532. \noindent The following examples are valid uses of {\tt PS}:
  17533. {\small\begin{verbatim}
  17534. psexplim 6;
  17535. ps(log x,x,1);
  17536. ps(e**(sin x),x,0);
  17537. ps(x/(1+x),x,infinity);
  17538. ps(sin x/(1-cos x),x,0);
  17539. \end{verbatim}}
  17540. \index{power series ! of user defined function}
  17541. New user-defined functions may be expanded provided the user provides
  17542. LET rules giving
  17543. \begin{enumerate}
  17544. \item the value of the function at the expansion point
  17545. \item a differentiation rule for the new function.
  17546. \end{enumerate}
  17547. \noindent For example
  17548. {\small\begin{verbatim}
  17549. operator sech;
  17550. forall x let df(sech x,x)= - sech x * tanh x;
  17551. let sech 0 = 1;
  17552. ps(sech(x**2),x,0);
  17553. \end{verbatim}}
  17554. \index{power series ! of integral}
  17555. The power series expansion of an integral may also be obtained (even if
  17556. \REDUCE\ cannot evaluate the integral in closed form). An example of
  17557. this is
  17558. {\small\begin{verbatim}
  17559. ps(int(e**x/x,x),x,1);
  17560. \end{verbatim}}
  17561. Note that if the integration variable is the same as the expansion
  17562. variable then \REDUCE's integration package is not called; if on the
  17563. other hand the two variables are different then the integrator is
  17564. called to integrate each of the coefficients in the power series
  17565. expansion of the integrand. The constant of integration is zero by
  17566. default. If another value is desired, then the shared variable {\tt
  17567. PSINTCONST} should be set to required value.\index{PSINTCONST (shared)}
  17568. \subsection{PSORDLIM Operator}
  17569. \index{PSORDLIM operator}
  17570. Syntax:
  17571. \hspace*{2em} {\tt PSORDLIM}(UPTO:{\em integer}):{\em integer}
  17572. \hspace*{4em} or
  17573. \hspace*{2em} {\tt PSORDLIM}():{\em integer}
  17574. An internal variable is set to the value of {\tt UPTO} (which should
  17575. evaluate to an integer). The value returned is the previous value of
  17576. the variable. The default value is 15.
  17577. If {\tt PSORDLIM} is called with no argument, the current value is
  17578. returned.
  17579. The significance of this control is that the system attempts to find
  17580. the order of the power series required, that is the order is the
  17581. degree of the first non-zero term in the power series. If the order
  17582. is greater than the value of this variable an error message is given
  17583. and the computation aborts. This prevents infinite loops in examples
  17584. such as
  17585. {\small\begin{verbatim}
  17586. ps(1 - (sin x)**2 - (cos x)**2,x,0);
  17587. \end{verbatim}}
  17588. where the expression being expanded is identically zero, but is not
  17589. recognised as such by \REDUCE.
  17590. \section{Controlling Power Series}
  17591. \subsection{PSTERM Operator}
  17592. \index{PSTERM operator}
  17593. Syntax:
  17594. \hspace*{2em} {\tt PSTERM}(TPS:{\em power series object},NTH:{\em integer}):{\em algebraic}
  17595. The operator {\tt PSTERM} returns the NTH term of the existing
  17596. power series object TPS. If NTH does not evaluate to
  17597. an integer or TPS to a power series object an error results. It
  17598. should be noted that an integer is treated as a power series.
  17599. \subsection{PSORDER Operator}
  17600. \index{PSORDER operator}
  17601. Syntax:
  17602. \hspace*{2em} {\tt PSORDER}(TPS:{\em power series object}):{\em integer}
  17603. The operator {\tt PSORDER} returns the order, that is the degree of
  17604. the first non-zero term, of the power series object TPS.
  17605. TPS should evaluate to a power series object or an error results. If
  17606. TPS is zero, the identifier {\tt UNDEFINED} is returned.
  17607. \subsection{PSSETORDER Operator}
  17608. \index{PSSETORDER operator}
  17609. Syntax:
  17610. \hspace*{2em} {\tt PSSETORDER}(TPS:{\em power series object}, ORD:{\em integer}):{\em integer}
  17611. The operator {\tt PSSETORDER} sets the order of the power series TPS to the
  17612. value ORD, which should evaluate to an integer. If
  17613. TPS does not evaluate to a power series object, then an error
  17614. occurs. The value returned by this operator is the previous order of
  17615. TPS, or 0 if the order of TPS was undefined. This
  17616. operator is useful for setting the order of the power series of a
  17617. function defined by a differential equation in cases where the power
  17618. series package is inadequate to determine the order automatically.
  17619. \subsection{PSDEPVAR Operator}
  17620. \index{PSDEPVAR operator}
  17621. Syntax:
  17622. \hspace*{2em} {\tt PSDEPVAR}(TPS:{\em power series object}):{\em identifier}
  17623. The operator {\tt PSDEPVAR} returns the expansion variable of the
  17624. power series object TPS. TPS should evaluate to a power
  17625. series object or an integer, otherwise an error results. If TPS
  17626. is an integer, the identifier {\tt UNDEFINED} is returned.
  17627. \subsection{PSEXPANSIONPT operator}
  17628. \index{PSEXPANSIONPT operator}
  17629. Syntax:
  17630. \hspace*{2em} {\tt PSEXPANSIONPT}(TPS:{\em power series object}):{\em algebraic}
  17631. The operator {\tt PSEXPANSIONPT} returns the expansion point of the
  17632. power series object TPS. TPS should evaluate to a power
  17633. series object or an integer, otherwise an error results. If TPS
  17634. is integer, the identifier {\tt UNDEFINED} is returned. If the
  17635. expansion is about infinity, the identifier {\tt INFINITY} is
  17636. returned.
  17637. \subsection{PSFUNCTION Operator}
  17638. \index{PSFUNCTION operator}
  17639. Syntax:
  17640. \hspace*{2em} {\tt PSFUNCTION}(TPS:{\em power series object}):{\em algebraic}
  17641. The operator {\tt PSFUNCTION} returns the function whose expansion
  17642. gave rise to the power series object TPS. TPS should
  17643. evaluate to a power series object or an integer, otherwise an error
  17644. results.
  17645. \subsection{PSCHANGEVAR Operator}
  17646. \index{PSCHANGEVAR operator}
  17647. Syntax:
  17648. \hspace*{2em} {\tt PSCHANGEVAR}(TPS:{\em power series object}, X:{\em kernel}):{\em power series object}
  17649. The operator {\tt PSCHANGEVAR} changes the dependent variable of the
  17650. power series object TPS to the variable X. TPS
  17651. should evaluate to a power series object and X to a kernel,
  17652. otherwise an error results. Also X should not appear as a
  17653. parameter in TPS. The power series with the new dependent
  17654. variable is returned.
  17655. \subsection{PSREVERSE Operator}
  17656. \index{PSREVERSE operator}
  17657. Syntax:
  17658. \hspace*{2em} {\tt PSREVERSE}(TPS:{\em power series object}):{\em power series}
  17659. Power series reversion. The power series TPS is functionally
  17660. inverted. Four cases arise:
  17661. \begin{enumerate}
  17662. \item If the order of the series is 1, then the expansion point of the
  17663. inverted series is 0.
  17664. \item If the order is 0 {\em and} if the first order term in TPS
  17665. is non-zero, then the expansion point of the inverted series is taken
  17666. to be the coefficient of the zeroth order term in TPS.
  17667. \item If the order is -1 the expansion point of the inverted series
  17668. is the point at infinity. In all other cases a \REDUCE\ error is
  17669. reported because the series cannot be inverted as a power series. Puiseux
  17670. \index{Puiseux expansion} expansion would be required to handle these cases.
  17671. \item If the expansion point of TPS is finite it becomes the
  17672. zeroth order term in the inverted series. For expansion about 0 or the
  17673. point at infinity the order of the inverted series is one.
  17674. \end{enumerate}
  17675. If TPS is not a power series object after evaluation an error results.
  17676. \noindent Here are some examples:
  17677. {\small\begin{verbatim}
  17678. ps(sin x,x,0);
  17679. psreverse(ws); % produces series for asin x about x=0.
  17680. ps(exp x,x,0);
  17681. psreverse ws; % produces series for log x about x=1.
  17682. ps(sin(1/x),x,infinity);
  17683. psreverse(ws); % produces series for 1/asin(x) about x=0.
  17684. \end{verbatim}}
  17685. \subsection{PSCOMPOSE Operator}
  17686. \index{PSCOMPOSE operator}
  17687. Syntax:
  17688. \hspace*{2em} {\tt PSCOMPOSE}(TPS1:{\em power series}, TPS2:{\em power series}):{\em power series}
  17689. \index{power series ! composition}
  17690. {\tt PSCOMPOSE} performs power series composition.
  17691. The power series TPS1 and TPS2 are functionally composed.
  17692. That is to say that TPS2 is substituted for the expansion
  17693. variable in TPS1 and the result expressed as a power series. The
  17694. dependent variable and expansion point of the result coincide with
  17695. those of TPS2. The following conditions apply to power series
  17696. composition:
  17697. \begin{enumerate}
  17698. \item If the expansion point of TPS1 is 0 then the order of the
  17699. TPS2 must be at least 1.
  17700. \item If the expansion point of TPS1 is finite, it should
  17701. coincide with the coefficient of the zeroth order term in TPS2.
  17702. The order of TPS2 should also be non-negative in this case.
  17703. \item If the expansion point of TPS1 is the point at infinity
  17704. then the order of TPS2 must be less than or equal to -1.
  17705. \end{enumerate}
  17706. If these conditions do not hold the series cannot be composed (with
  17707. the current algorithm terms of the inverted series would involve
  17708. infinite sums) and a \REDUCE\ error occurs.
  17709. \noindent Examples of power series composition include the following.
  17710. {\small\begin{verbatim}
  17711. a:=ps(exp y,y,0); b:=ps(sin x,x,0);
  17712. pscompose(a,b);
  17713. % Produces the power series expansion of exp(sin x)
  17714. % about x=0.
  17715. a:=ps(exp z,z,1); b:=ps(cos x,x,0);
  17716. pscompose(a,b);
  17717. % Produces the power series expansion of exp(cos x)
  17718. % about x=0.
  17719. a:=ps(cos(1/x),x,infinity); b:=ps(1/sin x,x,0);
  17720. pscompose(a,b);
  17721. % Produces the power series expansion of cos(sin x)
  17722. % about x=0.
  17723. \end{verbatim}}
  17724. \subsection{PSSUM Operator}
  17725. \index{PSSUM operator}
  17726. Syntax:
  17727. \begin{tabbing}
  17728. \hspace*{2em} {\tt PSSUM}(\=J:{\em kernel} = LOWLIM:{\em integer}, COEFF:{\em algebraic}, X:{\em kernel}, \\
  17729. \> ABOUT:{\em algebraic}, POWER:{\em algebraic}):{\em power series}
  17730. \end{tabbing}
  17731. The formal power series sum for J from LOWLIM to {\tt INFINITY} of
  17732. {\small\begin{verbatim}
  17733. COEFF*(X-ABOUT)**POWER
  17734. \end{verbatim}}
  17735. or if ABOUT is given as {\tt INFINITY}
  17736. {\small\begin{verbatim}
  17737. COEFF*(1/X)**POWER
  17738. \end{verbatim}}
  17739. is constructed and returned. This enables power series whose general
  17740. term is known to be constructed and manipulated using the other
  17741. procedures of the power series package.
  17742. J and X should be distinct simple kernels. The algebraics
  17743. ABOUT, COEFF and POWER should not depend on the
  17744. expansion variable X, similarly the algebraic ABOUT should
  17745. not depend on the summation variable J. The algebraic POWER should be
  17746. a strictly increasing integer valued function of J for J in the range
  17747. LOWLIM to {\tt INFINITY}.
  17748. {\small\begin{verbatim}
  17749. pssum(n=0,1,x,0,n*n);
  17750. % Produces the power series summation for n=0 to
  17751. % infinity of x**(n*n).
  17752. pssum(m=1,(-1)**(m-1)/(2m-1),y,1,2m-1);
  17753. % Produces the power series expansion of atan(y-1)
  17754. % about y=1.
  17755. pssum(j=1,-1/j,x,infinity,j);
  17756. % Produces the power series expansion of log(1-1/x)
  17757. % about the point at infinity.
  17758. pssum(n=0,1,x,0,2n**2+3n) + pssum(n=1,1,x,0,2n**2-3n);
  17759. % Produces the power series summation for n=-infinity
  17760. % to +infinity of x**(2n**2+3n).
  17761. \end{verbatim}}
  17762. \subsection{Arithmetic Operations}
  17763. \index{power series ! arithmetic}
  17764. As power series objects are domain elements they may be combined
  17765. together in algebraic expressions in algebraic mode of \REDUCE\ in the
  17766. normal way.
  17767. For example if A and B are power series objects then the commands such as:
  17768. \index{+ ! power series}\index{- ! power series}\index{/ ! power series}
  17769. \index{* ! power series}\index{** ! power series}
  17770. {\small\begin{verbatim}
  17771. a*b;
  17772. a**2+b**2;
  17773. \end{verbatim}}
  17774. will produce power series objects representing the product and the sum
  17775. of the squares of the power series objects A and B respectively.
  17776. \subsection{Differentiation}
  17777. \index{power series ! differentiation}
  17778. If A is a power series object depending on X then the input
  17779. {\tt df(a,x);} will produce the power series expansion of the derivative
  17780. of A with respect to X.
  17781. \section{Restrictions and Known Bugs}
  17782. If A and B are power series objects and X is a variable
  17783. which evaluates to itself then currently expressions such as {\tt a/b} and
  17784. {\tt a*x} do not evaluate to a single power series object (although the
  17785. results are in each case formally valid). Instead use {\tt ps(a/b,x,0)}
  17786. and {\tt ps(a*x,x,0)} {\em etc.}.
  17787. \chapter{TRI: TeX REDUCE interface}
  17788. \label{TRI}
  17789. \typeout{{TRI: TeX REDUCE interface}}
  17790. {\footnotesize
  17791. \begin{center}
  17792. Werner Antweiler, Andreas Strotmann and Volker Winkelmann \\
  17793. University of Cologne Computer Center,
  17794. Abt. Anwendungssoftware, Robert-Koch-Stra\ss{e} 10 \\
  17795. 5000 K"oln 41, Germany \\[0.05in]
  17796. e--mail: antweil@epas.utoronto.ca strotmann@rrz.uni-koeln.de winkelmann@rrz.uni-koeln.de
  17797. \end{center}
  17798. }
  17799. \ttindex{TRI}
  17800. The \REDUCE-\TeX-Interface incorporates three
  17801. levels of \TeX\ output: without line breaking, with line breaking,
  17802. and with line breaking plus indentation.
  17803. During loading the package some default initialisations are performed.
  17804. The default page width is set to 15 centimetres, the tolerance for
  17805. page breaking is set to 20 by default. Moreover, TRI is enabled
  17806. to translate Greek names, {\em e.g.\ }TAU or PSI, into equivalent \TeX\
  17807. symbols, {\em e.g.\ } $\tau$ or $\psi$, respectively. Letters are
  17808. printed lowercase as defined through assertion of the set
  17809. LOWERCASE.
  17810. \section{Switches for TRI}
  17811. The three TRI modes can be selected by switches, which can be used
  17812. alternatively and incrementally. Switching {\tt TEX}\ttindex{TEX} on
  17813. gives standard \TeX-output; switching {\tt TEXBREAK}\ttindex{TEXBREAK}
  17814. gives broken \TeX-output, and {\tt TEXINDENT}\ttindex{TEXINDENT} to
  17815. give broken \TeX-output plus indentation. Thus the three levels of
  17816. TRI are enabled or disabled according to:
  17817. {\small\begin{verbatim}
  17818. On TeX; % switch TeX is on
  17819. On TeXBreak; % switches TeX and TeXBreak are on
  17820. On TeXIndent; % switches TeX, TeXBreak and TeXIndent are on
  17821. Off TeXIndent; % switch TeXIndent is off
  17822. Off TeXBreak; % switches TeXBreak and TeXIndent are off
  17823. Off TeX; % all three switches are off
  17824. \end{verbatim}}
  17825. How TRI breaks multiple lines of \TeX-code may be controlled by
  17826. setting values for page width and tolerance\ttindex{TeXsetbreak}
  17827. {\small\begin{verbatim}
  17828. TeXsetbreak(page_width, tolerance);
  17829. \end{verbatim}}
  17830. Page width is measured in millimetres, and tolerance is a positive
  17831. integer in the closed interval $[0\ldots10000]$.\index{TRI ! page-width}
  17832. The higher the tolerance, the more breakpoints become feasible.
  17833. A tolerance of 0 means that actually no breakpoint will be considered
  17834. feasible, while a value of 10000 allows any breakpoint to be
  17835. considered feasible.\index{TRI ! tolerance}
  17836. For line-breaking without indentation, suitable values for the
  17837. tolerance lie between 10 and 100. As a rule of thumb, use
  17838. higher values the deeper the term is nested. If using indentation,
  17839. use much higher tolerance values; reasonable values for
  17840. tolerance here lie between 700 and 1500.
  17841. \subsection{Adding Translations}
  17842. Sometimes it is desirable to add special REDUCE-symbol-to-\TeX-item
  17843. translations. For such a task TRI provides a function
  17844. {\tt TeXlet} which binds any REDUCE-symbol to one of the predefined
  17845. \TeX-items. A call to this function has the following syntax:
  17846. \ttindex{TeXlet}
  17847. {\tt TeXlet}({\em REDUCE-symbol}, {\em \TeX-item});
  17848. For example
  17849. {\small\begin{verbatim}
  17850. TeXlet('velocity,'!v);
  17851. TeXlet('gamma,\verb|'!\!G!a!m!m!a! |);
  17852. TeXlet('acceleration,\verb|'!\!v!a!r!t!h!e!t!a! |);
  17853. \end{verbatim}}
  17854. Besides this method of single assertions one can assert
  17855. one of (currently) two standard sets providing substitutions
  17856. for lowercase and Greek letters. These sets are loaded by default.
  17857. These sets can be switched on or off using the functions
  17858. \noindent{\tt TeXassertset} {\em setname};\\
  17859. \noindent{\tt TeXretractset} {\em setname};
  17860. where the setnames currently defined are {\tt 'GREEK} and {\tt 'LOWERCASE}.
  17861. There are facilities for creating other sets of substitutions, using
  17862. the function {\tt TeXitem}\ttindex{TeXitem}.
  17863. \section{Examples of Use}
  17864. Some representative examples demonstrate the capabilities of TRI.
  17865. {\small\begin{verbatim}
  17866. load_package tri;
  17867. % TeX-REDUCE-Interface 0.50
  17868. % set greek asserted
  17869. % set lowercase asserted
  17870. % \tolerance 10
  17871. % \hsize=150mm
  17872. TeXsetbreak(150,250);
  17873. % \tolerance 250
  17874. % \hsize=150mm
  17875. on TeXindent;
  17876. (x+y)^16/(v-w)^16;
  17877. $$\displaylines{\qdd
  17878. \(x^{16}
  17879. +16\cdot x^{15}\cdot y
  17880. +120\cdot x^{14}\cdot y^{2}
  17881. +560\cdot x^{13}\cdot y^{3}
  17882. +1820\cdot x^{12}\cdot y^{4}
  17883. +4368\cdot x^{11}\cdot y^{5}\nl
  17884. \off{327680}
  17885. +8008\cdot x^{10}\cdot y^{6}
  17886. +11440\cdot x^{9}\cdot y^{7}
  17887. +12870\cdot x^{8}\cdot y^{8}
  17888. +11440\cdot x^{7}\cdot y^{9}
  17889. +8008\cdot x^{6}\cdot y^{10}\nl
  17890. \off{327680}
  17891. +4368\cdot x^{5}\cdot y^{11}
  17892. +1820\cdot x^{4}\cdot y^{12}
  17893. +560\cdot x^{3}\cdot y^{13}
  17894. +120\cdot x^{2}\cdot y^{14}
  17895. +16\cdot x\cdot y^{15}
  17896. +y^{16}
  17897. \)
  17898. /\nl
  17899. \(v^{16}
  17900. -16\cdot v^{15}\cdot w
  17901. +120\cdot v^{14}\cdot w^{2}
  17902. -560\cdot v^{13}\cdot w^{3}
  17903. +1820\cdot v^{12}\cdot w^{4}
  17904. -4368\cdot v^{11}\cdot w^{5}\nl
  17905. \off{327680}
  17906. +8008\cdot v^{10}\cdot w^{6}
  17907. -11440\cdot v^{9}\cdot w^{7}
  17908. +12870\cdot v^{8}\cdot w^{8}
  17909. -11440\cdot v^{7}\cdot w^{9}
  17910. +8008\cdot v^{6}\cdot w^{10}
  17911. -4368\cdot v^{5}\cdot w^{11}\nl
  17912. \off{327680}
  17913. +1820\cdot v^{4}\cdot w^{12}
  17914. -560\cdot v^{3}\cdot w^{13}
  17915. +120\cdot v^{2}\cdot w^{14}
  17916. -16\cdot v\cdot w^{15}
  17917. +w^{16}
  17918. \)
  17919. \Nl}$$
  17920. \end{verbatim}}
  17921. A simple example using matrices:
  17922. {\small\begin{verbatim}
  17923. load_package ri;
  17924. % TeX-REDUCE-Interface 0.50
  17925. % set greek asserted
  17926. % set lowercase asserted
  17927. % \tolerance 10
  17928. % \hsize=150mm
  17929. on Tex;
  17930. mat((1,a-b,1/(c-d)),(a^2-b^2,1,sqrt(c)),((a+b)/(c-d),sqrt(d),1));
  17931. $$
  17932. \pmatrix{1&a
  17933. -b&
  17934. \frac{1}{
  17935. c
  17936. -d}\cr
  17937. a^{2}
  17938. -b^{2}&1&
  17939. \sqrt{c}\cr
  17940. \frac{a
  17941. +b}{
  17942. c
  17943. -d}&
  17944. \sqrt{d}&1\cr
  17945. }
  17946. $$
  17947. \end{verbatim}}
  17948. Note that the resulting output uses a number of \TeX\ macros which are
  17949. defined in the file {\tt tridefs.tex} which is distributed with the
  17950. example file.
  17951. \chapter[TRIGSIMP: Trigonometric simplification]%
  17952. {TRIGSIMP: Simplification and factorisation of trigonometric
  17953. and hyperbolic functions}
  17954. \label{TRIGSIMP}
  17955. \typeout{{TRIGSIMP: Simplification and factorisation of trigonometric
  17956. and hyperbolic functions}}
  17957. {\footnotesize
  17958. \begin{center}
  17959. Wolfram Koepf, Andreas Bernig and Herbert Melenk\\
  17960. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  17961. Takustra\"se 7 \\
  17962. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  17963. e--mail: Koepf@zib.de
  17964. \end{center}
  17965. }
  17966. \ttindex{TRIGSIMP}
  17967. There are three
  17968. procedures included in TRIGSIMP: trigsimp, trigfactorize and triggcd.
  17969. The first is for finding simplifications of trigonometric or
  17970. hyperbolic expressions with many options, the second for factorising
  17971. them and the third
  17972. for finding the greatest common divisor of two trigonometric or
  17973. hyperbolic polynomials.
  17974. \section{Simplifiying trigonometric expressions}
  17975. As there is no normal form for trigonometric and hyperbolic functions,
  17976. the same function can convert in many different directions, {\em e.g. }
  17977. $\sin(2x) \leftrightarrow 2\sin(x)\cos(x)$.
  17978. The user has the possibility to give several parameters to the
  17979. procedure {\tt trigsimp} in order to influence the direction of
  17980. transformations. The decision whether a rational expression in
  17981. trigonometric and hyperbolic functions vanishes or not is possible.
  17982. \ttindex{trigsimp}
  17983. To simplify a function {\tt f}, one uses {\tt trigsimp(f[,options])}. Example:
  17984. {\small\begin{verbatim}
  17985. 2: trigsimp(sin(x)^2+cos(x)^2);
  17986. 1
  17987. \end{verbatim}}
  17988. Possible options are (* denotes the default):
  17989. \begin{enumerate}
  17990. \item {\tt sin} (*) or {\tt cos}\index{trigsimp ! sin}\index{trigsimp ! cos}
  17991. \item {\tt sinh} (*) or {\tt cosh}\index{trigsimp ! sinh}\index{trigsimp ! cosh}
  17992. \item {\tt expand} (*) or {\tt combine} or {\tt compact}\index{trigsimp ! expand}\index{trigsimp ! combine}\index{trigsimp ! compact}
  17993. \item {\tt hyp} or {\tt trig} or {\tt expon}\index{trigsimp ! hyp}\index{trigsimp ! trig}\index{trigsimp ! expon}
  17994. \item {\tt keepalltrig}\index{trigsimp ! keepalltrig}
  17995. \end{enumerate}
  17996. From each group one can use at most one option, otherwise an error
  17997. message will occur. The first group fixes the preference used while
  17998. transforming a trigonometric expression.
  17999. The second group is the equivalent for the hyperbolic functions.
  18000. The third group determines the type of transformations. With
  18001. the default {\tt expand}, an expression is written in a form only using
  18002. single arguments and no sums of arguments. With {\tt combine},
  18003. products of trigonometric functions are transformed to trigonometric
  18004. functions involving sums of arguments.
  18005. {\small\begin{verbatim}
  18006. trigsimp(sin(x)^2,cos);
  18007. 2
  18008. - cos(x) + 1
  18009. trigsimp(sin(x)*cos(y),combine);
  18010. sin(x - y) + sin(x + y)
  18011. -------------------------
  18012. 2
  18013. \end{verbatim}}
  18014. With {\tt compact}, the \REDUCE\ operator {\tt compact} (see
  18015. chapter~\ref{COMPACT}) is applied to {\tt f}.
  18016. This leads often to a simple form, but in contrast to {\tt expand} one
  18017. doesn't get a normal form.
  18018. {\small\begin{verbatim}
  18019. trigsimp((1-sin(x)**2)**20*(1-cos(x)**2)**20,compact);
  18020. 40 40
  18021. cos(x) *sin(x)
  18022. \end{verbatim}}
  18023. With the fourth group each expression is transformed to a
  18024. trigonometric, hyperbolic or exponential form:
  18025. {\small\begin{verbatim}
  18026. trigsimp(sin(x),hyp);
  18027. - sinh(i*x)*i
  18028. trigsimp(e^x,trig);
  18029. x x
  18030. cos(---) + sin(---)*i
  18031. i i
  18032. \end{verbatim}}
  18033. Usually, {\tt tan}, {\tt cot}, {\tt sec}, {\tt csc} are expressed in terms of
  18034. {\tt sin} and {\tt cos}. It can
  18035. be sometimes useful to avoid this, which is handled by the option
  18036. {\tt keepalltrig}:
  18037. {\small\begin{verbatim}
  18038. trigsimp(tan(x+y),keepalltrig);
  18039. - (tan(x) + tan(y))
  18040. ----------------------
  18041. tan(x)*tan(y) - 1
  18042. \end{verbatim}}
  18043. It is possible to use the options of different groups simultaneously.
  18044. \section{Factorising trigonometric expressions}
  18045. With {\tt trigfactorize(p,x)} one can factorise the trigonometric or
  18046. hyperbolic polynomial {\tt p} with respect to the argument x. Example:
  18047. \ttindex{trigfactorize}
  18048. {\small\begin{verbatim}
  18049. trigfactorize(sin(x),x/2);
  18050. x x
  18051. {2,cos(---),sin(---)}
  18052. 2 2
  18053. \end{verbatim}}
  18054. If the polynomial is not coordinated or balanced the output will equal
  18055. the input. In this case, changing the value for x can help to find a
  18056. factorisation:
  18057. {\small\begin{verbatim}
  18058. trigfactorize(1+cos(x),x);
  18059. {cos(x) + 1}
  18060. trigfactorize(1+cos(x),x/2);
  18061. x x
  18062. {2,cos(---),cos(---)}
  18063. 2 2
  18064. \end{verbatim}}
  18065. \section{GCDs of trigonometric expressions}
  18066. The operator {\tt triggcd}\ttindex{triggcd} is an application of {\tt
  18067. trigfactorize}. With its help the user can find the greatest common
  18068. divisor of two trigonometric or hyperbolic polynomials. The syntax is: {\tt
  18069. triggcd(p,q,x)}, where p and q are the polynomials and x is the
  18070. smallest unit to use. Example:
  18071. {\small\begin{verbatim}
  18072. triggcd(sin(x),1+cos(x),x/2);
  18073. x
  18074. cos(---)
  18075. 2
  18076. triggcd(sin(x),1+cos(x),x);
  18077. 1
  18078. \end{verbatim}}
  18079. See also the ASSIST package (chapter~\ref{ASSIST}).
  18080. \chapter{WU: Wu algorithm for poly systems}
  18081. \label{WU}
  18082. \typeout{{WU: Wu algorithm for polynomial systems}}
  18083. {\footnotesize
  18084. \begin{center}
  18085. Russell Bradford \\
  18086. School of Mathematical Sciences, University of Bath,\\
  18087. Bath, BA2 7AY, England \\[0.05in]
  18088. e--mail: rjb@maths.bath.ac.uk
  18089. \end{center}
  18090. }
  18091. \ttindex{WU}
  18092. The interface:
  18093. {\small\begin{verbatim}
  18094. 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});
  18095. \end{verbatim}}
  18096. calls {\tt wu}\ttindex{WU} with the named polynomials, and with the
  18097. variable ordering ${\tt x} > {\tt y} > {\tt z}$. In this example, {\tt
  18098. r} is a parameter.
  18099. The result is
  18100. {\small\begin{verbatim}
  18101. 2 3 2
  18102. {{{r + z - z - 1,
  18103. 2 2 2 2 4 2 2 2
  18104. r *y + r *z + r - y - y *z + z - z - 2,
  18105. 2
  18106. x*y + z - 1},
  18107. y},
  18108. 6 4 6 2 6 4 7 4 6 4 5 4 4
  18109. {{r *z - 2*r *z + r + 3*r *z - 3*r *z - 6*r *z + 3*r *z + 3*
  18110. 4 3 4 2 4 2 10 2 9 2 8 2 7
  18111. r *z + 3*r *z - 3*r + 3*r *z - 6*r *z - 3*r *z + 6*r *z +
  18112. 2 6 2 5 2 4 2 3 2 13 12 11
  18113. 3*r *z + 6*r *z - 6*r *z - 6*r *z + 3*r + z - 3*z + z
  18114. 10 9 8 7 6 4 3 2
  18115. + 2*z + z + 2*z - 6*z - z + 2*z + 3*z - z - 1,
  18116. 2 2 3 2
  18117. y *(r + z - z - 1),
  18118. 2
  18119. x*y + z - 1},
  18120. 2 3 2
  18121. y*(r + z - z - 1)}}
  18122. \end{verbatim}}
  18123. namely, a list of pairs of characteristic sets and initials for the
  18124. characteristic sets.
  18125. Thus, the first pair above has the characteristic set
  18126. $$ r^2 + z^3 - z^2 - 1,
  18127. r^2 y^2 + r^2 z + r^2 - y^4 - y^2 z^2 + z^2 - z - 2,
  18128. x y + z^2 - 1$$
  18129. and initial $y$.
  18130. According to Wu's theorem, the set of roots of the original polynomials
  18131. is the union of the sets of roots of the characteristic sets,
  18132. with the additional constraints that the corresponding initial is
  18133. non-zero. Thus, for the first pair above, we find the roots of
  18134. $\{r^2 + z^3 - z^2 - 1, \ldots~\}$ under the constraint that $y \neq 0$.
  18135. These roots, together with the roots of the other characteristic set
  18136. (under the constraint of $y(r^2+z^3-z^2-1) \neq 0$), comprise all the
  18137. roots of the original set.
  18138. \chapter[XCOLOR: Color factor in gauge theory]%
  18139. {XCOLOR: Calculation of the color factor in non-abelian gauge
  18140. field theories}
  18141. \label{XCOLOR}
  18142. \typeout{{XCOLOR: Calculation of the color factor in non-abelian gauge
  18143. field theories}}
  18144. {\footnotesize
  18145. \begin{center}
  18146. A. Kryukov \\
  18147. Institute for Nuclear Physics, Moscow State University \\
  18148. 119899, Moscow, Russia \\[0.05in]
  18149. e--mail: kryukov@npi.msu.su
  18150. \end{center}
  18151. }
  18152. \ttindex{XCOLOR}
  18153. XCOLOR calculates the colour factor in non-abelian gauge field
  18154. theories. It provides two commands and two operators.
  18155. \noindent{\tt SUdim} integer\ttindex{SUdim}
  18156. Sets the order of the SU group. The default value is 3.
  18157. \noindent{\tt SpTT} expression\ttindex{SpTT}
  18158. Sets the normalisation coefficient A in the equation
  18159. $Sp(T_i T_j) = A \Delta(i,j)$. The default value is 1/2.
  18160. \noindent{\tt QG}(inQuark, outQuark, Gluon)\ttindex{QG}
  18161. Describes the quark-gluon vertex. The parameters may be any identifiers.
  18162. The first and second of then must be in- and out- quarks correspondingly.
  18163. Third one is a gluon.
  18164. \noindent{\tt G3}(Gluon1, Gluon2, Gluon3)\ttindex{G3}
  18165. Describes the three-gluon vertex. The parameters may be any identifiers.
  18166. The order of gluons must be clockwise.
  18167. In terms of QG and G3 operators one can input a diagram in ``color'' space as
  18168. a product of these operators. For example
  18169. \newpage
  18170. {\small\begin{verbatim}
  18171. e1
  18172. ---->---
  18173. / \
  18174. / \
  18175. | e2 |
  18176. v1*............*v2
  18177. | |
  18178. \ /
  18179. \ e3 /
  18180. ----<---
  18181. \end{verbatim}}
  18182. where \verb+--->---+ is a quark and \verb+.......+ is a gluon.
  18183. The related \REDUCE\ expression is {\tt QG(e3,e1,e2)*QG(e1,e3,e2)}.
  18184. \chapter{XIDEAL: Gr\"obner for exterior algebra}
  18185. \label{XIDEAL}
  18186. \typeout{{XIDEAL: Gr\"obner Bases for exterior algebra}}
  18187. {\footnotesize
  18188. \begin{center}
  18189. David Hartley \\
  18190. GMD, Institute I1, Schloss Birlinghoven \\
  18191. D--53757 St. Augustin, Germany \\[0.05in]
  18192. e--mail: David.Hartley@gmd.de \\[0.1in]
  18193. and \\
  18194. Philip A.~Tuckey \\
  18195. Max Planck Institute for Physics \\
  18196. Foehringer Ring 6 \\
  18197. D--80805 Munich, Germany \\[0.05in]
  18198. e--mail: pht@iws170.mppmu.mpg.de
  18199. \end{center}
  18200. }
  18201. \ttindex{XIDEAL}
  18202. XIDEAL extends the Gr\"obner base method to exterior algebras.
  18203. XIDEAL constructs Gr\"obner bases for solving the left ideal membership
  18204. problem: Gr\"obner left ideal bases or GLIBs. For graded ideals, where each
  18205. form is homogeneous in degree, the distinction between left and right
  18206. ideals vanishes. Furthermore, if the generating forms are all homogeneous,
  18207. then the Gr\"obner bases for the non-graded and graded ideals are
  18208. identical. In this case, XIDEAL is able to save time by truncating the
  18209. Gr\"obner basis at some maximum degree if desired.
  18210. XIDEAL uses the EXCALC package (chapter~\ref{EXCALC}).
  18211. \section{Operators}
  18212. \subsubsection*{XIDEAL}
  18213. \f{XIDEAL} calculates a Gr\"obner left ideal basis in
  18214. an exterior algebra. The syntax is\ttindex{XIDEAL}
  18215. {\small\begin{verbatim}
  18216. XIDEAL(S:list of forms[,R:integer]):list of forms.
  18217. \end{verbatim}}
  18218. \f{XIDEAL} calculates the Gr\"obner left ideal basis for the left ideal
  18219. generated by \f{S} using graded lexicographical ordering based on the
  18220. current kernel ordering. The resulting list can be used for subsequent
  18221. reductions with \f{XMODULOP} as long as the kernel ordering is not
  18222. changed. If the set of generators \f{S} is graded, an optional parameter
  18223. \f{R} can be given, and \f{XIDEAL} produces a truncated basis suitable for
  18224. reducing exterior forms of degree less than or equal to \f{R} in the left
  18225. ideal. This can save time and space with large expressions, but the result
  18226. cannot be used for exterior forms of degree greater than \f{R}. See also
  18227. the switches \f{XSTATS} and \f{XFULLREDUCTION}.
  18228. \subsubsection*{XMODULO}
  18229. \f{XMODULO} reduces exterior forms to their (unique) normal forms modulo a
  18230. left ideal. The syntax is\ttindex{XMODULO}
  18231. {\small\begin{verbatim}
  18232. XMODULO(F:form, S:list of forms):form
  18233. \end{verbatim}}
  18234. or
  18235. {\small\begin{verbatim}
  18236. XMODULO(F:list of forms, S:list of forms):list of forms.
  18237. \end{verbatim}}
  18238. An alternative infix syntax is also available:
  18239. {\small\begin{verbatim}
  18240. F XMODULO S.
  18241. \end{verbatim}}
  18242. \f{XMODULO(F,S)} first calculates a Gr\"obner basis for the left ideal
  18243. generated by \f{S}, and then reduces \f{F}. \f{F} may be either a single
  18244. exterior form, or a list of forms, and \f{S} is a list of forms. If \f{F}
  18245. is a list of forms, each element is reduced, and any which vanish are
  18246. deleted from the result. If this operator is used more than once, and
  18247. \f{S} does not change between calls, then the Gr\"obner basis is not
  18248. recalculated. If the set of generators \f{S} is graded, then a truncated
  18249. Gr\"obner basis is calculated using the degree of \f{F} (or the maximal
  18250. degree in \f{F}).
  18251. \subsubsection*{XMODULOP}
  18252. \f{XMODULOP} reduces exterior forms to their (not necessarily unique)
  18253. normal forms modulo a set of exterior polynomials. The syntax
  18254. is\ttindex{XMODULOP}
  18255. {\small\begin{verbatim}
  18256. XMODULOP(F:form, S:list of forms):form
  18257. \end{verbatim}}
  18258. or
  18259. {\small\begin{verbatim}
  18260. XMODULOP(F:list of forms, S:list of forms):list of forms.
  18261. \end{verbatim}}
  18262. An alternative infix syntax is also available:
  18263. {\small\begin{verbatim}
  18264. F XMODULOP S.
  18265. \end{verbatim}}
  18266. \f{XMODULOP(F,S)} reduces \f{F} with respect to the set of exterior
  18267. polynomials \f{S}, which is not necessarily a Gr\"obner basis. \f{F} may be
  18268. either a single exterior form, or a list of forms, and \f{S} is a list of
  18269. forms. This operator can be used in conjunction with \f{XIDEAL} to produce
  18270. the same effect as \f{XMODULO}: for a single form \f{F} in an ideal
  18271. generated by the graded set \f{S}, \f{F XMODULO S} is equivalent to \f{F
  18272. XMODULOP XIDEAL(S,EXDEGREE F)}.
  18273. \section{Switches}
  18274. \subsubsection*{XFULLREDUCE}
  18275. \f{ON XFULLREDUCE}\ttindex{XFULLREDUCE} allows \f{XIDEAL} and
  18276. \f{XMODULO} to calculate reduced (but not necessarily normed)
  18277. Gr\"obner bases, which speeds up subsequent reductions, and guarantees
  18278. a unique form (up to scaling) for the Gr\"obner basis. \f{OFF
  18279. XFULLREDUCE} turns of this feature, which may speed up calculation of
  18280. the Gr\"obner basis. \f{XFULLREDUCE} is \f{ON} by default.
  18281. \subsubsection*{XSTATS}
  18282. \f{ON XSTATS}\ttindex{XSTATS} produces counting and timing
  18283. information. As \f{XIDEAL} is running, a hash mark (\verb.#.) is
  18284. printed for each form taken from the input list, followed by a
  18285. sequences of carets (\verb.^.) and dollar signs (\verb.$.). Each caret
  18286. represents a new basis element obtained by a simple wedge product, and
  18287. each dollar sign represents a new basis element obtained from an
  18288. S-polynomial. At the end, a table is printed summarising the
  18289. calculation. \f{XSTATS} is \f{OFF} by default.
  18290. \section{Examples}
  18291. Suppose EXCALC and XIDEAL have been loaded, the switches are at their
  18292. default settings, and the following exterior variables have been declared:
  18293. {\small\begin{verbatim}
  18294. pform x=0,y=0,z=0,t=0,f(i)=1,h=0,hx=0,ht=0;
  18295. \end{verbatim}}
  18296. In a commutative polynomial ring, a single polynomial is its own Gr\"obner
  18297. basis. This is no longer true for exterior algebras because of the presence
  18298. of zero divisors, and can lead to some surprising reductions:
  18299. {\small\begin{verbatim}
  18300. xideal {d x^d y - d z^d t};
  18301. {d T^d Z + d X^d Y,
  18302. d X^d Y^d Z,
  18303. d T^d X^d Y}
  18304. f(3)^f(4)^f(5)^f(6)
  18305. xmodulo {f(1)^f(2) + f(3)^f(4) + f(5)^f(6)};
  18306. 0
  18307. \end{verbatim}}
  18308. The heat equation, $h_{xx}=h_t$ can be represented by the following
  18309. exterior differential system.
  18310. {\small\begin{verbatim}
  18311. S := {d h - ht*d t - hx*d x,
  18312. d ht^d t + d hx^d x,
  18313. d hx^d t - ht*d x^d t};
  18314. \end{verbatim}}
  18315. \f{XMODULO} can be used to check that the exterior differential system is
  18316. closed under exterior differentiation.
  18317. {\small\begin{verbatim}
  18318. d S xmodulo S;
  18319. {}
  18320. \end{verbatim}}
  18321. Non-graded left and right ideals are no longer the same:
  18322. {\small\begin{verbatim}
  18323. d t^(d z+d x^d y) xmodulo {d z+d x^d y};
  18324. 0
  18325. (d z+d x^d y)^d t xmodulo {d z+d x^d y};
  18326. - 2*d t^d z
  18327. \end{verbatim}}
  18328. Higher order forms can now reduce lower order ones:
  18329. {\small\begin{verbatim}
  18330. d x xmodulo {d y^d z + d x,d x^d y + d z};
  18331. 0
  18332. \end{verbatim}}
  18333. Any form containing a 0-form term generates the whole ideal:
  18334. {\small\begin{verbatim}
  18335. xideal {1 + f(1) + f(1)^f(2) + f(2)^f(3)^f(4)};
  18336. {1}
  18337. \end{verbatim}}
  18338. \chapter[ZEILBERG: Indef \& definite summation]%
  18339. {ZEILBERG: A package for indefinite and definite summation}
  18340. \label{ZEILBERG}
  18341. \typeout{{ZEILBERG: A package for indefinite and definite summation}}
  18342. {\footnotesize
  18343. \begin{center}
  18344. Wolfram Koepf and Gregor St\"olting \\
  18345. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  18346. Takustra\"se 7 \\
  18347. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  18348. e--mail: Koepf@zib.de
  18349. \end{center}
  18350. }
  18351. \ttindex{ZEILBERG}
  18352. \newcommand{\N} {{\rm {\mbox{\protect\makebox[.15em][l]{I}N}}}}
  18353. The ZEILBERG package provides an implementation of the Gosper and
  18354. Zeilberger algorithms for indefinite, and definite summation of
  18355. hypergeometric terms, respectively, with extensions for ratios of
  18356. products of powers, factorials, $\Gamma$ function terms, binomial
  18357. coefficients, and shifted factorials that are rational-linear in their
  18358. arguments.
  18359. \section{The GOSPER summation operator}
  18360. The {\tt gosper}\ttindex{gosper} operator is an implementation of the
  18361. Gosper algorithm.
  18362. \begin{itemize}
  18363. \item
  18364. {\tt gosper(a,k)} determines a closed form antidifference. If it does
  18365. not return a closed form solution, then a closed form solution does
  18366. not exist.
  18367. \item
  18368. {\tt gosper(a,k,m,n)} determines
  18369. \[
  18370. \sum_{k=m}^n a_k
  18371. \]
  18372. using Gosper's algorithm. This is only successful if Gosper's
  18373. algorithm applies.
  18374. \end{itemize}
  18375. Example:
  18376. {\small\begin{verbatim}
  18377. gosper((-1)^(k+1)*(4*k+1)*factorial(2*k)/
  18378. (factorial(k)*4^k*(2*k-1)*factorial(k+1)),k);
  18379. k
  18380. - ( - 1) *factorial(2*k)
  18381. ------------------------------------
  18382. 2*k
  18383. 2 *factorial(k + 1)*factorial(k)
  18384. gosper(binomial(k,n),k);
  18385. (k + 1)*binomial(k,n)
  18386. -----------------------
  18387. n + 1
  18388. \end{verbatim}}
  18389. \section{EXTENDED\_GOSPER operator}
  18390. The {\tt extended\_gosper}\ttindex{extended\_gosper} operator is an
  18391. implementation of an extended version of Gosper's algorithm.
  18392. \begin{itemize}
  18393. \item
  18394. {\tt extended\_gosper(a,k)} determines an antidifference $g_k$ of $a_k$
  18395. whenever there is a number $m$ such that $h_{k}-h_{k-m}=a_k$, and $h_k$ is an
  18396. {\sl $m$-fold hypergeometric term}, i.\ e.
  18397. \[
  18398. h_{k}/h_{k-m}\quad\mbox{is a rational function with respect to $k$.}
  18399. \]
  18400. If it does not return a solution, then such a solution does not exist.
  18401. \item
  18402. {\tt extended\_gosper(a,k,m)}
  18403. determines an {\sl $m$-fold antidifference} $h_k$ of $a_k$,
  18404. i.\ e.\ $h_{k}-h_{k-m}=a_k$, if it is an $m$-fold hypergeometric term.
  18405. \end{itemize}
  18406. Examples:
  18407. {\small\begin{verbatim}
  18408. extended_gosper(binomial(k/2,n),k);
  18409. k k - 1
  18410. (k + 2)*binomial(---,n) + (k + 1)*binomial(-------,n)
  18411. 2 2
  18412. -------------------------------------------------------
  18413. 2*(n + 1)
  18414. extended_gosper(k*factorial(k/7),k,7);
  18415. k
  18416. (k + 7)*factorial(---)
  18417. 7
  18418. \end{verbatim}}
  18419. \section{SUMRECURSION operator}
  18420. The {\tt sumrecursion}\ttindex{sumrecursion} operator is an
  18421. implementation of the (fast) Zeilberger algorithm.
  18422. \begin{itemize}
  18423. \item
  18424. {\tt sumrecursion(f,k,n)} determines a holonomic recurrence equation
  18425. for
  18426. \[
  18427. {\tt sum(n)} =\sum\limits_{k=-\infty}^\infty f(n,k)
  18428. \]
  18429. with respect to $n$. %%, applying {\tt extended\_sumrecursion} if necessary
  18430. %%(section~\ref{sec:EXTENDED_SUMRECURSION}).
  18431. The resulting expression equals zero.
  18432. \item
  18433. {\tt sumrecursion(f,k,n,j)}
  18434. searches for a holonomic recurrence equation of order $j$.%% This
  18435. %%operator does not use
  18436. %%{\tt extended\_sumrecursion} automatically.
  18437. Note that if $j$ is too large, the recurrence equation
  18438. may not be unique, and only one particular solution is returned.
  18439. \end{itemize}
  18440. {\small\begin{verbatim}
  18441. sumrecursion(binomial(n,k),k,n);
  18442. 2*sum(n - 1) - sum(n)
  18443. \end{verbatim}}
  18444. %%\section{EXTENDED\_SUMRECURSION operator}
  18445. %%\label{sec:EXTENDED_SUMRECURSION}
  18446. %%
  18447. %%The {\tt extended\_sumrecursion}\ttindex{extended\_sumrecursion}
  18448. %%operator uses extension to handle hypergeometric terms. As {\tt
  18449. %%sumrecusion} uses this algorithm automatically in the case of three
  18450. %%arguments, it is only needed in the four argument case, or for
  18451. %%detailed investigations. More details may be found in the on-line
  18452. %%documentation.
  18453. \section{HYPERRECURSION operator}
  18454. If a recursion for a generalised hypergeometric function is to be
  18455. established, one can use
  18456. \begin{itemize}
  18457. \item
  18458. {\tt hyperrecursion(upper,lower,x,n)}\ttindex{hyperrecursion}
  18459. determines a holonomic recurrence equation with respect to $n$ for
  18460. \[_{p}F_{q}\left.\left(\begin{array}{cccc}
  18461. a_{1},&a_{2},&\cdots,&a_{p}\\
  18462. b_{1},&b_{2},&\cdots,&b_{q}\\
  18463. \end{array}\right| x\right) ,
  18464. \] where {\tt upper}$=\{a_{1}, a_{2}, \ldots, a_{p}\}$
  18465. is the list of upper parameters, and
  18466. {\tt lower}$=\{b_{1}, b_{2}, \ldots, b_{q}\}$
  18467. is the list of lower parameters depending on $n$.
  18468. \item
  18469. {\tt hyperrecursion(upper,lower,x,n,j)} $(j\in\N)$
  18470. searches only for a holonomic recurrence equation of order $j$. This
  18471. operator does not automatically use {\tt extended\_sumrecursion}.
  18472. \end{itemize}
  18473. {\small\begin{verbatim}
  18474. hyperrecursion({-n,b},{c},1,n);
  18475. (b - c - n + 1)*sum(n - 1) + (c + n - 1)*sum(n)
  18476. \end{verbatim}}
  18477. If a hypergeometric expression is given in hypergeometric notation, then
  18478. the use of {\tt hyperrecursion} is more natural than the use of
  18479. {\tt sumrecursion}.
  18480. Moreover the \REDUCE\ operator
  18481. \begin{itemize}
  18482. \item
  18483. {\tt hyperterm(upper,lower,x,k)}\ttindex{hyperterm} yields the
  18484. hypergeometric term
  18485. \[
  18486. \frac
  18487. {(a_{1})_{k}\cdot(a_{2})_{k}\cdots(a_{p})_{k}}
  18488. {(b_{1})_{k}\cdot(b_{2})_{k}\cdots(b_{q})_{k}\,k!}x^{k}
  18489. \]
  18490. with upper parameters {\tt upper}$=\{a_{1}, a_{2}, \ldots, a_{p}\}$,
  18491. and lower parameters {\tt lower}$=\{b_{1}, b_{2}, \ldots, b_{q}\}$
  18492. \end{itemize}
  18493. in connection with hypergeometric terms.
  18494. \section{HYPERSUM operator}
  18495. With the operator {\tt hypersum}\ttindex{hypersum}, hypergeometric
  18496. sums are directly evaluated in closed form whenever the extended
  18497. Zeilberger algorithm leads to a recurrence equation containing only
  18498. two terms:
  18499. \begin{itemize}
  18500. \item
  18501. {\tt hypersum(upper,lower,x,n)} determines a closed form representation
  18502. for\\
  18503. $_{p}F_{q}\left.\left(\begin{array}{cccc}
  18504. a_{1},&a_{2},&\cdots,&a_{p}\\
  18505. b_{1},&b_{2},&\cdots,&b_{q}\\
  18506. \end{array}\right| x\right)
  18507. $, where {\tt upper}$=\{a_{1}, a_{2}, \ldots, a_{p}\}$
  18508. is the list of upper parameters, and
  18509. {\tt lower}$=\{b_{1}, b_{2}, \ldots, b_{q}\}$
  18510. is the list of lower parameters depending on $n$. The result is given as a
  18511. hypergeometric term with respect to $n$.
  18512. If the result is a list of length $m$, we call it $m$-{\sl fold symmetric},
  18513. which is to be interpreted as follows:
  18514. Its $j^{th}$ part is the solution valid for all $n$ of the form $n=mk+j-1
  18515. \;(k\in\N_0)$.
  18516. In particular, if the resulting list contains two terms, then the
  18517. first part is the solution for even $n$, and the second part is the
  18518. solution for odd $n$.
  18519. \end{itemize}
  18520. {\small\begin{verbatim}
  18521. hypersum({a,1+a/2,c,d,-n},{a/2,1+a-c,1+a-d,1+a+n},1,n);
  18522. pochhammer(a - c - d + 1,n)*pochhammer(a + 1,n)
  18523. -------------------------------------------------
  18524. pochhammer(a - c + 1,n)*pochhammer(a - d + 1,n)
  18525. hypersum({a,1+a/2,d,-n},{a/2,1+a-d,1+a+n},-1,n);
  18526. pochhammer(a + 1,n)
  18527. -------------------------
  18528. pochhammer(a - d + 1,n)
  18529. \end{verbatim}}
  18530. Note that the operator {\tt togamma}\ttindex{togamma} converts
  18531. expressions given in factorial-$\Gamma$-binomial-Pochhammer notation
  18532. into a pure $\Gamma$ function representation:
  18533. {\small\begin{verbatim}
  18534. togamma(hypersum({a,1+a/2,d,-n},{a/2,1+a-d,1+a+n},-1,n));
  18535. gamma(a - d + 1)*gamma(a + n + 1)
  18536. -----------------------------------
  18537. gamma(a - d + n + 1)*gamma(a + 1)
  18538. \end{verbatim}}
  18539. \section{SUMTOHYPER operator}
  18540. With the operator {\tt sumtohyper}\ttindex{sumtohyper}, sums given in
  18541. factorial-$\Gamma$-binomial-Poch\-hammer notation are converted into
  18542. hypergeometric notation.
  18543. \begin{itemize}
  18544. \item
  18545. {\tt sumtohyper(f,k)} determines the hypergeometric representation
  18546. of\linebreak
  18547. $\sum\limits_{k=-\infty}^\infty f_k$, {\em i.e.\ } its output is {\tt
  18548. c*hypergeometric(upper,lower,x)}, corresponding to
  18549. the representation
  18550. \[
  18551. \sum\limits_{k=-\infty}^\infty f_k=c\cdot\;
  18552. _{p}F_{q}\left.\left(\begin{array}{cccc}
  18553. a_{1},&a_{2},&\cdots,&a_{p}\\
  18554. b_{1},&b_{2},&\cdots,&b_{q}\\
  18555. \end{array}\right| x\right)
  18556. \;,
  18557. \]
  18558. where {\tt upper}$=\{a_{1}, a_{2}, \ldots, a_{p}\}$
  18559. and {\tt lower}$=\{b_{1}, b_{2}, \ldots, b_{q}\}$
  18560. are the lists of upper and lower parameters.
  18561. \end{itemize}
  18562. Examples:
  18563. {\small\begin{verbatim}
  18564. sumtohyper(binomial(n,k)^3,k);
  18565. hypergeometric({ - n, - n, - n},{1,1},-1)
  18566. \end{verbatim}}
  18567. \section{Simplification Operators}
  18568. For the decision that an expression $a_k$ is a hypergeometric term, it is
  18569. necessary to find out whether or not $a_{k}/a_{k-1}$ is a rational
  18570. function with respect to $k$. For the purpose to decide
  18571. whether or not an expression involving powers, factorials,
  18572. $\Gamma$ function terms,
  18573. binomial coefficients, and Pochhammer symbols is a hypergeometric term,
  18574. the following simplification operators can be used:
  18575. \begin{itemize}
  18576. \item
  18577. {\tt simplify\_gamma(f)}\ttindex{simplify\_gamma} simplifies an
  18578. expression {\tt f} involving only rational, powers and $\Gamma$
  18579. function terms.
  18580. \item
  18581. {\tt simplify\_combinatorial(f)}\ttindex{simplify\_combinatorial}
  18582. simplifies an expression {\tt f} involving powers, factorials,
  18583. $\Gamma$ function terms, binomial coefficients, and Pochhammer symbols
  18584. by converting factorials, binomial coefficients, and Poch\-hammer
  18585. symbols into $\Gamma$ function terms, and applying {\tt
  18586. simplify\_gamma} to its result. If the output is not rational, it is
  18587. given in terms of $\Gamma$ functions. If factorials are preferred use
  18588. \item
  18589. {\tt gammatofactorial} (rule)\ttindex{gammatofactorial} converting $\Gamma$ function terms into
  18590. factorials using $\Gamma\:(x)\rightarrow (x-1)!$.
  18591. \item
  18592. {\tt simplify\_gamma2(f)}\ttindex{simplify\_gamma2}
  18593. uses the duplication formula of the $\Gamma$ function to simplify $f$.
  18594. \item
  18595. {\tt simplify\_gamman(f,n)}\ttindex{simplify\_gamman}
  18596. uses the multiplication formula of the $\Gamma$ function to simplify $f$.
  18597. \end{itemize}
  18598. The use of {\tt simplify\_combinatorial(f)} is a safe way to
  18599. decide the rationality for any ratio of products of powers, factorials,
  18600. $\Gamma$ function terms, binomial coefficients, and Pochhammer symbols.
  18601. Example:
  18602. {\small\begin{verbatim}
  18603. simplify_gamma2(gamma(2*n)/gamma(n));
  18604. 2*n 2*n + 1
  18605. 2 *gamma(---------)
  18606. 2
  18607. -----------------------
  18608. 2*sqrt(pi)
  18609. \end{verbatim}}
  18610. \chapter{ZTRANS: $Z$-transform package}
  18611. \label{ZTRANS}
  18612. \typeout{{ZTRANS: $Z$-transform package}}
  18613. {\footnotesize
  18614. \begin{center}
  18615. Wolfram Koepf and Lisa Temme \\
  18616. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  18617. Takustra\"se 7 \\
  18618. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  18619. e--mail: Koepf@zib.de
  18620. \end{center}
  18621. }
  18622. \ttindex{ZTRANS}
  18623. The $Z$-Transform of a sequence $\{f_n\}$ is the discrete analogue
  18624. of the Laplace Transform, and
  18625. \[{\cal Z}\{f_n\} = F(z) = \sum^\infty_{n=0} f_nz^{-n}\;.\] \\
  18626. This series converges in the region outside the circle
  18627. $|z|=|z_0|= \limsup\limits_{n \rightarrow \infty} \sqrt[n]{|f_n|}\;.$
  18628. In the same way that a Laplace Transform can be used to
  18629. solve differential equations, so $Z$-Transforms can be used
  18630. to solve difference equations.
  18631. \begin{tabbing}
  18632. {\bf SYNTAX:}\ \ {\tt ztrans($f_n$, n, z)}\ \ \ \ \ \ \ \
  18633. \=where $f_n$ is an expression, and $n$,$z$ \\
  18634. \> are identifiers.\\
  18635. \end{tabbing}
  18636. \ttindex{ztrans}
  18637. \begin{tabbing}
  18638. This pack\=age can compute the \= $Z$-Transforms of the \=following
  18639. list of $f_n$, and \\ certain combinations thereof.\\ \\
  18640. \>$1$
  18641. \>$e^{\alpha n}$
  18642. \>$\frac{1}{(n+k)}$ \\ \\
  18643. \>$\frac{1}{n!}$
  18644. \>$\frac{1}{(2n)!}$
  18645. \>$\frac{1}{(2n+1)!}$ \\ \\
  18646. \>$\frac{\sin(\beta n)}{n!}$
  18647. \>$\sin(\alpha n+\phi)$
  18648. \>$e^{\alpha n} \sin(\beta n)$ \\ \\
  18649. \>$\frac{\cos(\beta n)}{n!}$
  18650. \>$\cos(\alpha n+\phi)$
  18651. \>$e^{\alpha n} \cos(\beta n)$ \\ \\
  18652. \>$\frac{\sin(\beta (n+1))}{n+1}$
  18653. \>$\sinh(\alpha n+\phi)$
  18654. \>$\frac{\cos(\beta (n+1))}{n+1}$ \\ \\
  18655. \>$\cosh(\alpha n+\phi)$
  18656. \>${n+k \choose m}$\\
  18657. \end{tabbing}
  18658. \begin{tabbing}
  18659. \underline {{\bf Other Combinations}}\= \\ \\
  18660. \underline {Linearity}
  18661. \>${\cal Z} \{a f_n+b g_n \} = a{\cal Z} \{f_n\}+b{\cal Z}\{g_n\}$
  18662. \\ \\
  18663. \underline {Multiplication by $n$}
  18664. \>${\cal Z} \{n^k \cdot f_n\} = -z \frac{d}{dz} \left({\cal Z}\{n^{k-1} \cdot f_n,n,z\} \right)$
  18665. \\ \\
  18666. \underline {Multiplication by $\lambda^n$}
  18667. \>${\cal Z} \{\lambda^n \cdot f_n\}=F \left(\frac{z}{\lambda}\right)$
  18668. \\ \\
  18669. \underline {Shift Equation}
  18670. \>${\cal Z} \{f_{n+k}\} =
  18671. z^k \left(F(z) - \sum\limits^{k-1}_{j=0} f_j z^{-j}\right)$
  18672. \\ \\
  18673. \underline {Symbolic Sums}
  18674. \> ${\cal Z} \left\{ \sum\limits_{k=0}^{n} f_k \right\} =
  18675. \frac{z}{z-1} \cdot {\cal Z} \{f_n\}$ \\ \\
  18676. \>${\cal Z} \left\{ \sum\limits_{k=p}^{n+q} f_k \right\}$
  18677. \ \ \ combination of the above \\ \\
  18678. where $k$,$\lambda \in$ {\bf N}$- \{0\}$; and $a$,$b$ are variables
  18679. or fractions; and $p$,$q \in$ {\bf Z} or \\
  18680. are functions of $n$; and $\alpha$, $\beta$ and $\phi$ are angles
  18681. in radians.
  18682. \end{tabbing}
  18683. The calculation of the Laurent coefficients of a regular function
  18684. results in the following inverse formula for the $Z$-Transform:
  18685. If $F(z)$ is a regular function in the region $|z|> \rho$ then
  18686. $\exists$ a sequence \{$f_n$\} with ${\cal Z} \{f_n\}=F(z)$
  18687. given by \[f_n = \frac{1}{2 \pi i}\oint F(z) z^{n-1} dz\]
  18688. \begin{tabbing}
  18689. {\bf SYNTAX:}\ \ {\tt invztrans($F(z)$, z, n)}\ \ \ \ \ \ \ \
  18690. \=where $F(z)$ is an expression, \\
  18691. \> and $z$,$n$ are identifiers.
  18692. \end{tabbing}
  18693. \ttindex{invztrans}
  18694. \begin{tabbing}
  18695. This \= package can compute the Inverse \= Z-Transforms of any
  18696. rational function, \\ whose denominator can be factored over
  18697. ${\bf Q}$, in addition to the following list \\ of $F(z)$.\\ \\
  18698. \> $\sin \left(\frac{\sin (\beta)}{z} \ \right)
  18699. e^{\left(\frac{\cos (\beta)}{z} \ \right)}$
  18700. \> $\cos \left(\frac{\sin (\beta)}{z} \ \right)
  18701. e^{\left(\frac{\cos (\beta)}{z} \ \right)}$ \\ \\
  18702. \> $\sqrt{\frac{z}{A}} \sin \left( \sqrt{\frac{z}{A}} \ \right)$
  18703. \> $\cos \left( \sqrt{\frac{z}{A}} \ \right)$ \\ \\
  18704. \> $\sqrt{\frac{z}{A}} \sinh \left( \sqrt{\frac{z}{A}} \ \right)$
  18705. \> $\cosh \left( \sqrt{\frac{z}{A}} \ \right)$ \\ \\
  18706. \> $z \ \log \left(\frac{z}{\sqrt{z^2-A z+B}} \ \right)$
  18707. \> $z \ \log \left(\frac{\sqrt{z^2+A z+B}}{z} \ \right)$ \\ \\
  18708. \> $\arctan \left(\frac{\sin (\beta)}{z+\cos (\beta)} \ \right)$
  18709. \\
  18710. \end{tabbing}
  18711. here $k$,$\lambda \in$ {\bf N}$ - \{0\}$ and $A$,$B$ are fractions
  18712. or variables ($B>0$) and $\alpha$,$\beta$, \& $\phi$ are angles
  18713. in radians.
  18714. Examples:
  18715. {\small\begin{verbatim}
  18716. ztrans(sum(1/factorial(k),k,0,n),n,z);
  18717. 1/z
  18718. e *z
  18719. --------
  18720. z - 1
  18721. invztrans(z/((z-a)*(z-b)),z,n);
  18722. n n
  18723. a - b
  18724. ---------
  18725. a - b
  18726. \end{verbatim}}
  18727. %\documentstyle[11pt,reduce]{article}
  18728. \part{Standard Lisp Report}
  18729. \setcounter{examplectr}{0}
  18730. \chapter{The Standard Lisp Report}
  18731. \label{SL}
  18732. \typeout{{The Standard Lisp Report}}
  18733. {\footnotesize
  18734. \begin{center}
  18735. Jed Marti \\ A. C. Hearn \\ M. L. Griss \\ C. Griss
  18736. \end{center}
  18737. }
  18738. \ttindex{Standard Lisp Report}
  18739. %%% Function/method definition.
  18740. %%% de{fname}{arglist}{type}{text} For short arg lists.
  18741. %%% DE{fname}{arglist}{type}{text} For long arg lists.
  18742. \newlength{\argwidth} % Width of argument box.
  18743. \setlength{\argwidth}{4in}
  18744. \newlength{\dewidth}
  18745. \setlength{\dewidth}{4.5in} % Width of text box.
  18746. \newcommand{\de}[4]
  18747. {\vspace{.25in} \noindent
  18748. \begin{minipage}[t]{\textwidth} \index{#1} {\f{#1}}{#2}\hfill{\em #3} \\
  18749. \hspace*{.25in}\begin{minipage}[t]{\dewidth} #4 \end{minipage}
  18750. \end{minipage} }
  18751. %%% Global/fluid variable description.
  18752. %%% variable{name}{initial value}{type}{text}
  18753. \newcommand{\variable}[4]
  18754. {\vspace{.25in} \noindent
  18755. \begin{minipage}[t]{\textwidth} \index{#1 (#3)} {\bf #1} = #2 \hfill {\em #3}
  18756. \\
  18757. \hspace*{.25in} \ \begin{minipage}[t]{\dewidth} #4 \end{minipage}
  18758. \end{minipage}}
  18759. %%% Command to display an error or warning message in teletype format. Also
  18760. %%% leaves blank vertical space around it.
  18761. \newcommand{\errormessage}[1]
  18762. {\vspace{.1in} \noindent {\tt #1} \\ \vspace{.1in}}
  18763. %%% \p is a parameter name (or argument). Just do this as bf.
  18764. \newcommand{\p}[1] {{\bf #1}}
  18765. %%% \ty is a type - do as italics.
  18766. \newcommand{\ty}[1] {{\em #1}}
  18767. %\begin{document}
  18768. %\maketitle
  18769. \section{Introduction}
  18770. Although the programming language LISP was first formulated in
  18771. 1960~\cite{LISP1.5}, a widely accepted standard has never appeared. As
  18772. a result, various dialects of LISP were
  18773. produced~\cite{CDC-LISP,LISP/360,MACLISP,Interlisp,LISPF1,LISP1.6} in
  18774. some cases several on the same machine! Consequently, a user often
  18775. faces considerable difficulty in moving programs from one system to
  18776. another. In addition, it is difficult to write and use programs which
  18777. depend on the structure of the source code such as translators,
  18778. editors and cross-reference programs.
  18779. In 1969, a model for such a standard was produced~\cite{Hearn:69} as
  18780. part of a general effort to make a large LISP based algebraic
  18781. manipulation program, REDUCE~\cite{REDUCE3.3}, as portable as
  18782. possible. The goal of this work was to define a uniform subset of
  18783. LISP 1.5 and its variants so that programs written in this subset
  18784. could run on any reasonable LISP system.
  18785. In the intervening years, two deficiencies in the approach taken in
  18786. Ref.~\cite{Hearn:69} have emerged. First in order to be as general as
  18787. possible, the specific semantics and values of several key functions
  18788. were left undefined. Consequently, programs built on this subset could
  18789. not make any assumptions about the form of the values of such
  18790. functions. The second deficiency related to the proposed method of
  18791. implementation of this language. The model considered in effect two
  18792. versions of LISP on any given machine, namely Standard LISP and the
  18793. LISP of the host machine (which we shall refer to as Target LISP).
  18794. This meant that if any definition was stored in interpretive form, it
  18795. would vary from implementation to implementation, and consequently one
  18796. could not write programs in Standard LISP which needed to assume any
  18797. knowledge about the structure of such forms. This deficiency became
  18798. apparent during recent work on the development of a portable compiler
  18799. for LISP~\cite{PLC}. Clearly a compiler has to know precisely the
  18800. structure of its source code; we concluded that the appropriate source
  18801. was Standard LISP and not Target LISP.
  18802. With these thoughts in mind we decided to attempt again a definition
  18803. of Standard LISP. However, our approach this time is more aggressive.
  18804. In this document we define a standard for a reasonably large subset of
  18805. LISP with as precise as possible a statement about the semantics of
  18806. each function. Secondly, we now require that the target machine
  18807. interpreter be modified or written to support this standard, rather
  18808. than mapping Standard LISP onto Target LISP as previously.
  18809. We have spent countless hours in discussion over many of the
  18810. definitions given in this report. We have also drawn on the help and
  18811. advice of a lot of friends whose names are given in the
  18812. Acknowledgements. Wherever possible, we have used the definition of a
  18813. function as given in the LISP 1.5 Programmer's Manual~\cite{LISP1.5}
  18814. and have only deviated where we felt it desirable in the light of LISP
  18815. programming experience since that time. In particular, we have given
  18816. considerable thought to the question of variable bindings and the
  18817. definition of the evaluator functions EVAL and APPLY. We have also
  18818. abandoned the previous definition of LISP arrays in favor of the more
  18819. accepted idea of a vector which most modern LISP systems support.
  18820. These are the places where we have strayed furthest from the
  18821. conventional definitions, but we feel that the consistency which
  18822. results from our approach is worth the redefinition.
  18823. We have avoided entirely in this report problems which arise from
  18824. environment passing, such as those represented by the FUNARG problem.
  18825. We do not necessarily exclude these considerations from our standard,
  18826. but in this report have decided to avoid the controversy which they
  18827. create. The semantic differences between compiled and interpreted
  18828. functions is the topic of another paper~\cite{PLC}. Only functions
  18829. which affect the compiler in a general way make reference to it.
  18830. This document is not intended as an introduction to LISP rather it is
  18831. assumed that the reader is already familiar with some version. The
  18832. document is thus intended as an arbiter of the syntax and semantics of
  18833. Standard LISP. However, since it is not intended as an implementation
  18834. description, we deliberately leave unspecified many of the details on
  18835. which an actual implementation depends. For example, while we assume
  18836. the existence of a symbol table for atoms (the "object list" in LISP
  18837. terminology), we do not specify its structure, since conventional LISP
  18838. programming does not require this information. Our ultimate goal,
  18839. however, is to remedy this by defining an interpreter for Standard
  18840. LISP which is sufficiently complete that its implementation on any
  18841. given computer will be straightforward and precise. At that time, we
  18842. shall produce an implementation level specification for Standard LISP
  18843. which will extend the description of the primitive functions defined
  18844. herein by introducing a new set of lower level primitive functions in
  18845. which the structure of the symbol table, heap and so on may be
  18846. defined.
  18847. The plan of this chapter is as follows. In Section~\ref{dtypes} we
  18848. describe the various data types used in Standard LISP. In
  18849. Section~\ref{slfns}, a description of all Standard LISP functions is
  18850. presented, organized by type. These functions are defined in an RLISP
  18851. syntax which is easier to read than LISP S-expressions.
  18852. Section~\ref{slglobals} describes global variables which control the
  18853. operation of Standard LISP.
  18854. \section{Preliminaries}
  18855. \label{dtypes}
  18856. \subsection{Primitive Data Types}
  18857. \label{pdat}
  18858. \begin{description}
  18859. \item[integer] Integers are also called "fixed" numbers. The magnitude of
  18860. an integer is unrestricted. Integers in the LISP input stream are
  18861. \index{integer ! input} \index{integer ! magnitude}
  18862. recognized by the grammar:
  18863. \begin{tabbing}
  18864. \s{digit} ::= 0$\mid$1$\mid$2$\mid$3$\mid$4$\mid$5$\mid$6$\mid$7$\mid$8$\mid$9
  18865. \\
  18866. \s{unsigned-integer} ::= \s{digit}$\mid$\s{unsigned-integer}\s{digit} \\
  18867. \s{integer} ::= \= \s{unsigned-integer} $\mid$ \\
  18868. \> +\s{unsigned-integer} $\mid$ \\
  18869. \> ---\s{unsigned-integer}
  18870. \end{tabbing}
  18871. \item[floating] - Any floating point number. The precision of floating point
  18872. \index{floating ! input}
  18873. numbers is determined solely by the implementation. In BNF floating
  18874. point numbers are recognized by the grammar:
  18875. \begin{tabbing}
  18876. \s{base} ::= \= \s{unsigned-integer}.$\mid$.\s{unsigned-integer}$\mid$ \\
  18877. \> \s{unsigned-integer}.\s{unsigned-integer} \\
  18878. \> \s{unsigned-floating} ::= \s{base}$\mid$ \\
  18879. \> \s{base}E\s{unsigned-integer}$\mid$ \\
  18880. \> \s{base}E-\s{unsigned-integer}$\mid$ \\
  18881. \> \s{base}E+\s{unsigned-integer} \\
  18882. \s{floating} ::= \= \s{unsigned-floating}$\mid$ \\
  18883. \> +\s{unsigned-floating}$\mid$-\s{unsigned-floating}
  18884. \end{tabbing}
  18885. \item[id] An identifier is a string of characters which may have the
  18886. \index{id ! input} \index{identifier (see id)}
  18887. following items associated with it.
  18888. \begin{description}
  18889. \item[print name] \index{print name} The characters of the identifier.
  18890. \item[flags] An identifier may be tagged with a flag. Access is by the
  18891. FLAG, REMFLAG, and FLAGP functions defined in section~\ref{plist} on
  18892. page~\pageref{plist}. \index{FLAG} \index{REMFLAG} \index{FLAGP}
  18893. \item[properties] \index{properties} An identifier may have an
  18894. indicator-value pair associated with it. Access is by the PUT, GET,
  18895. and REMPROP functions defined in section~\ref{plist} on
  18896. page~\pageref{plist}.
  18897. \index{PUT} \index{GET} \index{REMPROP}
  18898. \item[values/functions] An identifier may have a value associated with
  18899. \index{values} \index{functions} it. Access to values is by SET and SETQ
  18900. defined in \index{SET} \index{SETQ} section~\ref{varsandbinds} on
  18901. page~\pageref{varsandbinds}. The method by which the value is attached
  18902. to the identifier is known as the binding type, being one of LOCAL,
  18903. GLOBAL, or FLUID. Access to the binding type is by the GLOBAL,
  18904. GLOBALP, FLUID, FLUIDP, and UNFLUID functions.
  18905. \index{GLOBAL} \index{GLOBALP} \index{FLUID} \index{FUIDP} \index{UNFLUID}
  18906. An identifier may have a function or macro associated with it. Access
  18907. is by the PUTD, GETD, and REMD functions (see ``Function Definition'',
  18908. section~\ref{fdef}, on page~\pageref{fdef}). \index{PUTD} \index{GETD}
  18909. \index{REMD} An identifier may not have both a function and a value
  18910. associated with it.
  18911. \item[OBLIST entry] \index{OBLIST entry} An identifier may be entered and
  18912. removed from a structure called the OBLIST. Its presence on the OBLIST
  18913. does not directly affect the other properties. Access to the OBLIST is
  18914. by the INTERN, REMOB, and READ functions. \index{INTERN} \index{REMOB}
  18915. \index{READ}
  18916. \end{description}
  18917. The maximum length of a Standard LISP identifier is 24 characters
  18918. \index{id ! maximum length}
  18919. (excluding occurrences of the escape character !) but an
  18920. \index{id ! escape character}
  18921. implementation may allow more. Special characters (digits in the first
  18922. position and punctuation) must be prefixed with an escape character,
  18923. an ! in Standard LISP. In BNF identifiers are recognized by the
  18924. grammar:
  18925. \begin{tabbing}
  18926. \s{special-character} ::= !\s{any-character} \\
  18927. \s{alphabetic} ::= \\
  18928. \hspace*{.25in} \= A$\mid$B$\mid$C$\mid$D$\mid$E$\mid$F$\mid$G$\mid$H$
  18929. \mid$I$\mid$J$\mid$K$\mid$L$\mid$M$\mid$N$\mid$O$\mid$P$\mid$Q$\mid$R$
  18930. \mid$S$\mid$T$\mid$U$\mid$V$\mid$W$\mid$X$\mid$Y$\mid$Z$\mid$ \\
  18931. \> a$\mid$b$\mid$c$\mid$d$\mid$e$\mid$f$\mid$g$\mid$h$\mid$i$\mid$j$
  18932. \mid$k$\mid$l$\mid$m$\mid$n$\mid$o$\mid$p$\mid$q$\mid$r$\mid$s$\mid$t$
  18933. \mid$u$\mid$v$\mid$w$\mid$x$\mid$y$\mid$z \\
  18934. \s{lead-character} ::= \s{special-character}$\mid$\s{alphabetic} \\
  18935. \s{regular-character} ::= \s{lead-character}$\mid$\s{digit} \\
  18936. \s{last-part} ::= \= \s{regular-character} $\mid$ \\
  18937. \> \s{last-part}\s{regular-character} \\
  18938. \s{id} ::= \s{lead-character}$\mid$\s{lead-character}\s{last-part}
  18939. \end{tabbing}
  18940. Note: Using lower case letters in identifiers may cause portability
  18941. problems. Lower case letters are automatically converted to upper case
  18942. when the !*RAISE flag is T. \index{*RAISE (global)}
  18943. \item[string] \index{string} A set of characters enclosed in double quotes as
  18944. in "THIS IS A STRING". A quote is included by doubling it as in "HE
  18945. SAID, ""LISP""". The maximum size of strings is 80 characters but an
  18946. implementation may allow more. Strings are not part of the OBLIST and
  18947. are considered constants like numbers, vectors, and function-pointers.
  18948. \item[dotted-pair] A primitive structure which has a left and right part.
  18949. \index{dotted-pair} \index{dot-notation}
  18950. A notation called {\em dot-notation} is used for dotted pairs and
  18951. takes the form:
  18952. \begin{tabbing}
  18953. (\s{left-part} . \s{right-part})
  18954. \end{tabbing}
  18955. The \s{left-part} is known as the CAR portion and the \s{right-part}
  18956. as the CDR portion. The left and right parts may be of any type.
  18957. Spaces are used to resolve ambiguity with floating point numbers.
  18958. \item[vector] \index{vector} A primitive uniform structure in which
  18959. an integer index is used to access random values in the structure. The
  18960. individual elements of a vector may be of any type. Access to vectors
  18961. is restricted to functions defined in ``Vectors''
  18962. section~\ref{vectors} on page~\pageref{vectors}. A notation for
  18963. vectors, {\em vector-notation}, has the elements of a vector
  18964. surrounded
  18965. \index{vector-notation}
  18966. by square brackets\footnote{Vector elements are not separated by
  18967. commas as in the published version of this document.}
  18968. \begin{tabbing}
  18969. \s{elements} ::= \s{any}$\mid$\s{any} \s{elements} \\
  18970. \s{vector} ::= [\s{elements}]
  18971. \end{tabbing}
  18972. \item[function-pointer] \index{function-pointer} An implementation may have
  18973. functions which deal with specific data types other than those listed.
  18974. The use of these entities is to be avoided with the exception of a
  18975. restricted use of the function-pointer, an access method to compiled
  18976. EXPRs and FEXPRs. A particular function-pointer must remain valid
  18977. \index{EXPR} \index{FEXPR}
  18978. throughout execution. Systems which change the location of a function
  18979. must use either an indirect reference or change all occurrences of the
  18980. associated value. There are two classes of use of function-pointers,
  18981. those which are supported by Standard LISP but are not well defined,
  18982. and those which are well defined.
  18983. \begin{description}
  18984. \item[Not well defined] Function pointers may be displayed by the print
  18985. functions or expanded by EXPLODE. \index{EXPLODE} The value appears in
  18986. the convention of the implementation site. The value is not defined in
  18987. Standard LISP. Function pointers may be created by COMPRESS
  18988. \index{COMPRESS} in the format used for printing but the value used is
  18989. not defined in Standard LISP. Function pointers may be created by
  18990. functions which deal with compiled function loading. Again, the values
  18991. created are not well defined in Standard LISP.
  18992. \item[Well defined] The function pointer associated with an EXPR or
  18993. FEXPR may be retrieved by GETD \index{GETD} and is valid as long as
  18994. Standard LISP is in execution. Function pointers may be stored using
  18995. \index{PUTD} \index{PUT} \index{SETQ} PUTD, PUT, SETQ and the like or by
  18996. being bound to variables. Function pointers may be checked for
  18997. equivalence by EQ. \index{EQ ! of function-pointers} The value may be
  18998. checked for being a function pointer by the CODEP function.
  18999. \index{CODEP}
  19000. \end{description}
  19001. \end{description}
  19002. \subsection{Classes of Primitive Data Types}
  19003. \label{pclasses}
  19004. The classes of primitive types are a notational convenience for
  19005. describing the properties of functions.
  19006. \begin{description}
  19007. \item[boolean] \index{boolean} The set of global variables \{T,NIL\},
  19008. or their respective values, \{T, NIL\}. \index{T (global)} \index{NIL
  19009. (global)}
  19010. \item[extra-boolean] \index{extra-boolean} Any value in the system.
  19011. Anything that is not NIL \index{NIL (global)} has the boolean
  19012. interpretation T. \index{T (global)}
  19013. \item[ftype] \index{ftype} The class of definable function types. The
  19014. set of ids \{EXPR, FEXPR, MACRO\}. \index{EXPR} \index{FEXPR}
  19015. \index{MACRO}
  19016. \item[number] \index{number} The set of \{integer, floating\}.
  19017. \item[constant] \index{constant} The set of \{integer, floating,
  19018. string, vector, function-pointer\}. Constants evaluate to themselves
  19019. (see the definition of EVAL in ``The Interpreter'',
  19020. section~\ref{interpreter} on page~\pageref{interpreter}). \index{EVAL
  19021. ! of constants}
  19022. \item[any] \index{any} The set of \{integer, floating, string, id,
  19023. dotted-pair, vector, function-pointer\}. An S-expression is another
  19024. term for any. All Standard LISP entities have some value unless an
  19025. ERROR occurs during evaluation or the function causes transfer of
  19026. control (such as GO and RETURN).
  19027. \item[atom] \index{atom} The set \{any\}-\{dotted-pair\}.
  19028. \end{description}
  19029. \subsection{Structures}
  19030. \index{data structures} \index{structures}
  19031. Structures are entities created out of the primitive types by the use
  19032. of dotted-pairs. Lists are structures very commonly required as actual
  19033. parameters to functions. Where a list of homogeneous entities is
  19034. required by a function this class will be denoted by
  19035. \s{{\bf xxx}-list} where {\bf \em xxx} is the name of a class of primitives
  19036. or structures. Thus a list of ids is an {\em id-list}, a list of
  19037. integers an {\em integer-list} and so on. \index{id-list}
  19038. \index{integer-list}
  19039. \index{-list}
  19040. \begin{description}
  19041. \item[list] \index{list} A list is recursively defined as NIL or the
  19042. \index{list-notation} \index{NIL (global)}
  19043. dotted-pair (any~.~list). A special notation called {\em
  19044. list-notation} is used to represent lists. List-notation eliminates
  19045. extra parentheses and dots. The list (a . (b . (c . NIL))) in list
  19046. notation is (a b c).
  19047. \index{dot-notation}
  19048. List-notation and dot-notation may be mixed as in (a b . c) or (a (b .
  19049. c) d) which are (a . (b . c)) and (a . ((b . c) . (d . NIL))). In BNF
  19050. lists are recognized by the grammar:
  19051. \begin{tabbing}
  19052. \s{left-part} ::= ( $\mid$ \s{left-part} \s{any} \\
  19053. \s{list} ::= \s{left-part}) $\mid$ \s{left-part} . \s{any})
  19054. \end{tabbing}
  19055. Note: () is an alternate input representation of NIL. \index{()}
  19056. \item[alist] \index{alist} An association list; each element of the list
  19057. is a dotted-pair, the CAR part being a key associated with the value
  19058. in the CDR part. \index{association list}
  19059. \item[cond-form] \index{cond-form} A cond-form is a list of 2 element lists
  19060. of the form:
  19061. (\p{ANTECEDENT}:{\em any} \p{CONSEQUENT}:{\em any})
  19062. The first element will henceforth be known as the antecedent and
  19063. \index{antecedent (cond-form)} \index{consequent (cond-form)}
  19064. the second as the consequent. The antecedent must have a value. The
  19065. consequent may have a value or an occurrence of GO or RETURN
  19066. \index{GO} \index{RETURN}
  19067. as described in the ``Program Feature Functions'', section~\ref{prog}
  19068. on page~\pageref{prog}.
  19069. \item[lambda] \index{LAMBDA} A LAMBDA expression which must have the form
  19070. (in list notation): (LAMBDA parameters body). ``parameters'' is a list
  19071. of formal parameters for ``body'' an S-expression to be evaluated. The
  19072. semantics of the evaluation are defined with the EVAL function (see
  19073. ``The Interpreter'', section~\ref{interpreter} on \index{EVAL ! lambda
  19074. expressions} page~\pageref{interpreter}). \index{lambda expression}
  19075. \item[function] \index{function} A LAMBDA expression or a function-pointer
  19076. to a function. A function is always evaluated as an EVAL, SPREAD form.
  19077. \index{EVAL ! function}
  19078. \end{description}
  19079. \subsection{Function Descriptions}
  19080. Each function is provided with a prototypical header line. Each formal
  19081. parameter is given a name and suffixed with its allowed type. Lower
  19082. case, italic tokens are names of classes and upper case, bold face,
  19083. tokens are parameter names referred to in the definition. The type of
  19084. the value returned by the function (if any) is suffixed to the
  19085. parameter list. If it is not commonly used the parameter type may be
  19086. a specific set enclosed in brackets \{\ldots\}. \index{\{\ldots\} ! as
  19087. syntax} For example:
  19088. \vspace{.1in}
  19089. \noindent \f{PUTD}(\p{FNAME}:\ty{id}, \p{TYPE}:\ty{ftype},
  19090. \p{BODY}:\{\ty{lambda, function-pointer}\}):\ty{id}
  19091. \vspace{.1in}
  19092. PUTD is a function with three parameters. The parameter FNAME is an id
  19093. to be the name of the function being defined. TYPE is the type of the
  19094. function being defined and BODY is a lambda expression or a
  19095. function-pointer. PUTD returns the name of the function being defined.
  19096. Functions which accept formal parameter lists of arbitrary length have
  19097. the type class and parameter enclosed in square brackets indicating
  19098. that zero or more occurrences of that argument are permitted.
  19099. \index{[\ldots] syntax} For example:
  19100. \vspace{.1in}
  19101. \noindent \f{AND}([\p{U}:\ty{any}]):\ty{extra-boolean}
  19102. \vspace{.1in}
  19103. AND is a function which accepts zero or more arguments which may be of
  19104. any type.
  19105. \subsection{Function Types}
  19106. EVAL type functions are those which are invoked with evaluated
  19107. \index{EVAL ! function type}
  19108. arguments. NOEVAL functions are invoked with unevaluated arguments.
  19109. \index{NOEVAL ! function type}
  19110. SPREAD type functions have their arguments passed in one-to-one
  19111. \index{SPREAD ! function type}
  19112. correspondence with their formal parameters. NOSPREAD functions
  19113. \index{NOSPREAD ! function type}
  19114. receive their arguments as a single list. EVAL, SPREAD functions are
  19115. \index{FEXPR}
  19116. associated with EXPRs and NO\-EVAL, NO\-SPREAD functions with FEXPRs.
  19117. EVAL, NO\-SPREAD and NOEVAL, SPREAD functions can be simulated using
  19118. NOEVAL, NO\-SPREAD functions or MACROs. \index{MACRO}
  19119. EVAL, SPREAD type functions may have a maximum of 15 parameters.
  19120. \index{formal parameter limit}
  19121. There is no limit on the number of parameters a NOEVAL, NOSPREAD
  19122. function or MACRO may have.
  19123. In the context of the description of an EVAL, SPREAD function, then we
  19124. speak of the formal parameters we mean their actual values. However,
  19125. in a NOEVAL, NOSPREAD function it is the unevaluated actual
  19126. parameters.
  19127. A third function type, the MACRO, implements functions which
  19128. \index{MACRO}
  19129. create S-expressions based on actual parameters. When a macro
  19130. invocation is encountered, the body of the macro, a lambda expression,
  19131. is invoked as a NOEVAL, NOSPREAD function with the macro's invocation
  19132. bound as a list to the macros single formal parameter. When the macro
  19133. has been evaluated the resulting S-expression is reevaluated. The
  19134. description of the EVAL and EXPAND
  19135. \index{EVAL ! MACRO functions}
  19136. functions provide precise details.
  19137. \subsection{Error and Warning Messages}
  19138. \index{error messages}
  19139. Many functions detect errors. The description of such functions will
  19140. include these error conditions and suggested formats for display
  19141. \index{ERROR}
  19142. of the generated error messages. A call on the ERROR function is
  19143. implied but the error number is not specified by Standard LISP. In
  19144. some cases a warning message is sufficient. To distinguish between
  19145. \index{warning messages} \index{***** (error message)}
  19146. \index{*** (warning message)}
  19147. errors and warnings, errors are prefixed with five asterisks and
  19148. warnings with only three.
  19149. Primitive functions check arguments that must be of a certain
  19150. primitive type for being of that type and display an error message if
  19151. the argument is not correct. The type mismatch error always takes the
  19152. form:
  19153. \index{error ! type mismatch error}
  19154. \errormessage{***** PARAMETER not TYPE for FN}
  19155. Here PARAMETER is the unacceptable actual parameter, TYPE is the type
  19156. that PARAMETER was supposed to be. FN is the name of the function that
  19157. detected the error.
  19158. \subsection{Comments}
  19159. \index{comments} \index{\%}
  19160. The character \% signals the start of a comment, text to be ignored
  19161. during parsing. A comment is terminated by the end of the line it
  19162. \index{READCH} \index{READ}
  19163. is on. The function READCH must be able to read a comment one
  19164. character at a time. Comments are transparent to the function READ.
  19165. \% may occur as a character in identifiers by preceding it with the
  19166. \index{escape character}
  19167. escape character !.
  19168. \section{Functions}
  19169. \label{slfns}
  19170. \subsection{Elementary Predicates}
  19171. \label{elpreds}
  19172. \index{predicate !}
  19173. \index{T (global)} \index{NIL (global)}
  19174. Functions in this section return T when the condition defined is met
  19175. and NIL when it is not. Defined are type checking functions and
  19176. elementary comparisons.
  19177. \de{ATOM}{(\p{U}:\ty{any}):{\ty boolean}}{eval, spread}
  19178. {Returns T if U is not a pair.
  19179. {\tt \begin{tabbing} EXPR PROCEDURE ATOM(U); \\
  19180. \hspace*{1em} NULL PAIRP U;
  19181. \end{tabbing}}}
  19182. \de{CODEP}{(\p{U}:\f{any}):{\ty boolean}}{eval, spread}
  19183. {Returns T if U is a function-pointer.}
  19184. \de{CONSTANTP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19185. {Returns T if U is a constant (a number, string, function-pointer, or
  19186. vector).
  19187. {\tt \begin{tabbing} EXPR PROCEDURE CONSTANTP(U); \\
  19188. \hspace*{1em} NULL OR(PAIRP U, IDP U);
  19189. \end{tabbing}}
  19190. }
  19191. \de{EQ}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{boolean}}{eval, spread}
  19192. {Returns T if U points to the same object as V. EQ is \underline{not}
  19193. a reliable comparison between numeric arguments. }
  19194. \de{EQN}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{boolean}}{eval, spread}
  19195. {Returns T if U and V are EQ or if U and V are numbers and have the
  19196. same value and type. }
  19197. \de{EQUAL}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{boolean}}{eval, spread}
  19198. {Returns T if U and V are the same. Dotted-pairs are compared
  19199. recursively to the bottom levels of their trees. Vectors must have
  19200. identical dimensions and EQUAL values in all positions. Strings must
  19201. \index{EQ ! of function-pointers} \index{EQN} have identical characters.
  19202. Function pointers must have EQ values. Other atoms must be EQN equal. }
  19203. \de{FIXP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19204. {Returns T if U is an integer (a fixed number).}
  19205. \de{FLOATP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19206. {Returns T if U is a floating point number. }
  19207. \de{IDP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19208. {Returns T if U is an id.}
  19209. \de{MINUSP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19210. {Returns T if U is a number and less than 0. If U is not a number or
  19211. is a positive number, NIL is returned.
  19212. {\tt \begin{tabbing} EXPR PROCEDURE MINUSP(U); \\
  19213. \hspace*{1em} IF NUMBERP U THEN LESSP(U, 0) ELSE NIL;
  19214. \end{tabbing}}}
  19215. \de{NULL}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19216. {Returns T if U is NIL.
  19217. {\tt \begin{tabbing} EXPR PROCEDURE NULL(U); \\
  19218. \hspace*{1em} U EQ NIL;
  19219. \end{tabbing}}}
  19220. \de{NUMBERP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19221. {Returns T if U is a number (integer or floating).
  19222. {\tt \begin{tabbing} EXPR PROCEDURE NUMBERP(U); \\
  19223. \hspace*{1em} IF OR(FIXP U, FLOATP U) THEN T ELSE NIL;
  19224. \end{tabbing}}}
  19225. \de{ONEP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread.}
  19226. {Returns T if U is a number and has the value 1 or 1.0. Returns NIL
  19227. otherwise. \footnote{The definition in the published report is
  19228. incorrect as it does not return T for \p{U} of 1.0.}
  19229. {\tt \begin{tabbing} EXPR PROCEDURE ONEP(U); \\
  19230. \hspace*{1em} OR(EQN(U, 1), EQN(U, 1.0));
  19231. \end{tabbing}}}
  19232. \de{PAIRP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19233. {Returns T if U is a dotted-pair. }
  19234. \de{STRINGP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19235. {Returns T if U is a string. }
  19236. \de{VECTORP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19237. {Returns T if U is a vector. }
  19238. \de{ZEROP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread.}
  19239. {Returns T if U is a number and has the value 0 or 0.0. Returns NIL
  19240. otherwise.\footnote{The definition in the published report is
  19241. incorrect as it does not return T for \p{U} of 0.0.}
  19242. {\tt \begin{tabbing} EXPR PROCEDURE ZEROP(U); \\
  19243. \hspace*{1em} OR(EQN(U, 0), EQN(U, 0.0));
  19244. \end{tabbing}}}
  19245. \subsection{Functions on Dotted-Pairs}
  19246. \index{dotted-pair}
  19247. The following are elementary functions on dotted-pairs. All functions
  19248. in this section which require dotted-pairs as parameters detect a type
  19249. mismatch error if the actual parameter is not a dotted-pair.
  19250. \de{CAR}{(\p{U}:\ty{dotted-pair}):\ty{any}}{eval, spread}
  19251. {CAR(CONS(a, b)) $\rightarrow$ a. The left part of U is returned. The
  19252. type
  19253. \index{CONS}
  19254. mismatch error occurs if U is not a dotted-pair.}
  19255. \de{CDR}{(\p{U}:\ty{dotted-pair}):\ty{any}}{eval, spread}
  19256. {CDR(CONS(a, b)) $\rightarrow$ b. The right part of U is returned. The
  19257. type
  19258. \index{CONS}
  19259. mismatch error occurs if U is not a dotted-pair.}
  19260. The composites of CAR and CDR are supported up to 4 levels, namely:
  19261. \index{CAR ! composite forms} \index{CDR ! composite forms}
  19262. \hspace*{1in}\begin{tabular}{l l l}
  19263. CAAAAR & CAAAR & CAAR \\ CAAADR & CAADR & CADR \\ CAADAR & CADAR &
  19264. CDAR \\ CAADDR & CADDR & CDDR \\ CADAAR & CDAAR & \\ CADADR & CDADR &
  19265. \\ CADDAR & CDDAR & \\ CADDDR & CDDDR & \\ CDAAAR & & \\ CDAADR & & \\
  19266. CDADAR & & \\ CDADDR & & \\ CDDAAR & & \\ CDDADR & & \\ CDDDAR & & \\
  19267. CDDDDR & &
  19268. \end{tabular}
  19269. \de{CONS}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{dotted-pair}}{eval, spread}
  19270. {Returns a dotted-pair which is not EQ to anything and has U as its
  19271. \index{EQ ! of dotted-pairs} \index{dotted-pair}
  19272. CAR part and V as its CDR part.}
  19273. \de{LIST}{([\p{U}:\ty{any}]):\ty{list}}{noeval, nospread, or macro}
  19274. {A list of the evaluation of each element of U is returned. The order
  19275. of evaluation need not be first to last as the following definition
  19276. implies.\footnote{The published report's definition implies a specific
  19277. ordering.}
  19278. {\tt \begin{tabbing} FEXPR PROCEDURE LIST(U); \\
  19279. \hspace*{1em} EVLIS U;
  19280. \end{tabbing}}}
  19281. \de{RPLACA}{(\p{U}:\ty{dotted-pair},
  19282. \p{V}:\ty{any}):\ty{dotted-pair}}{eval, spread}
  19283. {The CAR portion of the dotted-pair U is replaced by V. If dotted-pair
  19284. U is (a . b) then (V . b) is returned. The type mismatch error occurs
  19285. if U is not a dotted-pair. }
  19286. \de{RPLACD}{(\p{U}:\ty{dotted-pair},
  19287. \p{V}:\ty{any}):\ty{dotted-pair}}{eval, spread}
  19288. {The CDR portion of the dotted-pair U is replaced by V. If dotted-pair
  19289. U is (a . b) then (a . V) is returned. The type mismatch error occurs
  19290. if U is not a dotted-pair.}
  19291. \subsection{Identifiers}
  19292. \label{identifiers}
  19293. The following functions deal with identifiers and the OBLIST,
  19294. \index{OBLIST}
  19295. the structure of which is not defined. The function of the OBLIST is
  19296. to provide a symbol table for identifiers created during input.
  19297. Identifiers created by READ which have the same characters will
  19298. \index{READ} \index{EQ ! of identifiers}
  19299. therefore refer to the same object (see the EQ function in
  19300. ``Elementary Predicates'', section~\ref{elpreds} on
  19301. page~\pageref{elpreds}).
  19302. \de{COMPRESS}{(\p{U}:\ty{id-list}):\{\ty{atom}-\ty{vector}\}}{eval, spread}
  19303. {U is a list of single character identifiers which is built into a
  19304. Standard LISP entity and returned. Recognized are numbers, strings,
  19305. and identifiers with the escape character prefixing special
  19306. characters. The formats of these items appear in ``Primitive Data
  19307. Types'' section~\ref{pdat} on page~\pageref{pdat}. Identifiers are not
  19308. interned on the OBLIST. Function pointers may be compressed but this
  19309. is an undefined use. If an entity cannot be parsed out of U or
  19310. characters are left over after parsing an error occurs:
  19311. \errormessage{***** Poorly formed atom in COMPRESS}
  19312. }
  19313. \de{EXPLODE}{(\p{U}:\{\ty{atom}\}-\{\ty{vector}\}):\ty{id-list}}{eval, spread}
  19314. {Returned is a list of interned characters representing the characters
  19315. to print of the value of U. The primitive data types have these
  19316. formats:
  19317. \begin{description}
  19318. \item[integer] \index{integer ! output} Leading zeroes are suppressed and
  19319. a minus sign prefixes the digits if the integer is negative.
  19320. \item[floating] \index{floating ! output} The value appears in the format
  19321. [-]0.nn...nnE[-]mm if the magnitude of the number is too large or
  19322. small to display in [-]nnnn.nnnn format. The crossover point is
  19323. determined by the implementation.
  19324. \item[id] \index{id ! output} The characters of the print name of the
  19325. identifier are produced with special characters prefixed with the
  19326. escape character.
  19327. \item[string] \index{string ! output} The characters of the string are
  19328. produced surrounded by double quotes "\ldots".
  19329. \item[function-pointer] \index{function-pointer ! output} The value of the
  19330. function-pointer is created as a list of characters conforming to the
  19331. conventions of the system site.
  19332. \end{description}
  19333. The type mismatch error occurs if U is not a number, identifier,
  19334. string, or function-pointer. }
  19335. \de{GENSYM}{():\ty{identifier}}{eval, spread}
  19336. {Creates an identifier which is not interned on the OBLIST and
  19337. consequently not EQ to anything else. \index{OBLIST entry} \index{EQ !
  19338. of GENSYMs}}
  19339. \de{INTERN}{(\p{U}:\{\ty{id,string}\}):\ty{id}}{eval, spread}
  19340. {INTERN searches the OBLIST for an identifier with the same print name
  19341. \index{OBLIST entry}
  19342. as U and returns the identifier on the OBLIST if a match is found.
  19343. Any properties and global values associated with U may be lost. If U
  19344. does not match any entry, a new one is created and returned. If U has
  19345. more than the maximum number of characters permitted by the
  19346. implementation (the minimum number is 24) an error occurs:
  19347. \index{id ! minimum size}
  19348. \errormessage{***** Too many characters to INTERN}
  19349. }
  19350. \de{REMOB}{(\p{U}:\ty{id}):\ty{id}}{eval, spread}
  19351. {If U is present on the OBLIST it is removed. This does not affect U
  19352. \index{OBLIST entry}
  19353. having properties, flags, functions and the like. U is returned.}
  19354. \subsection{Property List Functions}
  19355. \label{plist}
  19356. \index{property list}
  19357. With each id in the system is a ``property list'', a set of entities
  19358. which are associated with the id for fast access. These entities are
  19359. called ``flags'' if their use gives the id a single valued
  19360. \index{flags}
  19361. property, and ``properties'' if the id is to have a multivalued
  19362. \index{properties}
  19363. attribute: an indicator with a property.
  19364. Flags and indicators may clash, consequently care should be taken to
  19365. avoid this occurrence. Flagging X with an id which already is an
  19366. indicator for X may result in that indicator and associated property
  19367. being lost. Likewise, adding an indicator which is the same id as a
  19368. flag may result in the flag being destroyed.
  19369. \de{FLAG}{(\p{U}:\ty{id-list}, \p{V}:\ty{id}):\ty{NIL}}{eval, spread}
  19370. {U is a list of ids which are flagged with V. The effect of FLAG is
  19371. that FLAGP will have the value T for those ids of U which were
  19372. flagged. Both V and all the elements of U must be identifiers or the
  19373. type mismatch error occurs.}
  19374. \de{FLAGP}{(\p{U}:\ty{any}, \p{V}:\ty{any}):\ty{boolean}}{eval, spread}
  19375. {Returns T if U has been previously flagged with V, else NIL. Returns
  19376. NIL if either U or V is not an id.}
  19377. \de{GET}{(\p{U}:\ty{any}, \p{IND}:\ty{any}):\ty{any}}{eval, spread}
  19378. {Returns the property associated with indicator IND from the property
  19379. list of U. If U does not have indicator IND, NIL is returned. GET
  19380. cannot be used to access functions (use GETD instead).
  19381. \index{GET ! not for functions}}
  19382. \de{PUT}{(\p{U}:\ty{id}, \p{IND}:\ty{id},
  19383. \p{PROP}:\ty{any}):\ty{any}}{eval, spread}
  19384. {The indicator IND with the property PROP is placed on the property
  19385. list of the id U. If the action of PUT occurs, the value of PROP is
  19386. returned. If either of U and IND are not ids the type mismatch error
  19387. will occur and no property will be placed. PUT cannot be used to
  19388. define functions (use PUTD instead).
  19389. \index{PUT ! not for functions}}
  19390. \de{REMFLAG}{(\p{U}:\ty{any-list}, \p{V}:\ty{id}):\ty{NIL}}{eval, spread}
  19391. {Removes the flag V from the property list of each member of the list
  19392. U. Both V and all the elements of U must be ids or the type mismatch
  19393. error will occur.}
  19394. \de{REMPROP}{(\p{U}:\ty{any}, \p{IND}:\ty{any}):\ty{any}}{eval, spread}
  19395. {Removes the property with indicator IND from the property list of U.
  19396. Returns the removed property or NIL if there was no such indicator.}
  19397. \subsection{Function Definition}
  19398. \label{fdef}
  19399. Functions in Standard LISP are global entities. To avoid
  19400. function-variable naming clashes no variable may have the same name as
  19401. a function. \index{function ! as GLOBAL}
  19402. \de{DE}{(\p{FNAME}:\ty{id}, \p{PARAMS}:\ty{id-list},
  19403. \p{FN}:\ty{any}):\ty{id}}{noeval, nospread}
  19404. {The function FN with the formal parameter list PARAMS is added to the
  19405. set of defined functions with the name FNAME. Any previous definitions
  19406. of the function are lost. The function created is of type
  19407. \index{*COMP (fluid)}
  19408. EXPR. If the !*COMP variable is non-NIL, the EXPR is first
  19409. \index{EXPR}
  19410. compiled. The name of the defined function is returned.
  19411. {\tt \begin{tabbing} FEXPR PROCEDURE DE(U); \\
  19412. \hspace*{1em} PUTD(CAR U, 'EXPR, LIST('LAMBDA, CADR U, CADDR U));
  19413. \end{tabbing}}}
  19414. \de{DF}{(\p{FNAME}:\ty{id}, \p{PARAM}:\ty{id-list},
  19415. \p{FN}:\ty{any}):\ty{id}}{noeval, nospread}
  19416. {The function FN with formal parameter PARAM is added to the set of
  19417. defined functions with the name FNAME. Any previous definitions of the
  19418. function are lost. The function created is of type FEXPR.
  19419. \index{*COMP variable} \index{FEXPR}
  19420. If the !*COMP variable is T the FEXPR is first compiled. The name of
  19421. the defined function is returned.
  19422. {\tt \begin{tabbing} FEXPR PROCEDURE DF(U); \\
  19423. \hspace*{1em} PUTD(CAR U, 'FEXPR, LIST('LAMBDA, CADR U, CADDR U)); \\
  19424. \end{tabbing} }}
  19425. \de{DM}{(\p{MNAME}:\ty{id}, \p{PARAM}:\ty{id-list},
  19426. \p{FN}:\ty{any}):\ty{id}}{noeval, nospread}
  19427. {The macro FN with the formal parameter PARAM is added to the set of
  19428. defined functions with the name MNAME. Any previous definitions of the
  19429. function are overwritten. The function created is of type MACRO.
  19430. \index{MACRO}
  19431. The name of the macro is returned.
  19432. {\tt \begin{tabbing} FEXPR PROCEDURE DM(U); \\
  19433. \hspace*{1em} PUTD(CAR U, 'MACRO, LIST('LAMBDA, CADR U, CADDR U));
  19434. \end{tabbing} }
  19435. }
  19436. \de{GETD}{(\p{FNAME}:\ty{any}):\{NIL, \ty{dotted-pair}\}}{eval, spread}
  19437. {If FNAME is not the name of a defined function, NIL is returned. If
  19438. FNAME is a defined function then the dotted-pair
  19439. \vspace{.15in}
  19440. (\p{TYPE}:\ty{ftype} . \p{DEF}:\{\ty{function-pointer, lambda}\})
  19441. \vspace{.15in}
  19442. is returned.}
  19443. \de{PUTD}{(\p{FNAME}:\ty{id}, \p{TYPE}:\ty{ftype},
  19444. \p{BODY}:\ty{function}):\ty{id}}{eval, spread}
  19445. {Creates a function with name FNAME and definition BODY of type TYPE.
  19446. If PUTD succeeds the name of the defined function is returned. The
  19447. effect of PUTD is that GETD will return a dotted-pair with the
  19448. functions type and definition. Likewise the GLOBALP predicate will
  19449. \index{GLOBALP} \index{function ! as global}
  19450. return T when queried with the function name.
  19451. If the function FNAME has already been declared as a GLOBAL or FLUID
  19452. variable the error:
  19453. \errormessage{***** FNAME is a non-local variable}
  19454. occurs and the function will not be defined. If function FNAME already
  19455. exists a warning message will appear:
  19456. \errormessage{*** FNAME redefined}
  19457. The function defined by PUTD will be compiled before definition
  19458. \index{*COMP (fluid)} if the !*COMP global variable is non-NIL.}
  19459. \de{REMD}{(\p{FNAME}:\ty{id}):\{NIL, \ty{dotted-pair}\}}{eval, spread}
  19460. {Removes the function named FNAME from the set of defined functions.
  19461. Returns the (ftype . function) dotted-pair or NIL as does GETD. The
  19462. global/function attribute of FNAME is removed and the name may be used
  19463. subsequently as a variable.}
  19464. \subsection{Variables and Bindings}
  19465. \label{varsandbinds}
  19466. \index{variable scope} \index{scope}
  19467. A variable is a place holder for a Standard LISP entity which is said
  19468. to be bound to the variable. The scope of a variable is the range over
  19469. which the variable has a defined value. There are three different
  19470. binding mechanisms in Standard LISP.
  19471. \begin{description}
  19472. \item[Local Binding] \index{local binding} This type of binding occurs
  19473. \index{scope ! local}
  19474. only in compiled functions. Local variables occur as formal parameters
  19475. in lambda expressions and as PROG form variables. The binding occurs
  19476. when a lambda expression is evaluated or when a PROG form is executed.
  19477. The scope of a local variable is the body of the function in which it
  19478. is defined.
  19479. \item[Global Binding] \index{global binding} Only one binding of a
  19480. \index{scope ! global}
  19481. global variable exists at any time allowing direct access to the value
  19482. bound to the variable. The scope of a global variable is universal.
  19483. Variables declared GLOBAL may not appear as parameters in lambda
  19484. expressions or as PROG form variables. A variable must be declared
  19485. GLOBAL prior to its use as a global variable since the default type
  19486. for undeclared variables is FLUID.
  19487. \item[Fluid Binding] \index{fluid binding}
  19488. \index{fluid binding ! as default} Fluid variables are global
  19489. in scope but may occur as \index{scope ! fluid} formal parameters or
  19490. PROG form variables. In interpreted functions all formal parameters
  19491. and PROG form variables are considered to have fluid binding until
  19492. changed to local binding by compilation. When fluid variables are
  19493. used as parameters they are rebound in such a way that the previous
  19494. binding may be restored. All references to fluid variables are to the
  19495. currently active binding.
  19496. \end{description}
  19497. \de{FLUID}{(\p{IDLIST}:\ty{id-list}):\p{NIL}}{eval, spread}
  19498. {The ids in IDLIST are declared as FLUID type variables (ids not
  19499. previously declared are initialized to NIL). Variables in IDLIST
  19500. already declared FLUID are ignored. Changing a variable's type from
  19501. GLOBAL to FLUID is not permissible and results in the error:
  19502. \errormessage{***** ID cannot be changed to FLUID}
  19503. }
  19504. \de{FLUIDP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19505. {If U has been declared FLUID (by declaration only) T is returned,
  19506. otherwise NIL is returned.}
  19507. \de{GLOBAL}{(\p{IDLIST}:\ty{id-list}):\p{NIL}}{eval, spread}
  19508. {The ids of IDLIST are declared global type variables. If an id has
  19509. not been declared previously it is initialized to NIL. Variables
  19510. already declared GLOBAL are ignored. Changing a variables type from
  19511. FLUID to GLOBAL is not permissible and results in the error:
  19512. \errormessage{***** ID cannot be changed to GLOBAL}
  19513. }
  19514. \de{GLOBALP}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19515. {If U has been declared GLOBAL or is the name of a defined function, T
  19516. is returned, else NIL is returned.}
  19517. \de{SET}{(\p{EXP}:\ty{id}, \p{VALUE}:\ty{any}):\ty{any}}{eval, spread}
  19518. {EXP must be an identifier or a type mismatch error occurs. The effect
  19519. of SET is replacement of the item bound to the identifier by VALUE.
  19520. If the identifier is not a local variable or has not been declared
  19521. GLOBAL it is automatically declared FLUID with the resulting warning
  19522. message:
  19523. \errormessage{*** EXP declared FLUID}
  19524. EXP must not evaluate to T or NIL or an error occurs:
  19525. \index{T ! cannot be changed} \index{NIL ! cannot be changed}
  19526. \errormessage{***** Cannot change T or NIL}
  19527. }
  19528. \de{SETQ}{(\p{VARIABLE}:\ty{id}, \p{VALUE}:\ty{any}):\ty{any}}{noeval,
  19529. nospread}
  19530. {If VARIABLE is not local or GLOBAL it is by default declared FLUID
  19531. and the warning message:
  19532. \errormessage{*** VARIABLE declared FLUID}
  19533. appears. The value of the current binding of VARIABLE is replaced by
  19534. the value of VALUE. VARIABLE must not be T or NIL or an error occurs:
  19535. \index{T ! cannot be changed} \index{NIL ! cannot be changed}
  19536. \errormessage{***** Cannot change T or NIL}
  19537. {\tt \begin{tabbing} MACRO PROCEDURE SETQ(X); \\
  19538. \hspace*{1em} LIST('SET, LIST('QUOTE, CADR X), CADDR X);
  19539. \end{tabbing}}
  19540. }
  19541. \de{UNFLUID}{(\p{IDLIST}:\ty{id-list}):\ty{NIL}}{eval, spread}
  19542. {The variables in IDLIST that have been declared as FLUID variables
  19543. are no longer considered as fluid variables. Others are ignored. This
  19544. affects only compiled functions as free variables in interpreted
  19545. functions are automatically considered fluid~\cite{PLC}.
  19546. \index{scope ! fluid and compiled}}
  19547. \subsection{Program Feature Functions}
  19548. \label{prog}
  19549. These functions provide for explicit control sequencing, and the
  19550. definition of blocks altering the scope of local variables.
  19551. \de{GO}{(\p{LABEL}:\ty{id})}{noeval, nospread}
  19552. {GO alters the normal flow of control within a PROG function. The next
  19553. statement of a PROG function to be evaluated is immediately preceded
  19554. by LABEL. A GO may only appear in the following situations:
  19555. \begin{enumerate}
  19556. \item At the top level of a PROG referencing a label which also
  19557. appears at the top level of the same PROG.
  19558. \item As the consequent of a COND item of a COND appearing on the top
  19559. level of a PROG.
  19560. \index{GO ! in COND}
  19561. \index{RETURN ! in COND}
  19562. \item As the consequent of a COND item which appears as the
  19563. consequent of a COND item to any level.
  19564. \item As the last statement of a PROGN which appears at the top level
  19565. of a PROG or in a PROGN appearing in the consequent of a COND to any
  19566. level subject to the restrictions of 2 and 3.
  19567. \item As the last statement of a PROGN within a PROGN or as the
  19568. consequent of a COND in a PROGN to any level subject to the
  19569. restrictions of 2, 3 and 4.
  19570. \end{enumerate}
  19571. If LABEL does not appear at the top level of the PROG in which the GO
  19572. appears, an error occurs:
  19573. \errormessage{***** LABEL is not a known label}
  19574. If the GO has been placed in a position not defined by rules 1-5,
  19575. another error is detected:
  19576. \errormessage{***** Illegal use of GO to LABEL}
  19577. }
  19578. \de{PROG}{(\p{VARS}:\ty{id-list},
  19579. [\p{PROGRAM}:\{\ty{id, any}\}]):\ty{any}}{noeval, nospread}
  19580. {VARS is a list of ids which are considered fluid when the PROG is
  19581. interpreted and local when compiled (see ``Variables and Bindings'',
  19582. section~\ref{varsandbinds} on page~\pageref{varsandbinds}). The PROGs
  19583. variables are allocated space when the PROG form is invoked and are
  19584. deallocated when the PROG is exited. PROG variables are initialized to
  19585. \index{PROG ! variables}
  19586. NIL. The PROGRAM is a set of expressions to be evaluated in order of
  19587. their appearance in the PROG function. Identifiers appearing in the
  19588. top level of the PROGRAM are labels which can be referenced by GO. The
  19589. value returned by the PROG function is determined by a RETURN function
  19590. \index{PROG ! default value}
  19591. or NIL if the PROG ``falls through''.}
  19592. \de{PROGN}{([\p{U}:\ty{any}]):\ty{any}}{noeval, nospread}
  19593. {U is a set of expressions which are executed sequentially. The value
  19594. returned is the value of the last expression.}
  19595. \de{PROG2}{(A:any, B:any)\ty{any}}{eval, spread}
  19596. {Returns the value of B.
  19597. {\tt \begin{tabbing} EXPR PROCEDURE PROG2(A, B);\\
  19598. \hspace*{1em} B;
  19599. \end{tabbing}}}
  19600. \de{RETURN}{(\p{U}:\ty{any})}{eval, spread}
  19601. {Within a PROG, RETURN terminates the evaluation of a PROG and returns
  19602. U as the value of the PROG. The restrictions on the placement of
  19603. RETURN are exactly those of GO. Improper placement of RETURN results
  19604. in the error:
  19605. \errormessage{***** Illegal use of RETURN}
  19606. }
  19607. \subsection{Error Handling}
  19608. \label{errors}
  19609. \de{ERROR}{(\p{NUMBER}:\ty{integer}, \p{MESSAGE}:\ty{any})}{eval, spread}
  19610. {NUMBER and MESSAGE are passed back to a surrounding ERRORSET (the
  19611. Standard LISP reader has an ERRORSET). MESSAGE is placed in the
  19612. \index{EMSG* (global)}
  19613. global variable EMSG!* and the error number becomes the value of the
  19614. surrounding ERRORSET. FLUID variables and local bindings are unbound
  19615. \index{fluid ! unbinding by ERROR}
  19616. to return to the environment of the ERRORSET. Global variables are not
  19617. affected by the process.}
  19618. \de{ERRORSET}{(\p{U}:\ty{any}, \p{MSGP}:\ty{boolean},
  19619. \p{TR}:\ty{boolean}):\ty{any}}{eval, spread}
  19620. {If an error occurs during the evaluation of U, the value of NUMBER
  19621. from the ERROR call is returned as the value of ERRORSET. In addition,
  19622. if the value of MSGP is non-NIL, the MESSAGE from the ERROR call is
  19623. displayed upon both the standard output device and the currently
  19624. selected output device unless the standard output device is not open.
  19625. The message appears prefixed with 5 asterisks. The MESSAGE
  19626. \index{***** (error message)}
  19627. list is displayed without top level parentheses. The MESSAGE from the
  19628. \index{EMSG* (global)}
  19629. ERROR call will be available in the global variable EMSG!*. The exact
  19630. format of error messages generated by Standard LISP functions
  19631. described in this document are not fixed and should not be relied upon
  19632. to be in any particular form. Likewise, error numbers generated by
  19633. Standard LISP functions are implementation dependent.
  19634. If no error occurs during the evaluation of U, the value of (LIST
  19635. (EVAL U)) is returned.
  19636. If an error has been signaled and the value of TR is non-NIL a
  19637. traceback sequence will be initiated on the selected output device.
  19638. The traceback will display information such as unbindings of FLUID
  19639. \index{fluid ! in traceback}
  19640. variables, argument lists and so on in an implementation dependent
  19641. format.}
  19642. \subsection{Vectors}
  19643. \label{vectors}
  19644. \index{vector}
  19645. Vectors are structured entities in which random elements may be
  19646. accessed with an integer index. A vector has a single dimension. Its
  19647. maximum size is determined by the implementation and available space.
  19648. A suggested input ``vector notation'' is defined in ``Classes of
  19649. Primitive Data Types'', section~\ref{pclasses} on
  19650. page~\pageref{pclasses} and output with EXPLODE, ``Identifiers''
  19651. section~\ref{identifiers} on page~\pageref{identifiers}.
  19652. \index{EXPLODE}
  19653. \de{GETV}{(\p{V}:\ty{vector}, \p{INDEX}:\ty{integer}):\ty{any}}{eval, spread}
  19654. {Returns the value stored at position INDEX of the vector V. The type
  19655. mismatch error may occur. An error occurs if the INDEX does not lie
  19656. within 0\ldots UPBV(V) inclusive:
  19657. \errormessage{***** INDEX subscript is out of range}
  19658. }
  19659. \de{MKVECT}{(\p{UPLIM}:\ty{integer}):\ty{vector}}{eval, spread}
  19660. {Defines and allocates space for a vector with UPLIM+1 elements
  19661. accessed as 0\ldots UPLIM. Each element is initialized to NIL. An
  19662. error will occur if UPLIM is $<$ 0 or there is not enough space for a
  19663. vector of this size:
  19664. \errormessage{***** A vector of size UPLIM cannot be allocated}
  19665. }
  19666. \de{PUTV}{(\p{V}:\ty{vector}, \p{INDEX}:\ty{integer},
  19667. \p{VALUE}:\ty{any}):\ty{any}}{eval, spread}
  19668. {Stores VALUE into the vector V at position INDEX. VALUE is returned.
  19669. The type mismatch error may occur. If INDEX does not lie in 0\ldots
  19670. UPBV(V) an error occurs:
  19671. \errormessage{***** INDEX subscript is out of range}
  19672. }
  19673. \de{UPBV}{(\p{U}:\ty{any}):{NIL,\ty{integer}}}{eval, spread}
  19674. {Returns the upper limit of U if U is a vector, or NIL if it is not.}
  19675. \subsection{Boolean Functions and Conditionals}
  19676. \de{AND}{([\p{U}:\ty{any}]):\ty{extra-boolean}}{noeval, nospread}
  19677. {AND evaluates each U until a value of NIL is found or the end of the
  19678. list is encountered. If a non-NIL value is the last value it is
  19679. returned, or NIL is returned.
  19680. {\tt \begin{tabbing} FEXPR PROCEDURE AND(U); \\ BEGIN \\
  19681. \hspace*{1em} IF NULL U THEN RETURN NIL; \\
  19682. LOOP: IF \= NULL CDR U THEN RETURN EVAL CAR U \\
  19683. \> ELSE IF NULL EVAL CAR U THEN RETURN NIL; \\
  19684. \hspace*{2em} \= U := CDR U; \\
  19685. \> GO LOOP \\
  19686. END;
  19687. \end{tabbing} }}
  19688. \de{COND}{([\p{U}:\ty{cond-form}]):\ty{any}}{noeval, nospread}
  19689. {The antecedents of all U's are evaluated in order of their appearance
  19690. until a non-NIL value is encountered. The consequent of the selected U
  19691. is evaluated and becomes the value of the COND. The consequent may
  19692. also contain the special functions GO and RETURN subject to the
  19693. restraints given for these functions in ``Program Feature Functions'',
  19694. section~\ref{prog} on page~\pageref{prog}.
  19695. \index{GO ! in COND} \index{RETUNR ! in CODE} In these cases COND does
  19696. not have a defined value, but rather an effect. If no antecedent is
  19697. non-NIL the value of COND is NIL. An error is detected if a U is
  19698. improperly formed:
  19699. \errormessage{***** Improper cond-form as argument of COND}
  19700. }
  19701. \de{NOT}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19702. {If U is NIL, return T else return NIL (same as function NULL).
  19703. {\tt \begin{tabbing} EXPR PROCEDURE NOT(U); \\
  19704. \hspace*{1em} U EQ NIL;
  19705. \end{tabbing}}
  19706. }
  19707. \de{OR}{([\p{U}:\ty{any}]):\ty{extra-boolean}}{noeval, nospread}
  19708. {U is any number of expressions which are evaluated in order of their
  19709. appearance. When one is found to be non-NIL it is returned as the
  19710. value of OR. If all are NIL, NIL is returned.
  19711. {\tt \begin{tabbing} FEXPR PROCEDURE OR(U); \\ BEGIN SCALAR X; \\
  19712. LOOP: IF \= NULL U THEN RETURN NIL \\
  19713. \> ELSE IF (X := EVAL CAR U) THEN RETURN X; \\
  19714. \hspace*{2em} \= U := CDR U; \\
  19715. \> GO LOOP \\
  19716. END;
  19717. \end{tabbing} }}
  19718. \subsection{Arithmetic Functions}
  19719. Conversions between numeric types are provided explicitly by the
  19720. \index{FIX} \index{FLOAT}
  19721. FIX and FLOAT functions and implicitly by any multi-parameter
  19722. \index{mixed-mode arithmetic}
  19723. arithmetic function which receives mixed types of arguments. A
  19724. conversion from fixed to floating point numbers may result in a loss
  19725. of precision without a warning message being generated. Since
  19726. \index{integer ! magnitude}
  19727. integers may have a greater magnitude that that permitted for floating
  19728. numbers, an error may be signaled when the attempted conversion cannot
  19729. be done. Because the magnitude of integers is unlimited the conversion
  19730. of a floating point number to a fixed number is always possible, the
  19731. only loss of precision being the digits to the right of the decimal
  19732. point which are truncated. If a function receives mixed types of
  19733. arguments the general rule will have the fixed numbers converted to
  19734. floating before arithmetic operations are performed. In all cases an
  19735. error occurs if the parameter to an arithmetic function is not a
  19736. number:
  19737. \errormessage{***** XXX parameter to FUNCTION is not a number}
  19738. XXX is the value of the parameter at fault and FUNCTION is the name of
  19739. the function that detected the error. Exceptions to the rule are noted
  19740. where they occur.
  19741. \de{ABS}{(\p{U}:\ty{number}):\ty{number}}{eval, spread}
  19742. {Returns the absolute value of its argument.
  19743. {\tt \begin{tabbing} EXPR PROCEDURE ABS(U); \\
  19744. \hspace*{1em} IF LESSP(U, 0) THEN MINUS(U) ELSE U;
  19745. \end{tabbing}}}
  19746. \de{ADD1}{(\p{U}:\ty{number}):\ty{number}}{eval, spread}
  19747. {Returns the value of U plus 1 of the same type as U (fixed or
  19748. floating).
  19749. {\tt \begin{tabbing} EXPR PROCEDURE ADD1(U); \\
  19750. % God knows why, but hspace* isn't accepted here.
  19751. \hspace{1em} PLUS2(U, 1);
  19752. \end{tabbing}}
  19753. }
  19754. \de{DIFFERENCE}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval,
  19755. spread}
  19756. {The value U - V is returned.}
  19757. \de{DIVIDE}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{dotted-pair}}{eval,
  19758. spread}
  19759. {The dotted-pair (quotient . remainder) is returned. The quotient part
  19760. is computed the same as by QUOTIENT and the remainder the same as by
  19761. REMAINDER. An error occurs if division by zero is attempted:
  19762. \index{division by zero}
  19763. \errormessage{***** Attempt to divide by 0 in DIVIDE}
  19764. {\tt \begin{tabbing} EXPR PROCEDURE DIVIDE(U, V); \\
  19765. \hspace*{1em} (QUOTIENT(U, V) . REMAINDER(U, V));
  19766. \end{tabbing}}}
  19767. \de{EXPT}{(\p{U}:\ty{number}, \p{V}:\ty{integer}):\ty{number}}{eval, spread}
  19768. {Returns U raised to the V power. A floating point U to an integer
  19769. power V does \underline{not} have V changed to a floating number
  19770. before exponentiation.}
  19771. \de{FIX}{(\p{U}:\ty{number}):\ty{integer}}{eval, spread}
  19772. {Returns an integer which corresponds to the truncated value of U. The
  19773. result of conversion must retain all significant portions of U. If U
  19774. is an integer it is returned unchanged. }
  19775. \de{FLOAT}{(\p{U}:\ty{number}):\ty{floating}}{eval, spread}
  19776. {The floating point number corresponding to the value of the argument
  19777. U is returned. Some of the least significant digits of an integer may
  19778. be lost do to the implementation of floating point numbers. FLOAT of a
  19779. floating point number returns the number unchanged. If U is too large
  19780. to represent in floating point an error occurs:
  19781. \errormessage{***** Argument to FLOAT is too large}
  19782. }
  19783. \de{GREATERP}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{boolean}}{eval,
  19784. spread}
  19785. {Returns T if U is strictly greater than V, otherwise returns NIL.}
  19786. \de{LESSP}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{boolean}}{eval, spread}
  19787. {Returns T if U is strictly less than V, otherwise returns NIL. }
  19788. \de{MAX}{([\p{U}:\ty{number}]):\ty{number}}{noeval, nospread, or macro}
  19789. {Returns the largest of the values in U. If two or more values are the
  19790. same the first is returned.
  19791. {\tt \begin{tabbing} MACRO PROCEDURE MAX(U); \\
  19792. \hspace*{1em} EXPAND(CDR U, 'MAX2);
  19793. \end{tabbing}}}
  19794. \de{MAX2}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19795. {Returns the larger of U and V. If U and V are the same value U is
  19796. returned (U and V might be of different types).
  19797. {\tt \begin{tabbing} EXPR PROCEDURE MAX2(U, V); \\
  19798. \hspace*{1em} IF LESSP(U, V) THEN V ELSE U;
  19799. \end{tabbing}}}
  19800. \de{MIN}{([\p{U}:\ty{number}]):\ty{number}}{noeval, nospread, or macro}
  19801. {Returns the smallest of the values in U. If two or more values are
  19802. the same the first of these is returned.
  19803. {\tt \begin{tabbing} MACRO PROCEDURE MIN(U); \\
  19804. \hspace*{1em} EXPAND(CDR U, 'MIN2);
  19805. \end{tabbing}}}
  19806. \de{MIN2}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19807. {Returns the smaller of its arguments. If U and V are the same value,
  19808. U is returned (U and V might be of different types).
  19809. {\tt \begin{tabbing} EXPR PROCEDURE MIN2(U, V); \\
  19810. \hspace*{1em} IF GREATERP(U, V) THEN V ELSE U;
  19811. \end{tabbing}}}
  19812. \de{MINUS}{(\p{U}:\ty{number}):\ty{number}}{eval, spread}
  19813. {Returns -U.
  19814. {\tt \begin{tabbing} EXPR PROCEDURE MINUS(U); \\
  19815. \hspace*{1em} DIFFERENCE(0, U);
  19816. \end{tabbing}}}
  19817. \de{PLUS}{([\p{U}:\ty{number}]):\ty{number}}{noeval, nospread, or macro}
  19818. {Forms the sum of all its arguments.
  19819. {\tt \begin{tabbing} MACRO PROCEDURE PLUS(U); \\
  19820. \hspace*{1em} EXPAND(CDR U, 'PLUS2);
  19821. \end{tabbing}}}
  19822. \de{PLUS2}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19823. {Returns the sum of U and V.}
  19824. \de{QUOTIENT}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19825. {The quotient of U divided by V is returned. Division of two positive
  19826. or two negative integers is conventional. When both U and V are
  19827. integers and exactly one of them is negative the value returned is the
  19828. negative truncation of the absolute value of U divided by the absolute
  19829. value of V. An error occurs if division by zero is attempted:
  19830. \index{division by zero}
  19831. \errormessage{***** Attempt to divide by 0 in QUOTIENT}
  19832. }
  19833. \de{REMAINDER}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval,
  19834. spread}
  19835. {If both U and V are integers the result is the integer remainder of U
  19836. divided by V. If either parameter is floating point, the result is the
  19837. difference between U and V*(U/V) all in floating point. If either
  19838. number is negative the remainder is negative. If both are positive or
  19839. both are negative the remainder is positive. An error occurs if V is
  19840. zero: \index{division by zero}
  19841. \errormessage{***** Attempt to divide by 0 in REMAINDER}
  19842. {\tt \begin{tabbing} EXPR PROCEDURE REMAINDER(U, V); \\
  19843. \hspace*{1em} DIFFERENCE(U, TIMES2(QUOTIENT(U, V), V));
  19844. \end{tabbing}}}
  19845. \de{SUB1}{(\p{U}:\ty{number}):\ty{number}}{eval, spread}
  19846. {Returns the value of U less 1. If U is a FLOAT type number, the
  19847. value returned is U less 1.0.
  19848. {\tt \begin{tabbing} EXPR PROCEDURE SUB1(U); \\
  19849. \hspace*{1em} DIFFERENCE(U, 1);
  19850. \end{tabbing}}}
  19851. \de{TIMES}{([\p{U}:\ty{number}]):\ty{number}}{noeval, nospread, or macro}
  19852. {Returns the product of all its arguments.
  19853. {\tt \begin{tabbing} MACRO PROCEDURE TIMES(U); \\
  19854. \hspace*{1em} EXPAND(CDR U, 'TIMES2);
  19855. \end{tabbing}}}
  19856. \de{TIMES2}{(\p{U}:\ty{number}, \p{V}:\ty{number}):\ty{number}}{eval, spread}
  19857. {Returns the product of U and V.}
  19858. \subsection{MAP Composite Functions}
  19859. \de{MAP}{(\p{X}:\ty{list}, F\p{N}:\ty{function}):\ty{any}}{eval, spread}
  19860. {Applies FN to successive CDR segments of X. NIL is returned.
  19861. {\tt \begin{tabbing} EXPR PROCEDURE MAP(X, FN); \\
  19862. \hspace*{1em} WHILE X DO $<<$ FN X; X := CDR X $>>$;
  19863. \end{tabbing}}}
  19864. \de{MAPC}{(X:list, FN:function):\ty{any}}{eval, spread}
  19865. {FN is applied to successive CAR segments of list X. NIL is returned.
  19866. {\tt \begin{tabbing} EXPR PROCEDURE MAPC(X, FN); \\
  19867. \hspace*{1em} WHILE X DO $<<$ FN CAR X; X := CDR X $>>$;
  19868. \end{tabbing}}}
  19869. \de{MAPCAN}{(X:list, FN:function):\ty{any}}{eval, spread}
  19870. {A concatenated list of FN applied to successive CAR elements of X is
  19871. returned.
  19872. {\tt \begin{tabbing} EXPR PROCEDURE MAPCAN(X, FN); \\
  19873. \hspace*{1em} IF\= NULL X THEN NIL \\
  19874. \> ELSE NCONC(FN CAR X, MAPCAN(CDR X, FN));
  19875. \end{tabbing}}}
  19876. \de{MAPCAR}{(X:list, FN:function):\ty{any}}{eval, spread}
  19877. {Returned is a constructed list of FN applied to each CAR of list X.
  19878. {\tt \begin{tabbing} EXPR PROCEDURE MAPCAR(X, FN); \\
  19879. \hspace*{1em} IF\= NULL X THEN NIL \\
  19880. \> ELSE FN CAR X . MAPCAR(CDR X, FN);
  19881. \end{tabbing}}}
  19882. \de{MAPCON}{(X:list, FN:function):\ty{any}}{eval, spread}
  19883. {Returned is a concatenated list of FN applied to successive CDR
  19884. segments of X.
  19885. {\tt \begin{tabbing} EXPR PROCEDURE MAPCON(X, FN); \\
  19886. \hspace*{1em} IF\= NULL X THEN NIL \\
  19887. \> ELSE NCONC(FN X, MAPCON(CDR X, FN));
  19888. \end{tabbing}}}
  19889. \de{MAPLIST}{(X:list, FN:function):\ty{any}}{eval, spread}
  19890. {Returns a constructed list of FN applied to successive CDR segments
  19891. of X.
  19892. {\tt \begin{tabbing} EXPR PROCEDURE MAPLIST(X, FN); \\
  19893. \hspace*{1em} IF\= NULL X THEN NIL \\
  19894. \> ELSE FN X . MAPLIST(CDR X, FN);
  19895. \end{tabbing}}}
  19896. \subsection{Composite Functions}
  19897. \de{APPEND}{(\p{U}:\ty{list}, \p{V}:\ty{list}):\ty{list}}{eval, spread}
  19898. {Returns a constructed list in which the last element of U is followed
  19899. by the first element of V. The list U is copied, V is not.
  19900. {\tt \begin{tabbing} EXPR PROCEDURE APPEND(U, V); \\
  19901. \hspace*{1em} IF\= NULL U THEN V \\
  19902. \> ELSE CAR U . APPEND(CDR U, V);
  19903. \end{tabbing}}}
  19904. \de{ASSOC}{(\p{U}:\ty{any}, \p{V}:\ty{alist}):\{\ty{dotted-pair},
  19905. NIL\}}{eval, spread}
  19906. {If U occurs as the CAR portion of an element of the alist V, the
  19907. dotted-pair in which U occurred is returned, else NIL is returned.
  19908. ASSOC might not detect a poorly formed alist so an invalid
  19909. \index{EQUAL ! in ASSOC} \index{alist ! in ASSOC}
  19910. construction may be detected by CAR or CDR.
  19911. {\tt \begin{tabbing} EXPR PROCEDURE ASSOC(U, V); \\
  19912. \hspace*{1em} IF \= NULL V THEN NIL \\
  19913. \> ELSE \= IF ATOM CAR V THEN \\
  19914. \> \> ERROR(000, LIST(V, "is a poorly formed alist")) \\
  19915. \> ELSE IF U = CAAR V THEN CAR V \\
  19916. \> ELSE ASSOC(U, CDR V);
  19917. \end{tabbing}}
  19918. }
  19919. \de{DEFLIST}{(\p{U}:\ty{dlist}, \p{IND}:\ty{id}):\ty{list}}{eval, spread}
  19920. {A "dlist" is a list in which each element is a two element list:
  19921. \index{dlist}
  19922. (ID:id PROP:any). Each ID in U has the indicator IND with property
  19923. PROP placed on its property list by the PUT function. The value of
  19924. DEFLIST is a list of the first elements of each two element list.
  19925. Like PUT, DEFLIST may not be used to define functions.
  19926. {\tt \begin{tabbing} EXPR PROCEDURE DEFLIST(U, IND); \\
  19927. \hspace*{1em} IF NULL U THEN NIL \\
  19928. \hspace*{2em} ELSE $<<$ \= PUT(CAAR U, IND, CADAR U); \\
  19929. \> CAAR U $>>$ . DEFLIST(CDR U, IND);
  19930. \end{tabbing}}
  19931. }
  19932. \de{DELETE}{(\p{U}:\ty{any}, \p{V}:\ty{list}):\ty{list}}{eval, spread}
  19933. {Returns V with the first top level occurrence of U removed from it.
  19934. \index{EQUAL ! in DELETE}
  19935. {\tt \begin{tabbing} EXPR PROCEDURE DELETE(U, V); \\
  19936. \hspace*{1em} IF NULL V THEN NIL \\
  19937. \hspace*{2em} ELSE IF CAR V = U THEN CDR V \\
  19938. \hspace*{2em} ELSE CAR V . DELETE(U, CDR V);
  19939. \end{tabbing}}}
  19940. \de{DIGIT}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19941. {Returns T if U is a digit, otherwise NIL.
  19942. {\tt \begin{tabbing} EXPR PROCEDURE DIGIT(U); \\
  19943. \hspace*{1em} IF MEMQ(U, '(!0 !1 !2 !3 !4 !5 !6 !7 !8 !9)) \\
  19944. \hspace*{2em} THEN T ELSE NIL;
  19945. \end{tabbing}}}
  19946. \de{LENGTH}{(\p{X}:\ty{any}):\ty{integer}}{eval, spread}
  19947. {The top level length of the list X is returned.
  19948. {\tt \begin{tabbing} EXPR PROCEDURE LENGTH(X); \\
  19949. \hspace*{1em} IF ATOM X THEN 0 \\
  19950. \hspace*{2em} ELSE PLUS(1, LENGTH CDR X);
  19951. \end{tabbing}}}
  19952. \de{LITER}{(\p{U}:\ty{any}):\ty{boolean}}{eval, spread}
  19953. {Returns T if U is a character of the alphabet, NIL
  19954. otherwise.\footnote{The published report omits escape characters.
  19955. These are required for both upper and lower case as some systems
  19956. default to lower.}
  19957. {\tt \begin{tabbing} EXPR PROCEDURE LITER(U); \\
  19958. \hspace*{1em} IF \= MEMQ(U, '(\=!A !B !C !D !E !F !G !H !I !J !K !L !M \\
  19959. \> \> !N !O !P !Q !R !S !T !U !V !W !X !Y !Z \\
  19960. \> \> !a !b !c !d !e !f !g !h !i !j !k !l !m \\
  19961. \> \> !n !o !p !q !r !s !t !u !v !w !x !y !z)) \\
  19962. \> THEN T ELSE NIL;
  19963. \end{tabbing}}}
  19964. \de{MEMBER}{(\p{A}:\ty{any}, \p{B}:\ty{list}):\ty{extra-boolean}}{eval, spread}
  19965. {Returns NIL if A is not a member of list B, returns the remainder of
  19966. B whose first element is A. \index{EQUAL ! in MEMBER}
  19967. {\tt \begin{tabbing} EXPR PROCEDURE MEMBER(A, B); \\
  19968. \hspace*{1em} IF NULL B THEN NIL \\
  19969. \hspace*{2em} ELSE IF A = CAR B THEN B \\
  19970. \hspace*{2em} ELSE MEMBER(A, CDR B);
  19971. \end{tabbing}}}
  19972. \de{MEMQ}{(\p{A}:\ty{any}, \p{B}:\ty{list}):\ty{extra-boolean}}{eval, spread}
  19973. {Same as MEMBER but an EQ check is used for comparison. \index{EQ ! in
  19974. MEMQ}
  19975. {\tt \begin{tabbing} EXPR PROCEDURE MEMQ(A, B); \\
  19976. \hspace*{1em} IF \= NULL B THEN NIL \\
  19977. \> ELSE IF A EQ CAR B THEN B \\
  19978. \> ELSE MEMQ(A, CDR B);
  19979. \end{tabbing}}}
  19980. \de{NCONC}{(\p{U}:\ty{list}, \p{V}:\ty{list}):\ty{list}}{eval, spread}
  19981. {Concatenates V to U without copying U. The last CDR of U is modified
  19982. to point to V.
  19983. {\tt \begin{tabbing} EXPR PROCEDURE NCONC(U, V); \\ BEGIN SCALAR W; \\
  19984. \hspace*{2em} \= IF NULL U THEN RETURN V; \\
  19985. \> W := U; \\
  19986. \> WHILE CDR W DO W := CDR W; \\
  19987. \> RPLACD(W, V); \\
  19988. \> RETURN U \\
  19989. END;
  19990. \end{tabbing}}}
  19991. \de{PAIR}{(\p{U}:\ty{list}, \p{V}:\ty{list}):\ty{alist}}{eval, spread}
  19992. {U and V are lists which must have an identical number of elements. If
  19993. not, an error occurs (the 000 used in the ERROR call is arbitrary and
  19994. need not be adhered to). Returned is a list where each element is a
  19995. dotted-pair, the CAR of the pair being from U, and the CDR the
  19996. corresponding element from V.
  19997. {\tt \begin{tabbing} EXPR PROCEDURE PAIR(U, V); \\
  19998. \hspace*{1em} IF AND(U, V) THEN (CAR U . CAR V) . PAIR(CDR U, CDR V) \\
  19999. \hspace*{2em} \= ELSE IF OR(U, V) THEN ERROR(000, \\
  20000. \hspace*{4em} "Different length lists in PAIR") \\
  20001. \> ELSE NIL;
  20002. \end{tabbing}}}
  20003. \de{REVERSE}{(\p{U}:\ty{list}):\ty{list}}{eval, spread}
  20004. {Returns a copy of the top level of U in reverse order.
  20005. {\tt \begin{tabbing} EXPR PROCEDURE REVERSE(U); \\ BEGIN SCALAR W; \\
  20006. \hspace*{2em} \= WHILE U DO $<<$ \= W := CAR U . W; \\
  20007. \> \> U := CDR U $>>$; \\
  20008. \> RETURN W \\
  20009. END;
  20010. \end{tabbing}}}
  20011. \de{SASSOC}{(\p{U}:\ty{any}, \p{V}:\ty{alist},
  20012. \p{FN}:\ty{function}):\ty{any}}{eval, spread}
  20013. {Searches the alist V for an occurrence of U. If U is not in the alist
  20014. the evaluation of function FN is returned. \index{EQUAL ! in SASSOC}
  20015. \index{alist ! in SASSOC}
  20016. {\tt \begin{tabbing} EXPR PROCEDURE SASSOC(U, V, FN); \\
  20017. \hspace*{1em} IF NULL V THEN FN() \\
  20018. \hspace*{2em} \= ELSE IF U = CAAR V THEN CAR V \\
  20019. \> ELSE SASSOC(U, CDR V, FN);
  20020. \end{tabbing}}}
  20021. \de{SUBLIS}{(\p{X}:\ty{alist}, \p{Y}:\ty{any}):\ty{any}}{eval, spread}
  20022. {The value returned is the result of substituting the CDR of each
  20023. element of the alist X for every occurrence of the CAR part of that
  20024. element in Y. \index{alist ! in SUBLIS}
  20025. {\tt \begin{tabbing} EXPR PROCEDURE SUBLIS(X, Y); \\
  20026. \hspace*{1em}IF NULL X THEN Y \\
  20027. \hspace*{2em} ELSE BEGIN \= SCALAR U; \\
  20028. \> U := ASSOC(Y, X); \\
  20029. \> RETURN \= IF U THEN CDR U \\
  20030. \> \> ELSE IF ATOM Y THEN Y \\
  20031. \> \> ELSE \= SUBLIS(X, CAR Y) . \\
  20032. \> \> \> SUBLIS(X, CDR Y) \\
  20033. \> END;
  20034. \end{tabbing}}}
  20035. \de{SUBST}{(\p{U}:\ty{any}, \p{V}:\ty{any}, \p{W}:\ty{any}):\ty{any}}{eval,
  20036. spread}
  20037. {The value returned is the result of substituting U for all
  20038. occurrences of V in W. \index{EQUAL ! in SUBST}
  20039. {\tt \begin{tabbing} EXPR PROCEDURE SUBST(U, V, W); \\
  20040. \hspace*{1em} IF NULL W THEN NIL \\
  20041. \hspace*{2em} \= ELSE IF V = W THEN U \\
  20042. \> ELSE IF ATOM W THEN W \\
  20043. \> ELSE SUBST(U, V, CAR W) . SUBST(U, V, CDR W);
  20044. \end{tabbing}}}
  20045. \subsection{The Interpreter}
  20046. \label{interpreter}
  20047. \de{APPLY}{(\p{FN}:\{\ty{id,function}\},
  20048. \p{ARGS}:\ty{any-list}):\ty{any}}{eval, spread}
  20049. {APPLY returns the value of FN with actual parameters ARGS. The actual
  20050. parameters in ARGS are already in the form required for binding to the
  20051. formal parameters of FN. Implementation specific portions described in
  20052. English are enclosed in boxes.
  20053. {\tt \begin{tabbing} EXPR PROCEDURE APPLY(FN, ARGS); \\ BEGIN SCALAR
  20054. DEFN; \\
  20055. \hspace*{2em}\= IF CODEP FN THEN RETURN \\
  20056. \> \hspace{1em} \framebox[3.25in]{\parbox{3.25in}{Spread the actual
  20057. parameters in ARGS
  20058. following the conventions: for calling functions, transfer to the
  20059. entry point of the function, and return the value returned by the
  20060. function.}}; \\
  20061. \> IF \= IDP FN THEN RETURN \\
  20062. \> \> IF \= NULL(DEFN := GETD FN) THEN \\
  20063. \> \> \> ERROR(000, LIST(FN, "is an undefined function")) \\
  20064. \> \> ELSE IF CAR DEFN EQ 'EXPR THEN \\
  20065. \> \> \> APPLY(CDR DEFN, ARGS) \\
  20066. \> \> ELSE ERROR(000, \\
  20067. \> \> \> LIST(FN, "cannot be evaluated by APPLY")); \\
  20068. \> IF OR(ATOM FN, NOT(CAR FN EQ 'LAMBDA)) THEN \\
  20069. \> \> ERROR(000, \\
  20070. \> \> LIST(FN, "cannot be evaluated by APPLY")); \\
  20071. \> RETURN \\
  20072. \> \> \framebox[3.25in]{\parbox{3.25in}{Bind the actual parameters in ARGS to
  20073. the formal
  20074. parameters of the lambda expression. If the two lists are not of equal
  20075. length then ERROR(000, "Number of parameters do not match"); The value
  20076. returned is EVAL CADDR FN.}} \\ END;
  20077. \end{tabbing}}}
  20078. \de{EVAL}{(\p{U}:\ty{any}):\ty{any}}{eval, spread}
  20079. {The value of the expression U is computed. Error numbers are
  20080. arbitrary. Portions of EVAL involving machine specific coding are
  20081. expressed in English enclosed in boxes.
  20082. {\tt \begin{tabbing} EXPR PROCEDURE EVAL(U); \\ BEGIN SCALAR FN; \\
  20083. \hspace*{2em} \= IF CONSTANTP U THEN RETURN U; \\
  20084. \> IF IDP U THEN RETURN \\
  20085. \> \hspace{1em} \framebox[3.25in]{\parbox{3.25in}{U is an id. Return the
  20086. value most currently
  20087. bound to U or if there is no such binding: ERROR(000, LIST("Unbound:",
  20088. U));}} \\
  20089. \> IF \= PAIRP CAR U THEN RETURN \\
  20090. \> \> IF CAAR U EQ 'LAMBDA THEN APPLY(CAR U, EVLIS CDR U) \\
  20091. \> \> ELSE ERROR(\= 000, LIST(CAR U, \\
  20092. \> \> \> "improperly formed LAMBDA expression")) \\
  20093. \> \> ELSE IF CODEP CAR U THEN \\
  20094. \> \> \> RETURN APPLY(CAR U, EVLIS CDR U); \\
  20095. \> FN := GETD CAR U; \\
  20096. \> IF NULL FN THEN \\
  20097. \> \> ERROR(000, LIST(CAR U, "is an undefined function")) \\
  20098. \> ELSE IF CAR FN EQ 'EXPR THEN \\
  20099. \> \> RETURN APPLY(CDR FN, EVLIS CDR U) \\
  20100. \> ELSE IF CAR FN EQ 'FEXPR THEN \\
  20101. \> \> RETURN APPLY(CDR FN, LIST CDR U) \\
  20102. \> ELSE IF CAR FN EQ 'MACRO THEN \\
  20103. \> \> RETURN EVAL APPLY(CDR FN, LIST U) \\
  20104. END;
  20105. \end{tabbing}}}
  20106. \de{EVLIS}{(\p{U}:\ty{any-list}):\ty{any-list}}{eval, spread}
  20107. {EVLIS returns a list of the evaluation of each element of U.
  20108. {\tt \begin{tabbing} EXPR PROCEDURE EVLIS(U); \\
  20109. \hspace*{1em} IF NULL U THEN NIL \\
  20110. \hspace*{2em} ELSE EVAL CAR U . EVLIS CDR U;
  20111. \end{tabbing}}}
  20112. \de{EXPAND}{(\p{L}:\ty{list}, \p{FN}:\ty{function}):\ty{list}}{eval, spread}
  20113. {FN is a defined function of two arguments to be used in the expansion
  20114. of a MACRO. EXPAND returns a list in the form:
  20115. \vspace{.15in}
  20116. (FN L$_0$ (FN L$_1$ \ldots (FN L$_{n-1}$ L$_n$) \ldots ))
  20117. \vspace{.15in}
  20118. where $n$ is the number of elements in L, L$_i$ is the $i$th element
  20119. of L.
  20120. {\tt \begin{tabbing} EXPR PROCEDURE EXPAND(L,FN); \\
  20121. \hspace*{1em} IF NULL CDR L THEN CAR L \\
  20122. \hspace*{2em} ELSE LIST(FN, CAR L, EXPAND(CDR L, FN));
  20123. \end{tabbing}}}
  20124. \de{FUNCTION}{(\p{FN}:\ty{function}):\ty{function}}{noeval, nospread}
  20125. {The function FN is to be passed to another function. If FN is to have
  20126. side effects its free variables must be fluid or global. FUNCTION is
  20127. like QUOTE but its argument may be affected by compilation. We do not
  20128. \index{FUNARGs not supported}
  20129. consider FUNARGs in this report.}
  20130. \de{QUOTE}{(U:any):\ty{any}}{noeval, nospread}
  20131. {Stops evaluation and returns U unevaluated.
  20132. {\tt \begin{tabbing} FEXPR PROCEDURE QUOTE(U); \\
  20133. \hspace*{2em}CAR U;
  20134. \end{tabbing}}}
  20135. \subsection{Input and Output}
  20136. \label{IO}
  20137. The user normally communicates with Standard LISP through
  20138. \index{standard devices}
  20139. ``standard devices''. The default devices are selected in accordance
  20140. with the conventions of the implementation site. Other input and
  20141. output devices or files may be selected for reading and writing using
  20142. the functions described herein.
  20143. \de{CLOSE}{(\p{FILEHANDLE}:\ty{any}):\ty{any}}{eval, spread}
  20144. {Closes the file with the internal name FILEHANDLE writing any
  20145. necessary end of file marks and such. The value of FILEHANDLE is that
  20146. returned by the corresponding OPEN. \index{OPEN} The value returned is
  20147. the value of FILEHANDLE. An error occurs if the file can not be
  20148. \index{file handle} \index{files}
  20149. closed.
  20150. \errormessage{ ***** FILEHANDLE could not be closed}
  20151. }
  20152. \de{EJECT}{():NIL}{eval, spread}
  20153. {Skip to the top of the next output page. Automatic EJECTs are
  20154. executed by the print functions when the length set by the PAGELENGTH
  20155. \index{PAGELENGTH} function is exceeded.}
  20156. \de{LINELENGTH}{(\p{LEN}:\{\ty{integer}, NIL\}):\ty{integer}}{eval, spread}
  20157. {If LEN is an integer the maximum line length to be printed before the
  20158. print functions initiate an automatic TERPRI is set to the value LEN.
  20159. \index{TERPRI}
  20160. No initial Standard LISP line length is assumed. The previous line
  20161. length is returned except when LEN is NIL. This special case returns
  20162. the current line length and does not cause it to be reset. An error
  20163. occurs if the requested line length is too large for the currently
  20164. selected output file or LEN is negative or zero.
  20165. \errormessage{ ***** LEN is an invalid line length}
  20166. }
  20167. \de{LPOSN}{():\ty{integer}}{eval, spread}
  20168. {Returns the number of lines printed on the current page. At the top
  20169. of a page, 0 is returned. }
  20170. \de{OPEN}{(\p{FILE}:\ty{any}, \p{HOW}:\ty{id}):\ty{any}}{eval, spread}
  20171. {Open the file with the system dependent name FILE for output if HOW
  20172. is EQ to OUTPUT, or input if HOW is EQ to INPUT. If the file is
  20173. \index{file handle} \index{files} \index{OUTPUT} \index{INPUT}
  20174. opened successfully, a value which is internally associated with the
  20175. file is returned. This value must be saved for use by RDS and WRS. An
  20176. error occurs if HOW is something other than INPUT or OUTPUT or the
  20177. file can't be opened.
  20178. \errormessage{***** HOW is not option for OPEN}
  20179. \errormessage{***** FILE could not be opened}
  20180. }
  20181. \de{PAGELENGTH}{(\p{LEN}:\{\ty{integer}, NIL\}):\ty{integer}}{eval, spread}
  20182. {Sets the vertical length (in lines) of an output page. Automatic page
  20183. EJECTs are executed by the print functions when this length is
  20184. \index{EJECT}
  20185. reached. The initial vertical length is implementation specific. The
  20186. previous page length is returned. If LEN is 0, no automatic page
  20187. ejects will occur. }
  20188. \de{POSN}{():\ty{integer}}{eval, spread}
  20189. {Returns the number of characters in the output buffer. When the
  20190. buffer is empty, 0 is returned.}
  20191. \de{PRINC}{(\p{U}:\ty{id}):\ty{id}}{eval, spread}
  20192. {U must be a single character id such as produced by EXPLODE or read
  20193. by READCH or the value of !\$EOL!\$. The effect is the character U
  20194. \index{\$EOL\$ (global)}
  20195. displayed upon the currently selected output device. The value of
  20196. !\$EOL!\$ causes termination of the current line like a call to
  20197. TERPRI.}
  20198. \de{PRINT}{(\p{U}:\ty{any}):\ty{any}}{eval, spread}
  20199. {Displays U in READ readable format and terminates the print line. The
  20200. value of U is returned.
  20201. {\tt \begin{tabbing} EXPR PROCEDURE PRINT(U); \\
  20202. \hspace*{2em} $<<$ PRIN1 U; TERPRI(); U $>>$;
  20203. \end{tabbing}}}
  20204. \de{PRIN1}{(\p{U}:\ty{any}):\ty{any}}{eval, spread}
  20205. {U is displayed in a READ readable form. The format of display is the
  20206. result of EXPLODE expansion; special characters are prefixed with the
  20207. escape character !, and strings are enclosed in "\ldots ". Lists are
  20208. displayed in list-notation and vectors in vector-notation. }
  20209. \de{PRIN2}{(\p{U}:\ty{any}):\ty{any}}{eval, spread}
  20210. {U is displayed upon the currently selected print device but output is
  20211. not READ readable. The value of U is returned. Items are displayed as
  20212. described in the EXPLODE function with the exceptions that the escape
  20213. character does not prefix special characters and strings are not
  20214. enclosed in "\ldots ". Lists are displayed in list-notation and
  20215. vectors in vector-notation. The value of U is returned. }
  20216. \de{RDS}{(\p{FILEHANDLE}:\ty{any}):\ty{any}}{eval, spread}
  20217. {Input from the currently selected input file is suspended and further
  20218. input comes from the file named. FILEHANDLE is a system dependent
  20219. \index{file handle}
  20220. internal name which is a value returned by OPEN. If FILEHANDLE is NIL
  20221. the standard input device is selected. When end of file is reached on
  20222. a non-standard input device, the standard input device is reselected.
  20223. When end of file occurs on the standard input device the Standard LISP
  20224. reader terminates. RDS returns the internal name of the previously
  20225. selected input file.
  20226. \index{standard input}
  20227. \errormessage{***** FILEHANDLE could not be selected for input}
  20228. }
  20229. \de{READ}{():\ty{any}}{}
  20230. {The next expression from the file currently selected for input. Valid
  20231. input forms are: vector-notation, dot-notation, list-notation,
  20232. numbers, function-pointers, strings, and identifiers with escape
  20233. characters. Identifiers are interned onW the OBLIST (see
  20234. \index{INTERN} \index{OBLIST entry}
  20235. the INTERN function in "Identifiers", section~\ref{identifiers} on
  20236. page~\pageref{identifiers}). READ returns the
  20237. \index{\$EOF\$ (global)}
  20238. value of !\$EOF!\$ when the end of the currently selected input file
  20239. is reached. }
  20240. \de{READCH}{():\ty{id}}{}
  20241. {Returns the next interned character from the file currently selected
  20242. for input. Two special cases occur. If all the characters in an input
  20243. \index{\$EOL\$ (global)} \index{\$EOF\$ (global)} record have been read,
  20244. the value of !\$EOL!\$ is returned. If the file selected for input has
  20245. all been read the value of !\$EOF!\$ is returned. Comments delimited
  20246. by \% and end-of-line are not transparent to READCH. \index{\% ! read
  20247. by READCH} }
  20248. \de{TERPRI}{():\p{NIL}}{}
  20249. {The current print line is terminated.}
  20250. \de{WRS}{(\p{FILEHANDLE}:\ty{any}):\ty{any}}{eval, spread}
  20251. {Output to the currently active output file is suspended and further
  20252. output is directed to the file named. FILEHANDLE is an internal name
  20253. which is returned by OPEN. The file named must have been opened for
  20254. output. If FILEHANDLE is NIL the standard output device is selected.
  20255. \index{file handle} \index{standard output}
  20256. WRS returns the internal name of the previously selected output file.
  20257. \errormessage{***** FILEHANDLE could not be selected for output}
  20258. }
  20259. \subsection{LISP Reader}
  20260. An EVAL read loop has been chosen to drive a Standard LISP system to
  20261. provide a continuity in functional syntax. Choices of messages and the
  20262. amount of extra information displayed are decisions left to the
  20263. implementor.
  20264. \index{STANDARD-LISP}
  20265. {\tt \begin{tabbing} EXPR PROCEDURE STANDARD!-LISP(); \\ BEGIN SCALAR
  20266. VALUE; \\
  20267. \hspace*{2em} \= RDS NIL; WRS NIL; \\
  20268. \> PRIN2 "Standard LISP"; TERPRI(); \\
  20269. \> WHILE T DO \\
  20270. \> \hspace*{1em} $<<$ \= PRIN2 "EVAL:"; TERPRI(); \\
  20271. \> \> VALUE := ERRORSET(QUOTE EVAL READ(), T, T); \\
  20272. \> \> IF NOT ATOM VALUE THEN PRINT CAR VALUE; \\
  20273. \> \> TERPRI() $>>$; \\
  20274. END;
  20275. \end{tabbing}}
  20276. \de{QUIT}{()}{}
  20277. {Causes termination of the LISP reader and control to be transferred
  20278. to the operating system.}
  20279. \section{System GLOBAL Variables}
  20280. \label{slglobals}
  20281. These variables provide global control of the LISP system, or
  20282. implement values which are constant throughout execution.\footnote{The
  20283. published document does not specify that all these are GLOBAL.}
  20284. \variable{*COMP}{NIL}{global}
  20285. {The value of !*COMP controls whether or not PUTD compiles the
  20286. function defined in its arguments before defining it. If !*COMP is NIL
  20287. the function is defined as an xEXPR. If !*COMP is something else the
  20288. function is first compiled. Compilation will produce certain changes
  20289. in the semantics of functions particularly FLUID type access.}
  20290. \variable{EMSG*}{NIL}{global}
  20291. {Will contain the MESSAGE generated by the last ERROR call (see
  20292. \index{ERROR}
  20293. ``Error Handling'' section~\ref{errors} on page~\pageref{errors}).}
  20294. \variable{\$EOF\$}{\s{an uninterned identifier}}{global}
  20295. {The value of !\$EOF!\$ is returned by all input functions when the
  20296. end
  20297. \index{end of file}
  20298. of the currently selected input file is reached.}
  20299. \variable{\$EOL\$}{\s{an uninterned identifier}}{global}
  20300. {The value of !\$EOL!\$ is returned by READCH when it reaches the end
  20301. of
  20302. \index{READCH} \index{end of line} \index{PRINC}
  20303. a logical input record. Likewise PRINC will terminate its current line
  20304. (like a call to TERPRI) when !\$EOL!\$ is its argument.}
  20305. \variable{*GC}{NIL}{global}
  20306. {!*GC controls the printing of garbage collector messages. If NIL no
  20307. \index{garbage collector}
  20308. indication of garbage collection may occur. If non-NIL various system
  20309. dependent messages may be displayed.}
  20310. \variable{NIL}{NIL}{global}
  20311. {NIL is a special global variable. It is protected from being modified
  20312. by SET or SETQ.
  20313. \index{NIL ! cannot be changed}}
  20314. \variable{*RAISE}{NIL}{global}
  20315. {If !*RAISE is non-NIL all characters input through Standard LISP
  20316. input/output functions will be raised to upper case. If !*RAISE is NIL
  20317. characters will be input as is.}
  20318. \variable{T}{T}{global}
  20319. {T is a special global variable. It is protected from being modified
  20320. by SET or SETQ. \index{T ! cannot be changed}}
  20321. \section{The Extended Syntax}
  20322. Whenever it is possible to define Standard LISP functions in LISP the
  20323. text of the function will appear in an extended syntax. These
  20324. definitions are supplied as an aid to understanding the behavior of
  20325. functions and not as a strict implementation guide. A formal scheme
  20326. for the translation of extended syntax to Standard LISP is presented
  20327. to eliminate misinterpretation of the definitions.
  20328. \subsection{Definition}
  20329. The goal of the transformation scheme is to produce a PUTD invocation
  20330. which has the function translated from the extended syntax as its
  20331. actual parameter. A rule has a name in brackets
  20332. \s{\ldots} by which it is known and is defined by what follows the meta
  20333. symbol ::=. Each rule of the set consists of one or more
  20334. ``alternatives'' separated by the $\mid$ meta symbol, being the
  20335. different ways in which the rule will be matched by source text. Each
  20336. alternative is composed of a ``recognizer'' and a ``generator''
  20337. separated by the $\Longrightarrow$ meta symbol. The recognizer is a
  20338. concatenation of any of three different forms. 1) Terminals - Upper
  20339. case lexemes and punctuation which is not part of the meta syntax
  20340. represent items which must appear as is in the source text for the
  20341. rule to succeed. 2) Rules - Lower case lexemes enclosed in \s{\ldots}
  20342. are names of other rules. The source text is matched if the named
  20343. rule succeeds. 3) Primitives - Lower case singletons not in brackets
  20344. are names of primitives or primitive classes of Standard LISP. The
  20345. syntax and semantics of the primitives are given in Part I.
  20346. The recognizer portion of the following rule matches an extended
  20347. syntax procedure:
  20348. \s{function} ::= ftype PROCEDURE id (\s{id list}); \\
  20349. \hspace*{2em} \s{statement}; $\Longrightarrow$
  20350. A function is recognized as an ``ftype'' (one of the tokens EXPR,
  20351. FEXPR, etc.) followed by the keyword PROCEDURE, followed by an ``id''
  20352. (the name of the function), followed by an \s{id list} (the formal
  20353. parameter names) enclosed in parentheses. A semicolon terminates the
  20354. title line. The body of the function is a
  20355. \s{statement} followed by a semicolon. For example:
  20356. {\small\begin{verbatim}
  20357. EXPR PROCEDURE NULL(X); EQ(X, NIL);
  20358. \end{verbatim}}
  20359. \noindent satisfies the recognizer, causes the generator to be activated and
  20360. the rule to be matched successfully.
  20361. The generator is a template into which generated items are
  20362. substituted. The three syntactic entities have corresponding meanings
  20363. when they appear in the generator portion. 1) Terminals - These
  20364. lexemes are copied as is to the generated text. 2) Rules - If a rule
  20365. has succeeded in the recognizer section then the value of the rule is
  20366. the result of the generator portion of that rule. 3) Primitives -
  20367. When primitives are matched the primitive lexeme replaces its
  20368. occurrence in the generator.
  20369. If more than one occurrence of an item would cause ambiguity in the
  20370. generator portion this entity appears with a bracketed subscript.
  20371. Thus:
  20372. \begin{tabbing}
  20373. \s{conditional} ::= \\
  20374. \hspace*{2em} IF \s{expression} \= THEN \s{statement$_1$} \\
  20375. \> ELSE \s{statement$_2$} \ldots
  20376. \end{tabbing}
  20377. \noindent has occurrences of two different \s{statement}s. The generator
  20378. portion uses the subscripted entities to reference the proper
  20379. generated value.
  20380. The \s{function} rule appears in its entirety as:
  20381. \begin{tabbing}
  20382. \s{function} ::= ftype PROCEDURE id (\s{id list});\s{statement};
  20383. $\Longrightarrow$ \\
  20384. \hspace*{2em} \=(PUTD \= (QUOTE id) \\
  20385. \> \> (QUOTE ftype) \\
  20386. \> \>(QUOTE (LAMBDA (\s{id list}) \s{statement})))
  20387. \end{tabbing}
  20388. If the recognizer succeeds (as it would in the case of the NULL
  20389. procedure example) the generator returns:
  20390. {\small\begin{verbatim}
  20391. (PUTD (QUOTE NULL) (QUOTE EXPR) (QUOTE (LAMBDA (X) (EQ X NIL))))
  20392. \end{verbatim}}
  20393. The identifier in the template is replaced by the procedure name NULL,
  20394. \s{id list} by the single formal parameter X, the \s{statement} by (EQ
  20395. X NIL) which is the result of the \s{statement} generator. EXPR
  20396. replaces ftype, the type of the defined procedure.
  20397. \subsection{The Extended Syntax Rules}
  20398. \begin{tabbing}
  20399. \s{function} ::= ftype \k{PROCEDURE} id (\s{id list}); \s{statement};
  20400. $\Longrightarrow$ \\
  20401. \hspace*{2em} \= (PUTD \= (QUOTE id) \\
  20402. \> \> (QUOTE ftype) \\
  20403. \> \> (QUOTE (LAMBDA (\s{id list}) \s{statement}))) \\ \\
  20404. \s{id list} ::= id $\Longrightarrow$ id $\mid$ \\
  20405. \> id, \s{id list} $\Longrightarrow$ id \s{id list} $\mid$ \\
  20406. \> $\Longrightarrow$ NIL \\
  20407. \s{statement} ::= \s{expression} $\Longrightarrow$ \s{expression} $\mid$ \\
  20408. \> \s{proper statement} $\Longrightarrow$ \s{proper statement} \\ \\
  20409. \s{proper statement} ::= \\
  20410. \> \s{assignment statement} $\Longrightarrow$ \s{assignment statement}
  20411. $\mid$ \\
  20412. \> \s{conditional statement} $\Longrightarrow$ \s{conditional statement}
  20413. $\mid$ \\
  20414. \> \s{while statement} $\Longrightarrow$ \s{while statement} $\mid$ \\
  20415. \> \s{compound statement} $\Longrightarrow$ \s{compound statement} \\ \\
  20416. \s{assignment statement} ::= id := \s{expression} $\Longrightarrow$ \\
  20417. \> \> (SETQ id \s{expression}) \\ \\
  20418. \s{conditional statement} ::= \\
  20419. \> \k{IF} \s{expression} \k{THEN} \s{statement$_1$} \k{ELSE}
  20420. \s{statement$_2$} $\Longrightarrow$ \\
  20421. \> \hspace{2em} \= (COND (\s{expression} \s{statement$_1$})(T
  20422. \s{statement$_2$})) $\mid$ \\
  20423. \> \k{IF} \s{expression} \k{THEN} \s{statement} $\Longrightarrow$ \\
  20424. \> \> (COND (\s{expression} \s{statement})) \\ \\
  20425. \s{while statement} ::= \k{WHILE} \s{expression} \k{DO} \s{statement}
  20426. $\Longrightarrow$ \\
  20427. \> \> (PROG NIL \\
  20428. \> \> LBL \= (COND ((NULL \s{expression}) (RETURN NIL))) \\
  20429. \> \> \> \s{statement} \\
  20430. \> \> \> (GO LBL)) \\ \\
  20431. \s{compound statement} ::= \\
  20432. \> \k{BEGIN} \k{SCALAR} \s{id list}; \s{program list} \k{END}
  20433. $\Longrightarrow$ \\
  20434. \> \> (PROG (\s{id list}) \s{program list}) $\mid$ \\
  20435. \> \k{BEGIN} \s{program list} \k{END} $\Longrightarrow$ \\
  20436. \> \> (PROG NIL \s{program list}) $\mid$ \\
  20437. \> \k{$<<$} \s{statement list} \k{$>>$} $\Longrightarrow$ (PROGN
  20438. \s{statement list}) \\ \\
  20439. \s{program list} ::= \s{full statement} $\Longrightarrow$ \s{full statement}
  20440. $\mid$ \\
  20441. \> \s{full statement} \s{program list} $\Longrightarrow$ \\
  20442. \> \> \s{full statement} \s{program list} \\ \\
  20443. \s{full statement} ::= \s{statement} $\Longrightarrow$ \s{statement} $\mid$
  20444. id: $\Longrightarrow$ id \\ \\
  20445. \s{statement list} ::= \s{statement} $\Longrightarrow$ \s{statement} $\mid$ \\
  20446. \> \s{statement}; \s{statement list} $\Longrightarrow$ \\
  20447. \> \> \s{statement} \s{statement list} \\ \\
  20448. \s{expression} ::= \\
  20449. \> \s{expression$_1$} \k{.} \s{expression$_2$} $\Longrightarrow$ \\
  20450. \> \> (CONS \s{expression$_1$} \s{expression$_2$} $\mid$ \\
  20451. \> \s{expression$_1$} \k{=} \s{expression$_2$} $\Longrightarrow$ \\
  20452. \> \> (EQUAL \s{expression$_1$} \s{expression$_2$}) $\mid$ \\
  20453. \> \s{expression$_1$} \k{EQ} \s{expression$_2$} $\Longrightarrow$ \\
  20454. \> \> (EQ \s{expression$_1$} \s{expression$_2$}) $\mid$ \\
  20455. \> '\s{expression} $\Longrightarrow$ (QUOTE \s{expression}) $\mid$ \\
  20456. \> function \s{expression} $\Longrightarrow$ (function \s{expression})
  20457. $\mid$ \\
  20458. \> function(\s{argument list}) $\Longrightarrow$ (function \s{argument list})
  20459. $\mid$ \\
  20460. \> number $\Longrightarrow$ number $\mid$ \\
  20461. \> id $\Longrightarrow$ id \\ \\
  20462. \s{argument list} ::= () $\Longrightarrow$ $\mid$ \\
  20463. \> \s{expression} $\Longrightarrow$ \s{expression} $\mid$ \\
  20464. \> \s{expression}, \s{argument list} $\Longrightarrow$ \s{expression}
  20465. \s{argument list}
  20466. \end{tabbing}
  20467. Notice the three infix operators . EQ and = which are translated into
  20468. calls on CONS, EQ, and EQUAL respectively. Note also that a call on a
  20469. function which has no formal parameters must have () as an argument
  20470. list. The QUOTE function is abbreviated by '.
  20471. %\bibliography{sl}
  20472. %\bibliographystyle{plain}
  20473. %\end{document}
  20474. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  20475. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EndCodemist
  20476. \part{Appendix}
  20477. \appendix
  20478. \chapter{Reserved Identifiers}
  20479. We list here all identifiers that are normally reserved in \REDUCE{}
  20480. including names of commands, operators and switches initially in the system.
  20481. Excluded are words that are reserved in specific implementations of the
  20482. system.
  20483. \vspace{13pt}
  20484. \begin{list}{}{\renewcommand{\makelabel}[1]{#1\hspace{\fill}}%
  20485. \settowidth{\labelwidth}{Numerical Operators}%
  20486. \setlength{\labelsep}{1em}%
  20487. \settowidth{\leftmargin}{Numerical Operators\hspace*{\labelsep}}%
  20488. \sloppy}
  20489. \item[Commands] {\tt ALGEBRAIC} {\tt ANTISYMMETRIC}
  20490. {\tt ARRAY} {\tt BYE} {\tt CLEAR} \linebreak
  20491. {\tt CLEARRULES} {\tt COMMENT} {\tt
  20492. CONT} {\tt DECOMPOSE} {\tt DEFINE} {\tt DEPEND} {\tt DISPLAY} {\tt ED}
  20493. {\tt EDITDEF} {\tt END} {\tt EVEN} {\tt FACTOR} {\tt FOR} {\tt FORALL}
  20494. {\tt FOREACH} {\tt GO} {\tt GOTO} {\tt IF} {\tt IN} {\tt INDEX} {\tt INFIX}
  20495. {\tt INPUT} {\tt INTEGER} {\tt KORDER} {\tt LET} {\tt LINEAR} {\tt LISP}
  20496. {\tt LISTARGP} {\tt LOAD} {\tt LOAD\_PACKAGE} {\tt MASS} {\tt MATCH} {\tt
  20497. MATRIX} {\tt MSHELL} {\tt NODEPEND} {\tt NONCOM} {\tt NONZERO} {\tt NOSPUR}
  20498. {\tt ODD} {\tt OFF}
  20499. {\tt ON} {\tt OPERATOR} {\tt ORDER} {\tt OUT} {\tt PAUSE} {\tt PRECEDENCE}
  20500. {\tt PRINT\_PRECISION} {\tt PROCEDURE} {\tt QUIT} {\tt REAL} {\tt REMFAC}
  20501. {\tt REMIND} {\tt RETRY} {\tt RETURN} {\tt SAVEAS} {\tt SCALAR} {\tt
  20502. SETMOD} {\tt SHARE} {\tt SHOWTIME} {\tt SHUT} {\tt SPUR} {\tt SYMBOLIC}
  20503. {\tt SYMMETRIC} {\tt VECDIM} {\tt VECTOR} {\tt WEIGHT} {\tt WRITE} {\tt
  20504. WTLEVEL}
  20505. \item[Boolean Operators] {\tt EVENP} {\tt FIXP}
  20506. {\tt FREEOF} {\tt NUMBERP} {\tt ORDP} {\tt PRIMEP}
  20507. \item[Infix Operators]
  20508. \verb|:=| \verb|=| \verb|>=| \verb|>| \verb|<=| \verb|<| \verb|=>|
  20509. \verb|+| \verb|*| \verb|/| \verb|^| \verb|**| \verb|.| {\tt WHERE}
  20510. {\tt SETQ} {\tt OR} {\tt AND} {\tt MEMBER} {\tt MEMQ} {\tt
  20511. EQUAL} {\tt NEQ} {\tt EQ} {\tt GEQ} {\tt GREATERP} {\tt LEQ} {\tt LESSP}
  20512. {\tt PLUS} {\tt DIFFERENCE} {\tt MINUS} {\tt TIMES} {\tt QUOTIENT} {\tt
  20513. EXPT} {\tt CONS}
  20514. \item[Numerical Operators] {\tt ABS} {\tt ACOS}
  20515. {\tt ACOSH} {\tt ACOT} {\tt ACOTH} {\tt ACSC} {\tt ACSCH} {\tt ASEC} {\tt
  20516. ASECH} {\tt ASIN} {\tt ASINH} {\tt ATAN} {\tt ATANH} {\tt ATAN2} {\tt COS}
  20517. {\tt COSH} {\tt COT} {\tt COTH} {\tt CSC} {\tt CSCH} {\tt EXP} {\tt
  20518. FACTORIAL} {\tt FIX} {\tt FLOOR} {\tt HYPOT} {\tt LN} {\tt LOG} {\tt LOGB}
  20519. {\tt LOG10} {\tt NEXTPRIME} {\tt ROUND} {\tt SEC} {\tt SECH} {\tt SIN}
  20520. {\tt SINH} {\tt SQRT} {\tt TAN} {\tt TANH}
  20521. \item[Prefix Operators] {\tt APPEND} {\tt
  20522. ARGLENGTH} {\tt CEILING} {\tt COEFF} {\tt COEFFN} {\tt COFACTOR} {\tt
  20523. CONJ} {\tt DEG} {\tt DEN} {\tt DET} {\tt DF} {\tt DILOG} {\tt EI}
  20524. {\tt EPS} {\tt ERF} {\tt FACTORIZE} {\tt FIRST} {\tt GCD} {\tt G} {\tt
  20525. IMPART} {\tt INT} {\tt INTERPOL} {\tt LCM} {\tt LCOF} {\tt LENGTH} {\tt
  20526. LHS} {\tt LINELENGTH} {\tt LTERM} {\tt MAINVAR} {\tt MAT} {\tt MATEIGEN}
  20527. {\tt MAX} {\tt MIN} {\tt MKID} {\tt NULLSPACE} {\tt NUM} {\tt PART} {\tt
  20528. PF} {\tt PRECISION} {\tt RANDOM} {\tt RANDOM\_NEW\_SEED} {\tt RANK} {\tt
  20529. REDERR} {\tt REDUCT} {\tt REMAINDER} {\tt REPART} {\tt REST} {\tt
  20530. RESULTANT} {\tt REVERSE} {\tt RHS} {\tt SECOND} {\tt SET} {\tt SHOWRULES}
  20531. {\tt SIGN} {\tt SOLVE} {\tt STRUCTR} {\tt SUB} {\tt SUM} {\tt THIRD} {\tt
  20532. TP} {\tt TRACE} {\tt VARNAME}
  20533. \item[Reserved Variables] {\tt CARD\_NO} {\tt E} {\tt EVAL\_MODE}
  20534. {\tt FORT\_WIDTH} {\tt HIGH\_POW} {\tt I} {\tt INFINITY} {\tt K!*} {\tt
  20535. LOW\_POW} {\tt NIL} {\tt PI} {\tt ROOT\_MULTIPLICITY} {\tt T}
  20536. \item[Switches] {\tt ADJPREC} {\tt ALGINT} {\tt ALLBRANCH} {\tt ALLFAC}
  20537. {\tt BFSPACE} {\tt COMBINEEXPT} {\tt COMBINELOGS}
  20538. {\tt COMP} {\tt COMPLEX} {\tt CRAMER} {\tt CREF} {\tt DEFN} {\tt DEMO}
  20539. {\tt DIV} {\tt ECHO} {\tt ERRCONT} {\tt EVALLHSEQP} {\tt EXP} {\tt
  20540. EXPANDLOGS} {\tt EZGCD} {\tt FACTOR} {\tt FORT} {\tt FULLROOTS} {\tt GCD}
  20541. {\tt IFACTOR} {\tt INT} {\tt INTSTR} {\tt LCM} {\tt LIST} {\tt LISTARGS}
  20542. {\tt MCD} {\tt MODULAR} {\tt MSG} {\tt MULTIPLICITIES} {\tt NAT} {\tt
  20543. NERO} {\tt NOSPLIT} {\tt OUTPUT} {\tt PERIOD} {\tt PRECISE} {\tt PRET}
  20544. {\tt PRI} {\tt RAT} {\tt RATARG} {\tt RATIONAL} {\tt RATIONALIZE} {\tt
  20545. RATPRI} {\tt REVPRI} {\tt RLISP88} {\tt ROUNDALL} {\tt ROUNDBF} {\tt
  20546. ROUNDED} {\tt SAVESTRUCTR} {\tt SOLVESINGULAR} {\tt TIME} {\tt TRA} {\tt
  20547. TRFAC} {\tt TRIGFORM} {\tt TRINT}
  20548. \item[Other Reserved Ids] {\tt BEGIN} {\tt DO} {\tt
  20549. EXPR} {\tt FEXPR} {\tt INPUT} {\tt LAMBDA} {\tt
  20550. LISP} {\tt MACRO} {\tt PRODUCT} {\tt REPEAT} {\tt SMACRO} {\tt
  20551. SUM} {\tt UNTIL} {\tt WHEN} {\tt WHILE} {\tt WS}
  20552. \end{list}
  20553. \newpage
  20554. \addcontentsline{toc}{chapter}{Index}{}
  20555. \appendix
  20556. \bibliographystyle{plain}
  20557. \bibliography{bibl,sl}
  20558. \printindex
  20559. \end{document}