jhdriver.red 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. module jhdriver;
  2. % Author: James H. Davenport.
  3. fluid '(!*algint
  4. !*backtrace
  5. !*coates
  6. !*noacn
  7. !*tra
  8. !*trmin
  9. !*structure
  10. basic!-listofallsqrts
  11. basic!-listofnewsqrts
  12. gaussiani
  13. intvar
  14. listofallsqrts
  15. listofnewsqrts
  16. previousbasis
  17. sqrt!-intvar
  18. sqrtflag
  19. sqrts!-in!-integrand
  20. sqrts!-mod!-prime
  21. taylorasslist
  22. varlist
  23. zlist);
  24. global '(tryharder);
  25. switch algint,coates,noacn,tra,trmin;
  26. exports algebraiccase,doalggeom,coates!-multiple;
  27. !*algint := t; % Assume algebraic integration wanted if this module
  28. % is loaded.
  29. symbolic procedure operateon(reslist,x);
  30. begin
  31. scalar u,v,answer,save;
  32. scalar sqrts!-mod!-prime;
  33. u:=zmodule(reslist);
  34. v:=answer:=nil ./ 1;
  35. while u and not atom v do <<
  36. v:=findfunction cdar u;
  37. if not atom v then <<
  38. if !*tra or !*trmin then <<
  39. printc "Extension logarithm is ";
  40. printsq v >>;
  41. save:=tryharder;
  42. tryharder:=x;
  43. v:= combine!-logs(caar u, simplogsq v);
  44. tryharder:=save;
  45. answer:=!*addsq(answer,v);
  46. u:=cdr u >> >>;
  47. if atom v
  48. then return v
  49. else return answer
  50. end;
  51. symbolic procedure findfunction divisor;
  52. begin
  53. scalar v,places,mults,ans,dof1k;
  54. scalar previousbasis;
  55. % ***time-hack-2 :::
  56. % A hack for decreasing the amount of work done in COATES.
  57. divisor:=for each u in divisor collect
  58. correct!-mults u;
  59. if !*coates
  60. then go to nohack;
  61. v:=precoates(divisor,intvar,nil);
  62. if not atom v
  63. then return v;
  64. nohack:
  65. for each u in divisor do <<
  66. places:=(car u).places;
  67. mults :=(cdr u).mults >>;
  68. v:=coates(places,mults,intvar);
  69. if not atom v
  70. then return v;
  71. dof1k:=differentials!-1 getsqrtsfromplaces places;
  72. if null dof1k
  73. then interr "Must be able to integrate over curves of genus 0";
  74. if not mazurp(places,dof1k)
  75. then go to general;
  76. ans:='provably!-impossible;
  77. for i:=2:12 do
  78. if (i neq 11) and
  79. not atom (ans:=coates!-multiple(places,mults,i))
  80. then i:=12; % leave the loop - we have an answer.
  81. return ans;
  82. general:
  83. v:=findmaninparm places;
  84. if null v
  85. then return algebraic!-divisor(divisor,dof1k);
  86. if not maninp(divisor,v,dof1k)
  87. then return 'provably!-impossible;
  88. v:=1;
  89. loop:
  90. v:=iadd1 v;
  91. if not atom (ans:=coates!-multiple(places,mults,v))
  92. then return ans;
  93. go to loop
  94. end;
  95. symbolic procedure correct!-mults u;
  96. begin
  97. scalar multip;
  98. multip:=cdr u;
  99. for each v in car u do
  100. if (lsubs v eq intvar) and
  101. eqcar(rsubs v,'expt)
  102. then multip:=multip * (caddr rsubs v);
  103. return (car u).multip
  104. end;
  105. symbolic procedure algebraiccase(expression,zlist,varlist);
  106. begin
  107. scalar rischpart,deriv,w,firstterm;
  108. scalar sqrtflag,!*structure; % set !*structure to NIL, else
  109. % sqrt(z)^2 isn't simplified
  110. sqrtflag:=t;
  111. sqrtsave(listofallsqrts,listofnewsqrts,list(intvar . intvar));
  112. rischpart:= errorset!*(list('doalggeom,mkquote expression),
  113. !*backtrace);
  114. newplace list (intvar.intvar);
  115. if atom rischpart
  116. then <<
  117. if !*tra then printc "Inner integration failed";
  118. deriv:=nil ./ 1;
  119. % assume no answer.
  120. rischpart:=deriv >>
  121. else
  122. if atom car rischpart
  123. then <<
  124. if !*tra or !*trmin then
  125. printc "The 'logarithmic part' is not elementary";
  126. return (nil ./ 1) . expression >>
  127. else <<
  128. rischpart:=car rischpart;
  129. deriv:=!*diffsq(rischpart,intvar) where sqrtflag=nil;
  130. % deriv := squashsqrt deriv;
  131. % Should no longer be necessary.
  132. if !*tra or !*trmin then <<
  133. printc "Inner working yields";
  134. printsq rischpart;
  135. printc "with derivative";
  136. printsq deriv >> >>;
  137. deriv:=!*addsq(expression,negsq deriv);
  138. if null numr deriv
  139. then return rischpart . (nil ./ 1); % no algebraic part.
  140. if null involvesq(deriv,intvar)
  141. then return !*addsq(rischpart,
  142. !*multsq(deriv,((mksp(intvar,1) .* 1) .+ nil) ./ 1))
  143. . (nil ./ 1);
  144. % if the difference is merely a constant.
  145. varlist:=getvariables deriv;
  146. zlist:=findzvars(varlist,list intvar,intvar,nil);
  147. varlist:=setdiff(varlist,zlist);
  148. firstterm:=simp!* car zlist; % this may crop up.
  149. w:=sqrt2top !*multsq(deriv,invsq !*diffsq(firstterm,intvar));
  150. if null involvesq(w,intvar)
  151. then return !*addsq(rischpart,!*multsq(w,firstterm)) . (nil ./ 1);
  152. if !*noacn then interr "Testing only logarithmic code";
  153. deriv:=transcendentalcase(deriv,intvar,nil,zlist,varlist);
  154. return !*addsq(car deriv, rischpart) . cdr deriv
  155. end;
  156. symbolic procedure doalggeom(differential);
  157. begin
  158. scalar reslist,place,placelist,
  159. savetaylorasslist,sqrts!-in!-integrand,
  160. taylorasslist;
  161. placelist:=findpoles(differential,intvar);
  162. reslist:=nil;
  163. sqrts!-in!-integrand:=sqrtsinsq (differential,intvar);
  164. while placelist do <<
  165. place:=car placelist;
  166. placelist:=cdr placelist;
  167. savetaylorasslist:=taylorasslist;
  168. place:=find!-residue(differential,intvar,place);
  169. if place
  170. then reslist:=append(place,reslist)
  171. else taylorasslist:=savetaylorasslist >>;
  172. if reslist
  173. then go to serious;
  174. if !*tra or !*trmin
  175. then printc "No residues => no logs";
  176. return nil ./ 1;
  177. serious:
  178. placelist:=operateon(reslist,intvar);
  179. if placelist eq 'failed
  180. then interr "Divisor operations failed";
  181. return placelist
  182. end;
  183. symbolic procedure algebraic!-divisor(divisor,dof1k);
  184. if length dof1k = 1
  185. then lutz!-nagell(divisor)
  186. else bound!-torsion(divisor,dof1k);
  187. symbolic procedure coates!-multiple(places,mults,v);
  188. begin
  189. scalar ans;
  190. if not atom (ans:=coates(places,
  191. for each u in mults collect v*u,
  192. intvar))
  193. then <<
  194. if !*tra or !*trmin then <<
  195. princ "Divisor has order ";
  196. printc v >>;
  197. return !*kk2q list('nthroot,mk!*sq ans,v) >>
  198. else return ans
  199. end;
  200. symbolic procedure mazurp(places,dof1k);
  201. % Checks to ensure we have an elliptic curve over the rationals.
  202. begin
  203. % scalar sqrt2,sqrt4,v;
  204. % sqrt2:=0;
  205. % % Number of SQRTs of things of degree 1 or 2;
  206. % sqrt4:=0;
  207. % % " " " 3 or 4;
  208. % for each u in getsqrtsfromplaces places do <<
  209. % v:=!*q2f simp u;
  210. % if sqrtsinsq(v,intvar)
  211. % then return nil;
  212. % % Cannot use nested SQRTs;
  213. % v:=car stt(v,intvar);
  214. % if v < 3
  215. % then if sqrt4>0
  216. % then return nil
  217. % else if sqrt2>1
  218. % then return nil
  219. % else sqrt2:=iadd1 sqrt2
  220. % else if v < 5
  221. % then if sqrt2>0 or sqrt4>0
  222. % then return nil
  223. % else sqrt4:=1
  224. % else return nil >>;
  225. scalar answer;
  226. if length dof1k neq 1
  227. then return nil;
  228. % Genus = # linearly independent differentials of 1st kind;
  229. % We know know that it is of genus = 1.
  230. answer:=t;
  231. while answer and places do
  232. if sqrtsintree(basicplace car places,nil,nil)
  233. then answer:= nil
  234. else places:=cdr places;
  235. if null answer then return nil;
  236. if !*tra then
  237. <<prin2 "*** We can apply Mazur's bound on the torsion of";
  238. prin2t "elliptic curves over the rationals">>;
  239. return t
  240. end;
  241. endmodule;
  242. end;