ghyper.red 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. module ghyper; % Generalized Hypergeometric Functions.
  2. % Author : Victor Adamchik, Byelorussian University Minsk, Byelorussia.
  3. % Major modifications by: Winfried Neun, ZIB Berlin.
  4. % Oct 22, 2001, hypergeometric({a,b},{0},z) returns
  5. % unevaluated (without error) as requested by Francis Wright
  6. put('GHF,'simpfn,'simpGHF)$
  7. symbolic procedure simpGHF u;
  8. if null cddr u then
  9. rerror('specialf,125,
  10. "WRONG NUMBER OF ARGUMENTS TO GHF-FUNCTION")
  11. else
  12. if or(not numberp car u,not numberp cadr u) then
  13. rerror('specialf,126,"INVALID AS INTEGER")
  14. else
  15. begin scalar vv,v;
  16. v:=redpar1(cddr u,car u);
  17. vv:=redpar1(cdr v,cadr u);
  18. if null cddr vv then return
  19. GHFsq(list(car u,cadr u),listsq car v,
  20. listsq car vv, simp cadr vv);
  21. return rerror ('specialf,127,
  22. "WRONG NUMBER OF ARGUMENTS TO GHF-FUNCTION");
  23. end$
  24. symbolic procedure GHFexit(a,b,z);
  25. begin scalar aa,bb;
  26. aa:= 'list . listprepsq a;
  27. bb:= 'list . listprepsq b;
  28. return mksqnew('hypergeometric .
  29. append(list(aa,bb),list(prepsq z)))$
  30. end;
  31. %***********************************************************************
  32. %* GHF as a polynomial *
  33. %***********************************************************************
  34. symbolic procedure listmaxsq u;
  35. % u - list of numbers of SQ.
  36. % return - max value.
  37. if null cdr u then car u else
  38. if null caar u then car u else
  39. if null caadr u then cadr u else
  40. if greaterp(caar u,caadr u) or equal(car u,cadr u) then
  41. listmaxsq((car u) . cddr u) else
  42. listmaxsq((cadr u) . cddr u)$
  43. symbolic procedure GHFpolynomp (u,a);
  44. begin scalar w1,w2;
  45. M1:
  46. if null u then
  47. if null w1 then <<u:=w2; return (NIL . a) >>
  48. else <<u:=listmaxsq(w1);
  49. a:=u . append(delete(u,w1),w2);
  50. return (T . a)>>
  51. else
  52. if parfool(car u) then (w1:=(car u) . w1)
  53. else (w2:=(car u) . w2);
  54. u:=cdr u;
  55. GOTO M1;
  56. end$
  57. symbolic procedure polynom(u,a,b,z);
  58. % u - list of SQ.
  59. begin scalar s; integer k;
  60. if null caar(u) then return '(1 . 1) else
  61. s := GHFpolynomp (b,a);
  62. a := cdr s;
  63. if car s then
  64. if null caar a or greaterp(caar a,caar u) then
  65. <<%rerror('special,124,
  66. % "zero in the denominator of the GHF-function");
  67. b:=a; a:=u;
  68. return GHFexit(a,b,z);
  69. >>
  70. else b:=a;
  71. k:=1; s:=1 . 1;
  72. M:
  73. s:=addsq(s,quotsq(multsq(multpochh(u,simp k),exptsq(z,k)),
  74. multpochh(append(list('(1 . 1)),b),simp k)));
  75. k:=k+1;
  76. if greaterp(k,car negsq(car u)) then return s else goto m;
  77. end$
  78. %***********************************************************************
  79. %* Lowering of the order GHF *
  80. %***********************************************************************
  81. symbolic smacro procedure GHFlowering1p;
  82. begin scalar sa,sb,w1,w2;
  83. sa:=a; sb:=b;
  84. M1: if null b then << a:=sa; b:=sb; return NIL
  85. >>;
  86. M2: if null a then << w2:= (car b) . w2;
  87. b:=cdr b;
  88. a:=sa; w1:=nil;
  89. GOTO M1
  90. >>
  91. else
  92. if numberp(prepsq diff1sq(car a,car b)) and
  93. greaterp(car(diff1sq(car a,car b)),0) then
  94. <<
  95. b:=car b . append(w2,cdr b);
  96. a:=diff1sq(car a,car b) . append(w1,cdr a);
  97. return T
  98. >> else
  99. <<
  100. w1:=(car a) . w1;
  101. a:=cdr a;
  102. GOTO M2
  103. >>;
  104. end$
  105. symbolic procedure lowering1(x,y,u,z);
  106. % x -- (m . a).
  107. % y -- (g . b).
  108. addsq(GHFsq(u,append(list(diff1sq(addsq(car x,car y),'(1 . 1))),
  109. cdr x),
  110. append(list(car y),cdr y),z),
  111. multsq(GHFsq(u,append(list(addsq(car x,car y)),listplus(cdr x,
  112. '(1 . 1))),
  113. append(list(addsq(car y,'(1 . 1))),
  114. listplus(cdr y,'(1 . 1))),z),
  115. quotsq(multsq(z,multlist(cdr x)),
  116. multsq(car y,multlist(cdr y)))))$
  117. symbolic smacro procedure GHFlowering2p;
  118. begin scalar sa,sb,w1,wa,fl;
  119. if equal(z,'(1 . 1)) then return NIL;
  120. sa:=a; sb:=b;
  121. M1: if null b then
  122. << b:=sb;
  123. if fl then a:=wa . sa else a:= sa;
  124. return NIL
  125. >>;
  126. M2: if null a then
  127. << b:=cdr b;
  128. a:=sa; w1:=nil;
  129. GOTO M1
  130. >>
  131. else
  132. if numberp(prepsq diff1sq(car b,car a)) and
  133. lessp(car(diff1sq(car a,car b)),0) then
  134. if fl then
  135. if not equal(wa,car a) then
  136. << b:=sb;
  137. a:=list(wa,car a) . append(w1,cdr a);
  138. return T
  139. >>
  140. else
  141. <<
  142. w1:=(car a) . w1;
  143. a:=cdr a;
  144. GOTO M2
  145. >>
  146. else
  147. << fl:=T;
  148. sa:=append(w1,cdr a);
  149. wa:=car a;
  150. b:=cdr b; a:=sa; w1:=nil;
  151. GOTO M1
  152. >>
  153. else
  154. << w1:= (car a) .w1;
  155. a:=cdr a;
  156. GOTO M2
  157. >>;
  158. end$
  159. symbolic procedure lowering2(x,b,u,z);
  160. % x -- (r s).(a).
  161. diff1sq(multsq(GHFsq(u,append(list(caar x,addsq('(1 . 1),cadar x)),
  162. cdr x),b,z),
  163. quotsq(cadar x,diff1sq(cadar x,caar x))),
  164. multsq(GHFsq(u,append(list(addsq('(1 . 1),caar x),cadar x),
  165. cdr x),b,z),
  166. quotsq(caar x,diff1sq(cadar x,caar x))))$
  167. symbolic smacro procedure GHFlowering3p;
  168. %return a = (mmm . a1).
  169. begin scalar sa,w,mmm; % MM used in SPDE as a global.
  170. sa:=a;
  171. M1: if null a then << a:=sa; return NIL >>
  172. else
  173. if not numberp(prepsq car a) then
  174. <<w:= (car a) . w; a:=cdr a; GOTO M1 >>;
  175. if member ('(1 . 1), a) then <<mmm := '(1 . 1);
  176. a:= delete('(1 . 1),a)>>
  177. else << mmm:= car a; a:=cdr a >>; % WN 2.2 94
  178. M2: if null a then
  179. if listnumberp b then << a:=mmm . w; return T >>
  180. else << a:=sa; return NIL>>
  181. else
  182. if equal(car a,'(1 . 1)) then
  183. <<a:=sa; return NIL>>
  184. else
  185. <<w:=(car a) . w;
  186. a:=cdr a;
  187. GOTO M2
  188. >>;
  189. end$
  190. symbolic procedure listnumberp(v);
  191. % v -- list of SQ.
  192. % value is T if numberp exist in (v).
  193. if null v then NIL
  194. else
  195. if numberp(prepsq car v) then T
  196. else listnumberp(cdr v)$
  197. symbolic procedure lowering3(a,b,u,z);
  198. multsq(quotsq(multlist(difflist(b,'(1 . 1))),multsq(z,multlist(
  199. difflist(cdr a,'(1 . 1))))),
  200. diff1sq(GHFsq(u, (car a) . difflist(cdr a,'(1 . 1)),
  201. difflist(b,'(1 . 1)),z),
  202. GHFsq(u,append(list(diff1sq(car a,'(1 . 1))),
  203. difflist(cdr a,'(1 . 1))),difflist(b,'(1 . 1)),z)))$
  204. %***********************************************************************
  205. %* GHFsq, main entry *
  206. %***********************************************************************
  207. symbolic procedure GHFsq(u,a,b,z);
  208. % u -- (p q) PF.
  209. % a,b -- lists of SQ.
  210. % z -- SQ.
  211. begin scalar c,aaa;
  212. u:=redpar(a,b);
  213. a:=car u;b:=cadr u;u:=list(length(a), length(b));
  214. if null car(z) then return '(1 . 1) else
  215. if listparfool(b,(nil .1)) and not listparfool(a,(nil . 1)) then
  216. % return rerror('specialf,128,
  217. %"zero in the denominator of the GHF-function")
  218. return GHFexit(a,b,z)
  219. else
  220. aaa := GHFpolynomp(a,a);
  221. a := cdr aaa;
  222. if car aaa then return polynom(a,a,b,z) else
  223. if GHFlowering1p() then return lowering1(a,b,u,z) else
  224. if GHFlowering2p() then return lowering2(a,b,u,z) else
  225. if GHFlowering3p() then return lowering3(a,b,u,z) else
  226. if car u = 0 and cadr u = 0 then return expdeg(simp 'e,z) else
  227. if car u = 0 and cadr u = 1 then return GHF01(a,b,z) else
  228. if car u = 1 and cadr u = 0 then
  229. if z='(1 . 1) then return GHFexit(a,b,z)
  230. else
  231. return expdeg(diff1sq('(1 . 1),z),if null a then '(nil . 1)
  232. else negsq(car a))
  233. else
  234. if car u = 1 and cadr u = 1 then return GHF11(a,b,z) else
  235. if car u = 1 and cadr u = 2 then return GHF12(a,b,z) else
  236. if car u = 2 and cadr u = 1 then return GHF21(a,b,z) else
  237. if car u = cadr u + 1 then
  238. if (c:=GHFmid(a,b,z)) = 'FAIL
  239. then return GHFexit(a,b,z)
  240. else return c;
  241. if car u <= cadr u then return GHFexit(a,b,z);
  242. return rerror('specialf,131,"hypergeometric series diverges");
  243. end$
  244. %***********************************************************************
  245. % p = q+1 *
  246. %***********************************************************************
  247. symbolic procedure GHFmid(a,b,z);
  248. begin scalar c;
  249. c:= redpar(a,difflist(b, '(1 . 1)));
  250. if length(cadr c) > 0 or length(car c) > 1 then return 'FAIL
  251. else
  252. return formulaformidcase(length(b), caar c,
  253. diff1sq(car b,'(1 . 1)), z);
  254. end$
  255. symbolic procedure formulaformidcase(p,b,a,z);
  256. if not(p = 1) and b = '(1 . 1) and z = '(1 . 1) then
  257. multsq(simpx1(prepsq(multsq('(-1 . 1),a)),p,1),
  258. quotsq(dfpsisq(a,simp(p-1)),gamsq(simp p)))
  259. else
  260. if b = '(1 . 1) and z='(-1 . 1) then
  261. quotsq(multsq(simpx1(prepsq(multsq('(-1 . 2),a)),p,1),
  262. diff1sq(dfpsisq(multsq(a, '(1 . 2)),simp(p-1)),
  263. dfpsisq(multsq(addsq('(1 . 1),a),'(1 . 2)),
  264. simp(p-1)))),
  265. gamsq(simp p))
  266. else
  267. if z = '(1 . 1) and not numberp(prepsq b) then
  268. multsq(
  269. subsqnew(
  270. derivativesq(
  271. quotsq(gamsq(simp 'r),gamsq(addsq(simp 'r,diff1sq('(1 . 1),b)))),
  272. 'r,simp(p-1)),
  273. a,'r),
  274. quotsq(
  275. multsq(multsq(simpx1(prepsq(multsq('(-1 . 1),a)),p,1), '(-1 . 1)),
  276. gamsq(diff1sq('(1 . 1),b))),
  277. gamsq(simp p)))
  278. else
  279. if z='(-1 . 1) and numberp prepsq(b) then
  280. begin scalar c; integer k;
  281. return multsq(
  282. subsqnew(
  283. derivativesq( addsq(
  284. <<
  285. k:=prepsq(b) - 1; c:='(nil . 1);
  286. while prepsq(k)>0 do
  287. <<
  288. c:=addsq(c, multsq(gamsq(b),
  289. simppochh(diff1sq(simp(1+k),simp 'r),
  290. simp(prepsq(b)-1-k))));
  291. k:=k-1
  292. >>;
  293. c
  294. >>,
  295. quotsq(
  296. multsq(gamsq(diff1sq(b,simp 'r)),
  297. diff1sq(psisq(multsq(addsq(simp 'r,'(1 . 1)),'(1 . 2))),
  298. psisq(multsq(simp 'r,'(1 . 2))))),
  299. multsq((2 . 1), gamsq(diff1sq('(1 . 1),simp 'r))))),
  300. 'r,p-1), a, 'r),
  301. quotsq(
  302. multsq(simpx1(prepsq(multsq('(-1 . 1),a)),p,1), '(-1 . 1)),
  303. multsq(gamsq(simp p),gamsq(simp b))))
  304. end
  305. else 'FAIL$
  306. %***********************************************************************
  307. %* Particular cases *
  308. %***********************************************************************
  309. symbolic procedure GHF01(a,b,z);
  310. if znak z then
  311. multsq(gamsq(car b),multsq(bessmsq(diff1sq(car b,'(1 . 1)),
  312. multsq('(2 . 1),simpx1(prepsq z,1,2))),
  313. expdeg(z,quotsq(diff1sq('(1 . 1),car b),'(2 . 1)))))
  314. else
  315. multsq(gamsq(car b),multsq(besssq(diff1sq(car b,'(1 . 1)),
  316. multsq('(2 . 1),simpx1(prepsq(negsq z),1,2))),expdeg(negsq z,
  317. quotsq(diff1sq('(1 . 1),car b),'(2 . 1))))) $
  318. symbolic procedure GHF11(a,b,z);
  319. if equal(car b,multsq('(2 . 1),car a)) then
  320. multsq(multsq(gamsq(addsq('(1 . 2),car a)),expdeg(simp 'e,
  321. multsq(z,'(1 . 2)))),
  322. multsq(expdeg(multsq(z,'(1 . 4)),diff1sq('(1 . 2),car a)),
  323. bessmsq(diff1sq(car a,'(1 . 2)),multsq(z,'(1 . 2)))))
  324. else
  325. if equal(car a,'(1 . 2)) and equal(car b,'(3 . 2)) then
  326. multsq(quotsq(simpx1('pi,1,2),'(2 . 1)),
  327. if znak z then
  328. quotsq(simpfunc('erfi,simpx1(prepsq z,1,2)),simpx1(prepsq z,1,2))
  329. else
  330. quotsq(simpfunc('erf,simpx1(prepsq(negsq z),1,2)),
  331. simpx1(prepsq(negsq z),1,2)))
  332. else
  333. if equal(car a,'(1 . 1)) and equal(car b,'(3 . 2)) and znak z then
  334. multsq(multsq('(1 . 2),expdeg(simp 'e,z)),
  335. multsq(simpfunc('erf,simpx1(prepsq z,1,2)),simpx1(prepsq
  336. quotsq(simp('pi),z),1,2)))
  337. else GHFexit(a,b,z)$
  338. symbolic procedure GHF21(a,b,z);
  339. if and(equal(car a,'(1 . 2)),equal(cadr a,'(1 . 2)),
  340. equal(car b,'(3 . 2)),znak(z))
  341. then
  342. quotsq(simpfunc('asin,simpx1(prepsq(z),1,2)),
  343. simpx1(prepsq(z),1,2))
  344. else
  345. if ((equal(car a,'(1 . 2)) and equal(cadr a,'(1 . 1))) or
  346. (equal(car a,'(1 . 1)) and equal(cadr a,'(1 . 2)))) and
  347. equal(car b,'(3 . 2))
  348. then
  349. <<
  350. if not znak(z) then
  351. quotsq(simpfunc('atan,simpx1(prepsq(negsq z),1,2)),
  352. simpx1(prepsq(negsq z),1,2)) else
  353. % if not equal(z,'(1 . 1)) then
  354. % quotsq(simpfunc('log,addsq('(1 . 1),simpx1(prepsq z,1,2))),
  355. % multsq(simpfunc('log,diff1sq('(1 . 1),simpx1(prepsq z,1,2))),
  356. % multsq('(2 . 1),simpx1(prepsq z,1,2)))) else
  357. if not equal(z,'(1 . 1)) then
  358. multsq(simpfunc('log,quotsq(addsq('(1 . 1),simpx1(prepsq z,1,2)),
  359. diff1sq('(1 . 1),simpx1(prepsq z,1,2)))),
  360. invsq(multsq('(2 . 1),simpx1(prepsq z,1,2)))) else
  361. GHFexit(a,b,z)
  362. >>
  363. else
  364. if and(equal(car a,'(1 . 1)),equal(cadr a,'(1 . 1)),
  365. equal(car b,'(2 . 1)),not equal(z,'(1 . 1)))
  366. then
  367. quotsq(simpfunc('log,addsq('(1 . 1),negsq z)),negsq z)
  368. else
  369. if equal(diff1sq(addsq(car a,cadr a),car b),'(-1 . 2)) and
  370. (equal(multsq('(2 . 1),car a),car b) or
  371. equal(multsq('(2 . 1),cadr a),car b))
  372. then
  373. multsq(expdeg(addsq('(1 . 1),
  374. simpx1(prepsq(diff1sq('(1 . 1),z)),1,2)),
  375. diff1sq('(1 . 1),car b)),expdeg('(2 . 1),addsq(car b,'(-1 . 1))))
  376. else
  377. if z='(1 . 1)
  378. and (not numberp prepsq diff1sq(car b,addsq(car a, cadr a))
  379. or prepsq(diff1sq(car b,addsq(car a, cadr a))) > 0 )
  380. then quotsq(multsq(gamsq(car b),
  381. gamsq(diff1sq(car b,addsq(car a,cadr a))) ),
  382. multsq(gamsq(diff1sq(car b,car a)),
  383. gamsq(diff1sq(car b,cadr a))))
  384. else
  385. if car a='(1 . 1) and cadr a='(1 . 1) and numberp prepsq car b and
  386. prepsq car(b) > 0 and not(z='(1 . 1)) then
  387. formula136(prepsq car b,z) else
  388. GHFexit(a,b,z)$
  389. symbolic procedure formula136(m,z);
  390. begin scalar c; integer k;
  391. c:='(nil . 1); k:=2;
  392. while k<=m-1 do
  393. << c:=addsq(c,quotsq(exptsq(diff1sq(z,'(1 . 1)),k),
  394. multsq(exptsq(z,k),simp(m-k))));
  395. k:=k+1
  396. >>;
  397. c:=diff1sq(c,multsq(exptsq(quotsq(diff1sq(z,'(1 . 1)),z),m),
  398. simpfunc('log,diff1sq('(1 . 1),z))));
  399. return
  400. multsq(c,
  401. quotsq(multsq(simp(m-1),z),exptsq(diff1sq(z,'(1 . 1)),2)));
  402. end$
  403. symbolic procedure GHF12(a,b,z);
  404. if equal(car a,'(3 . 4)) and (equal(car b,'(3 . 2)) and equal(cadr b,
  405. '(7 . 4)) or equal(car b,'(7 . 4)) and equal(cadr b,'(3 . 2)))
  406. and not znak z then
  407. <<z:=multsq('(2 . 1),simpx1(prepsq(negsq z),1,2));
  408. multsq(quotsq(multsq('(3 . 1),simpx1('pi,1,2)),
  409. multsq(simpx1(2,1,2),simpx1(prepsq z,3,2))),
  410. simpfunc('intfs,z)) >>
  411. else
  412. if equal(car a,'(1 . 4)) and (equal(car b,'(1 . 2)) and equal(cadr b,
  413. '(5 . 4)) or equal(car b,'(5 . 4)) and equal(cadr b,'(1 . 2)))
  414. and not znak z then
  415. <<z:=multsq((2 . 1),simpx1(prepsq(negsq z),1,2));
  416. multsq(quotsq(simpx1('pi,1,2),multsq(simpx1(2,1,2),
  417. simpx1(prepsq z,1,2))),simpfunc('intfc,z)) >>
  418. else GHFexit(a,b,z)$
  419. symbolic smacro procedure fehler();
  420. rerror('specialf,139,"Wrong arguments to hypergeometric");
  421. symbolic procedure hypergeom(U);
  422. begin scalar list1,list2,res,res1;
  423. if not (length(u) = 3) then fehler();
  424. if pairp u then list1 :=car u else fehler();
  425. if pairp cdr u then list2 := cadr u else fehler();
  426. if not pairp cddr u then fehler();
  427. if not eqcar(list1,'list) then fehler();
  428. if not eqcar(list2,'list) then fehler();
  429. list1 := for each x in cdr list1 collect simp reval x;
  430. list2 := for each x in cdr list2 collect simp reval x;
  431. res := ghfsq(list (length list1,length list2),
  432. list1,list2,simp caddr u);
  433. res1 := prepsq res;
  434. return if eqcar(res1,'hypergeometric) then res else simp res1;
  435. end;
  436. put('hypergeometric,'simpfn,'hypergeom);
  437. % something is missing:
  438. algebraic let {hypergeometric({1/2,1/2},{3/2},-(~x)^2) => asinh(x)/x };
  439. algebraic let hypergeometric({~a,~b},{~c},-(~z/(1-~z))) =>
  440. hypergeometric({a,c-b},{c},z) * (1-z)^a;
  441. % Pfaff's reflection law
  442. flag ('(permutationof),'boolean);
  443. symbolic procedure permutationof(set1,set2);
  444. length set1 = length set2
  445. and not setdiff(set1,set2);
  446. algebraic let {
  447. hypergeometric({},~lowerind,~z) =>
  448. 3/(32*sqrt(2)*(-z)^(3/4))*
  449. (cosh(2*(-z*4)^(1/4))*sin(2*(-z*4)^(1/4)) -
  450. sinh(2*(-z*4)^(1/4))*cos(2*(-z*4)^(1/4)))
  451. when permutationof(lowerind,{5/4,3/2,7/4})
  452. and numberp z and z < 0,
  453. hypergeometric({},~lowerind,~z) =>
  454. 1/(4*(-4*z)^(1/4))*
  455. (sinh(2*(-z*4)^(1/4))*cos(2*(-z*4)^(1/4)) +
  456. cosh(2*(-z*4)^(1/4))*sin(2*(-z*4)^(1/4)))
  457. when permutationof(lowerind,{5/4,1/2,3/4})
  458. and numberp z and z < 0,
  459. hypergeometric({},~lowerind,~z) =>
  460. 1/(8*(-z)^(1/2))*sinh(2*(-z*4)^(1/4))*sin(2*(-z*4)^(1/4))
  461. when permutationof(lowerind,{3/4,5/4,3/2})
  462. and numberp z and z < 0,
  463. hypergeometric({},~lowerind,~z) =>
  464. cosh(2*(-z*4)^(1/4))*cos(2*(-z*4)^(1/4))
  465. when permutationof(lowerind,{1/4,1/2,3/4})
  466. and numberp z and z < 0,
  467. hypergeometric({},~lowerind,~z) =>
  468. 3/(64*z^(3/4))*(sinh(4*z^(1/4)) -sin(4*z^(1/4)))
  469. when permutationof(lowerind,{5/4,3/2,7/4}),
  470. hypergeometric({},~lowerind,~z) =>
  471. 1/(8*z^(1/4))*(sinh(4*z^(1/4)) +sin(4*z^(1/4)))
  472. when permutationof(lowerind,{5/4,1/2,3/4}),
  473. hypergeometric({},~lowerind,~z) =>
  474. 1/(16*z^(1/2))*(cosh(4*z^(1/4)) -cos(4*z^(1/4)))
  475. when permutationof(lowerind,{3/4,5/4,3/2}),
  476. hypergeometric({},~lowerind,~z) =>
  477. 1/2*(cosh(4*z^(1/4)) + cos(4*z^(1/4)))
  478. when permutationof(lowerind,{1/4,1/2,3/4})
  479. };
  480. algebraic
  481. << hypergeometric_rules:=
  482. { hypergeometric({~a},{},~x) => (1-x)^(-a) when not(numberp x and x=1),
  483. % F(a;b;z)
  484. hypergeometric({1/2},{5/2},~x) =>
  485. 3/(4*x)*((1+2*x)/2*sqrt(pi/x)*erfi(sqrt(x))-e^x),
  486. hypergeometric({1},{1/2},~x) =>
  487. 1+sqrt(pi*x)*e^x*erf(sqrt(x)),
  488. hypergeometric({1},{3/2},~x) =>
  489. 1/2*sqrt(pi/x)*e^x*erf(sqrt(x)),
  490. hypergeometric({1},{5/2},~x) =>
  491. 3/(2*x)*(1/2*sqrt(pi/x)*e^(x)*erf(sqrt(x))-1),
  492. hypergeometric({1},{7/2},~x) =>
  493. 5/(4*x^2)*(3/2*sqrt(pi/x)*e^x*erf(sqrt(x))-3-2*x),
  494. hypergeometric({3/2},{5/2},-~x) =>
  495. e^(-x)*hypergeometric({1},{5/2},x),
  496. hypergeometric({3/2},{5/2},~x) =>
  497. 3/(2*x)*(e^x-1/2*sqrt(pi/x)*erfi(sqrt(x))),
  498. hypergeometric({5/2},{7/2},-~x) =>
  499. e^(-x)*hypergeometric({1},{7/2},x),
  500. hypergeometric({7/2},{9/2},-~x) =>
  501. e^(-x)*hypergeometric({1},{9/2},x),
  502. hypergeometric({~a},{~b},~x) =>
  503. a*(-x)^(-a)*m_gamma(a,-x) when b = a + 1,
  504. hypergeometric({~a},{~b},~x) =>
  505. (a+1)*(e^(x)+(-x-a)*(-x)^(-a-1)*m_gamma(a+1,-x))
  506. when b = a + 2,
  507. % F(a,b;c;z)
  508. hypergeometric({-1/2,1},{3/2},-~x) =>
  509. (1/2)*(1+(1+x)*(atan(sqrt(x))/sqrt(x))),
  510. hypergeometric({-1/2,1},{3/2},~x) =>
  511. (1/2)*(1+(1-x)*(atanh(sqrt(x))/sqrt(x))),
  512. hypergeometric({1/2,1},{5/2},-~x) =>
  513. (3/2*-x)*(1-(1+x)*(atan(sqrt(x))/sqrt(x))),
  514. hypergeometric({1/2,1},{5/2},~x) =>
  515. (3/2*x)*(1-(1-x)*(atanh(sqrt(x))/sqrt(x))),
  516. hypergeometric({~a + 1/2,~a},{1/2},~x) =>
  517. (1-x)^(-a)*cos(2*a*atan(sqrt(-x))),
  518. hypergeometric({5/4,3/4},{1/2},~x) =>
  519. (1-x)^(-3/4)*cos(3/2*atan(sqrt(-x))),
  520. hypergeometric({(~n+1)/2 + 1/2,(~n+1)/2},{1/2},~x) =>
  521. (1-x)^(-(n+1)/2)*cos((n+1)*atan(sqrt(-x))),
  522. hypergeometric({7/4,5/4},{3/2},~x) =>
  523. 2/3*(1-x)^(-3/4)/sqrt(-x)*sin(3/2*atan(sqrt(-x))),
  524. hypergeometric({~a + 1/2,~a},{3/2},~x) =>
  525. ((1-x)^(1/2-a))/((2*a-1)*sqrt(-x))*sin((2*a-1)*atan(sqrt(-x))),
  526. hypergeometric({(~n+2)/2 + 1/2,(~n+2)/2},{3/2},~x) =>
  527. ((1-x)^(1/2-(n+2)/2))/((2*(n+2)/2-1)*sqrt(-x))*sin((2*(n+2)/2-1)
  528. *atan(sqrt(-x))),
  529. % F(a;b,c;z);
  530. hypergeometric({-1/2},{1/2,1/2},-~x) =>
  531. cos(2*sqrt(x))+2*sqrt(x)*si(2*sqrt(x)),
  532. hypergeometric({-1/2},{1/2,1/2},~x) =>
  533. cosh(2*sqrt(x))-2*x*shi(2*sqrt(x)),
  534. hypergeometric({-1/2},{1/2,3/2},-~x) =>
  535. (1/2)*(cos(2*sqrt(x))+(sin(2*sqrt(x)))/(2*sqrt(x))
  536. +2*sqrt(x)*si(2*sqrt(x))),
  537. hypergeometric({-1/2},{1/2,3/2},~x) =>
  538. (1/2)*(cosh(2*sqrt(x))+(sinh(2*sqrt(x)))/(2*sqrt(x))
  539. -2*sqrt(x)*shi(2*sqrt(x))),
  540. hypergeometric({-1/2},{3/2,3/2},-~x) =>
  541. (1/4)*(cos(2*sqrt(x))+(sin(2*sqrt(x)))/(2*sqrt(x))
  542. +(1+2*x)*(si(2*sqrt(x)))/sqrt(x)),
  543. hypergeometric({-1/2},{3/2,3/2},~x) =>
  544. (1/4)*(cosh(2*sqrt(x)) +(sinh(2*sqrt(x)))/(2*sqrt(x))
  545. +(1-2*x)*(shi(2*sqrt(x)))/sqrt(x)),
  546. hypergeometric({1/2},{3/2,3/2},-~x) =>
  547. si(2*sqrt(x))/(2*sqrt(x)),
  548. hypergeometric({1/2},{3/2,3/2},~x) =>
  549. shi(2*sqrt(x))/(2*sqrt(x)),
  550. hypergeometric({1/2},{5/2,3/2},-~x) =>
  551. 3/(8*-x)*(2*sqrt(x)*si(2*sqrt(x))-cos(2*sqrt(x))+
  552. (sin(2*sqrt(x)))/(2*sqrt(x))),
  553. hypergeometric({1/2},{5/2,3/2},~x) =>
  554. 3/(8*x)*(2*sqrt(x)*shi(2*sqrt(x))-cosh(2*sqrt(x))+
  555. (sinh(2*sqrt(x)))/(2*sqrt(x))),
  556. hypergeometric({1},{3/4,5/4},~x) =>
  557. 1/2*sqrt(pi/sqrt(-x))*(cos(2*sqrt(-x))*fresnel_c(2*sqrt(-x))
  558. + sin(2*sqrt(-x))*fresnel_s(2*sqrt(-x))),
  559. hypergeometric({1},{5/4,7/4},~x) =>
  560. 3*sqrt(pi)/(8*(sqrt(-x))^(3/2))*(sin(2*sqrt(-x))
  561. *fresnel_c(2*sqrt(-x))-cos(2*sqrt(-x))*fresnel_s(2*sqrt(-x))),
  562. hypergeometric({5/2},{7/2,7/2},-~x) =>
  563. (75/(16*x^2))*(3*si(2*sqrt(x))/(2*sqrt(x))
  564. - 2*sin(2*sqrt(x))/sqrt(x) + cos(2*sqrt(x))),
  565. hypergeometric({5/2},{7/2,7/2},~x) =>
  566. (75/(16*x^2))*(3*shi(2*sqrt(x))/(2*sqrt(x))
  567. - 2*sinh(2*sqrt(x))/sqrt(x) + cosh(2*sqrt(x))),
  568. hypergeometric({~a},{~b,3/2},~x) =>
  569. -2^(1-2*a)*a*(sqrt(-x))^(-2*a)*
  570. (gamma(2*a-1)*cos(a*pi)+fresnel_s(2*sqrt(-x),2*a-1))
  571. when b = a + 1,
  572. hypergeometric({~a},{~b,1/2},~x) =>
  573. 2^(1-2*a)*a*(sqrt(-x))^(-2*a)*
  574. (gamma(2*a)*cos(a*pi)-fresnel_c(2*sqrt(-x),2*a))
  575. when b = a + 1
  576. };
  577. let hypergeometric_rules;
  578. operator Poisson!-Charlier, Toronto;
  579. let { Toronto(~m,~n,~x) =>
  580. Gamma(m/2 + 1/2)/factorial n * x^(2*n-2*m+1)*exp(-x^2) *
  581. KummerM(m/2+1/2,1+n,x^2),
  582. Poisson!-Charlier(~n,~nu,~x) =>
  583. pochhammer(1 + nu-n,n)/(sqrt factorial n * x^(n/2))*
  584. sum(pochhammer(-n,i)*x^i/
  585. (pochhammer(1+nu-n,i) * factorial i)
  586. ,i,0,n)
  587. };
  588. >>;
  589. endmodule;
  590. end;