findres.red 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. module findres;
  2. % Author: James H. Davenport.
  3. fluid '(!*gcd
  4. !*tra
  5. !*trmin
  6. basic!-listofallsqrts
  7. basic!-listofnewsqrts
  8. intvar
  9. listofallsqrts
  10. listofnewsqrts
  11. nestedsqrts
  12. sqrt!-intvar
  13. taylorvariable);
  14. exports find!-residue,findpoles;
  15. imports sqrt2top,jfactor,prepsq,printplace,simpdf,involvesf,simp;
  16. imports stt,interr,mksp,negf,multf,addf,let2,substitutesq,subs2q,quotf;
  17. imports printsq,clear,taylorform,taylorevaluate,involvesf,!*multsq;
  18. imports sqrtsave,sqrtsinsq,sqrtsign;
  19. symbolic procedure find!-residue(simpdl,x,place);
  20. % evaluates residue of simpdl*dx at place given by x=place(y).
  21. begin
  22. scalar deriv,nsd,poss,slist;
  23. listofallsqrts:=basic!-listofallsqrts;
  24. listofnewsqrts:=basic!-listofnewsqrts;
  25. deriv:=simpdf(list(place,x));
  26. if involvesf(numr deriv,intvar)
  27. then return residues!-at!-new!-point(simpdl,x,place);
  28. if eqcar(place,'quotient) and (cadr place iequal 1)
  29. then goto place!-correct;
  30. place:=simp list('difference,intvar,place);
  31. if involvesq(place,intvar)
  32. then interr "Place wrongly formatted";
  33. place:=list('plus,intvar,prepsq place);
  34. place!-correct:
  35. if car place eq 'plus and caddr place = 0
  36. then place:=list(x.x)
  37. else place:=list(x.place);
  38. % the substitution required.
  39. nsd:=substitutesq(simpdl,place);
  40. deriv:=!*multsq(nsd,deriv);
  41. % differential is deriv * dy, where x=place(y).
  42. if !*tra then <<
  43. printc "Differential after first substitution is ";
  44. printsq deriv >>;
  45. while involvesq(deriv,sqrt!-intvar)
  46. do <<
  47. sqrtsave(basic!-listofallsqrts,basic!-listofnewsqrts,place);
  48. nsd:=list(list(x,'expt,x,2));
  49. deriv:=!*multsq(substitutesq(deriv,nsd),!*kk2q x);
  50. % derivative of x**2 is 2x, but there's a jacobian of 2 to
  51. % consider.
  52. place:=nconc(place,nsd) >>;
  53. % require coeff x**-1 in deriv.
  54. nestedsqrts:=nil;
  55. slist:=sqrtsinsq(deriv,x);
  56. if !*tra and nestedsqrts
  57. then printc "We have nested square roots";
  58. slist:=sqrtsign(slist,intvar);
  59. % The reversip is to ensure that the simpler sqrts are at
  60. % the front of the list.
  61. % Slist is a list of all combinations of signs of sqrts.
  62. taylorvariable:=x;
  63. for each branch in slist do <<
  64. nsd:=taylorevaluate(taylorform substitutesq(deriv,branch),-1);
  65. if numr nsd
  66. then poss:=(append(place,branch).sqrt2top nsd).poss >>;
  67. poss:=reversip poss;
  68. if null poss
  69. then go to finished;
  70. % poss is a list of all possible residues at this place.
  71. if !*tra
  72. then <<
  73. princ "Residues at ";
  74. printplace place;
  75. printc " are ";
  76. mapc(poss, function (lambda u; <<
  77. printplace car u;
  78. printsq cdr u >>)) >>;
  79. finished:
  80. sqrtsave(basic!-listofallsqrts,basic!-listofnewsqrts,place);
  81. return poss
  82. end;
  83. symbolic procedure residues!-at!-new!-point(func,x,place);
  84. begin
  85. scalar place2,tempvar,topterm,a,b,xx;
  86. if !*tra then <<
  87. printc "Find residues at all roots of";
  88. superprint place >>;
  89. place2:=numr simp place;
  90. topterm:=stt(place2,x);
  91. if car topterm = 0
  92. then interr "Why are we here?";
  93. tempvar:=gensym();
  94. place2:=addf(place2,
  95. multf(!*p2f mksp(x,car topterm),negf cdr topterm));
  96. % The remainder of PLACE2.
  97. let2(list('expt,tempvar,car topterm),
  98. subst(tempvar,x,prepsq(place2 ./ cdr topterm)),
  99. nil,t);
  100. place2:=list list(x,'plus,x,tempvar);
  101. !*gcd:=nil;
  102. % No unnecessary work: only factors of X worry us.
  103. func:=subs2q substitutesq(func,place2);
  104. !*gcd:=t;
  105. xx:=!*k2f x;
  106. while (a:=quotf(numr func,xx)) and (b:=quotf(denr func,xx))
  107. do func:=a ./ b;
  108. if !*tra then <<
  109. printc "which gives rise to ";
  110. printsq func >>;
  111. if null a
  112. then b:=quotf(denr func,xx);
  113. % because B goes back to the last time round that WHILE loop.
  114. if b then go to hard;
  115. if !*tra then printc "There were no residues";
  116. clear tempvar;
  117. return nil;
  118. % *** thesis remark ***
  119. % This test for having an X in the denominator only works
  120. % because we are at a new place, and hence (remark of Trager)
  121. % if we have a residue at one place over this point, we must have one
  122. % at them all, since the places are indistinguishable;
  123. hard:
  124. taylorvariable:=x;
  125. func:=taylorevaluate(taylorform func,-1);
  126. printsq func;
  127. interr "so far"
  128. end;
  129. symbolic procedure findpoles(simpdl,x);
  130. begin
  131. scalar simpdl2,poles;
  132. % finds possible poles of simpdl * dx.
  133. simpdl2:=sqrt2top simpdl;
  134. poles:=jfactor(denr simpdl2,x);
  135. poles := for each j in poles collect prepsq j;
  136. % what about the place at infinity.
  137. poles:=list('quotient,1,x).poles;
  138. if !*tra or !*trmin
  139. then <<
  140. printc "Places at which poles could occur ";
  141. for each u in poles do
  142. printplace list(intvar.u) >>;
  143. return poles
  144. end;
  145. endmodule;
  146. end;