pmrules2.red 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. module pmrules2; % More rules for PM Pattern matcher.
  2. % NOTE: This module is supplied for information purposes only. It
  3. % still needs work to run properly in REDUCE 3.4. However,
  4. % the examples are sufficiently useful that the module is
  5. % included in the distribution.
  6. load!-package 'pmrules; % This loads both PM and PMRULES.
  7. algebraic;
  8. % Absolute Value Function.
  9. % Use the name XAbs to avoid problems with abs.
  10. xabs(?a*?b) ::- xabs(?a)*xabs(?b);
  11. xabs(?a/?b) ::- xabs(?a)/xabs(?b);
  12. xabs(?a^?n) ::- xabs(?a)^?n;
  13. xabs(?x _=posp(?x)) :- ?x;
  14. xabs(?x _=posp(-?x)) :- -?x;
  15. % XComb -generalization of Comb to general real arguments.
  16. % Author: Paul C Abbott, Univ. of Western Australia, Nov 85.
  17. comb(?a,?b)::- gamma(?a+1)/gamma(?b+1)/gamma(?a-?b+1);
  18. comb(?a,?n _=natp(?n+1))::- (-1)^?n *poc(-?a,?n)/fctl(?n);
  19. % Parity testing simplification.
  20. % Author: J Gottschalk, Univ. of Western Australia, Mar 85.
  21. % SMP already realizes that Evenp[x]:1 => Intp[x]:1 ;
  22. % Use the name XEvenp to avoid probles with evenp.
  23. XEvenp((??x _=XEvenp(??x))+(?y _=XEvenp(?y))) :- t;
  24. XEvenp((??x _= oddp(??x))+(?y _= oddp(?y))) :- t;
  25. XEvenp((??x _= oddp(??x))+(?y _=XEvenp(?y))) :- 0;
  26. XEvenp((??x _= intp(??x)) * (?y _=XEvenp(?y))) :- t;
  27. XEvenp((??x _= oddp(??x)) * (?y _= oddp(?y))) :- 0;
  28. XEvenp(( ?x _= XEvenp(?x))^(?y _= intp(?y))) :- t;
  29. XEvenp(( ?x _= oddp(?x))^(?y _= intp(?y))) :- 0;
  30. oddp((??x _= oddp(??x))+(?y _= oddp(?y))) :- 0;
  31. oddp((??x _=XEvenp(??x))+(?y _=XEvenp(?y))) :- 0;
  32. oddp((??x _= oddp(??x))+(?y _=XEvenp(?y))) :- t;
  33. oddp((??x _= intp(??x)) * (?y _=XEvenp(?y))) :- 0;
  34. oddp((??x _= oddp(??x)) * (?y _= oddp(?y))) :- t;
  35. oddp(( ?x _= XEvenp(?x))^(?y _= intp(?y))) :- 0;
  36. oddp(( ?x _= oddp(?x))^(?y _= intp(?y))) :- t;
  37. % Legendre polynomials in ?x of order ?n, ?n a natural number.
  38. operator legp;
  39. legp(?x,0) :- 1;
  40. legp(?x,1) :- ?x;
  41. legp(?x,?n _=natp(?n))
  42. ::- ((2*?n-1)*?x*legp(?x,?n-1)-(?n-1)*legp(?x,?n-2))/?n;
  43. % Using Mset.
  44. operator mlegp;
  45. mlegp(?x,0) :- 1;
  46. mlegp(?x,1) :- ?x;
  47. mlegp(?x,?n _=natp(?n))
  48. ::- ((2*?n-1)*?x*mlegp(?x,?n-1)-(?n-1)*mlegp(?x,?n-2))/?n;
  49. comment * Generalized hypergeometric functions: elementary identities *;
  50. % Author: John Gottschalk, Univ. of Western Australia, Sep 84.
  51. comment P: XWarning is automatically loaded. ;
  52. ;
  53. % Keywords:: hypergeometric: generalized hypergeometric functions:
  54. % Ghg: sums: summation: gauss: vandermonde: saalschutz: whipple:
  55. % kummer: watson: dixon: dougall.
  56. comment This file contains assignments and substitutions for rewriting
  57. special generalized hypergeometric functions in terms of Gamma
  58. and Polygamma functions. ;
  59. comment These identities are from Appendix 3 of Slater "Generalized
  60. Hypergeometric Functions", Cambridge University Press,1966.
  61. Those that have been omitted may be simply derived form other
  62. results, for example equation III.25 is is a result of equation
  63. III.11. ;
  64. flag('(#), 'symmetric);
  65. % Some commonly used theorems can be called by the following names:
  66. intdiff ::- sghg(0,{1,2,3,4});
  67. gauss ::- sghg(0,5);
  68. vandermonde ::- sghg(0,6);
  69. saalschutz ::- sghg(0,7);
  70. whipple ::- sghg(0,8);
  71. kummer ::- sghg(0,9);
  72. watson ::- sghg(0,10);
  73. dixon ::- sghg(0,11);
  74. dougall ::- sghg(0,12);
  75. nearlypoised ::- sghg(0,{13,14,15});
  76. wellpoised ::- flat({sghg(0,{16,17,18,19}),dixon,dougall,kummer});
  77. comment The patterns are written with a "=" sign as the pattern matcher
  78. in version 1.5.0. will return a 0 for matches like
  79. Match[a/2+1/2,(a+1)/2], but use of Eq gets around this problem;
  80. comment Reduction for 2F1(1,a:a+m:-1) when m is a natural number. ;
  81. %SGhg(0,1) :- Ghg(2,1,#(1,?a),#(?b _=Natp(?b-?a)),-1) ->
  82. % (-1)^(?b-?a-1) *Gamma(?b)/
  83. % (2*Gamma(?a)) *Sum((-1)^n/(Gamma(n+1) *Gamma(?b-?a-n))
  84. % * (Psi(?b/2-n/2)-Psi(?b/2-n/2-1/2)),{n,0,?b-?a-1}) ;
  85. %SGhg(0,2) :- Ghg(?p _=?p>2,?p-1,#(1,??a),
  86. % #(??b) _=Union({??b})-Union({??a}) = {1},1) -->
  87. % -Psi(?p-2,{??a}(1)) * (-1)^?p * ({??a}(1))^(?p-1)/Fctl(?p-2);
  88. %SGhg(0,3) :- Ghg(?p _=?p>2,?p-1,#(1,??a),
  89. % #(??b) _=Union({??b})-Union({??a}) = {1},-1) -->
  90. % (Psi(?p-2,({??a}(1))/2+1/2)-Psi(?p-2,({??a}(1))/2)) * (-1)^?p
  91. % * ({??a}(1))^(?p-1) *2^(1-?p)/Fctl(?p-2);
  92. sghg(0,4) :- ghg(3,2,#(1,?a,?b),#(?a+1,?b+1),1 _=symbwt(?b~=?a)) ->
  93. ?a *?b/(?a-?b) * (psi(?a)-psi(?b));
  94. comment Gauss's theorem ;
  95. sghg(0,5) :- ghg(2,1,#(?a,?b),#(?c),1) ->
  96. gamma(?c) *gamma(?c-?a-?b)/(gamma(?c-?a) *gamma(?c-?b));
  97. comment Vandermonde's theorem ;
  98. sghg(0,6) :- ghg(2,1,#(?a,?n _=natp(1-?n)),#(?c),1)
  99. -> poc(?c-?a,-?n)/poc(?c,-?n);
  100. comment Saalschutz's theorem ;
  101. sghg(0,7) :- ghg(3,2,#(?a,?b,?n _=natp(1-?n)),
  102. #(?c,?d _=?d=?a+?b+?n-?c+1),1) ->
  103. gamma(?c-?a-?n) *gamma(?c-?b-?n) *gamma(?c) *gamma(?c-?a-?b)/
  104. (gamma(?c-?a) *gamma(?c-?b) *gamma(?c-?n) *gamma(?c-?a-?b-?n));
  105. comment Whipple's theorem ;
  106. sghg(0,8) :- ghg(3,2,#(?a,?b _=?b=1-?a,?c),#(?d,?e) _=?d+?e=1+2*?c,1) ->
  107. pi *2^(1-2*?c) *gamma(?d) *gamma(?e)/
  108. (gamma((?a+?e)/2) *gamma((?a+?d)/2) *gamma((?d+?e)/2)
  109. *gamma((?b+?d)/2));
  110. comment Kummer's theorem ;
  111. sghg(0,9) :- ghg(2,1,#(?a,?b),#(?c _=?c=1+?a-?b),-1) ->
  112. gamma(1+?a-?b) *gamma(1+?a/2)/(gamma(1+?a) *gamma(1+?a/2-?b)) ;
  113. comment Watson's Theorem ;
  114. sghg(0,10) :- ghg(3,2,#(?a,?b,?c),#(?d _=?d=(1+?a+?b)/2,?e _=?e=2*?c),1)->
  115. gamma(1/2) *gamma(?c+1/2) *gamma((1+?a+?b)/2) *gamma((1-?a-?b)/2+?c)/
  116. (gamma((1+?a)/2) *gamma((1+?b)/2) *gamma((1-?a)/2+?c)
  117. *gamma((1-?b)/2+?c));
  118. comment Dixon's theorem ;
  119. sghg(0,11):- ghg(3,2,#(?a,?b,?c),#(?d _=?d=1+?a-?b,?e _=?e=1+?a-?c),1) ->
  120. gamma(1+?a/2) *gamma(1+?a-?b)*gamma(1+?a-?c)*gamma(1+?a/2-?b-?c)/
  121. (gamma(1+?a)*gamma(1+?a/2-?b)*gamma(1+?a/2-?c)*gamma(1+?a-?b-?c));
  122. comment Dougall's theorem ;
  123. sghg(0,12) :- ghg(7,6,#(?a,?f _=?f=1+?a/2,?b,?c,?d,?e,?n _=natp(1-?n) &
  124. 1+2*?a-?b-?c-?d-?e-?n=0),
  125. #(?g _=?g=?a/2,?h _=?h=1+?a-?b,?i _=?i=1+?a-?c,?j _=?j=1+?a-?d,
  126. ?k _=?k=1+?a-?e,?l _=?l=1+?a-?n),1) ->
  127. poc(1+?a,-?n) *poc(1+?a-?b-?c,-?n) *poc(1+?a-?b-?d,-?n)
  128. *poc(1+?a-?c-?d,-?n)/
  129. (poc(1+?a-?b,-?n) *poc(1+?a-?c,-?n) *poc(1+?a-?d,-?n)
  130. *poc(1+?a-?b-?c-?d,-?n));
  131. comment Appendix III.15 in Slater's book ;
  132. sghg(0,13) :- ghg(3,2,#(?a,?c _=?c=1+?a/2,?n _=natp(1-?n)),
  133. #(?d _=?d=?a/2,?b),1) ->
  134. (?b-?a-1+?n) *poc(?b-?a,-?n-1)/poc(?b,-?n);
  135. comment Appendix III.16 in Slater's book ;
  136. sghg(0,14) :- ghg(3,2,#(?a,?b,?n _=natp(1-?n)),
  137. #(?c _=?c=1+?a-?b,?d _=?d=1+2*?b+?n),1) ->
  138. poc(?a-2*?b,-?n) *poc(1+?a/2-?b,-?n) *poc(-?b,-?n)/
  139. (poc(1+?a-?b,-?n) *poc(?a/2-?b,-?n) *poc(-2*?b,-?n));
  140. comment Appendix III.17 in Slater's book ;
  141. sghg(0,15) :- ghg(4,3,#(?a,?c _=?c=1+?a/2,?b,?n _=natp(1-?n)),
  142. #(?d _=?d=?a/2,?e _=?e=1+?a-?b,?f _=?f=1+2*?b+?n),1) ->
  143. poc(?a-2*?b,-?n) *poc(-?b,-?n)/(poc(1+?a-?b,-?n) *poc(-2*?b,-?n));
  144. comment Appendix III.19 in Slater's book ;
  145. sghg(0,16) :- ghg(7,6,#(?a,?b,?c _=?c=1+?a/2,?d _=?d=1/2+?b,
  146. ?e _=?e=?a-2*?b,?f _=?f=1+2*?a-2*?b-?n,?n _=natp(1-?n)),
  147. #(?g _=?g=?a/2,?h _=?h=1+?a-?b,?i _=?i=?a+1/2-?b,?j _=?j=1+2*?b,
  148. ?k _=?k=2*?b-?a+?n,?l _=?l=1+?a-?n),1) ->
  149. poc(1+?a,-?n) *poc(1+2*?a-4*?b,-?n)/(poc(1+?a-2*?b,-?n)
  150. *poc(1+2*?a-2*?b,-?n));
  151. comment Appendix III.20 in Slater's book ;
  152. sghg(0,17) :- ghg(4,3,#(?a,?b,?n _=natp(1-?n),?c _=?c=1/2+?a),
  153. #(?d _=?d=?b/2+?n/2,?e _=?e=?b/2+?n/2+1/2,?f _=?f=1+2*?a),1) ->
  154. poc(?b+?n-2*?a,-?n)/poc(?b+?n,-?n);
  155. comment Appendix III.10 in Slater's book ;
  156. sghg(0,18) :- ghg(4,3,#(?a,?b,?c,?d _=?d=1+?a/2),
  157. #(?e _=?e=?a/2,?f _=?f=1+?a-?b,?g _=?g=1+?a-?c),-1) ->
  158. gamma(1+?a-?b) *gamma(1+?a-?c)/(gamma(1+?a) *gamma(1+?a-?b-?c));
  159. comment Appendix III.12 in Slater's book ;
  160. sghg(0,19) :- ghg(5,4,#(?a,?b,?c,?d,?e _=?e=1+?a/2),
  161. #(?f _=?f=?a/2,?g _=?g=1+?a-?b,?h _=?h=1+?a-?c,?i _=?i=1+?a-?d),1) ->
  162. gamma(1+?a-?b) *gamma(1+?a-?c) *gamma(1+?a-?d) *gamma(1+?a-?b-?c-?d)/
  163. (gamma(1+?a)*gamma(1+?a-?b-?c)*gamma(1+?a-?b-?d)*gamma(1+?a-?c-?d));
  164. comment The ?y _=?y=?x is needed to overcome a bug. It should be removed
  165. later. ;
  166. ghg(?p,?q,#(?x,??a),#(?y _=?y = ?x & ~natp(1-?y),??b),?z) ::-
  167. ghg(?p-1,?q-1,#(??a),#(??b),?z);
  168. ghg(?p,1,#(?x,??a),#(?y _=?y = ?x & ~natp(1-?y)),?z)
  169. :- ghg(?p-1,0,#(??a),#(),?z);
  170. ghg(1,?q,#(?x),#(?y _=?y = ?x & ~natp(1-?y),??b),?z)
  171. :- ghg(0,?q-1,#(),#(??b),?z);
  172. ghg(1,1,#(?x),#(?y _=?y = ?x & ~natp(1-?y)),?z) :- e^?z;
  173. ghg(1,0,#(?a),?b,?z ) :- (1-?z)^(-?a);
  174. ghg(0,0,?a,?b,?z) :- e^?z;
  175. %Ghg(?p,?q,#(0,??a),#(??b) _=~In(?1 _=Natp(1-?1),{??b},2),?z) :- 1;
  176. ghg(?p,?q,#(??t),#(??b),0) :- 1;
  177. comment If one of the bottom parameters is zero or a negative integer
  178. the hypergeometric functions may be singular, so the presence
  179. of a functions of this type causes a warning message to
  180. be printed. ;
  181. comment Note In seems to have an off by one level spec., so this may
  182. need changing in future. ;
  183. comment W: Sum[Smp] is redefined to be Inf.
  184. The identities may not be correct if one of the bottom parameters
  185. is a negative integer, even though the function may be well-behaved.
  186. The convergence of hypergeometric series should be checked using the
  187. file XCvgt before the identities here are used. ;
  188. % ------------------------------ gauss1 --------------------------------
  189. % Generalized Hypergeometric functions - transformations on pFqs.
  190. % Keywords: Hypergeometric, Ghg, Transformations, reversal of series,
  191. % Saalschutz.
  192. % Author: Kevin McIsaac, Univ. of Western Australia, Jul 85.
  193. % Some of this code references sum. This causes a problem in REDUCE.
  194. gamma({??a}) ::- ap(times,map(gamma,{??a}));
  195. %_Gamma(Init) ::- Loadonce(XGammaV);
  196. %_Poc(Init) ::- Loadonce(XPocV);
  197. % SRev reverses finite Hypergeometric series.
  198. sghg(6,1) :- srev ::-
  199. ghg(?p,?q,#(?m _=natp(1-?m),??a),#(??b),?z) -->
  200. ap(times,map(poc(?1,-?m),{??a}))/ap(times,map(poc(?1,-?m),{??b}))*
  201. (-?z)^(-?m)
  202. *ghg(?q+1,?p-1,ap(#,cat({?m},map(1-?1+?m,{??b}))),
  203. ap(#,map(1-?1+?m,{??a})),
  204. (-1)^(-1 + ?p + ?q)/?z);
  205. % If there is more than one -ve integer in the numerator the smallest
  206. % should be used. In the current implementation the largest is used
  207. % because of the natural ordering of Comm functions.
  208. % The followong are commented out since in leads to an infinite recursion
  209. %
  210. %comment :SSaal
  211. % Saalschutzs theorem in non-terminating form;
  212. %
  213. sghg(6,2) :- ssaal:-
  214. ghg(3,2,#(?e,?f,?g),#(?b,?c _=(?e+?f+?g+1=?b+?c)),1) ->
  215. gamma({?e,?f,?g,?e+?b-1,?f+?b-1,?g+?b-1})
  216. /gamma({?c-?e,?c-?f,?c-?g})-
  217. gamma({?b,1+?g-?c,1+?f-?c,1+?e-?c,?c-1})
  218. /gamma({1-?c,1+?b-?c,?e,?f,?g})
  219. *ghg(3,2,#(1+?e-?c,1+?f-?c,1+?g-?c),#(2-?c,1+?b-?c),1);
  220. comment : SDixon
  221. Generalization of Dixons theorem, Slater p52 (2.3.3.7);
  222. sghg(6,3) :- sdixon :-
  223. ghg(3,2,#(?a,?b,?c),#(?e,?f),1) ->
  224. gamma({?e,?f,?e+?f-?a-?b-?c})
  225. /gamma({?a,?e+?f-?a-?c,?e+?f-?a-?b})*
  226. ghg(3,2,#(?e-?a,?f-?a,?e+?f-?a-?b-?c),
  227. #(?e+?f-?a-?c,?e+?f-?a-?b),1);
  228. comment : SGhg[6,4]
  229. Three term relations, Slater p 115 (4.3.4);
  230. sghg(6,4) :-
  231. ghg(3,2,#(?a,?b,?c),#(?d,?e),1) ->
  232. gamma({1-?a,?d,?e,?c-?b})/gamma({?e-?b,?d-?b,1+?b-?a,?c})
  233. *ghg(3,2,#(?b,1+?b-?d,1+?b-?e),#(1+?b-?c,1+?b-?a),1) +
  234. gamma({1-?a,?d,?e,?b-?c})/gamma({?e-?c,?d-?c,1+?c-?a,?b})
  235. *ghg(3,2,#(?c,1+?c-?e,1+?c-?d),#(1+?c-?b,1+?c-?a),1);
  236. comment : SGhg[6,5]
  237. transforms a nearly-poised 3F2(-1) to a 4F3(1). Page 33 of Bailey;
  238. sghg(6,5) :- ghg(3,2,#(?a,?b,?c),#(?d,?e _=?e+?c=?d+?b),-1) -->
  239. ap(gamma({?k-?b,?k-?c})/gamma({?k,?k-?b-?c})
  240. *ghg(4,3,#(?b,?c,?k/2-?a/2,?k/2+1/2-?a/2),
  241. #(?k-?a,?k/2,?k/2+1/2),1),
  242. {?b+?d});
  243. %comment SGhg[6,6][?n]
  244. % writes Ghg[p,q,#[a1,..,ap],#[b1,..,bq],z] in terms of
  245. % Ghg[p+1,q+1,#[1,a1+n,..,ap+n],#[n+1,b1+n,..,bq+n],z] for
  246. % n positive or negative. ;
  247. %SGhg(6,6,(?n _=Natp(1+?n)) :- Ghg(?p,?q,#(??a),#(??b),?z) -->
  248. % Ap(Sum,{Ap(times,Map(Poc(?1,%r),{??a})) *?z^%r/
  249. % (Ap(times,Map(Poc(?1,%r),{??b})) *Gamma(%r+1)),
  250. % {%r,0,?n-1}}) +
  251. % Ap(times,Map(Poc(?1,?n),{??a})) *?z^?n /
  252. % (Ap(times,Map(Poc(?1,?n),{??b})) *Gamma(1+?n))
  253. % *Ghg(?p+1,?q+1,Ap(#,Cat({??a}+?n,{1})),
  254. % ap(#,cat({??b}+?n,{1+?n})),?z);
  255. %
  256. %SGhg(6,6,(?n _=Natp(-?n)) :- Ghg(?p,?q,#(??a),#(??b),?z) -->
  257. % -Ap(Sum,{Ap(times,Map(Gamma(?1+%r)/Gamma(?1),{??a})) *?z^%r/
  258. % (Ap(times,Map(Poc(?1,%r),{??b})) *Gamma(%r+1)),
  259. % {%r,?n,-1}}) +
  260. % Ap(times,Map(Gamma(?1+?n)/Gamma(?1),{??a})) *?z^?n/
  261. % (Ap(times,Map(Poc(?1,?n),{??b})) *Gamma(1+?n))
  262. % *Ghg(?p+1,?q+1,Ap(#,Cat({??a}+?n,{1})),
  263. % ap(#,cat({??b}+?n,{1+?n})),?z);
  264. sghg(6,7) :- ghg(6,5,#(?a,1+?a/2,?c,?d,?e,?f),
  265. #(?a/2,1+?a-?c,1+?a-?d,1+?a-?e,1+?a-?f),-1) ->
  266. gamma(1+?a-?e) *gamma(1+?a-?f)/(gamma(1+?a) *gamma(1+?a-?e-?f))
  267. *ghg(3,2,#(1+?a-?c-?d,?e,?f),#(1+?a-?c,1+?a-?d),1);
  268. sghg(6,8) :- ghg(6,5,#(?a,?b _=?b=1+?a/2,?c,?d,?e,?n _=natp(1-?n)),
  269. #(?f _=?f=?a/2,?g _=?g=1+?a-?c,?h _=?h=1+?a-?d,
  270. ?i _=?i=1+?a-?e,?j _=?j=1+?a-?n),-1) ->
  271. gamma(1+?a-?e) *gamma(1+?a-?n)/(gamma(1+?a) *gamma(1+?a-?e-?n))
  272. *ghg(3,2,#(1+?a-?c-?d,?e,?n),#(1+?a-?c,1+?a-?d),1);
  273. %_XGhg6(Loaded) :- 1;
  274. comment Special Elementary Cases of Gausses Series;
  275. comment Abramowitz & Stegun, 15.1;
  276. comment Incomplete. Rest of transformations must be added.
  277. xgauss(1,3) :- Ghg(2,1,#(1,1),#(2),?z) -> 1/?z * Ln(1-?z);
  278. xgauss(1,4) :- ghg(2,1,#(1/2,1),#(3/2),?z) ->
  279. 1/(2*sqrt(?z))*ln((1+sqrt(?z))/(1-sqrt(?z)));
  280. xgauss(1,5) :- ghg(2,1,#(1/2,1),#(3/2),?z) ->
  281. 1/sqrt(-?z) * arctan(sqrt(-?z));
  282. xgauss(1,6) :-{ghg(2,1,#(1/2,1/2),#(3/2),?z) ->
  283. 1/sqrt(?z) * arcsin(sqrt(?z)),
  284. ghg(2,1,#(1,1),#(3/2),?z) ->
  285. 1/((1-?z)*sqrt(?z)) * arcsin(sqrt(?z))};
  286. xgauss(1,7) :-{ghg(2,1,#(1/2,1/2),#(3/2),?z) ->
  287. 1/sqrt(-?z) * ln(sqrt(?z)+(1-?z)),
  288. ghg(2,1,#(1,1),#(3/2),?z) ->
  289. 1/((1+?z)*sqrt(-?z)) * ln(sqrt(?z)+(1-?z))};
  290. xgauss(1,8) :- ghg(2,1,#(?a,?b),#(?b),?z) -> (1-?z)^(-?a);
  291. xgauss(1,9) :- ghg(2,1,#(?a,?a+1/2),#(1/2),?z) ->
  292. 1/2*((1+sqrt(z))^(-2*?a) + (1-sqrt(?z))^(-2*?a));
  293. xgauss(1,10):- ghg(2,1,#(?a,?a+1/2),#(3/2),?z) ->
  294. 1/(2*sqrt(?z)*(1-2*?a))*
  295. ((1+sqrt(z))^(-2*?a) + (1-sqrt(?z))^(-2*?a));
  296. comment Incomplete. Rest of transformations must be added.;
  297. comment Hypergeometric functions. Transformations of the argument; ;
  298. comment Abramowitiz & Stegun 15.3
  299. comment Linear transformations *;
  300. sgauss(3,3):- ghg(2,1,#(?a,?b),#(?c),?z) ->
  301. (1-?z)^(?c-?b-?a)*ghg(2,1,#(?c-?a,?c-?b),#(?c),?z);
  302. sgauss(3,4):- ghg(2,1,#(?a,?b),#(?c),?z) ->
  303. ghg(2,1,#(?a,?c-?b),#(?c),?z/(?z-1))/(1-?z)^?a;
  304. sgauss(3,5):- ghg(2,1,#(?a,?b),#(?c),?z) ->
  305. gamma(?c)*gamma(?c-?a-?b)/(gamma(?c-?a)*gamma(?c-?b))*
  306. ghg(2,1,#(?a,?b),#(?a+?b-?c+1),1-?z)
  307. +(1-?z)^(?c-?a-?b)*gamma(?c)*gamma(?a+?b-?c)/(gamma(?a)*
  308. gamma(?b))*ghg(2,1,#(?c-?a,?c-?b),#(?c-?a-?b+1),1-?z);
  309. sgauss(3,6):- ghg(2,1,#(?a,?b),#(?c),?z) ->
  310. 1/(-?z)^?a*gamma(?c)*gamma(?b-?a)
  311. /(gamma(?b)*gamma(?c-?a))*
  312. ghg(2,1,#(?a,1-?c+?a),#(1-?b+?a),1/?z)
  313. +1/(-?z)^?b*gamma(?c)*gamma(?a-?b)
  314. /(gamma(?a)*gamma(?c-?b))*
  315. ghg(2,1,#(?b,1-?c+?b),#(1-?a+?b),1/?z);
  316. sgauss(3,7):- ghg(2,1,#(?a,?b),#(?c),?z) ->
  317. 1/(1-?z)^?a*gamma(?c)*gamma(?b-?a)
  318. /(gamma(?b)*gamma(?c-?a))*
  319. ghg(2,1,#(?a,?c-?b),#(?a-?b+1),1/(1-?z))
  320. +1/(1-?z)^?b*gamma(?c)*gamma(?a-?b)
  321. /(gamma(?a)*gamma(?c-?b))*
  322. ghg(2,1,#(?b,?c-?a),#(?b-?a+1),1/(1-?z));
  323. sgauss(3,8):- ghg(2,1,#(?a,?b),#(?c),?z) ->
  324. 1/?z^?a*gamma(?c)*gamma(?c-?a-?b)/ (gamma(?c-?a)*
  325. gamma(?c-?b))*ghg(2,1,#(?a,?a-?c+1),
  326. #(?a+?b-?c+1),1-1/?z)
  327. +(1-?z)^(?c-?a-?b)*?z^(?a-?c) *
  328. gamma(?c)*gamma(?a+?b-?c)/(gamma(?a)*gamma(?b)) *
  329. ghg(2,1,#(?c-?a,1-?a),#(?c-?a-?b+1),1-1/?z);
  330. comment* Quadratic transformations *;
  331. sgauss(3,15):- ghg(2,1,#(?a,?b),#(2*?b),?z) ->
  332. (1-?z)^(-?a/2)*ghg(2,1,#(?a/2,?b-?a/2),#(?b+1),
  333. ?z^2/(4*?z-4));
  334. sgauss(3,16):- ghg(2,1,#(?a,?b),#(2*?b),?z) ->
  335. (1-?z/2)^(-?a)*ghg(2,1,#(?a/2,?a/2+1/2),
  336. #(?b+1/2),?z^2/(2-?z)^2);
  337. sgauss(3,17):- ghg(2,1,#(?a,?b),#(2*?b),?z) ->
  338. (1/2+sqrt(1-?z)/2)^(-2*?a)
  339. *ghg(2,1,#(?a,?a-?b+1/2),#(?b+1/2),
  340. ((1-sqrt(1-?z))/(1+sqrt(1-?z)))^2);
  341. sgauss(3,18):- ghg(2,1,#(?a,?b),#(2*?b),?z) -> (1-?z)^(-?a/2)
  342. *ghg(2,1,#(?a,2*?b-?a),#(?b+1/2),-(1-sqrt(1-?z))^2
  343. /(4*sqrt(1-?z)));
  344. sgauss(3,19):- ghg(2,1,#(?a,?b _=?b=?a+1/2),#(?c),?z) ->
  345. (1/2+sqrt(1-?z)/2)^(-2*?a)
  346. *ghg(2,1,#(2*?a,2*?a-?c+1),#(?c),(1-sqrt(1-?z))
  347. /(1+sqrt(1-?z)));
  348. sgauss(3,20):- {ghg(2,1,#(?a,?b _=?b=?a+1/2),#(?c),?z) ->
  349. (1-sqrt(?z))^(-2*?a)
  350. *ghg(2,1,#(2*?a,?c-1/2),#(2*?c-1),
  351. -2*sqrt(?z)/(1-sqrt(?z))),
  352. ghg(2,1,#(?a,?b _=?b=?a+1/2),#(?c),?z) ->
  353. (1+sqrt(?z))^(-2*?a)
  354. *ghg(2,1,#(2*?a,?c-1/2),#(2*?c-1),
  355. 2*sqrt(?z)/(1+sqrt(?z)))};
  356. sgauss(3,21):- ghg(2,1,#(?a,?b _=?b=?a+1/2),#(?c),?z) -> 1/(1-?z)^?a
  357. *ghg(2,1,#(2*?a,2*?c-2*?a-1),#(?c),(sqrt(1-?z)-1)
  358. /(2*sqrt(1-?z)));
  359. sgauss(3,22):- ghg(2,1,#(?a,?b),#(?a+?b+1/2),?z) ->
  360. ghg(2,1,#(2*?a,2*?b),#(?a+?b+1/2),1/2-sqrt(1-?z)/2);
  361. sgauss(3,23):- ghg(2,1,#(?a,?b),#(?a+?b+1/2),?z) ->
  362. (1/2+sqrt(1-?z)/2)^(-2*?a)
  363. *ghg(2,1,#(2*?a,?a-?b+1/2),#(?a+?b+1/2),
  364. (sqrt(1-?z)-1)/(sqrt(1-?z)+1));
  365. sgauss(3,24):- ghg(2,1,#(?a,?b),#(?a+?b-1/2),?z) ->
  366. 1/sqrt(1-?z)*ghg(2,1,#(2*?a-1,2*?b-1),#(?a+?b-1/2),
  367. 1/2-sqrt(1-?z)/2);
  368. sgauss(3,25):- ghg(2,1,#(?a,?b),#(?a+?b-1/2),?z) ->
  369. (1/2+sqrt(1-?z)/2)^(1-2*?a)/sqrt(1-?z)
  370. *ghg(2,1,#(2*?a-1,?a-?b+1/2),#(?a+?b-1/2),
  371. (sqrt(1-?z)-1)/(sqrt(1-?z)+1));
  372. sgauss(3,26):- ghg(2,1,#(?a,?b),#(?a-?b+1),?z) ->
  373. 1/(1+?z)^(2*?a)*ghg(2,1,#(?a/2,?a/2+1/2),#(?a-?b+1),
  374. 4*?z/(1+?z)^2);
  375. sgauss(3,27):- {ghg(2,1,#(?a,?b),#(?a-?b+1),?z) -> (1+sqrt(?z))^(-2*?a)
  376. *ghg(2,1,#(?a,?a-?b+1/2),#(2*?a-2*?b+1),
  377. 4*sqrt(?z)/(1+sqrt(?z))^2),
  378. ghg(2,1,#(?a,?b),#(?a-?b+1),?z) -> (1-sqrt(?z))^(-2*?a)
  379. *ghg(2,1,#(?a,?a-?b+1/2),#(2*?a-2*?b+1),
  380. -4*sqrt(?z)/(1-sqrt(?z))^2)};
  381. sgauss(3,28):- ghg(2,1,#(?a,?b),#(?a-?b+1),?z) ->
  382. 1/(1-?z)^?a*ghg(2,1,#(?a/2,?a/2-?b+1/2),#(?a-?b+1),
  383. -4*?z/(1-?z)^2);
  384. sgauss(3,29):- ghg(2,1,#(?a,?b),#((?a+?b+1)/2),?z) ->
  385. ghg(2,1,#(?a/2,?b/2),#((?a+?b+1)/2),-4*?z*(?z-1));
  386. sgauss(3,30):- ghg(2,1,#(?a,?b),#(?a/2+?b/2+1/2),?z) -> 1/(1-2*?z)^?a
  387. *ghg(2,1,#(?a/2,?a/2+1/2),#(?a/2+?b/2+1/2),
  388. 4*?z*(?z-1)/(1-2*?z)^2);
  389. sgauss(3,31):- ghg(2,1,#(?a,1-?a),#(?c),?z) ->
  390. (1-?z)^(?c-1)*ghg(2,1,#(?c/2-?a/2,?c/2+?a/2-1/2),
  391. #(?c),4*?z-4*?z^2);
  392. sgauss(3,32):- ghg(2,1,#(?a,1-?a),#(?c),?z) ->
  393. (1-?z)^(?c-1)* (1-2*?z)^(?a-?c)
  394. *ghg(2,1,#(?c/2-?a/2,?c/2-?a/2+1/2),#(?c),
  395. 4*?z*(?z-1)/(1-2*?z)^2);
  396. % Gaussian hypergeometric functions. Orthogonal polynomials.
  397. % Abramowitz and Stegun section 15.4.
  398. sgauss(4,3):- ghg(2,1,#(?n _=intp(-?n),-?n),#(1/2),?x)
  399. -> chet(-?n,1-2 *?x);
  400. sgauss(4,4):- ghg(2,1,#(?n _=intp(-?n),1-?n),#(1),?x)
  401. -> legp(-?n,1-2 *?x);
  402. sgauss(4,5):- ghg(2,1,#(?n _=intp(-?n),?a-?n),#(?a/2+1/2),?x) ->
  403. fctl(-?n)/poc(?a,-?n) *geg(-?n,?a/2,1-2 *?x);
  404. sgauss(4,6):- ghg(2,1,#(?n _=intp(-?n),?c),#(?a),?x) ->
  405. fctl(-?n)/poc(?a,-?n)*jacp(-?n,?a-1,?c-?a+?n,1-2*?x);
  406. endmodule;
  407. end;