TPS.TEX 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. \documentstyle[11pt,reduce]{article}
  2. \title{Truncated Power Series}
  3. \date{}
  4. \author{Alan Barnes \\
  5. Dept. of Computer Science and Applied Mathematics \\
  6. Aston University, Aston Triangle, \\
  7. Birmingham B4 7ET \\ GREAT BRITAIN \\
  8. Email: barnesa@aston.ac.uk \\[0.1in]
  9. and \\[0.1in]
  10. Julian Padget \\
  11. School of Mathematics, University of Bath \\
  12. Claverton Down, Bath, BA2 7AY \\
  13. GREAT BRITAIN \\
  14. Email: jap@maths.bath.ac.uk}
  15. \begin{document}
  16. \maketitle
  17. \index{power series} \index{truncated power series}
  18. \index{Barnes, Alan} \index{Padget, Julian}
  19. \section{Introduction}
  20. \index{Power series expansions}
  21. This package implements formal power series expansions in one
  22. variable using the domain mechanism of REDUCE. This means that power
  23. series objects can be added, multiplied, differentiated etc. like other
  24. first class objects in the system. A lazy evaluation scheme is used in
  25. the package and thus terms of the series are not evaluated until they
  26. are required for printing or for use in calculating terms in other
  27. power series. The series are extendible giving the user the impression
  28. that the full infinite series is being manipulated. The errors that
  29. can sometimes occur using series that are truncated at some fixed depth
  30. (for example when a term in the required series depends on terms of an
  31. intermediate series beyond the truncation depth) are thus avoided.
  32. Below we give a brief description of the operators available in the
  33. power series package together with some examples of their use.
  34. \subsection{PS Operator}
  35. Syntax:
  36. \noindent{\tt PS}(EXPRN:{\em algebraic},DEPVAR:{\em kernel},
  37. ABOUT:{\em algebraic}):{\em ps object}
  38. \index{PS operator}
  39. The {\tt PS} operator returns a power series object
  40. (a tagged domain element)
  41. representing the univariate formal power series expansion of EXPRN with
  42. respect to the dependent variable DEPVAR about the expansion point
  43. ABOUT. EXPRN may itself contain power series objects.
  44. The algebraic expression ABOUT should simplify to an expression
  45. which is independent of the dependent variable DEPVAR, otherwise
  46. an error will result. If ABOUT is the identifier {\tt INFINITY}
  47. then the power series expansion about DEPVAR = $\infty$ is
  48. obtained in ascending powers of 1/DEPVAR.
  49. \index{PSEXPLIM operator}
  50. If the command is terminated by a semi-colon, a power series object
  51. representing EXPRN is compiled and then a number of terms of the
  52. power series expansion are evaluated and printed. The expansion is
  53. carried out as far as the value specified by {\tt PSEXPLIM}. If,
  54. subsequently, the value of {\tt PSEXPLIM} is increased, sufficient
  55. information is stored in the power series object to enable the
  56. additional terms to be calculated without recalculating the terms
  57. already obtained.
  58. If the command is terminated by a dollar symbol, a power series object
  59. is compiled, but at most one term is calculated at this stage.
  60. If the function has a pole at the expansion point then the correct
  61. Laurent series expansion will be produced.
  62. \noindent The following examples are valid uses of {\tt PS}:
  63. \begin{verbatim}
  64. psexplim 6;
  65. ps(log x,x,1);
  66. ps(e**(sin x),x,0);
  67. ps(x/(1+x),x,infinity);
  68. ps(sin x/(1-cos x),x,0);
  69. \end{verbatim}
  70. \index{power series ! of user defined function}
  71. New user-defined functions may be expanded provided the user provides
  72. LET rules giving
  73. \begin{enumerate}
  74. \item the value of the function at the expansion point
  75. \item a differentiation rule for the new function.
  76. \end{enumerate}
  77. \noindent For example
  78. \begin{verbatim}
  79. operator sech;
  80. forall x let df(sech x,x)= - sech x * tanh x;
  81. let sech 0 = 1;
  82. ps(sech(x**2),x,0);
  83. \end{verbatim}
  84. \index{power series ! of integral}
  85. The power series expansion of an integral may also be obtained (even if
  86. REDUCE cannot evaluate the integral in closed form). An example of
  87. this is
  88. \begin{verbatim}
  89. ps(int(e**x/x,x),x,1);
  90. \end{verbatim}
  91. Note that if the integration variable is the same as the expansion
  92. variable then REDUCE's integration package is not called; if on the
  93. other hand the two variables are different then the integrator is
  94. called to integrate each of the coefficients in the power series
  95. expansion of the integrand. The constant of integration is zero by
  96. default.
  97. \subsection{PSEXPLIM Operator}
  98. \index{PSEXPLIM Operator}
  99. Syntax:
  100. \hspace*{2em} {\tt PSEXPLIM}(UPTO:{\em integer}):{\em integer}
  101. \hspace*{4em} or
  102. \hspace*{2em} {\tt PSEXPLIM}():{\em integer}
  103. Calling this operator sets an internal variable of the
  104. TPS package to the value of UPTO (which should evaluate to an integer).
  105. The value returned is the previous value of this variable.
  106. The default value is six.
  107. If {\tt PSEXPLIM} is called with no argument, the current value for
  108. the expansion limit is returned.
  109. \subsection{PSORDLIM Operator}
  110. \index{PSORDLIM operator}
  111. Syntax:
  112. \hspace*{2em} {\tt PSORDLIM}(UPTO:{\em integer}):{\em integer}
  113. \hspace*{4em} or
  114. \hspace*{2em} {\tt PSORDLIM}():{\em integer}
  115. An internal variable is set to the value of {\tt UPTO} (which should
  116. evaluate to an integer). The value returned is the previous value of
  117. the variable. The default value is 15.
  118. If {\tt PSORDLIM} is called with no argument, the current value is
  119. returned.
  120. The significance of this control is that the system attempts to find
  121. the order of the power series required, that is the order is the
  122. degree of the first non-zero term in the power series. If the order
  123. is greater than the value of this variable an error message is given
  124. and the computation aborts. This prevents infinite loops in examples
  125. such as
  126. \begin{verbatim}
  127. ps(1 - (sin x)**2 - (cos x)**2,x,0);
  128. \end{verbatim}
  129. where the expression being expanded is identically zero, but is not
  130. recognized as such by REDUCE.
  131. \subsection{PSTERM Operator}
  132. \index{PSTERM operator}
  133. Syntax:
  134. \hspace*{2em} {\tt PSTERM}(TPS:{\em power series object},
  135. NTH:{\em integer}):{\em algebraic}
  136. The operator {\tt PSTERM} returns the NTH term of the existing
  137. power series object TPS. If NTH does not evaluate to
  138. an integer or TPS to a power series object an error results. It
  139. should be noted that an integer is treated as a power series.
  140. \subsection{PSORDER Operator}
  141. \index{PSORDER operator}
  142. Syntax:
  143. \hspace*{2em} {\tt PSORDER}(TPS:{\em power series object}):{\em integer}
  144. The operator {\tt PSORDER} returns the order, that is the degree of
  145. the first non-zero term, of the power series object TPS.
  146. TPS should evaluate to a power series object or an error results. If
  147. TPS is zero, the identifier {\tt UNDEFINED} is returned.
  148. \subsection{PSSETORDER Operator}
  149. \index{PSSETORDER operator}
  150. Syntax:
  151. \hspace*{2em} {\tt PSSETORDER}(TPS:{\em power series object},
  152. ORD:{\em integer}):{\em integer}
  153. The operator {\tt PSSETORDER} sets the order of the power series
  154. TPS to the value ORD, which should evaluate to an integer. If
  155. TPS does not evaluate to a power series object, then an error
  156. occurs. The value returned by this operator is the previous order of
  157. TPS, or 0 if the order of TPS was undefined. This
  158. operator is useful for setting the order of the power series of a
  159. function defined by a differential equation in cases where the power
  160. series package is inadequate to determine the order automatically.
  161. \subsection{PSDEPVAR Operator}
  162. \index{PSDEPVAR operator}
  163. Syntax:
  164. \hspace*{2em} {\tt PSDEPVAR}(TPS:{\em power series object})
  165. :{\em identifier}
  166. The operator {\tt PSDEPVAR} returns the expansion variable of the
  167. power series object TPS. TPS should evaluate to a power
  168. series object or an integer, otherwise an error results. If TPS
  169. is an integer, the identifier {\tt UNDEFINED} is returned.
  170. \subsection{PSEXPANSIONPT operator}
  171. \index{PSEXPANSIONPT operator}
  172. Syntax:
  173. \hspace*{2em}
  174. {\tt PSEXPANSIONPT}(TPS:{\em power series object}):{\em algebraic}
  175. The operator {\tt PSEXPANSIONPT} returns the expansion point of the
  176. power series object TPS. TPS should evaluate to a power
  177. series object or an integer, otherwise an error results. If TPS
  178. is integer, the identifier {\tt UNDEFINED} is returned. If the
  179. expansion is about infinity, the identifier {\tt INFINITY} is
  180. returned.
  181. \subsection{PSFUNCTION Operator}
  182. \index{PSFUNCTION operator}
  183. Syntax:
  184. \hspace*{2em}
  185. {\tt PSFUNCTION}(TPS:{\em power series object}):{\em algebraic}
  186. The operator {\tt PSFUNCTION} returns the function whose expansion
  187. gave rise to the power series object TPS. TPS should
  188. evaluate to a power series object or an integer, otherwise an error
  189. results.
  190. \subsection{PSCHANGEVAR Operator}
  191. \index{PSCHANGEVAR operator}
  192. Syntax:
  193. \hspace*{2em} {\tt PSCHANGEVAR}(TPS:{\em power series object},
  194. X:{\em kernel}):{\em power series object}
  195. The operator {\tt PSCHANGEVAR} changes the dependent variable of the
  196. power series object TPS to the variable X. TPS
  197. should evaluate to a power series object and X to a kernel,
  198. otherwise an error results. Also X should not appear as a
  199. parameter in TPS. The power series with the new dependent
  200. variable is returned.
  201. \subsection{PSREVERSE Operator}
  202. \index{PSREVERSE operator}
  203. Syntax:
  204. \hspace*{2em}
  205. {\tt PSREVERSE}(TPS:{\em power series object}):{\em power series}
  206. Power series reversion. The power series TPS is functionally
  207. inverted. Four cases arise:
  208. \begin{enumerate}
  209. \item If the order of the series is 1, then the expansion point of the
  210. inverted series is 0.
  211. \item If the order is 0 {\em and} if the first order term in TPS
  212. is non-zero, then the expansion point of the inverted series is taken
  213. to be the coefficient of the zeroth order term in TPS.
  214. \item If the order is -1 the expansion point of the inverted series
  215. is the point at infinity. In all other cases a REDUCE error is
  216. reported because the series cannot be inverted as a power series.
  217. Puiseux \index{Puiseux expansion} expansion would be required to
  218. handle these cases.
  219. \item If the expansion point of TPS is finite it becomes the
  220. zeroth order term in the inverted series. For expansion about 0 or the
  221. point at infinity the order of the inverted series is one.
  222. \end{enumerate}
  223. If TPS is not a power series object after evaluation an error results.
  224. \noindent Here are some examples:
  225. \begin{verbatim}
  226. ps(sin x,x,0);
  227. psreverse(ws); % produces series for asin x about x=0.
  228. ps(exp x,x,0);
  229. psreverse ws; % produces series for log x about x=1.
  230. ps(sin(1/x),x,infinity);
  231. psreverse(ws); % produces series for 1/asin(x) about x=0.
  232. \end{verbatim}
  233. \subsection{PSCOMPOSE Operator}
  234. \index{PSCOMPOSE operator}
  235. Syntax:
  236. \hspace*{2em} {\tt PSCOMPOSE}(TPS1:{\em power series},
  237. TPS2:{\em power series}):{\em power series}
  238. \index{power series ! composition}
  239. {\tt PSCOMPOSE} performs power series composition.
  240. The power series TPS1 and TPS2 are functionally composed.
  241. That is to say that TPS2 is substituted for the expansion
  242. variable in TPS1 and the result expressed as a power series. The
  243. dependent variable and expansion point of the result coincide with
  244. those of TPS2. The following conditions apply to power series
  245. composition:
  246. \begin{enumerate}
  247. \item If the expansion point of TPS1 is 0 then the order of the
  248. TPS2 must be at least 1.
  249. \item If the expansion point of TPS1 is finite, it should
  250. coincide with the coefficient of the zeroth order term in TPS2.
  251. The order of TPS2 should also be non-negative in this case.
  252. \item If the expansion point of TPS1 is the point at infinity
  253. then the order of TPS2 must be less than or equal to -1.
  254. \end{enumerate}
  255. If these conditions do not hold the series cannot be composed (with
  256. the current algorithm terms of the inverted series would involve
  257. infinite sums) and a REDUCE error occurs.
  258. \noindent Examples of power series composition include the following.
  259. \begin{verbatim}
  260. a:=ps(exp y,y,0); b:=ps(sin x,x,0);
  261. pscompose(a,b);
  262. % Produces the power series expansion of exp(sin x)
  263. % about x=0.
  264. a:=ps(exp z,z,1); b:=ps(cos x,x,0);
  265. pscompose(a,b);
  266. % Produces the power series expansion of exp(cos x)
  267. % about x=0.
  268. a:=ps(cos(1/x),x,infinity); b:=ps(1/sin x,x,0);
  269. pscompose(a,b);
  270. % Produces the power series expansion of cos(sin x)
  271. % about x=0.
  272. \end{verbatim}
  273. \subsection{PSSUM Operator}
  274. \index{PSSUM operator}
  275. Syntax:
  276. \begin{tabbing}
  277. \hspace*{2em} {\tt PSSUM}(\=J:{\em kernel} = LOWLIM:{\em integer},
  278. COEFF:{\em algebraic}, X:{\em kernel}, \\
  279. \> ABOUT:{\em algebraic}, POWER:{\em algebraic}):{\em power series}
  280. \end{tabbing}
  281. The formal power series sum for J from LOWLIM to {\tt INFINITY} of
  282. \begin{verbatim}
  283. COEFF*(X-ABOUT)**POWER
  284. \end{verbatim}
  285. or if ABOUT is given as {\tt INFINITY}
  286. \begin{verbatim}
  287. COEFF*(1/X)**POWER
  288. \end{verbatim}
  289. is constructed and returned. This enables power series whose general
  290. term is known to be constructed and manipulated using the other
  291. procedures of the power series package.
  292. J and X should be distinct simple kernels. The algebraics
  293. ABOUT, COEFF and POWER should not depend on the
  294. expansion variable X, similarly the algebraic ABOUT should
  295. not depend on the summation variable J. The algebraic POWER should be
  296. a strictly increasing integer valued function of J for J in the range
  297. LOWLIM to {\tt INFINITY}.
  298. \begin{verbatim}
  299. pssum(n=0,1,x,0,n*n);
  300. % Produces the power series summation for n=0 to
  301. % infinity of x**(n*n).
  302. pssum(m=1,(-1)**(m-1)/(2m-1),y,1,2m-1);
  303. % Produces the power series expansion of atan(y-1)
  304. % about y=1.
  305. pssum(j=1,-1/j,x,infinity,j);
  306. % Produces the power series expansion of log(1-1/x)
  307. % about the point at infinity.
  308. pssum(n=0,1,x,0,2n**2+3n) + pssum(n=1,1,x,0,2n**2-3n);
  309. % Produces the power series summation for n=-infinity
  310. % to +infinity of x**(2n**2+3n).
  311. \end{verbatim}
  312. \subsection{PSCOPY Operator}
  313. \index{PSCOPY operator}
  314. Syntax:
  315. \hspace*{2em} {\tt PSCOPY}(TPS:{\em power series}):{\em power series}
  316. This procedure returns a copy of the power series {\tt TPS}. The copy
  317. has no shared sub-structures in common with the original series. This
  318. enables substitutions to be performed on the series without
  319. side-effects on previously computed objects. For example:
  320. \begin{verbatim}
  321. clear a;
  322. b := ps(sin(a*x)), x, 0);
  323. b where a => 1;
  324. \end{verbatim}
  325. will result in {\tt a} being set to 1 in each of the terms of the
  326. power series and the resulting expressions being simplified. Owing to
  327. the way power series objects are implemented using Lisp vectors, this
  328. has the side-effect that the value of {\tt b} is changed. This may be
  329. avoided by copying the series with {\tt PSCOPY} before applying the
  330. substitution, thus:
  331. \begin{verbatim}
  332. b := ps(sin(a*x)), x, 0);
  333. pscopy b where a => 1;
  334. \end{verbatim}
  335. \subsection{Arithmetic Operations}
  336. \index{power series ! arithmetic}
  337. As power series objects are domain elements they may be combined
  338. together in algebraic expressions in algebraic mode of REDUCE in the
  339. normal way.
  340. For example if A and B are power series objects then the commands
  341. such as:
  342. \index{+ ! power series} \index{- ! power series}
  343. \index{/ ! power series} \index{* ! power series}
  344. \index{** ! power series}
  345. \begin{verbatim}
  346. a*b;
  347. a/b;
  348. a**2+b**2;
  349. \end{verbatim}
  350. will produce power series objects representing the product,quotient
  351. and the sum of the squares of the power series objects A and B
  352. respectively.
  353. \subsection{Differentiation}
  354. \index{power series ! differentiation}
  355. If A is a power series object depending on X then the input
  356. {\tt df(a, x);} will produce the power series expansion of the
  357. derivative of A with respect to X.
  358. {\em Note} however that currently the input {\tt int(a, x);} will
  359. not work as intended; instead one must input
  360. {\tt ps(int(a, x),x,0);}
  361. in order to obtain the power series expansion of the integral of
  362. {\tt a}.
  363. \section{Restrictions and Known Bugs}
  364. If A is a power series object and X is a variable
  365. which evaluates to itself then currently expressions such as {\tt a*x}
  366. do not evaluate to a single power series object (although the
  367. result is formally valid). Instead use {\tt ps(a*x,x,0)} {\em etc.}.
  368. Similarly expressions such as {\tt sin(A)} where {\tt A} is a PS object
  369. currently will not be expanded. For example:
  370. \begin{verbatim}
  371. a:=ps(1/(1+x),x,0);
  372. b:=sin a;
  373. \end{verbatim}
  374. will not expand {\tt sin(1/(1+x))} as a power series. In fact
  375. \begin{verbatim}
  376. SIN(1 - X + X**2 - X**3 + .....)
  377. \end{verbatim}
  378. will be returned. However,
  379. \begin{verbatim}
  380. b:=ps(sin(a),x,0);
  381. \end{verbatim}
  382. or
  383. \begin{verbatim}
  384. b:=ps(sin(1/(1+x)),x,0);
  385. \end{verbatim}
  386. should work as intended.
  387. The handling of functions with essential singularities is currently
  388. erratic: usually an error message
  389. \hspace*{2em} {\tt ***** Essential Singularity}
  390. or
  391. \hspace*{2em} {\tt ***** Logarithmic Singularity}
  392. occurs but occasionally a division by
  393. zero error or some drastic error like (for PSL) binding stack
  394. overflow may occur.
  395. Mixed mode arithmetic of power series objects with other domain
  396. elements is quite restricted: only integers and floats can currently
  397. be converted to power series objects.
  398. The printing of power series currently leaves something to be
  399. desired: often line-breaks appear in the middle of terms.
  400. There is no simple way to write the results of power series
  401. calculation to a file and read them back into REDUCE at a later
  402. stage.
  403. \end{document}