1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137 |
- REDUCE 3.6, 15-Jul-95, patched to 6 Mar 96 ...
- % Tests of Assist Package version 2.1.
- % DATE : 25 December 1993
- % Author: H. Caprasse <caprasse@vm1.ulg.ac.be>
- %load_package assist$
- Comment 2. HELP for ASSIST:;
- ;
- helpassist(assist);
- Arguments must be integers from 3 to 15
- They correspond to the section numbers in the documentation:
- 3 for switches 4 for lists 5 for bags 6 for sets
- 7 for utilities 8 for properties 9 for control functions
- 10 for polynomes
- 11 for trigonometric or
- hyperbolic functions
- 12 for arrays 13 for vectors
- 14 for grassmann variables 15 for matrices
- ;
- helpassist(6);
- {union,setp,mkset,setdiff,symdiff}
- ;
- Comment 3. CONTROL OF SWITCHES:;
- ;
- switches;
- **** exp:=t .................... allfac:= t ****
- **** ezgcd:=nil ................. gcd:= nil ****
- **** mcd:=t ....................... lcm:= t ****
- **** div:=nil ................... rat:= nil ****
- **** intstr:=nil ........... rational:= nil ****
- **** precise:=t ........... reduced:= nil ****
- **** complex:=nil ....... rationalize:= nil ****
- **** factor:= nil ....... combineexpt:= nil ****
- **** complex:= nil ....... distribute:= nil ****
- off exp;
- on gcd;
- switches;
- **** exp:=nil .................... allfac:= t ****
- **** ezgcd:=nil ................. gcd:= t ****
- **** mcd:=t ....................... lcm:= t ****
- **** div:=nil ................... rat:= nil ****
- **** intstr:=nil ........... rational:= nil ****
- **** precise:=t ........... reduced:= nil ****
- **** complex:=nil ....... rationalize:= nil ****
- **** factor:= nil ....... combineexpt:= nil ****
- **** complex:= nil ....... distribute:= nil ****
- switchorg;
- switches;
- **** exp:=t .................... allfac:= t ****
- **** ezgcd:=nil ................. gcd:= nil ****
- **** mcd:=t ....................... lcm:= t ****
- **** div:=nil ................... rat:= nil ****
- **** intstr:=nil ........... rational:= nil ****
- **** precise:=nil ........... reduced:= nil ****
- **** complex:=nil ....... rationalize:= nil ****
- **** factor:= nil ....... combineexpt:= nil ****
- **** complex:= nil ....... distribute:= nil ****
- ;
- if !*mcd then "the switch mcd is on";
- the switch mcd is on
- if !*gcd then "the switch gcd is on";
- ;
- Comment 4. MANIPULATION OF THE LIST STRUCTURE:;
- ;
- t1:=mklist(4);
- t1 := {0,0,0,0}
- Comment MKLIST does NEVER destroy anything ;
- mklist(t1,3);
- {0,0,0,0}
- mklist(t1,10);
- {0,0,0,0,0,0,0,0,0,0}
- ;
- % Generation of n duplicates of list :
- algnlist({a,x^2,1},3);
- 2
- {{a,x ,1},
- 2
- {a,x ,1},
- 2
- {a,x ,1}}
- ;
- sequences 3;
- {{0,0,0},
- {1,0,0},
- {0,1,0},
- {1,1,0},
- {0,0,1},
- {1,0,1},
- {0,1,1},
- {1,1,1}}
- lisp;
- nil
- sequences 3;
- ((0 0 0) (1 0 0) (0 1 0) (1 1 0) (0 0 1) (1 0 1) (0 1 1) (1 1 1))
- algebraic;
- ;
- frequency append(t1,t1);
- {{0,8}}
- elmult(a1,t1);
- 0
- insert(a1,t1,2);
- {0,a1,0,0,0}
- li:=list(1,2,5);
- li := {1,2,5}
- insert_keep_order(4,li,lessp);
- {1,2,4,5}
- merge_list(li,li,lessp);
- {1,1,2,2,5,5}
- for i:=1:4 do t1:= (t1.i:=mkid(a,i));
- % for i:=1:2 do t1:=(t1.i:=mkid(a,i));
- t1.1;
- a1
- t1:=(t1.1) . t1;
- t1 := {a1,a1,a2,a3,a4}
- position(a2,t1);
- 3
- pair(t1,t1);
- {{a1,a1},{a1,a1},{a2,a2},{a3,a3},{a4,a4}}
- depth list t1;
- 2
- depth a1;
- 0
- appendn(li,li,li);
- {1,2,5,1,2,5,1,2,5}
- ;
- comment 5. THE BAG STRUCTURE AND ITS ASSOCIATED FUNCTIONS
- ;
- aa:=bag(x,1,"A");
- aa := bag(x,1,A)
- putbag bg1,bg2;
- t
- on errcont;
- putbag list;
- ***** list invalid as BAG
- off errcont;
- aa:=bg1(x,y**2);
- 2
- aa := bg1(x,y )
- ;
- if bagp aa then "this is a bag";
- this is a bag
- ;
- clearbag bg2;
- ;
- depth bg2(x);
- 0
- ;
- if baglistp aa then "this is a bag or list";
- this is a bag or list
- if baglistp list(x) then "this is a bag or list";
- this is a bag or list
- ;
- ab:=bag(x1,x2,x3);
- ab := bag(x1,x2,x3)
- al:=list(y1,y2,y3);
- al := {y1,y2,y3}
- first ab;
- bag(x1)
- third ab;
- bag(x3)
- first al;
- y1
- last ab;
- bag(x3)
- last al;
- y3
- belast ab;
- bag(x1,x2)
- belast al;
- {y1,y2}
- rest ab;
- bag(x2,x3)
- rest al;
- {y2,y3}
- depth al;
- 1
- depth bg1(ab);
- 2
- ;
- ab.1;
- x1
- al.3;
- y3
- on errcont;
- ab.4;
- ***** Expression bag(x1,x2,x3) does not have part 4
- off errcont;
- kernlist(aa);
- 2
- {x,y }
- listbag(list x,bg1);
- bg1(x)
- size ab;
- 3
- length al;
- 3
- remove(ab,3);
- bag(x1,x2)
- delete(y2,al);
- {y1,y3}
- reverse al;
- {y3,y2,y1}
- member(x3,ab);
- bag(x3)
- al:=list(x**2,x**2,y1,y2,y3);
- 2
- al := {x ,
- 2
- x ,
- y1,
- y2,
- y3}
- ;
- elmult(x**2,al);
- 2
- position(y3,al);
- 5
- ;
- repfirst(xx,al);
- 2
- {xx,x ,y1,y2,y3}
- represt(xx,ab);
- bag(x1,xx)
- insert(x,al,3);
- 2 2
- {x ,x ,x,y1,y2,y3}
- insert( b,ab,2);
- bag(x1,b,xx)
- insert(ab,ab,1);
- bag(bag(x1,xx),x1,xx)
- substitute (new,y1,al);
- 2 2
- {x ,x ,new,y2,y3}
- ;
- appendn(ab,ab,ab);
- {x1,xx,x1,xx,x1,xx}
- append(ab,al);
- 2 2
- bag(x1,xx,x ,x ,y1,y2,y3)
- append(al,ab);
- 2 2
- {x ,x ,y1,y2,y3,x1,xx}
- ;
- comment Association list or bag may be constructed and thoroughly used;
- ;
- l:=list(a1,a2,a3,a4);
- l := {a1,a2,a3,a4}
- b:=bg1(x1,x2,x3);
- b := bg1(x1,x2,x3)
- al:=pair(list(1,2,3,4),l);
- al := {{1,a1},{2,a2},{3,a3},{4,a4}}
- ab:=pair(bg1(1,2,3),b);
- ab := bg1(bg1(1,x1),bg1(2,x2),bg1(3,x3))
- ;
- comment : A BOOLEAN function abaglistp to test if it is an association;
- ;
- if abaglistp bag(bag(1,2)) then "it is an associated bag";
- it is an associated bag
- ;
- % Values associated to the keys can be extracted
- % first occurence ONLY.
- ;
- asfirst(1,al);
- {1,a1}
- asfirst(3,ab);
- bg1(3,x3)
- ;
- assecond(a1,al);
- {1,a1}
- assecond(x3,ab);
- bg1(3,x3)
- ;
- aslast(z,list(list(x1,x2,x3),list(y1,y2,z)));
- {y1,y2,z}
- asrest(list(x2,x3),list(list(x1,x2,x3),list(y1,y2,z)));
- {x1,x2,x3}
- ;
- clear a1;
- ;
- % All occurences.
- asflist(x,bg1(bg1(x,a1,a2),bg1(x,b1,b2)));
- bg1(bg1(x,a1,a2),bg1(x,b1,b2))
- asslist(a1,list(list(x,a1),list(y,a1),list(x,y)));
- {{x,a1},{y,a1}}
- restaslist(bag(a1,x),bg1(bag(x,a1,a2),bag(a1,x,b2),bag(x,y,z)));
- bg1(bg1(x,b2),bg1(a1,a2))
- restaslist(list(a1,x),bag(bag(x,a1,a2),bag(a1,x,b2),bag(x,y,z)));
- bag(bag(x,b2),bag(a1,a2))
- ;
- Comment 6. SETS AND THEIR MANIPULATION FUNCTIONS
- ;
- ts:=mkset list(a1,a1,a,2,2);
- ts := {a1,a,2}
- if setp ts then "this is a SET";
- this is a SET
- ;
- union(ts,ts);
- {a1,a,2}
- diffset(ts,list(a1,a));
- {2}
- diffset(list(a1,a),ts);
- {}
- symdiff(ts,ts);
- {}
- intersect(listbag(ts,set1),listbag(ts,set2));
- set1(a1,a,2)
- Comment 7. GENERAL PURPOSE UTILITY FUNCTIONS :;
- ;
- clear a1,a2,a3,a,x,y,z,x1,x2,op$
- ;
- % DETECTION OF A GIVEN VARIABLE IN A GIVEN SET
- ;
- mkidnew();
- G0
- mkidnew(a);
- aG1
- dellastdigit 23;
- 2
- detidnum aa;
- detidnum a10;
- 10
- detidnum a1b2z34;
- 34
- list_to_ids list(a,1,rr,22);
- a1rr22
- ;
- if oddp 3 then "this is an odd integer";
- this is an odd integer
- ;
- <<prin2 1; followline 7; prin2 8;>>;
- 1
- 8
- ;
- operator foo;
- foo(x):=x;
- foo(x) := x
- foo(x)==value;
- value
- x:=x;
- x := value
- ;
- clear x;
- ;
- randomlist(10,20);
- {8,1,8,0,5,7,3,8,0,5,5,9,0,5,2,0,7,5,5,1}
- % Generation of tables of random numbers:
- % One dimensional:
- mkrandtabl({4},10,ar);
- {4}
- ;
- % Two dimensional:
- mkrandtabl({3,4},10,ar);
- *** array ar redefined
- {3,4}
- ;
- % With a base which is a decimal number:
- on rounded;
- mkrandtabl({5},3.5,ar);
- *** array ar redefined
- {5}
- off rounded;
- ;
- combnum(8,3);
- 56
- permutations(bag(a1,a2,a3));
- bag(bag(a1,a2,a3),bag(a1,a3,a2),bag(a2,a1,a3),bag(a2,a3,a1),bag(a3,a1,a2),
- bag(a3,a2,a1))
- permutations {1,2,3};
- {{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}}
- cyclicpermlist{1,2,3};
- {{1,2,3},{2,3,1},{3,1,2}}
- combinations({1,2,3},2);
- {{2,3},{1,3},{1,2}}
- labc:={a,b,c};
- labc := {a,bg1(x1,x2,x3),c}
- symmetrize(labc,foo,cyclicpermlist);
- foo(bg1(x1,x2,x3),c,a) + foo(a,bg1(x1,x2,x3),c) + foo(c,a,bg1(x1,x2,x3))
- symmetrize(labc,list,permutations);
- {bg1(x1,x2,x3),a,c} + {bg1(x1,x2,x3),c,a} + {a,bg1(x1,x2,x3),c}
- + {a,c,bg1(x1,x2,x3)} + {c,bg1(x1,x2,x3),a} + {c,a,bg1(x1,x2,x3)}
- symmetrize({labc},foo,cyclicpermlist);
- foo({bg1(x1,x2,x3),c,a}) + foo({a,bg1(x1,x2,x3),c}) + foo({c,a,bg1(x1,x2,x3)})
- extremum({1,2,3},lessp);
- 1
- extremum({1,2,3},geq);
- 3
- extremum({a,b,c},ordp);
- bg1(x1,x2,x3)
- ;
- funcvar(x+y);
- {x,y}
- funcvar(sin log(x+y));
- {x,y}
- funcvar(sin pi);
- funcvar(x+e+i);
- {x}
- ;
- depatom a;
- a
- depend a,x,y;
- depatom a;
- {x,y}
- depend op,x,y,z;
- implicit op;
- op
- explicit op;
- op(x,y,z)
- depend y,zz;
- explicit op;
- op(x,y(zz),z)
- aa:=implicit op;
- aa := op
- clear op;
- ;
- korder x,z,y;
- korderlist;
- (x z y)
- ;
- if checkproplist({1,2,3},fixp) then "it is a list of integers";
- it is a list of integers
- ;
- if checkproplist({a,b1,c},idp) then "it is a list of identifiers";
- it is a list of identifiers
- ;
- if checkproplist({1,b1,c},idp) then "it is a list of identifiers";
- ;
- lmix:={1,1/2,a,"st"};
- 1
- lmix := {1,---,a,st}
- 2
- ;
- extractlist(lmix,fixp);
- {1}
- extractlist(lmix,numberp);
- 1
- {1,---}
- 2
- extractlist(lmix,idp);
- {a}
- extractlist(lmix,stringp);
- {st}
- ;
- comment 8. PROPERTIES AND FLAGS:;
- ;
- putflag(list(a1,a2),fl1,t);
- t
- putflag(list(a1,a2),fl2,t);
- t
- displayflag a1;
- {fl1,fl2}
- ;
- clearflag a1,a2;
- displayflag a2;
- {}
- putprop(x1,propname,value,t);
- x1
- displayprop(x1,prop);
- {}
- displayprop(x1,propname);
- {propname,value}
- ;
- putprop(x1,propname,value,0);
- displayprop(x1,propname);
- {}
- ;
- Comment 9. CONTROL FUNCTIONS:;
- ;
- alatomp z;
- t
- z:=s1;
- z := s1
- alatomp z;
- t
- ;
- alkernp z;
- t
- alkernp log sin r;
- t
- ;
- precp(difference,plus);
- t
- precp(plus,difference);
- precp(times,.);
- precp(.,times);
- t
- ;
- if stringp x then "this is a string";
- if stringp "this is a string" then "this is a string";
- this is a string
- ;
- if nordp(b,a) then "a is ordered before b";
- operator op;
- for all x,y such that nordp(x,y) let op(x,y)=x+y;
- op(a,a);
- op(a,a)
- op(b,a);
- op(bg1(x1,x2,x3),a)
- op(a,b);
- bg1(x1,x2,x3) + a
- clear op;
- ;
- depvarp(log(sin(x+cos(1/acos rr))),rr);
- t
- ;
- operator op;
- symmetric op;
- op(x,y)-op(y,x);
- 0
- remsym op;
- op(x,y)-op(y,x);
- op(x,y) - op(y,x)
- ;
- clear y,x,u,v;
- clear op;
- ;
- % DISPLAY and CLEARING of user's objects of various types entered
- % to the console. Only TOP LEVEL assignments are considered up to now.
- % The following statements must be made INTERACTIVELY. We put them
- % as COMMENTS for the user to experiment with them. We do this because
- % in a fresh environment all outputs are nil.
- ;
- % THIS PART OF THE TEST SHOULD BE REALIZED INTERACTIVELY.
- % SEE THE ** ASSIST LOG ** FILE .
- %v1:=v2:=1;
- %show scalars;
- %aa:=list(a);
- %show lists;
- %array ar(2);
- %show arrays;
- %load matr$
- %matrix mm;
- %show matrices;
- %x**2;
- %saveas res;
- %show saveids;
- %suppress scalars;
- %show scalars;
- %show lists;
- %suppress all;
- %show arrays;
- %show matrices;
- ;
- comment end of the interactive part;
- ;
- clear op;
- operator op;
- op(x,y,z);
- op(x,y,s1)
- clearop op;
- t
- clearfunctions abs,tan;
- *** abs is unprotected : Cleared ***
- *** tan is a protected function: NOT cleared ***
- "Clearing is complete"
- ;
- comment THIS FUNCTION MUST BE USED WITH CARE !!"!!!;
- ;
- Comment 10. HANDLING OF POLYNOMIALS
- clear x,y,z;
- COMMENT To see the internal representation :;
- ;
- off pri;
- ;
- pol:=(x-2*y+3*z**2-1)**3;
- 3 2 2 2 2 4
- pol := x + ( - 6*y + 9*s1 - 3)*x + (12*y + ( - 36*s1 + 12)*y + 27*s1 - 18*
- 2 3 2 2 4 2
- s1 + 3)*x - 8*y + (36*s1 - 12)*y + ( - 54*s1 + 36*s1 - 6)*y + 27*s1
- 6 4 2
- - 27*s1 + 9*s1 - 1
- ;
- pold:=distribute pol;
- 6 4 2 3 2 2 2 2 2
- pold := 27*s1 - 27*s1 + 9*s1 + x - 6*y*x + 9*s1 *x - 3*x + 12*y *x + 27*
- 4 2 2 3 2 2 2
- s1 *x - 18*s1 *x - 36*s1 *y*x + 12*y*x + 3*x - 8*y + 36*s1 *y - 12*y
- 4 2
- - 54*s1 *y + 36*s1 *y - 6*y - 1
- ;
- on distribute;
- leadterm (pold);
- 6
- 27*s1
- pold:=redexpr pold;
- 4 2 3 2 2 2 2 2 4
- pold := - 27*s1 + 9*s1 + x - 6*y*x + 9*s1 *x - 3*x + 12*y *x + 27*s1 *x -
- 2 2 3 2 2 2
- 18*s1 *x - 36*s1 *y*x + 12*y*x + 3*x - 8*y + 36*s1 *y - 12*y - 54*s1
- 4 2
- *y + 36*s1 *y - 6*y - 1
- leadterm pold;
- 4
- - 27*s1
- ;
- off distribute;
- polp:=pol$
- leadterm polp;
- 3
- x
- polp:=redexpr polp;
- 2 2 2 2 4 2
- polp := ( - 6*y + 9*s1 - 3)*x + (12*y + ( - 36*s1 + 12)*y + 27*s1 - 18*s1
- 3 2 2 4 2 6
- + 3)*x - 8*y + (36*s1 - 12)*y + ( - 54*s1 + 36*s1 - 6)*y + 27*s1 -
- 4 2
- 27*s1 + 9*s1 - 1
- leadterm polp;
- 2 2
- ( - 6*y + 9*s1 - 3)*x
- ;
- monom polp;
- 6
- {27*s1 ,
- 4
- - 27*s1 ,
- 2
- 9*s1 ,
- 2
- - 6*y*x ,
- 2 2
- 9*s1 *x ,
- 2
- - 3*x ,
- 2
- 12*y *x,
- 4
- 27*s1 *x,
- 2
- - 18*s1 *x,
- 2
- - 36*s1 *y*x,
- 12*y*x,
- 3*x,
- 3
- - 8*y ,
- 2 2
- 36*s1 *y ,
- 2
- - 12*y ,
- 4
- - 54*s1 *y,
- 2
- 36*s1 *y,
- - 6*y,
- -1}
- ;
- on pri;
- ;
- splitterms polp;
- 2 2
- {{9*s1 *x ,
- 2
- 12*x*y ,
- 12*x*y,
- 4
- 27*s1 *x,
- 3*x,
- 2 2
- 36*s1 *y ,
- 2
- 36*s1 *y,
- 6
- 27*s1 ,
- 2
- 9*s1 },
- 2
- {6*x *y,
- 2
- 3*x ,
- 2
- 36*s1 *x*y,
- 2
- 18*s1 *x,
- 3
- 8*y ,
- 2
- 12*y ,
- 4
- 54*s1 *y,
- 6*y,
- 4
- 27*s1 ,
- 1}}
- ;
- splitplusminus polp;
- 6 4 2 2 2 2 2 2 2
- {3*(9*s1 + 9*s1 *x + 3*s1 *x + 12*s1 *y + 12*s1 *y + 3*s1 + 4*x*y + 4*x*y
- + x),
- 4 4 2 2 2 2 3 2
- - 54*s1 *y - 27*s1 - 36*s1 *x*y - 18*s1 *x - 6*x *y - 3*x - 8*y - 12*y
- - 6*y - 1}
- ;
- divpol(pol,x+2*y+3*z**2);
- 4 2 2 2 2 2
- {9*s1 + 6*s1 *x - 24*s1 *y - 9*s1 + x - 8*x*y - 3*x + 28*y + 18*y + 3,
- 3 2
- - 64*y - 48*y - 12*y - 1}
- ;
- lowestdeg(pol,y);
- 0
- ;
- Comment 11. HANDLING OF SOME TRANSCENDENTAL FUNCTIONS:;
- ;
- trig:=((sin x)**2+(cos x)**2)**4;
- trig :=
- 8 6 2 4 4 2 6 8
- cos(x) + 4*cos(x) *sin(x) + 6*cos(x) *sin(x) + 4*cos(x) *sin(x) + sin(x)
- trigreduce trig;
- 1
- trig:=sin (5x);
- trig := sin(5*x)
- trigexpand trig;
- 4 2 2 4
- sin(x)*(5*cos(x) - 10*cos(x) *sin(x) + sin(x) )
- trigreduce ws;
- sin(5*x)
- trigexpand sin(x+y+z);
- cos(s1)*cos(x)*sin(y) + cos(s1)*cos(y)*sin(x) + cos(x)*cos(y)*sin(s1)
- - sin(s1)*sin(x)*sin(y)
- ;
- ;
- hypreduce (sinh x **2 -cosh x **2);
- -1
- ;
- ;
- clear a,b,c,d;
- ;
- Comment 12. COERCION FROM ARRAY TO LIST AND VICE-VERSA:;
- on rounded;
- array_to_list ar;
- {2.77546499305,1.79693268486,3.43100115041,2.11636272025,3.45447023392}
- ;
- off rounded;
- ll:={{a,b},{b,c},{c,d}}$
- list_to_array(ll,1,ar);
- *** array ar redefined
- ar(1);
- {b,c}
- list_to_array(ll,2,ar);
- *** array ar redefined
- ar(1,1);
- c
- ;
- clear ar;
- ;
- Comment 13. HANDLING OF N-DIMENSIONAL VECTORS:;
- ;
- clear u1,u2,v1,v2,v3,v4,w3,w4;
- u1:=list(v1,v2,v3,v4);
- u1 := {v1,v2,v3,v4}
- u2:=bag(w1,w2,w3,w4);
- u2 := bag(w1,w2,w3,w4)
- %
- sumvect(u1,u2);
- {v1 + w1,
- v2 + w2,
- v3 + w3,
- v4 + w4}
- minvect(u2,u1);
- bag( - v1 + w1, - v2 + w2, - v3 + w3, - v4 + w4)
- scalvect(u1,u2);
- v1*w1 + v2*w2 + v3*w3 + v4*w4
- crossvect(rest u1,rest u2);
- {v3*w4 - v4*w3,
- - v2*w4 + v4*w2,
- v2*w3 - v3*w2}
- mpvect(rest u1,rest u2, minvect(rest u1,rest u2));
- 0
- scalvect(crossvect(rest u1,rest u2),minvect(rest u1,rest u2));
- 0
- ;
- Comment 14. HANDLING OF GRASSMANN OPERATORS:;
- ;
- putgrass eta,eta1;
- grasskernel:=
- {eta(~x)*eta(~y) => -eta y * eta x when nordp(x,y),
- (~x)*(~x) => 0 when grassp x};
- grasskernel := {eta(~x)*eta(~y) => - eta(y)*eta(x) when nordp(x,y),
- ~x*~x => 0 when grassp(x)}
- ;
- eta(y)*eta(x);
- eta(y)*eta(x)
- eta(y)*eta(x) where grasskernel;
- - eta(x)*eta(y)
- let grasskernel;
- eta(x)^2;
- 0
- eta(y)*eta(x);
- - eta(x)*eta(y)
- operator zz;
- grassparity (eta(x)*zz(y));
- 1
- grassparity (eta(x)*eta(y));
- 0
- grassparity(eta(x)+zz(y));
- parity undefined
- clearrules grasskernel;
- grasskernel:=
- {eta(~x)*eta(~y) => -eta y * eta x when nordp(x,y),
- eta1(~x)*eta(~y) => -eta x * eta1 y,
- eta1(~x)*eta1(~y) => -eta1 y * eta1 x when nordp(x,y),
- (~x)*(~x) => 0 when grassp x};
- grasskernel := {eta(~x)*eta(~y) => - eta(y)*eta(x) when nordp(x,y),
- eta1(~x)*eta(~y) => - eta(x)*eta1(y),
- eta1(~x)*eta1(~y) => - eta1(y)*eta1(x) when nordp(x,y),
- ~x*~x => 0 when grassp(x)}
- ;
- let grasskernel;
- eta1(x)*eta(x)*eta1(z)*eta1(w);
- - eta(x)*eta1(s1)*eta1(w)*eta1(x)
- clearrules grasskernel;
- remgrass eta,eta1;
- clearop zz;
- t
- ;
- Comment 15. HANDLING OF MATRICES:;
- ;
- clear m,mm,b,b1,bb,cc,a,b,c,d,a1,a2;
- load_package matrix;
- baglmat(bag(bag(a1,a2)),m);
- t
- m;
- [a1 a2]
- on errcont;
- ;
- baglmat(bag(bag(a1),bag(a2)),m);
- ***** (mat ((*sq ((((a1 . 1) . 1)) . 1) t) (*sq ((((a2 . 1) . 1)) . 1) t)))
- should be an identifier
- off errcont;
- % **** i.e. it cannot redefine the matrix! in order
- % to avoid accidental redefinition of an already given matrix;
- clear m;
- baglmat(bag(bag(a1),bag(a2)),m);
- t
- m;
- [a1]
- [ ]
- [a2]
- on errcont;
- baglmat(bag(bag(a1),bag(a2)),bag);
- ***** operator bag invalid as matrix
- off errcont;
- comment Right since a bag-like object cannot become a matrix.;
- ;
- coercemat(m,op);
- op(op(a1),op(a2))
- coercemat(m,list);
- {{a1},{a2}}
- ;
- on nero;
- unitmat b1(2);
- matrix b(2,2);
- b:=mat((r1,r2),(s1,s2));
- [r1 r2]
- b := [ ]
- [s1 s2]
- b1;
- [1 0]
- [ ]
- [0 1]
- b;
- [r1 r2]
- [ ]
- [s1 s2]
- mkidm(b,1);
- [1 0]
- [ ]
- [0 1]
- ;
- seteltmat(b,newelt,2,2);
- [r1 r2 ]
- [ ]
- [s1 newelt]
- geteltmat(b,2,1);
- s1
- %
- b:=matsubr(b,bag(1,2),2);
- [r1 r2]
- b := [ ]
- [1 2 ]
- ;
- submat(b,1,2);
- [1]
- ;
- bb:=mat((1+i,-i),(-1+i,-i));
- [i + 1 - i]
- bb := [ ]
- [i - 1 - i]
- cc:=matsubc(bb,bag(1,2),2);
- [i + 1 1]
- cc := [ ]
- [i - 1 2]
- ;
- cc:=tp matsubc(bb,bag(1,2),2);
- [i + 1 i - 1]
- cc := [ ]
- [ 1 2 ]
- matextr(bb, bag,1);
- bag(i + 1, - i)
- ;
- matextc(bb,list,2);
- { - i, - i}
- ;
- hconcmat(bb,cc);
- [i + 1 - i i + 1 i - 1]
- [ ]
- [i - 1 - i 1 2 ]
- vconcmat(bb,cc);
- [i + 1 - i ]
- [ ]
- [i - 1 - i ]
- [ ]
- [i + 1 i - 1]
- [ ]
- [ 1 2 ]
- ;
- tpmat(bb,bb);
- [ 2*i - i + 1 - i + 1 -1]
- [ ]
- [ -2 - i + 1 i + 1 -1]
- [ ]
- [ -2 i + 1 - i + 1 -1]
- [ ]
- [ - 2*i i + 1 i + 1 -1]
- bb tpmat bb;
- [ 2*i - i + 1 - i + 1 -1]
- [ ]
- [ -2 - i + 1 i + 1 -1]
- [ ]
- [ -2 i + 1 - i + 1 -1]
- [ ]
- [ - 2*i i + 1 i + 1 -1]
- ;
- clear hbb;
- hermat(bb,hbb);
- [ - i + 1 - (i + 1)]
- [ ]
- [ i i ]
- % id hbb changed to a matrix id and assigned to the hermitian matrix
- % of bb.
- ;
- end;
- (TIME: assist 940 950)
|