spde.red 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  1. module spde; % Determine Lie symmetries of partial differential eqns.
  2. % Author: Fritz Schwarz.
  3. %*******************************************************************$
  4. % $
  5. % This is the REDUCE package SPDE for determining $
  6. % Lie symmetries of partial differential equations $
  7. % Version of November 1986 $
  8. % $
  9. % $
  10. % Fritz Schwarz $
  11. % GMD Institut F1 $
  12. % Postfach 1240 $
  13. % 5205 St. Augustin $
  14. % West Germany $
  15. % $
  16. % Tel. 02241-142782 $
  17. % EARN Id. DBNGMD21.GF1002 $
  18. %*******************************************************************$
  19. algebraic operator x,u,xi,eta,c,xi!*,eta!*$
  20. algebraic operator deq,dx,du,gl,gen,sder,rule$
  21. share pclass,mm,nn$
  22. global'(pclass mm nn depl!* num!-cgen num!-dgen)$
  23. lisp(pclass:=mm:=nn:=num!-cgen:=num!-dgen:=0)$
  24. lisp(operator simpsys,result,prsys,prsys!*)$
  25. fluid '(!*list kord!*)$
  26. fluid'(uhf dfsub csub czero rdep !*rational)$
  27. fluid'(list!-m list!-deq list!-pq)$
  28. %symbolic procedure prload$
  29. % begin
  30. % if not getd 'solve1 then load solve1,solvetab,quartic;
  31. % if not getd 'depend1 then load depend;
  32. % if not getd 'ratfunpri then load ratprin;
  33. % end$
  34. symbolic procedure prload; nil;
  35. %*******************************************************************$
  36. % Auxiliary RLISP procedures $
  37. %*******************************************************************$
  38. symbolic procedure ordp(u,v)$
  39. %Modified ordering function which orders kernels with CAR parts;
  40. %DF, ETA, XI and C ahead of anything else;
  41. if null u then null v else if null v then t else
  42. if eq(u,'df) or eq(u,'eta) and not eq(v,'df)
  43. or eq(u,'xi) and not(eq(v,'df) or eq(v,'eta))
  44. or eq(u,'c) and not(eq(v,'df) or eq(v,'eta) or eq(v,'xi)) then t else
  45. if eq(u,'eta) and eq(v,'df)
  46. or eq(u,'xi) and (eq(v,'df) or eq(v,'eta))
  47. or eq(u,'c) and (eq(v,'df) or eq(v,'eta) or eq(v,'xi))
  48. or eq(v,'df) or eq(v,'eta) or eq(v,'xi) or eq(v,'c) then nil else
  49. if atom u then if atom v then
  50. if numberp u then numberp v and not u<v else
  51. if numberp v then t else orderp(u,v) else nil else
  52. if atom v then t else
  53. if car u=car v then ordp(cdr u,cdr v) else ordp(car u,car v)$
  54. symbolic procedure makeset u$
  55. if not u then nil else
  56. if member(car u,cdr u) then makeset cdr u else
  57. car u . makeset cdr u$
  58. symbolic procedure lastmem u$
  59. if cdr u then lastmem cdr u else car u$
  60. symbolic procedure xmember(u,v)$ reverse member(u,reverse v)$
  61. symbolic procedure sacar(a,u)$
  62. if atom u then nil else
  63. if eq(a,car u) and cdr u then list u else
  64. append(sacar(a,car u),sacar(a,cdr u))$
  65. symbolic procedure scar(a,u)$
  66. if atom u then nil else if a=car u then u else
  67. scar(a,car u) or scar(a,cdr u)$
  68. symbolic procedure inter(u,v);
  69. if not u then nil else
  70. if member(car u,v) then
  71. (car u) . inter(cdr u,v) else inter(cdr u,v)$
  72. symbolic procedure compl(u,v)$
  73. if not u then nil else if member(car u,v) then
  74. compl(cdr u,v) else car u . compl(cdr u,v)$
  75. symbolic procedure vlist u$
  76. %U is list of items, returns U with all integers omitted;
  77. if not u then nil else
  78. if numberp car u then vlist cdr u else (car u) . vlist cdr u$
  79. symbolic procedure delnil u$
  80. %U is list, returns U with all occurences of nil deleted;
  81. if not u then nil else
  82. if car u then (car u) . delnil cdr u else delnil cdr u$
  83. symbolic procedure prlist u$
  84. %U is list of items, returns list of all pairs in U;
  85. if not u then nil else
  86. if pairp car u then (car u) . prlist cdr u else prlist cdr u$
  87. symbolic procedure appends(u,v,w)$ append(u,append(v,w))$
  88. symbolic procedure propa(fn,u)$
  89. %FN is predicate of a single argument, U a list;
  90. %Returns T if predicate is true for all elements of U;
  91. begin scalar ind;
  92. ind:=t;
  93. while ind and u do <<ind:=apply(fn,list car u); u:=cdr u>>;
  94. return ind;
  95. end$
  96. symbolic procedure sortx(fn,u)$
  97. begin scalar v,w;
  98. while u do<<v:=maxmem(fn,u); u:=delete(v,u); w:=v . w>>;
  99. return w;
  100. end$
  101. symbolic procedure maxmem(fn,u)$
  102. %FN is function of a single argument, U a list;
  103. %Returns element of U for which FN is maximal;
  104. begin scalar v;
  105. v:=car u;
  106. foreach x in cdr u do
  107. if greaterp(apply(fn,list x),apply(fn,list v)) then v:=x;
  108. return v;
  109. end$
  110. symbolic procedure maxl u$
  111. %U is list of integers, returns largest element of U;
  112. if not u then -10000 else max(car u,maxl cdr u)$
  113. symbolic procedure suml u$
  114. %U is list of integers, returns sum of all elements;
  115. if not u then 0 else plus2(car u,suml cdr u)$
  116. symbolic procedure spde!-subsetp(u,v)$
  117. %U and V are list representing sets;
  118. %Returns T if set U is subset of V;
  119. if not u then t else
  120. member(car u,v) and spde!-subsetp(cdr u,v)$
  121. symbolic procedure product!-set2(u,v)$
  122. %U and V are lists representing sets, returns list representing;
  123. %product set of sets represented by U and V;
  124. begin scalar w;
  125. foreach x in u do foreach y in v do w:=list(x,y) . w;
  126. return w;
  127. end$
  128. symbolic procedure leqgrt(l,i,j)$
  129. i leq j and eqn(l,i) or i geq add1 j$
  130. symbolic procedure fidep u$
  131. assoc(u,depl!*) and cdr assoc(u,depl!*)$
  132. symbolic procedure mkdep u$
  133. foreach x in cdr u do depend1(car u,x,t)$
  134. symbolic procedure rmdep u$
  135. <<rmsubs(); foreach x in cdr u do depend1(car u,x,nil)>>$
  136. symbolic procedure blanks l;
  137. begin scalar u;
  138. u := '(!");
  139. for k:=1:l do u:='! . u;
  140. return compress('!" . u)
  141. end$
  142. symbolic procedure terpri2$ <<terpri(); terpri()>>$
  143. %*******************************************************************$
  144. % Auxiliary procedures for manipulating standard forms $
  145. %*******************************************************************$
  146. symbolic procedure lcf u$ not domainp u and lc u$
  147. symbolic procedure minus!-f u$
  148. %U is s.f., returns T if lnc U is negative;
  149. minusf numr simp reval u$
  150. lisp operator minus!-f$
  151. symbolic procedure lengthn u$
  152. if not u then 0 else
  153. if numberp car u then plus(sub1 car u,lengthn cdr u) else
  154. plus(1,lengthn cdr u)$
  155. symbolic procedure degreef(u,v)$
  156. %U is s.f., V kernel, returns degree of V in U;
  157. if domainp u then 0 else
  158. if mvar u=v then ldeg u else
  159. max(degreef(lc u,v),degreef(red u,v))$
  160. symbolic procedure lengthf u$
  161. %U is prefix s.f., returns printlength for U;
  162. if not u then 0 else
  163. if atom u then flatsizec u else
  164. if eqcar(u,'plus)
  165. then plus(times(3,sub1 length cdr u),lengthf cdr u) else
  166. if eqcar(u,'times) or eqcar(u,'minus)
  167. then plus(sub1 length cdr u,lengthf cdr u) else
  168. if eqcar(u,'quotient) then
  169. if !*rational then add1 add1 max(flatsizec cadr u,flatsizec caddr u)
  170. else add1 plus(flatsizec cadr u,flatsizec caddr u) else
  171. if eqcar(u,'expt) then add1 flatsizec cadr u else
  172. if eqcar(u,'dx) or eqcar(u,'du) then plus(flatsizec cadr u,4) else
  173. if eqcar(u,'xi) or eqcar(u,'eta) or eqcar(u,'c)
  174. or eqcar(u,'x) or eqcar(u,'u) then times(2,length u) else
  175. if eqcar(u,'df) then plus(4,lengthf cadr u,lengthf cddr u) else
  176. plus(lengthf car u,lengthf cdr u)$
  177. lisp operator lengthf$
  178. symbolic procedure diford u$ lengthn cddr u$
  179. symbolic procedure adiff(u,v)$
  180. %U is kernel with CAR part DF, V is kernel;
  181. %Returns U integrated with respect to V;
  182. if not member(v,u) then u else
  183. if length u=3 and member(v,u) then cadr u else
  184. if not cdr member(v,u)
  185. or not numberp cadr member(v,u) then delete(v,u) else
  186. if cadr member(v,u)=2 then
  187. append(xmember(v,u),cddr member(v,u)) else
  188. append(xmember(v,u),(sub1 cadr member(v,u)) . cddr member(v,u))$
  189. symbolic procedure sub!-int!-df u$
  190. %U is kernel with CAR part INT, returns integrated kernel if CADR;
  191. %part of U is DF and integration variable occurs as argument of DF;
  192. if eqcar(cadr u,'df) and member(lastmem u,cadr u) then
  193. adiff(cadr u,lastmem u) else u$
  194. symbolic procedure subintf u$
  195. %U is s.f., performs all integrations which may be done;
  196. %by cancellation of corresponding differentiation;
  197. begin
  198. foreach x in makeset sacar('int,u) do
  199. u:=subst(sub!-int!-df x,x,u);
  200. return numr simp prepf u;
  201. end$
  202. symbolic procedure monop u$
  203. %Returns T if u is monomial;
  204. domainp u or not red u and monop lc u$
  205. symbolic procedure solvef(u,v)$ car solve0(prepf u,v)$
  206. symbolic procedure comfacn u$ lnc ckrn u$
  207. symbolic procedure remfacn u$ quotf(u,lnc ckrn u)$
  208. %*******************************************************************$
  209. % Procedures for manipulating l.d.f.'s, U is always l.d.f. $
  210. % in this section $
  211. %*******************************************************************$
  212. symbolic procedure ldf!-mvar u$
  213. %Returns function argument of mvar U;
  214. (if eqcar(x,'df) then cadr x else x) where x=mvar u;
  215. symbolic procedure ldf!-fvar u$
  216. %Returns all function arguments occuring in U;
  217. makeset foreach x in u collect ldt!-tvar x$
  218. symbolic procedure ldf!-fvar!-part(u,v)$
  219. %V is function xi(i), eta(alpha) or c(k), returns l.d.f. of those;
  220. %terms in U with ldt-tvar x equal to V, overall factors not removed;
  221. begin scalar w;
  222. foreach x in u do if eq(ldt!-tvar x,v) then w:=x . w;
  223. return reverse w;
  224. end$
  225. symbolic procedure ldf!-dep!-var u$
  226. %Returns all variables x(i) or u(alpha) which occur as;
  227. %arguments of XI, ETA or C;
  228. begin scalar v;
  229. foreach x in u do if assoc(ldt!-tvar x,depl!*) then
  230. v:=append(cdr assoc(ldt!-tvar x,depl!*),v);
  231. return makeset v;
  232. end$
  233. symbolic procedure ldf!-pow!-var u$
  234. %Returns all variables x(i) or u(alpha) which occur as powers;
  235. begin scalar v,z;
  236. foreach x in u do v:=append(v,kernels tc x);
  237. foreach y in prlist makeset v do
  238. if eqcar(y,'x) or eqcar(y,'u) then z:=y . z;
  239. return makeset z;
  240. end$
  241. symbolic procedure ldf!-deg(u,v)$
  242. %V is kernel x(i) or u(alpha), returns degree of U in V;
  243. maxl foreach x in u collect degreef(tc x,v)$
  244. symbolic procedure ldf!-spf!-var u$
  245. %Returns all variables x(i) or u(alpha) which occur as;
  246. %arguments of any other kernel than xi, eta or c;
  247. begin scalar v,z;
  248. foreach x in u do v:=append(v,kernels tc x);
  249. foreach y in prlist makeset v do
  250. if not eqcar(y,'x) and not eqcar(y,'u) then
  251. z:=appends(sacar('x,cdr y),sacar('u,cdr y),z);
  252. return makeset z;
  253. end$
  254. symbolic procedure ldf!-all!-var u$
  255. %Returns all variables x(i) or u(alpha) which occur in U;
  256. makeset appends(ldf!-dep!-var u,ldf!-pow!-var u,ldf!-spf!-var u)$
  257. symbolic procedure ldf!-sep!-var u$
  258. %Returns all variables w.r.t. which U may be separated;
  259. compl(compl(ldf!-pow!-var u,ldf!-dep!-var u),ldf!-spf!-var u)$
  260. symbolic procedure ldf!-int!-var u$
  261. %Returns all variables w.r.t. which U may be integrated;
  262. if eqcar(mvar u,'df) then
  263. begin scalar v;
  264. v:=ldf!-all!-var u;
  265. while v and u do
  266. <<v:=compl(v,compl(ldt!-dep car u,ldt!-dfvar car u)); u:=cdr u>>;
  267. return v;
  268. end$
  269. symbolic procedure ldf!-int u$
  270. %U is l.d.f, returns U with all possible integrations performed;
  271. %or unchanged if integration is not possible;
  272. begin scalar v,w,z,test; integer nfun;
  273. a:
  274. test:=nil;
  275. w:=ldf!-int!-var u;
  276. nfun:=find!-nfun();
  277. foreach x in w do
  278. if not smember('int,z:=caadr algebraic int(lisp prepf u,x))
  279. or not smember('int,z:=subintf z) then
  280. <<v:=!*a2k list('c,nfun:=nfun+1); test:=t;
  281. mkdep(v . delete(x,ldf!-all!-var u));
  282. u:=addf(z,!*k2f v)>>;
  283. if test then go to a;
  284. return u;
  285. end$
  286. symbolic procedure ldf!-df!-diff u$
  287. %Returns list of all df-kernels which may be obtained;
  288. %from U by differentiation or nil;
  289. begin scalar dfvar,dfsub,v,w,z0,z; integer n0,nmax;
  290. v:=compl(ldf!-dep!-var u,ldf!-spf!-var u);
  291. if not v then return;
  292. w:=foreach x in v collect list(x,add1 ldf!-deg(u,x));
  293. nmax:=maxl foreach x in w collect cadr x;
  294. while (n0:=n0+1) leq nmax and not(z0:=nil) do
  295. <<foreach x in w do if cadr x geq n0 then z0:=(car x) . z0;
  296. z:=z0 . z>>;
  297. z:=reverse z;
  298. dfvar:=foreach x in car z collect list x;
  299. foreach x in cdr z do dfvar:=
  300. append(dfvar,foreach y in dfvar collect car product!-set2(x,y));
  301. foreach x in dfvar do
  302. begin scalar p,q;
  303. p:=x; q:=u;
  304. while p and q and red q do
  305. <<q:=ldf!-simp numr difff(q,car p); p:=cdr p>>;
  306. if pairp q and not red q and eqcar(mvar q,'df) then
  307. dfsub:=(mvar q) . dfsub;
  308. end;
  309. return makeset dfsub;
  310. end$
  311. symbolic procedure ldf!-sub!-var u$
  312. %Returns function w.r.t. which U may be resolved;
  313. begin scalar v,w,z;
  314. w:=ldf!-all!-var u;
  315. foreach x in u do if not v and not eqcar(z:=tvar x,'df)
  316. and monop tc x and spde!-subsetp(w,ldt!-dep x)
  317. and not smember(z,delete(x,u)) then v:=z;
  318. return v;
  319. end$
  320. symbolic procedure ldf!-simp u$
  321. %Returns l.d.f. form of U;
  322. if not u then nil else
  323. if not red u then numr simp prepf !*k2f mvar u else
  324. begin scalar v;
  325. v:=numr simp prepf u;
  326. if not domainp v then v := quotf(v,cdr comfac v);
  327. return absf v
  328. end$
  329. symbolic procedure ldf!-sep u$
  330. %Returns list of l.d.f. into which U has been separated;
  331. begin scalar v; integer k;
  332. if not(v:=ldf!-sep!-var u) then return list u;
  333. foreach x in v do u:=subst(list('ux,1,k:=k+1),x,u);
  334. return foreach x in coeff!-all(u,'ux) collect
  335. ldf!-simp numr simp prepf x;
  336. end$
  337. symbolic procedure ldf!-subf0 u$
  338. %Returns U with CZERO substituted;
  339. ldf!-simp delnil foreach x in u collect ldt!-subt0 x$
  340. %*******************************************************************$
  341. % Procedures for manipulating l.d.t.'s, U is always l.d.t. $
  342. % in this section $
  343. %*******************************************************************$
  344. symbolic procedure ldt!-tvar u$
  345. %U is l.d.t., returns function argument of tvar U;
  346. (if eqcar(x,'df) then cadr x else x) where x=tvar u$
  347. symbolic procedure ldt!-dfvar u$
  348. %U is l.d.t., returns variables w.r.t. which tvar u is derived or nil;
  349. (if eqcar(x,'df) then vlist cddr x else nil) where x=tvar u$
  350. symbolic procedure ldt!-dep u$
  351. %U is l.d.t., returns list of variables x or y which occur as;
  352. %arguments LDT-tvar u;
  353. (if x then cdr x else nil) where x=assoc(ldt!-tvar u,depl!*)$
  354. symbolic procedure ldt!-subt0 u$
  355. %U is l.d.t., returns U if LDT-tvar u is not on czero;
  356. if not member(ldt!-tvar u,czero) then u else nil$
  357. %*******************************************************************$
  358. % Procedures for constructing the determining system $
  359. %*******************************************************************$
  360. symbolic procedure cresys u$
  361. begin scalar r,v,w,lgl,lsub,depl!*!*,list!-sder;
  362. remprop('df,'kvalue); remprop('df,'klist);
  363. remprop('c,'kvalue); remprop('c,'klist);
  364. prload();
  365. rmsubs();
  366. depl!*:=nil;
  367. if car u then
  368. list!-deq:=foreach x in u collect assoc(x,get(car x,'kvalue)) else
  369. list!-deq:=get('deq,'kvalue);
  370. if eqn(length list!-deq,1) then
  371. begin scalar p;
  372. p:=maxmem(function length,makeset sacar('u,list!-deq));
  373. p:=mk!*sq !*k2q p;
  374. list!-sder:=list list(list('sder, cadaar list!-deq),p);
  375. end else if car u then
  376. list!-sder:=foreach x in list!-deq collect
  377. assoc(list('sder,cadar x),get('sder,'kvalue)) else
  378. list!-sder:=get('sder,'kvalue);
  379. if not list!-deq then rederr
  380. "Differential equations not defined";
  381. if not list!-sder then rederr
  382. "Substitutions for derivatives not defined";
  383. mm:=find!-m list!-deq; nn:=find!-n list!-deq;
  384. list!-m:=
  385. makeset foreach x in sacar('u,list!-deq) collect cadr x;
  386. for k:=1:nn do<<w:=!*a2k list('xi,k) . w; v:=!*a2k list('x,k) . v>>;
  387. for k:=1:mm do if member(k,list!-m) then
  388. <<w:=!*a2k list('eta,k) . w; v:=!*a2k list('u,k) . v>>;
  389. for k:=1:nn do r:=(!*a2k list('dx,k)) . r;
  390. for k:=1:mm do r:=(!*a2k list('du,k)) . r;
  391. for k:=1:mm do depl!*!*:=(!*a2k list('eta,k) . v) . depl!*!*;
  392. for k:=1:nn do depl!*!*:=(!*a2k list('xi,k) . v) . depl!*!*;
  393. depl!*:=depl!*!*;
  394. kord!*:=reverse r;
  395. foreach x in list!-sder do
  396. lsub:=((mvar caadr cadr x) . prepsq caar solvef(caadr cadr assoc
  397. (list('deq,cadar x),list!-deq),mvar caadr cadr x)) . lsub;
  398. foreach x in list!-deq do
  399. begin scalar s,z,lx,lu;
  400. z:=caadr cadr x;
  401. lx:=makeset sacar('x,z);
  402. lu:=makeset sacar('u,z);
  403. foreach y in lx do s:=addf(s,
  404. multf(!*k2f !*a2k list('xi,cadr y),numr simp prepsq difff(z,y)));
  405. foreach y in lu do if length y=2 then
  406. s:=addf(s,multf
  407. (!*k2f !*a2k list('eta,cadr y),numr simp prepsq difff(z,y))) else
  408. s:=addf(s, multf(numr zeta!* cdr y,numr simp prepsq difff(z,y)));
  409. s:=numr subf(s,lsub);
  410. s:=numr subf(s,lsub);
  411. lgl:=append(coeff!-all(s,'u),lgl);
  412. end;
  413. uhf:=list(makeset lgl,foreach x in reverse w collect !*k2q x);
  414. end$
  415. lisp rlistat'(cresys)$
  416. symbolic procedure totder(u,i)$
  417. begin scalar z,v,w;
  418. v:=car difff(u,!*a2k list('x,i));
  419. z:=makeset sacar('u,u);
  420. for k:=1:mm do if member(k,list!-m) then
  421. z:=(!*a2k list('u,k)) . z;
  422. foreach x in makeset z do w:=addf(w,
  423. multf(!*k2f !*a2k append(x,list i),car difff(u,x)));
  424. return numr simp prepf addf(v,w);
  425. end$
  426. symbolic procedure zeta!* u$
  427. if not get('deq,'kvalue) and (eqn(mm,0) or eqn(nn,0)) then
  428. rederr"Number of variables not defined" else
  429. if length u geq 3 then
  430. begin scalar v,w;
  431. prload();
  432. if eqn(nn,0) then nn:=find!-n list!-deq;
  433. v:=totder(numr zeta!* reverse cdr reverse u,car reverse u);
  434. for s:=1:nn do w:=addf(w,
  435. multf(!*k2f !*a2k('u . append(reverse cdr reverse u,list s)),
  436. totder(!*k2f !*a2k list('xi,s),car reverse u)));
  437. return simp prepsq(addf(v,negf w) ./ 1);
  438. end else
  439. begin scalar v,w;
  440. prload();
  441. if eqn(nn,0) then
  442. <<nn :=find!-n list!-deq; mm:=find!-m list!-deq>> else
  443. begin scalar p,z;
  444. for k:=1:mm do z:=cons(k,z);
  445. for k:=1:nn do p:=(!*a2k list('x,k)) . p;
  446. for k:=1:mm do p:=(!*a2k list('u,k)) . p;
  447. for k:=1:nn do mkdep((!*a2k list('xi,k)) . p);
  448. for k:=1:mm do mkdep((!*a2k list('eta,k)) . p);
  449. list!-m:=z;
  450. end;
  451. v:=totder(!*k2f !*a2k list('eta,car u),cadr u);
  452. for s:=1:nn do w:=addf(w,
  453. multf(!*k2f !*a2k list('u,car u,s),
  454. totder(!*k2f !*a2k list('xi,s),car reverse u)));
  455. return simp prepsq(addf(v,negf w) ./ 1);
  456. end$
  457. symbolic procedure simpu u$
  458. !*p2q mksp(('u . (car u . reverse ordn cdr u)),1)$
  459. put('u,'simpfn,'simpu)$
  460. put('zeta,'simpfn,'zeta!*)$
  461. symbolic procedure coeff!-all(u,v)$
  462. begin scalar z;
  463. list!-pq:=nil;
  464. splitrec(u,v,1,nil);
  465. foreach x in list!-pq do
  466. z:=(ldf!-simp numr simp prepf cdr x) . z;
  467. return makeset z;
  468. end$
  469. symbolic procedure splitrec(u,v,p,q)$
  470. if domainp u then
  471. begin scalar y;
  472. p:=multf(u,p);
  473. if y:=assoc(q,list!-pq) then
  474. rplacd(y,addf(cdr y,p)) else list!-pq:=(q . p) . list!-pq;
  475. end else
  476. begin
  477. if eqcar(mvar u,v) and length mvar u greaterp 2
  478. then splitrec(lc u,v,p,(lpow u) . q)
  479. else splitrec(lc u,v,!*t2f(lpow(u) .* p),q);
  480. if red u then splitrec(red u,v,p,q);
  481. end$
  482. symbolic procedure find!-m u$
  483. maxl makeset foreach x in sacar('u,u) collect cadr x$
  484. symbolic procedure find!-n u$
  485. begin scalar vx,vu,wx,wu;
  486. vx:=makeset sacar('x,u);
  487. vu:=makeset sacar('u,u);
  488. foreach x in vx do wx:=(cadr x) . wx;
  489. foreach x in vu do if length x geq 3 then
  490. wu:=append(cddr x,wu);
  491. return max(maxl wx,maxl wu);
  492. end$
  493. %*******************************************************************$
  494. % Procedures for solving the determining system $
  495. %*******************************************************************$
  496. symbolic procedure rule0$
  497. %Searches for equations of the form C(I)=0 and stores them on CZERO;
  498. if uhf then foreach x in car uhf do
  499. if not red x and not eqcar(mvar x,'df)
  500. then czero:=(mvar x) . czero$
  501. symbolic procedure rule1$
  502. %Searches for equations of the form DF(function,variable)=0;
  503. %and stores it on the list RDEP;
  504. if uhf and car uhf then
  505. begin scalar dfsub;
  506. foreach x in car uhf do
  507. if not red x and eqcar(mvar x,'df) and eqn(diford mvar x,1)
  508. then rdep:=(mvar x) . rdep;
  509. if rdep then return t;
  510. end$
  511. symbolic procedure rule1!-diff$
  512. %Searches for equations of the form DF(function,variable)=0;
  513. %which may be obtained by a single differentiation and stores it on;
  514. %the list RDEP;
  515. if uhf and car uhf then
  516. begin scalar u,v,z;
  517. foreach x in car uhf do if(z:=ldf!-df!-diff x) then
  518. u:=append(z,u);
  519. foreach x in u do if eqn(diford x,1) then v:=x . v;
  520. rdep:=makeset v;
  521. if rdep then return t;
  522. end$
  523. symbolic procedure rulec l$
  524. %Searches for equations of length L which may be solved for a;
  525. %function and stores the corresponding rules on CSUB;
  526. if uhf and car uhf then
  527. begin scalar v;
  528. foreach u in car uhf do if leqgrt(length u,l,4)
  529. and (v:=ldf!-sub!-var u) and not smember(v,csub)
  530. and not inter(foreach x in csub collect car x,ldf!-fvar u)
  531. then csub:=(v . prepsq caar solvef(u,v)) . csub;
  532. if csub then return t;
  533. end$
  534. symbolic procedure ruledf l$
  535. %Searches for equations of the form DF(function,derivative list)=0;
  536. %the derivative beeing of order L and stores the resulting;
  537. %substitution polynomial on CSUB;
  538. if uhf and car uhf then
  539. begin scalar dfsub;
  540. foreach x in car uhf do
  541. if not red x and eqcar(mvar x,'df) and eqn(diford mvar x,l)
  542. and not smember(ldf!-mvar x,dfsub) then dfsub:=(mvar x) . dfsub;
  543. csub:=foreach x in dfsub collect(cadr x) . crepol x;
  544. if csub then return t;
  545. end$
  546. symbolic procedure ruledf!-diff l$
  547. %Searches for all equations of the form;
  548. %DF(function,derivative list)=0 which may be obtained by;
  549. %differentiation, picks out those of order L and stores;
  550. %the corresponding substitution polynomial on CSUB;
  551. if uhf and car uhf then
  552. begin scalar v,dfsub;
  553. foreach u in car uhf do v:=append(v,ldf!-df!-diff u);
  554. if not(v:=makeset v) then return;
  555. foreach x in v do if eqn(diford x,l) then dfsub:=x . dfsub;
  556. if not dfsub then return;
  557. csub:=((cadar dfsub) . crepol car dfsub) . csub;
  558. if csub then return t;
  559. end$
  560. symbolic procedure rule!-int l$
  561. %Searches for an equation of length L which may be solved for a;
  562. %function after beeing integrated and stores the corresponding;
  563. %rule on CSUB;
  564. if uhf and car uhf then
  565. begin scalar v,w;
  566. foreach u in car uhf do if not csub and leqgrt(length u,l,4)
  567. and (v:=ldf!-sub!-var(w:=ldf!-int u))
  568. then csub:=list(v . prepsq caar solvef(w,v));
  569. if csub then return t;
  570. end$
  571. symbolic procedure simpsys0$
  572. %Removes variable which are stored on list CZERO;
  573. begin scalar u,v;
  574. if pclass=2 then<<write"Entering SIMPSYS0"; terpri2()>>;
  575. u:=delnil foreach x in car uhf collect ldf!-subf0 x;
  576. v:=foreach x in cadr uhf collect ldf!-subf0 numr x ./ denr x;
  577. uhf:=list(makeset u,v);
  578. if pclass=1 then
  579. begin
  580. terpri2();
  581. if eqn(length czero,1) then
  582. write"Substitution" else write"Substitutions";
  583. terpri();
  584. foreach x in czero do
  585. algebraic write (lisp aeval x),":=0";
  586. terpri();
  587. end;
  588. if pclass=2 then<<write"CZERO:="; prettyprint czero; terpri()>>;
  589. czero:=nil;
  590. if pclass=2 then<<write"Leaving SIMPSYS0"; terpri2()>>;
  591. end$
  592. symbolic procedure simpsys!-rdep$
  593. %Removes dependencies which are stored on list RDEP;
  594. begin scalar u,v;
  595. if pclass=2 then<<write"Entering SIMPSYS!-RDEP"; terpri2()>>;
  596. foreach x in rdep do rmdep cdr x;
  597. u:=makeset delnil foreach x in car uhf collect ldf!-simp x;
  598. v:=foreach x in cadr uhf collect simp prepsq x;
  599. uhf:=list(u,v);
  600. if pclass=1 then
  601. begin
  602. terpri();
  603. write"Dependencies removed"; terpri2();
  604. foreach x in rdep do
  605. <<maprin cadr x; prin2!*" independent of ";
  606. maprin caddr x; terpri!* t;>>;
  607. terpri();
  608. end;
  609. if pclass=2 then<<write"RDEP:='"; prettyprint rdep; terpri()>>;
  610. if pclass=2 then<<write"Leaving SIMPSYS!-RDEP"; terpri2()>>;
  611. end$
  612. symbolic procedure simpsys!-sep$
  613. %Performs all possible separations;
  614. if uhf and car uhf then
  615. begin scalar u,v,test;
  616. if pclass=2 then<<write"Entering SIMPSYS!-SEP"; terpri2()>>;
  617. foreach x in car uhf do
  618. if eqn(length(v:=ldf!-sep x),1) then u:=x . u else
  619. begin
  620. u:=append(v,u);
  621. if pclass=1 or pclass=2 then
  622. begin scalar z; integer l;
  623. terpri();
  624. l:=length car uhf-length member(x,car uhf)+1;
  625. write"Equation ",l," separated into the terms";
  626. terpri();
  627. if pclass=1 then for k:=1:length v do
  628. begin
  629. z:=prepf nth(v,k);
  630. !*list := lengthf z geq 50;
  631. algebraic write"Term ",k," ",z;
  632. end;
  633. if pclass=2 then foreach y in v do prettyprint y;
  634. end;
  635. test:=t;
  636. end;
  637. !*list := nil;
  638. if test then uhf:=list(reverse makeset u,cadr uhf);
  639. if pclass=2 then<<write"Leaving SIMPSYS!-SEP"; terpri2()>>;
  640. end$
  641. symbolic procedure simpsys!-sub$
  642. %Performs all substitutions which are stored on CSUB;
  643. if uhf and car uhf then
  644. begin scalar u,v;
  645. if pclass=2 then<<write"Entering SIMPSYS!-SUB"; terpri2()>>;
  646. if pclass=1 then prrule csub;
  647. if pclass=2 then<<write"CSUB:='"; prettyprint csub; terpri()>>;
  648. u:=makeset delnil foreach x in car uhf collect
  649. ldf!-simp numr subf(x,csub);
  650. v:=foreach x in cadr uhf collect subsq(x,csub);
  651. uhf:=list(u,v);
  652. csub:=nil;
  653. if pclass=2 then<<write"Leaving SIMPSYS!-SUB"; terpri2()>>;
  654. end$
  655. symbolic procedure simpsys$
  656. if not uhf then
  657. rederr"The determining system is not defined" else
  658. if not car uhf then
  659. rederr"The determining system completely solved" else
  660. begin scalar u,v; integer nfun;
  661. prload();
  662. u:=makeset delnil foreach x in car uhf collect ldf!-simp x;
  663. v:=foreach x in cadr uhf collect simp prepsq x;
  664. uhf:=list(u,v);
  665. mark0:
  666. if pclass=1 then<<prsys!*"Entering main loop">> else
  667. if pclass=2 then prtlist"Entering main loop";
  668. czero:=csub:=rdep:=nil;
  669. simpsys!-sep();
  670. rule0();
  671. if czero then<<simpsys0(); go to mark0>>;
  672. if rule1() or rule1!-diff() then<<simpsys!-rdep(); go to mark0>>;
  673. if ruledf 2 or rulec 2 or rule!-int 2 or ruledf!-diff 2
  674. or ruledf 3 or rulec 3 or rule!-int 3 or ruledf!-diff 3
  675. or ruledf 4 or rulec 4 or rule!-int 4 or ruledf!-diff 4
  676. or ruledf 5 or rulec 5 or rule!-int 5 or ruledf!-diff 5
  677. then <<simpsys!-sub(); go to mark0>>;
  678. if car uhf then
  679. <<write"Determining system is not completely solved";
  680. terpri2(); prsys!*"The remaining equations are";
  681. if not zerop(nfun:=find!-nfun()) then
  682. write"Number of functions is ",nfun>>;
  683. end$
  684. symbolic procedure crepol u$
  685. begin scalar l1,f; integer pow,nfun;
  686. nfun:=find!-nfun();
  687. l1:=cdr assoc(car(u:=cdr u),depl!*);
  688. while (u:=cdr u) do
  689. begin scalar v;
  690. v:=car u;
  691. if length u=1 or not numberp cadr u then pow:=1 else
  692. <<pow:=cadr u; u:=delete(pow,u);>>;
  693. for k:=1:pow do
  694. begin scalar w;
  695. w:=!*a2k list('c,nfun:=nfun+1);
  696. mkdep(w . delete(v,l1));
  697. if k=1 then f:=w . f;
  698. if k=2 then f:=list('times,w,v) . f;
  699. if k geq 3 then
  700. f:=list('times,w,list('expt,v,k-1)) . f;
  701. end;
  702. end;
  703. return append('(plus),f);
  704. end$
  705. %*************************************************************$
  706. % Procedures for analysing the result $
  707. %*************************************************************$
  708. symbolic procedure cpar u$
  709. begin scalar v;
  710. v:=makeset appends(sacar('xi,u),sacar('eta,u),sacar('c,u));
  711. foreach x in v do if not assoc(x,depl!*) then v:=delete(x,v);
  712. return v;
  713. end$
  714. symbolic procedure makeset!-c!-x u$
  715. if not u then nil else
  716. if member!-c!-x(car u,cdr u) then makeset!-c!-x cdr u else
  717. car u . makeset!-c!-x cdr u$
  718. symbolic procedure member!-c!-x(u,v)$
  719. if not v then nil else
  720. if equal!-c!-x(u,car v) then v else member!-c!-x(u,cdr v)$
  721. symbolic procedure equal!-c!-x(u,v)$
  722. begin scalar p,q;
  723. p:=scar('c,u) or scar('xi,u) or scar('eta,u);
  724. q:=scar('c,v) or scar('xi,v) or scar('eta,v);
  725. return equal(subst('cxx,p,u),subst('cxx,q,v));
  726. end$
  727. symbolic procedure numgen$ length get('gen,'kvalue)$
  728. symbolic operator numgen$
  729. symbolic procedure gengen$
  730. begin scalar u,z,cgen,dgen; integer ngen;
  731. remprop('gen,'kvalue); remprop('gen,'klist);
  732. foreach x in cadr uhf do u:=append(ldf!-fvar numr x,u);
  733. foreach x in makeset u do
  734. begin scalar v,w;
  735. w:=nil ./ 1;
  736. if assoc(x,depl!*) then
  737. v:=foreach y in cadr uhf collect
  738. simp prepsq(ldf!-fvar!-part(numr y,x) ./denr y) else
  739. v:=foreach y in cadr uhf collect
  740. simp prepsq((lcf ldf!-fvar!-part(numr y,x)) ./denr y);
  741. for k:=1:nn do if numr nth(v,k) then
  742. w:=addsq(multsq(nth(v,k),!*k2q !*a2k list('dx,k)),w);
  743. for k:=1:mm do if numr nth(v,nn+k) then
  744. w:=addsq(multsq(nth(v,nn+k),!*k2q !*a2k list('du,k)),w);
  745. if assoc(x,depl!*) then
  746. cgen:=(absf remfacn numr simp prepf numr w) . cgen else
  747. dgen:=(absf remfacn numr simp prepf numr w) . dgen;
  748. end;
  749. dgen:=makeset dgen; cgen:=makeset!-c!-x cgen;
  750. num!-dgen:=length dgen; num!-cgen:=length cgen;
  751. for k:=1:nn do if member(z:=!*k2f !*a2k list('dx,k),dgen) then
  752. <<setk(list('gen,ngen:=add1 ngen),prepf z); dgen:=delete(z,dgen)>>;
  753. for k:=1:mm do if member(z:=!*k2f !*a2k list('du,k),dgen) then
  754. <<setk(list('gen,ngen:=add1 ngen),prepf z); dgen:=delete(z,dgen)>>;
  755. dgen:=sortx(function length,dgen);
  756. foreach x in dgen do setk(list('gen,ngen:=add1 ngen),prepf x);
  757. cgen:=sortx(function length,cgen);
  758. foreach x in cgen do setk(list('gen,ngen:=add1 ngen),prepf x);
  759. end$
  760. symbolic operator gengen$
  761. algebraic procedure comm(a,b)$
  762. begin scalar z;
  763. if (lisp length list!-deq)=0 then
  764. <<write"Differential equations not defined"; return nil>>;
  765. z:= (for k:=1:nn sum df(a,dx k)*df(b,x k)-df(b,dx k)*df(a,x k))
  766. +(for k:=1:mm sum df(a,du k)*df(b,u k)-df(b,du k)*df(a,u k))$
  767. return z;
  768. end$
  769. algebraic procedure result$
  770. begin integer l;
  771. if (l:=lisp length list!-deq)=1 then
  772. write"The differential equation" else
  773. write"The differential equations";
  774. for j:=1:l do
  775. begin scalar z; integer i,k;
  776. lisp(z:=car cadadr nth(list!-deq,j));
  777. i:=lisp cadar nth(list!-deq,j);
  778. k:=lisp lengthf prepf z;
  779. symbolic(!*list := k>40);
  780. write"DEQ(",i,"):=",lisp prepf z;
  781. end;
  782. !*list := nil;
  783. if (lisp length car uhf) neq 0 then
  784. prsys!*"The determining system is not completely solved" else
  785. <<lisp gengen(); prgen(); comm!-tab()>>;
  786. end$
  787. %*************************************************************$
  788. % Procedures for displaying the output $
  789. %*************************************************************$
  790. symbolic procedure prsys!* u$
  791. if uhf and car uhf then
  792. <<terpri(); write u; terpri(); prsys(); terpri()>>$
  793. symbolic procedure prsys$
  794. begin scalar v;
  795. terpri();
  796. remprop('gl,'kvalue); remprop('gl,'klist);
  797. for k:=1:length car uhf do
  798. begin scalar z; integer l;
  799. z:=prepf nth(car uhf,k);
  800. l:=lengthf prepf nth(car uhf,k);
  801. !*list := l>50;
  802. algebraic write"GL(",k,"):=",z;
  803. setk(list('gl,k),z);
  804. end;
  805. terpri2();
  806. write"The remaining dependencies";
  807. terpri2();
  808. v:=makeset
  809. appends(sacar('xi,car uhf),sacar('eta,car uhf),sacar('c,car uhf));
  810. foreach x in v do write!-dep x;
  811. !*list := nil;
  812. end$
  813. symbolic procedure prrule u$
  814. begin
  815. terpri2();
  816. if eqn(length u,1) then
  817. write"Substitution" else write"Substitutions";
  818. terpri2();
  819. foreach x in u do
  820. <<maprin car x; prin2!*" = "; maprin cdr x; terpri!* t;>>;
  821. terpri();
  822. foreach x in u do foreach y in sacar('c,cdr x) do write!-dep y;
  823. end$
  824. symbolic procedure prtlist u$
  825. <<write u; terpri2(); write"DEPL!*:='"; prettyprint depl!*;
  826. write"UHF:='"; prettyprint uhf>>$
  827. symbolic procedure write!-df!-sub$
  828. if get('df,'kvalue) then
  829. begin scalar w;
  830. w:=get('df,'kvalue);
  831. remprop('df,'kvalue);
  832. terpri();
  833. if length w=1 then write"Constraint" else write"Constraints";
  834. terpri2();
  835. foreach x in w do
  836. begin scalar u,v;
  837. u:=car x;
  838. v:=cadadr x;
  839. algebraic write lisp u,":=",lisp prepsq v;
  840. terpri2();
  841. end;
  842. put('df,'kvalue,w);
  843. end$
  844. algebraic procedure prgen$
  845. begin scalar lcpar;
  846. for k:=1:nn do <<order dx k; factor dx k>>;
  847. for k:=1:mm do factor du k$
  848. lisp(lcpar:=cpar get('gen,'kvalue));
  849. write"The symmetry generators are";
  850. for k:=1:numgen() do
  851. if (lisp lengthf reval list('gen,k)) leq 60 then
  852. <<symbolic(!*list := nil); write"GEN(",k,"):=",gen k>> else
  853. begin scalar z; integer r,s,nt; operator gen!*;
  854. nt:=lisp length(z:=numr simp reval list('gen,k));
  855. r:=lisp maxl foreach x in z collect abs comfacn list x;
  856. if r=1 then r:=0 else r:=lisp flatsizec r;
  857. for l:=1:nt do gen!* l:=lisp prepf list nth(z,l);
  858. for l:=1:nt do
  859. begin
  860. symbolic(!*list := lengthf prepf tc nth(z,l) geq 56);
  861. s:=lisp abs comfacn list nth(z,l);
  862. if r=0 then s:=0 else
  863. if s=1 then s:=-1 else s:=lisp flatsizec s;
  864. if l=1 then write"GEN(",k,"):=",lisp blanks(r-s+1),gen!* 1 else
  865. if minus!-f gen!* l=t then
  866. write lisp blanks(r-s+6),gen!* l else
  867. write lisp blanks(r-s+6)," + ",gen!* l;
  868. end;
  869. clear gen!*;
  870. symbolic(!*list := nil);
  871. end;
  872. if (lisp length lcpar) neq 0 then
  873. <<write"The remaining dependencies"; lisp terpri()>>;
  874. for k:=1:(lisp length lcpar) do
  875. <<lisp write!-dep nth(lcpar,k);>>;
  876. if (lisp length lcpar) neq 0 then lisp terpri();
  877. lisp write!-df!-sub();
  878. end$
  879. algebraic procedure comm!-tab$
  880. if (lisp num!-dgen) geq 2 then
  881. begin integer nd; scalar v;
  882. nd:=lisp num!-dgen;
  883. write"The non-vanishing commutators of the finite subgroup";
  884. for i:=1:nd-1 do for j:=(i+1):nd do
  885. if(v:=comm(gen i,gen j)) neq 0 then
  886. if (lisp lengthf reval v) leq 60 then
  887. <<symbolic(!*list := nil); write"COMM(",i,",",j,"):= ",v>> else
  888. begin integer r,s,nt; scalar z; operator gen!*;
  889. nt:=lisp length(z:=numr simp reval v);
  890. r:=lisp maxl foreach x in z collect abs comfacn list x;
  891. if r=1 then r:=0 else r:=lisp flatsizec r;
  892. for i:=1:nt do gen!* i:=lisp prepf list nth(z,i);
  893. for l:=1:nt do
  894. begin
  895. symbolic(!*list := lengthf reval list('gen!*,l) geq 63);
  896. s:=lisp abs comfacn list nth(z,l);
  897. if r=0 then s:=0 else
  898. if s=1 then s:=-1 else s:=lisp flatsizec s;
  899. if l=1 then
  900. write"COMM(",i,",",j,"):=",lisp blanks(r-s+1),gen!* 1 else
  901. if minus!-f gen!* l=t then
  902. write lisp blanks(r-s+9),gen!* l else
  903. write lisp blanks(r-s+9)," + ",gen!* l;
  904. end;
  905. clear gen!*;
  906. end;
  907. symbolic(!*list := nil);
  908. end$
  909. symbolic procedure write!-dep u$
  910. if assoc(reval u,depl!*) then
  911. begin scalar v;
  912. v:=cdr assoc(u,depl!*);
  913. write car u,"(",cadr u,") depends on ";
  914. write caar v,"(",cadar v,")";
  915. foreach x in cdr v do write",",car x,"(",cadr x,")";
  916. terpri2();
  917. end$
  918. symbolic operator write!-dep$
  919. symbolic procedure find!-nfun$
  920. if not get('c,'klist) then 0 else
  921. maxl makeset foreach x in get('c,'klist) collect cadar x$
  922. endmodule;
  923. end;