tpsfns.red 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. module tpsfns;
  2. % Expansion of elementary functions as power series using DOMAINVALCHK
  3. % Example sin a where a is a power series will now be expanded
  4. %
  5. % Author: Alan Barnes, March 1989
  6. % Currently only ps!:expt!: ever gets called and that only for
  7. % integer exponents
  8. fluid '(!*numval);
  9. put('exp, '!:ps!:, 'ps!:exp!:);
  10. put('log, '!:ps!:, 'ps!:log!:);
  11. put('sin, '!:ps!:, 'ps!:sin!:);
  12. put('cos, '!:ps!:, 'ps!:cos!:);
  13. put('tan, '!:ps!:, 'ps!:tan!:);
  14. put('asin, '!:ps!:, 'ps!:asin!:);
  15. put('acos, '!:ps!:, 'ps!:acos!:);
  16. put('atan, '!:ps!:, 'ps!:atan!:);
  17. put('sinh, '!:ps!:, 'ps!:sinh!:);
  18. put('cosh, '!:ps!:, 'ps!:cosh!:);
  19. put('tanh, '!:ps!:, 'ps!:tanh!:);
  20. put('asinh, '!:ps!:, 'ps!:asinh!:);
  21. put('acosh, '!:ps!:, 'ps!:acosh!:);
  22. put('atanh, '!:ps!:, 'ps!:atanh!:);
  23. put('expt, '!:ps!:, 'ps!:expt!:);
  24. % the above is grotty but necessary as unfortunately DOMAINVALCHK
  25. % passes arglist of sin (rather than sin . arglist) to ps!:sin!: etc
  26. symbolic procedure ps!:expt!:(base,exp);
  27. % currently this only gets called when exp is an integer
  28. % but it should work in general
  29. begin scalar depvar,about, knownps, ps!:level;
  30. % begin scalar !*numval, depvar,about, knownps;
  31. % NB binding of !*numval avoids infinite loop. Not necessary now -- AB?
  32. ps!:level := 0;
  33. about:= ps!:expansion!-point base;
  34. if null about then <<
  35. about:= ps!:expansion!-point exp;
  36. depvar:=ps!:depvar exp>>
  37. else depvar:=ps!:depvar base;
  38. return
  39. if null about then % we have two constant power series
  40. << if ps!:p base then base := ps!:value base;
  41. if ps!:p exp then exp := ps!:value exp;
  42. about := simp!* list('expt, base, exp);
  43. make!-constantps (about, prepsqxx about, depvar) >>
  44. else
  45. ps!:expt!-crule(list('expt, base,exp),depvar,about)
  46. end;
  47. symbolic procedure ps!:unary!:fn(fn, arg);
  48. begin scalar !*numval, knownps, ps!:level;
  49. % NB binding of !*numval avoids infinite loop
  50. ps!:level := 0;
  51. return ps!:compile(list(fn, arg),
  52. ps!:depvar arg,
  53. ps!:expansion!-point arg)
  54. end;
  55. symbolic procedure ps!:cos!: arg;
  56. ps!:unary!:fn('cos,arg);
  57. symbolic procedure ps!:sin!: arg;
  58. ps!:unary!:fn('sin,arg);
  59. symbolic procedure ps!:tan!: arg;
  60. ps!:unary!:fn('tan,arg);
  61. symbolic procedure ps!:log!: arg;
  62. ps!:unary!:fn('log,arg);
  63. symbolic procedure ps!:exp!: arg;
  64. ps!:unary!:fn('exp,arg);
  65. symbolic procedure ps!:cosh!: arg;
  66. ps!:unary!:fn('cosh,arg);
  67. symbolic procedure ps!:sinh!: arg;
  68. ps!:unary!:fn('sinh,arg);
  69. symbolic procedure ps!:tanh!: arg;
  70. ps!:unary!:fn('tanh,arg);
  71. symbolic procedure ps!:asin!: arg;
  72. ps!:unary!:fn('asin,arg);
  73. symbolic procedure ps!:acos!: arg;
  74. ps!:unary!:fn('acos,arg);
  75. symbolic procedure ps!:atan!: arg;
  76. ps!:unary!:fn('atan,arg);
  77. symbolic procedure ps!:asinh!: arg;
  78. ps!:unary!:fn('asinh,arg);
  79. symbolic procedure ps!:acosh!: arg;
  80. ps!:unary!:fn('acosh,arg);
  81. symbolic procedure ps!:atanh!: arg;
  82. ps!:unary!:fn('atanh,arg);
  83. endmodule;
  84. end;