specfn.red 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. module specfn; % Special functions package for REDUCE.
  2. % Author: Chris Cannam, Sept-Nov 1992.
  3. % Winfried Neun, Nov 1992 ...
  4. % contribution from various authors ...
  5. % |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| %
  6. % %
  7. % Please report bugs to Winfried Neun, %
  8. % Konrad-Zuse-Zentrum %
  9. % fuer Informationstechnik Berlin, %
  10. % Heilbronner Str. 10 %
  11. % 10711 Berlin - Wilmersdorf %
  12. % Federal Republic of Germany %
  13. % or by email, neun@sc.ZIB-Berlin.de %
  14. % %
  15. % |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| %
  16. % %
  17. % This package provides algebraic and numeric %
  18. % manipulations upon various special functions: %
  19. % %
  20. % -- Bernoulli Numbers %
  21. % -- Gamma Function %
  22. % -- Pochhammer Notation %
  23. % -- Digamma (Psi) Function and Derivatives %
  24. % -- Riemann Zeta Function %
  25. % -- Bessel Functions J, Y, I and K %
  26. % -- Airy Functions %
  27. % -- Hankel Functions H1 and H2 %
  28. % -- Kummer Hypergeometric Functions M and U %
  29. % -- Struve, Lommel and Whittaker Functions %
  30. % -- Integral funtions, Si, Ci, s_i (=si), Ei,... %
  31. % -- Simplification of Factorials %
  32. % -- Solid and Spherical Harmonics %
  33. % -- Jacobi Elliptic Functions %
  34. % -- Elliptic Integrals %
  35. % %
  36. % accessible through the new operators Bernoulli, Gamma, %
  37. % Pochhammer, Psi, Polygamma, Zeta, BesselJ, BesselY, %
  38. % BesselI, BesselK, Hankel1, Hankel2, KummerM, KummerU, %
  39. % AiryAi, AiryBi, AiryAiPrime, AiryBiPrime, %
  40. % Elliptic{sn,cn,dn...}, Elliptic{E,F,K...}
  41. % Beta, StruveL, StruveH, Lommel1, Lommel2, WhittakerM %
  42. % and WhittakerW, with the new switch SaveSFs. %
  43. % %
  44. % |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| %
  45. create!-package ('(specfn sfconsts sfgen sfbern dilog sfbinom sfpolys
  46. sfsums simpfact harmonic jsymbols recsimpl sfellip
  47. sfellipi sfint),
  48. '(contrib specfn));
  49. exports sq2bf!*, c!:prec!:;
  50. switch savesfs;
  51. on savesfs;
  52. symbolic smacro procedure mksqnew u;
  53. !*p2f(car fkern(u) .* 1) ./ 1;
  54. symbolic fluid '(bernoulli!-alist new!*bfs bf!*base sf!-alist !*savefs);
  55. symbolic ( bernoulli!-alist := nil );
  56. symbolic ( sf!-alist := nil );
  57. symbolic ( new!*bfs := fluidp '!:bprec!: );
  58. symbolic ( bf!*base := (if new!*bfs then 2 else 10) );
  59. symbolic ( if not globalp 'log2of10 then
  60. << global '(log2of10); log2of10 := 3.32193 >> );
  61. symbolic smacro procedure sq2bf!*(x);
  62. (if fixp x then i2bf!: x
  63. else ((if car y neq '!:rd!: then retag cdr !*rn2rd y
  64. else retag cdr y) where y = !*a2f x));
  65. symbolic smacro procedure c!:prec!:;
  66. (if new!*bfs then lispeval '!:bprec!: else !:prec!:);
  67. % These functions are needed in other modules.
  68. algebraic procedure complex!*on!*switch;
  69. if not symbolic !*complex then
  70. if symbolic !*msg then
  71. << off msg;
  72. on complex;
  73. on msg >>
  74. else on complex
  75. else t;
  76. algebraic procedure complex!*off!*switch;
  77. if symbolic !*complex then
  78. if symbolic !*msg then
  79. << off msg; off complex; on msg >>
  80. else off complex
  81. else t;
  82. algebraic procedure complex!*restore!*switch(fl);
  83. if not fl then
  84. if symbolic !*msg then
  85. << off msg;
  86. if symbolic !*complex then
  87. off complex
  88. else on complex;
  89. on msg >>
  90. else if symbolic !*complex then
  91. off complex
  92. else on complex;
  93. %algebraic operator besselJ,besselY,besselI,besselK,hankel1,hankel2;
  94. %algebraic (operator kummerM, kummerU, struveh, struvel
  95. % ,lommel1, lommel2 ,whittakerm, whittakerw,
  96. % Airy_Ai, Airy_Bi,Airy_AiPrime,Airy_biprime);
  97. defautoload_operator(besselj,specbess);
  98. defautoload_operator(bessely,specbess);
  99. defautoload_operator(besseli,specbess);
  100. defautoload_operator(besselk,specbess);
  101. defautoload_operator(hankel1,specbess);
  102. defautoload_operator(hankel2,specbess);
  103. defautoload_operator(kummerM,specbess);
  104. defautoload_operator(kummerU,specbess);
  105. defautoload_operator(struveh,specbess);
  106. defautoload_operator(struvel,specbess);
  107. defautoload_operator(lommel1,specbess);
  108. defautoload_operator(lommel2,specbess);
  109. defautoload_operator(whittakerm,specbess);
  110. defautoload_operator(whittakerw,specbess);
  111. defautoload_operator(Airy_Ai,specbess);
  112. defautoload_operator(Airy_Bi,specbess);
  113. defautoload_operator(Airy_AiPrime,specbess);
  114. defautoload_operator(Airy_biprime,specbess);
  115. defautoload_operator(gamma,sfgamma);
  116. defautoload_operator(igamma,sfgamma);
  117. defautoload_operator(polygamma,sfgamma);
  118. defautoload_operator(psi,sfgamma);
  119. defautoload_operator(ibeta,sfgamma);
  120. defautoload_operator(beta,sfgamma);
  121. defautoload_operator(pochhammer,sfgamma);
  122. defautoload_operator(zeta,sfgamma);
  123. endmodule;
  124. end;