definth.red 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. module definth;
  2. fluid '(mellin!-transforms!* mellin!-coefficients!*);
  3. algebraic <<
  4. operator indefint2;
  5. indefint2_rules :=
  6. { indefint2((~f1+~~f2)/~~f3,~x,~y) =>
  7. indefint2(f1/f3,x,y)+indefint2(f2/f3,x,y) when not(f2=0),
  8. indefint2(~n,~f1-~f2,~x,~y) =>
  9. indefint2(n,f1,x,y)-indefint2(n,f2,x,y),
  10. indefint2(~n,~f1+~f2,~x,~y) =>
  11. indefint2(n,f1,x,y)+indefint2(n,f2,x,y),
  12. indefint2(1/~x^(~~a),~f,~x,~y) => transf(defint_choose(f,x),-a,y,x),
  13. indefint2(~x^(~~b)*sqrt(~x),~f,~x,~y) =>
  14. transf(defint_choose(f,x),b+1/2,y,x),
  15. indefint2(sqrt(~x),~f,~x,~y) =>
  16. transf(defint_choose(f,x),1/2,y,x),
  17. indefint2(~x^(~~a),~f,~x,~y) => transf(defint_choose(f,x),a,y,x),
  18. indefint2(~b*~ff,~f,~x,~y) => b*indefint2(ff,f,x,y) when freeof (b,x),
  19. indefint2(~b/(~~c*~ff),~f,~x,~y) => b/c*indefint2(1/ff,f,x,y)
  20. when freeof (b,x) and freeof (c,x) and not(b=1 and c=1),
  21. indefint2(~ff/~b,~f,~x,~y) =>
  22. 1/b*indefint2(ff,f,x,y) when freeof (b,x),
  23. indefint2(~b*~ff,~f,~x,~y) => b*indefint2(ff,f,x,y) when freeof (b,x),
  24. indefint2(~ff/~b,~f,~x,~y) =>
  25. 1/b*indefint2(ff,f,x,y) when freeof (b,x),
  26. indefint2(~~b,~f,~x,~y) => b*indefint2(f,x,y)
  27. when freeof (b,x) and not(b=1),
  28. indefint2(~f,~x,~y) => transf(defint_choose(f,x),0,y,x)
  29. };
  30. let indefint2_rules;
  31. symbolic procedure simpinteg(u);
  32. begin scalar ff1,alpha,y,var,chosen_num,coef,!*uncached;
  33. !*uncached := t;
  34. ff1 := prepsq simp car u;
  35. if ff1 = 'UNKNOWN then return simp 'UNKNOWN;
  36. alpha := cadr u;
  37. y := caddr u;
  38. var := cadddr u;
  39. chosen_num := cadr ff1;
  40. if chosen_num = 0 then << alpha := caddr ff1;
  41. return simp reval algebraic(alpha*y)>>
  42. else
  43. << put('f1,'g,getv(mellin!-transforms!*,chosen_num));
  44. coef := getv(mellin!-coefficients!*,chosen_num);
  45. if coef then MELLINCOEF:= coef else MELLINCOEF :=1;
  46. return simp list('new_mei,'f1 . cddr ff1,alpha,y,var)>>;
  47. end$
  48. put('new_mei,'simpfn,'new_meijer)$
  49. symbolic procedure new_meijer(u);
  50. begin scalar f,y,mellin,new_mellin,m,n,p,q,old_num,old_denom,temp,a1,
  51. b1,a2,b2,alpha,num,denom,n1,temp1,temp2,coeff,v,var,new_var,new_y,
  52. new_v,k;
  53. f := prepsq simp car u;
  54. y := caddr u;
  55. mellin := bastab(car f,cddr f);
  56. temp := car cddddr mellin;
  57. var := cadr f;
  58. if not idp VAR then RETURN error(99,'FAIL); % something is rotten, if not...
  59. % better give up
  60. temp := reval algebraic(sub(x=var,temp));
  61. mellin := {car mellin,cadr mellin,caddr mellin,cadddr mellin,temp};
  62. temp := reduce_var(cadr u,mellin,var);
  63. alpha := simp!* car temp;
  64. new_mellin := cdr temp;
  65. if car cddddr new_mellin neq car cddddr mellin then
  66. << k := car cddddr mellin;
  67. y := reval algebraic(sub(var=y,k));
  68. new_y := simp y>>
  69. else
  70. << new_var := car cddddr new_mellin;
  71. new_y := simp reval algebraic(sub(x=y,new_var))>>;
  72. n1 := addsq(alpha,'(1 . 1));
  73. temp1 := {'expt,y,prepsq n1};
  74. temp2 := cadddr new_mellin;
  75. coeff := simp!* reval algebraic(temp1*temp2);
  76. m := caar new_mellin;
  77. n := cadar new_mellin;
  78. p := caddar new_mellin;
  79. q := car cdddar new_mellin;
  80. old_num := cadr new_mellin;
  81. old_denom := caddr new_mellin;
  82. for i:=1 :n do
  83. << if old_num = nil then a1 := append(a1,{simp!* old_num })
  84. else << a1 := append(a1,{simp!* car old_num});
  85. old_num := cdr old_num>>;
  86. >>;
  87. for j:=1 :m do
  88. << if old_denom = nil then b1 := append(b1,{simp!* old_denom })
  89. else << b1 := append(b1,{simp!* car old_denom});
  90. old_denom := cdr old_denom>>;
  91. >>;
  92. a2 := listsq old_num;
  93. b2 := listsq old_denom;
  94. if a1 = nil and a2 = nil then
  95. num := list({negsq alpha})
  96. else if a2 = nil then num := list(append(a1,{negsq alpha}))
  97. else
  98. << num := append(a1,{negsq alpha}); num := append({num},a2)>>;
  99. if b1 = nil and b2 = nil then
  100. denom := list({subtrsq(negsq alpha,'(1 . 1))})
  101. else if b2 = nil then
  102. denom := list(b1,subtrsq(negsq alpha,'(1 . 1)))
  103. else
  104. << denom := list(b1,subtrsq(negsq alpha,'(1 . 1)));
  105. denom := append(denom,b2)>>;
  106. v := gfmsq(num,denom,new_y);
  107. if v = 'fail then return simp 'fail
  108. else v := prepsq v;
  109. if eqcar(v,'meijerg) then new_v := v else new_v := simp v;
  110. return multsq(new_v,coeff);
  111. end$
  112. symbolic procedure reduce_var(u,v,var1);
  113. % Reduce Meijer G functions of powers of x to x
  114. begin scalar var,m,n,coef,alpha,beta,alpha1,alpha2,expt_flag,k,temp1,
  115. temp2,const,new_k;
  116. var := car cddddr(v);
  117. beta := 1;
  118. % If the Meijer G-function is is a function of a variable which is not
  119. % raised to a power then return initial function
  120. if length var = 0 then return u . v
  121. else
  122. << k := u; coef := cadddr v;
  123. for each i in var do
  124. << if listp i then
  125. << if car i = 'expt then
  126. << alpha := caddr i; expt_flag := 't>>
  127. else if car i = 'sqrt then
  128. << beta := 2; alpha := 1; expt_flag := 't>>
  129. else if car i = 'times then
  130. << temp1 := cadr i; temp2 := caddr i;
  131. if listp temp1 then
  132. << if car temp1 = 'sqrt then
  133. << beta := 2; alpha1 := 1; expt_flag := 't>>
  134. else if car temp1 = 'expt and listp caddr temp1 then
  135. << beta := cadr cdaddr temp1;
  136. alpha1 := car cdaddr temp1;
  137. expt_flag := 't>>;
  138. >>;
  139. if listp temp2 and car temp2 = 'expt then
  140. << alpha2 := caddr temp2; expt_flag := 't>>;
  141. if alpha1 neq 'nil then
  142. alpha := reval algebraic(alpha1 + beta*alpha2)
  143. else alpha := alpha2;
  144. >>;
  145. >>
  146. else
  147. << if i = 'expt then << alpha := caddr var; expt_flag := 't>>;
  148. >>;
  149. >>;
  150. % If the Meijer G-function is is a function of a variable which is not
  151. % raised to a power then return initial function
  152. if expt_flag = nil then return u . v
  153. % Otherwise reduce the power by using the following formula :-
  154. %
  155. % y (c*y)^(m/n)
  156. % / /
  157. % | n |
  158. % |t^k*F((c*t)^(m/n))dt = --------- |z^[((k + 1)*n - m)/m]*F(z)dz
  159. % | m*c^(k+1) |
  160. % / /
  161. % 0 0
  162. else
  163. << if listp alpha then << m := cadr alpha; n := caddr alpha;
  164. n := reval algebraic(beta*n)>>
  165. else << m := alpha; n := beta>>;
  166. const := reval algebraic(sub(var1=1,var));
  167. const := reval algebraic(1/(const^(n/m)));
  168. new_k := reval algebraic(((k + 1)*n - m)/m);
  169. coef := reval algebraic((n/m)*coef*(const)^(k+1));
  170. var := reval algebraic(var^(n/m));
  171. return {new_k,car v,cadr v, caddr v,coef,var}>>;
  172. >>;
  173. end$
  174. >>;
  175. endmodule;
  176. end;