precoats.red 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. module precoats;
  2. % Author: James H. Davenport.
  3. fluid '(!*tra
  4. basic!-listofallsqrts
  5. basic!-listofnewsqrts
  6. sqrt!-intvar
  7. taylorvariable
  8. thisplace);
  9. exports precoates;
  10. imports mksp,algint!-subf,subzero2,substitutesq,removeduplicates,
  11. printsq,basicplace,extenplace,interr,get!-correct!-sqrts,
  12. printplace,simptimes,subzero,negsq,addsq,involvesq,taylorform,
  13. taylorevaluate,mk!*sq,!*exptsq,!*multsq,!*invsq,sqrt2top,
  14. jfactor,sqrtsave,antisubs;
  15. symbolic procedure infsubs(w);
  16. if caar w = thisplace
  17. then (cdar w).(cdr w)
  18. else (thisplace.(car w)).(cdr w);
  19. % thisplace is (z quotient 1 z) so we are moving to infinity.
  20. symbolic procedure precoates(residues,x,movedtoinfinity);
  21. begin
  22. scalar answer,placeval,reslist,placelist,placelist2,thisplace;
  23. reslist:=residues;
  24. placelist:=nil;
  25. while reslist do <<
  26. % car reslist = <substitution list>.<value>;
  27. placeval:=algint!-subf((mksp(x,1) .* 1) .+ nil,caar reslist);
  28. if 0 neq cdar reslist
  29. then if null numr subzero2(denr placeval,x)
  30. then <<
  31. if null answer
  32. then answer:='infinity
  33. else if answer eq 'finite
  34. then answer:='mixed;
  35. if !*tra
  36. then printc "We have an residue at infinity" >>
  37. else <<
  38. if null answer
  39. then answer:='finite
  40. else if answer eq 'infinity
  41. then answer:='mixed;
  42. placelist:=placeval.placelist;
  43. if !*tra
  44. then printc "This is a finite residue" >>;
  45. reslist:=cdr reslist >>;
  46. if answer eq 'mixed
  47. then return answer;
  48. if answer eq 'infinity
  49. then <<
  50. thisplace:=list(x,'quotient,1,x);
  51. % maps x to 1/x.
  52. answer:=precoates(for each u in residues collect infsubs u,x,t);
  53. % derivative of 1/x is -1/x**2.
  54. if atom answer
  55. then return answer
  56. else return substitutesq(answer,list(thisplace)) >>;
  57. placelist2:=removeduplicates placelist;
  58. answer := 1 ./ 1;
  59. % the null divisor.
  60. if !*tra then <<
  61. printc "The divisor has elements at:";
  62. for each j in placelist2 collect printsq j>>;
  63. while placelist2 do begin
  64. scalar placelist3,extrasubs,u,bplace;
  65. % loop over all distinct places.
  66. reslist:=residues;
  67. placelist3:=placelist;
  68. placeval:=nil;
  69. while reslist do <<
  70. if car placelist2 = car placelist3
  71. then <<
  72. placeval:=(cdar reslist).placeval;
  73. thisplace:= caar reslist;
  74. % the substitutions defining car placelist.
  75. u:=caar reslist;
  76. bplace:=basicplace u;
  77. u:=extenplace u;
  78. extrasubs:=u.extrasubs >>;
  79. reslist:=cdr reslist;
  80. placelist3:=cdr placelist3 >>;
  81. % placeval is a list of all the residues at this place.
  82. if !*tra then <<
  83. princ "List of multiplicities at this place:";
  84. printc placeval;
  85. princ "with substitutions:";
  86. superprint extrasubs >>;
  87. if 0 neq mapply(function plus2,placeval)
  88. then interr "Divisor not effective";
  89. get!-correct!-sqrts bplace;
  90. u:=pbuild(x,extrasubs,placeval);
  91. sqrtsave(basic!-listofallsqrts,basic!-listofnewsqrts,bplace);
  92. if atom u
  93. then <<
  94. placelist2:=nil;
  95. % set to terminate loop.
  96. answer:=u >>
  97. else <<
  98. answer:=substitutesq(!*multsq(answer,u),antisubs(thisplace,x));
  99. placelist2:=cdr placelist2 >>
  100. end;
  101. % loaded in pbuild to check for poles at the correct places.
  102. return answer
  103. end;
  104. symbolic procedure dlist(u);
  105. % Given a list of lists,converts to a list.
  106. if null u
  107. then nil
  108. else if null car u
  109. then dlist cdr u
  110. else append(car u,dlist cdr u);
  111. symbolic procedure debranch(extrasubs,reslist);
  112. begin
  113. scalar substlist;
  114. % remove spurious substitutions.
  115. for each u in dlist extrasubs do
  116. if not ((car u) member substlist)
  117. then substlist:=(car u).substlist;
  118. % substlist is a list of all the possible substitutions).
  119. while substlist do
  120. begin scalar tsqrt,usqrt;
  121. scalar with1,with2,without1,without2,wres;
  122. scalar a1,a2,b1,b2;
  123. % decide if tsqrt is redundant.
  124. tsqrt:=car substlist;
  125. substlist:=cdr substlist;
  126. wres:=reslist;
  127. for each place in extrasubs do <<
  128. usqrt:=assoc(tsqrt,place);
  129. % usqrt is s.s' or s.(minus s').
  130. if null usqrt
  131. then interr "Places not all there";
  132. if cadr usqrt eq 'sqrt
  133. then<<
  134. with2:=(car wres).with2;
  135. with1:=delete(usqrt,place).with1>>
  136. else<<
  137. if not (cadr usqrt eq 'minus)
  138. then interr "Ramification format error";
  139. without2:=(car wres).without2;
  140. without1:=delete(usqrt,place).without1 >>;
  141. wres:=cdr wres>>;
  142. % first see if one item appears passim.
  143. if null with1
  144. then go to itswithout;
  145. if null without1
  146. then go to itswith;
  147. % Now must see if WITH2 matches WITHOUT2 in order WITH1/WITHOUT1.
  148. a1:=with1;
  149. a2:=with2;
  150. outerloop:
  151. b1:=without1;
  152. b2:=without2;
  153. innerloop:
  154. if (car a1) = (car b1)
  155. then << if (car a2) neq (car b2)
  156. then return nil
  157. else go to outeriterate >>;
  158. b1:=cdr b1;
  159. b2:=cdr b2;
  160. if null b1
  161. then return nil
  162. else go to innerloop;
  163. % null b1 => lists do not match at all.
  164. outeriterate:
  165. a1:=cdr a1;
  166. a2:=cdr a2;
  167. if a1
  168. then go to outerloop;
  169. if !*tra then <<
  170. princ "Residues reduce to:";
  171. printc without2;
  172. printc "at ";
  173. mapc(without1,function printplace) >>;
  174. extrasubs:=without1;
  175. reslist:=without2;
  176. return;
  177. itswithout:
  178. % everything is in the "without" list.
  179. with1:=without1;
  180. with2:=without2;
  181. itswith:
  182. % remove usqrt from the with lists.
  183. extrasubs:=for each u in with1 collect delete(assoc(tsqrt,u),u);
  184. if !*tra then <<
  185. printc "The following appears throughout the list ";
  186. printc tsqrt >>;
  187. reslist:=with2
  188. end;
  189. return extrasubs.reslist
  190. end;
  191. symbolic procedure pbuild(x,extrasubs,placeval);
  192. begin
  193. scalar multivals,u,v,answer;
  194. u:=debranch(extrasubs,placeval);
  195. extrasubs:=car u;
  196. placeval:=cdr u;
  197. % remove spurious entries.
  198. if (length car extrasubs) > 1
  199. then return 'difficult;
  200. % hard cases not allowed for.
  201. multivals := mapovercar dlist extrasubs;
  202. u:=simptimes removeduplicates multivals;
  203. answer:= 1 ./ 1;
  204. while extrasubs do <<
  205. v:=substitutesq(u,car extrasubs);
  206. v:=!*addsq(u,negsq subzero(v,x));
  207. v:=mkord1(v,x);
  208. if !*tra then <<
  209. princ "Required component is ";
  210. printsq v >>;
  211. answer:=!*multsq(answer,!*exptsq(v,car placeval));
  212. % place introduced with correct multiplicity.
  213. extrasubs:=cdr extrasubs;
  214. placeval:=cdr placeval >>;
  215. if length jfactor(denr sqrt2top !*invsq answer,x) > 1
  216. then return 'many!-poles
  217. else return answer
  218. end;
  219. symbolic procedure findord(v,x);
  220. begin
  221. scalar nord,vd;
  222. %given v(x) with v(0)=0, makes v'(0) nonzero.
  223. nord:=0;
  224. taylorvariable:=x;
  225. while involvesq(v,sqrt!-intvar) do
  226. v:=substitutesq(v,list(x.list('expt,x,2)));
  227. vd:=taylorform v;
  228. loop:
  229. nord:=nord+1;
  230. if null numr taylorevaluate(vd,nord)
  231. then go to loop;
  232. return nord
  233. end;
  234. symbolic procedure mkord1(v,x);
  235. begin
  236. scalar nord;
  237. nord:=findord(v,x);
  238. if nord iequal 1
  239. then return v;
  240. if !*tra then <<
  241. princ "Order reduction: ";
  242. printsq v;
  243. princ "from order ";
  244. princ nord;
  245. printc " to order 1" >>;
  246. % Note that here we do not need to simplify, since SIMPLOG will
  247. % remove all these SQRTs or EXPTs later.
  248. return !*p2q mksp(list('nthroot,mk!*sq v,nord),1)
  249. end;
  250. endmodule;
  251. end;