residue.red 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. module residue; % Calculation of residues
  2. % Author: Wolfram Koepf
  3. % Version 1.0, April 1995
  4. % needs taylor package for execution.
  5. remflag('(load_package),'eval);
  6. load_package taylor;
  7. create!-package('(residue),'(contrib misc));
  8. fluid '(!*taylor!-max!-precision!-cycles!*);
  9. % enlarging recursion depth
  10. symbolic(!*taylor!-max!-precision!-cycles!* := 20);
  11. % polynomials and rational functions
  12. % by Winfried Neun
  13. symbolic procedure PolynomQQQ (x);
  14. (if fixp xx then 1 else
  15. if not onep denr (xx := cadr xx) then NIL
  16. else begin scalar kerns,kern,aa,var,fform,mvv,degg;
  17. fform := sfp mvar numr xx;
  18. var := reval cadr x;
  19. if fform then << xx := numr xx;
  20. while (xx neq 1) do
  21. << mvv := mvar xx;
  22. degg := ldeg xx;
  23. xx := lc xx;
  24. if domainp mvv then <<if not freeof(mvv,var) then
  25. << xx := 1 ; kerns := list list('sin,var) >> >> else
  26. kerns := append ( append (kernels mvv,kernels degg),kerns) >> >>
  27. else kerns := kernels !*q2f xx;
  28. aa: if null kerns then return 1;
  29. kern := first kerns;
  30. kerns := cdr kerns;
  31. if not(eq (kern, var)) and depends(kern,var)
  32. then return NIL else go aa;
  33. end) where xx = aeval(car x);
  34. put('PolynomQQ,'psopfn,'polynomQQQ);
  35. symbolic procedure ttttype_ratpoly(u);
  36. ( if fixp xx then 1 else
  37. if not eqcar (xx , '!*sq) then nil
  38. else polynomQQQ(list(mk!*sq(numr cadr xx ./ 1),reval cadr u))
  39. and polynomQQQ(list(mk!*sq(denr cadr xx ./ 1),reval cadr u))
  40. ) where xx = aeval(car u);
  41. flag ('(type_ratpoly),'boolean);
  42. put('type_ratpoly,'psopfn,'ttttype_ratpoly);
  43. symbolic procedure type_ratpoly(f,z);
  44. ttttype_ratpoly list(f,z);
  45. % Calculation of residues,
  46. % by Wolfram Koepf
  47. algebraic procedure residue(f,x,a);
  48. begin
  49. scalar tmp,numerator,denominator,numcof,dencof;
  50. if not freeof(f,factorial) then rederr("not yet implemented");
  51. if not freeof(f,gamma) then rederr("not yet implemented");
  52. if not freeof(f,binomial) then rederr("not yet implemented");
  53. if not freeof(f,pochhammer) then rederr("not yet implemented");
  54. tmp:=taylortostandard(taylor(f,x,a,0));
  55. if a=infinity then tmp:=-sub(x=1/x,tmp);
  56. if PolynomQQ(tmp,x) then return(0);
  57. if part(tmp,0)=taylor then rederr("taylor fails");
  58. if not type_ratpoly(tmp,x) then return(nil);
  59. tmp:=sub(x=x+a,tmp);
  60. numerator:=num(tmp);
  61. denominator:=den(tmp);
  62. if numerator=0 or deg(denominator,x)<1 then return(0) else
  63. <<
  64. numcof:=coeffn(numerator,x,deg(denominator,x)-1);
  65. if numcof=0 then return(0);
  66. if freeof(denominator,x) then dencof:=denominator
  67. else dencof:=lcof(denominator,x);
  68. return(numcof/dencof);>>
  69. end$
  70. % Calculation of the pole order of a meromorphic function,
  71. % by Wolfram Koepf
  72. algebraic procedure poleorder(f,x,a);
  73. begin
  74. scalar tmp,denominator;
  75. if not freeof(f,factorial) then rederr("not yet implemented");
  76. if not freeof(f,gamma) then rederr("not yet implemented");
  77. if not freeof(f,binomial) then rederr("not yet implemented");
  78. if not freeof(f,pochhammer) then rederr("not yet implemented");
  79. tmp:=taylortostandard(taylor(f,x,a,0));
  80. if a=infinity then tmp:=-sub(x=1/x,tmp);
  81. if PolynomQQ(tmp,x) then return(0);
  82. denominator:=den(tmp);
  83. return(deg(denominator,x));
  84. end$
  85. endmodule;
  86. end;