\input /usr3/local/lib/tex82/manmac
\input mymacs
\tenpoint
\pageno=800
\def\rhead{Experimental Pages for The Macsyma Manual}
\def\chapno{ 4}
\beginchapter Chapter 4. Using Macsyma
\medbreak
first sections of chapter 4 omitted
\medbreak
\subsection Poisson Series Functions.
Special efficient representations have been vital for success in certain types
of computations. Calculations in the field of Celestial Mechanics have used a
representation known as {\it Poisson series}.
The space and time efficiency of Poisson series can be helpful in a variety
of other domains where the calculations involve
the approximate solution of differential equations
similar to those describing the perturbed motion of planets.
% abbreviate pi and qi
\def\pi{$p_i$}
\def\qi{$q_i$}
A Poisson series is a finite sum: $\sum_{i}$ \pi~$trig_{i}$(\qi) where $trig$ is either sin or cos. The form
\pi\ is some non-trigonometric expression. The argument \qi\ of the typical
trigonometric function has a specific form described below which is sufficiently
general to support a useful calculus of operations and which allows the compute
r to maintain an efficient canonical simplified form for all results. The \pi can
be represented as general \ma\ expressions, or, for special problems, they
can be encoded more efficiently, as described near the end of this section.
The argument \qi\ is a sum of integer multiples of a fixed, pre-determined set of
angle-variables. The default is the set of 6 identifiers $\{$ |u,v,w x,y,z|$\}$.
This set may be changed by assigning an alternative list of identifiers to the macsyma
symbol |poisvars|. For example |poisvars:[r,s,t]$| establishes the set of angle variables $\{$|r,s,t|$\}$.
In general, these angle variables must not occur in the coefficients, \pi .
In order to provide for an efficient representation,
you must have an {\it a priori} bound on the magnitude of the numerical coefficients in the \qi\
during the computation. This is not a problem since
in typical applications because you can usually anticipate
the maximum frequencies of the trigonometric terms of interest.
All these coefficients will be
packaged into a fixed-length vector, an integer, for efficient processing.
What
this means to the user is that if $ \cos ( a_{u}u +a_{v}v + \cdots + a_{z} z)$
occurs, then $ \vert a_{k} \vert $ must
not exceed a pre-agreed-upon limit. The \ma\ variable |poislim| controls this
limit.
It has a default value of 5 (providing 5 bits of information or a coefficient range of -15 to 15) if there are the default 6 angle variables in use. That
is, in the default case, $\sin 15 x$ can be represented, but $ \sin 17 x $ cannot.
Ordinarily, the number of variables in |poisvars| times |poislim| should be kept
under 30 if computation time and space is of concern.
If fewer variables are used in |poisvars|, then |poislim| will be set higher, since all bit fields of from 10 to 30 bits are equally (in)expensive.
\fd1 intopois(e) returns the Poisson series form of a general \ma\ expression \a1 .
Since it is not necessarily apparent to you that an expression or a part of it is
in Poisson form, the display program uses the notation |/P/| just to the right of
the line label in displaying the
result of \thisfn\ or any result which includes a Poisson series.
\fd1 poissimp(e) returns a general \ma\ expression equivalent to the expression
\a1 , but which has been transformed into a Poisson series and then back.
In general it will have the effect of transforming the expression into a sum of trigonometric terms.
The expression \a1\ may be in \ma's general representation, or
it may be an expression which has Poisson series components. For example, \a1
might be a product of two previously computed Poisson series, |g*h|, or a sum
|g+h|,
or an integer power of a series |g^3|, etc. This function is in effect a fast ca
nonical simplification algorithm, and also can be used to change a Poisson serie
s into general \ma\ form.
\fd1 printpois(p) prints a (potentially very long) Poisson series in a readable
format.
In common with |poissimp|, it will convert \a1\ into a Poisson encoding first if
necessary. It returns the value |done|.
\fd1 poistrim() is a reserved function name. If you define a function of this name, it
gets applied during Poisson multiplication. |Poistrim| is a function of n argum
ents where n is the length of the poisvars list (default 6). These arguments ar
e the coefficients of the variables on poisvars in a term. Terms for which pois
trim returns true are eliminated during multiplication. This function can be use
d to retain only those terms whose angular frequency is of interest. This is ill
ustrated in the example below.
\fd2 diff(a,b) returns the derivative of the Poisson series a with respect to the in
determinate b. B must occur only in the trigonometric arguments (i.e. is on the
list poisvars) or only in the coefficients. Note that the usual diff command is
used, and that this specialized efficient differentiation takes place only
if the first argument is a Poisson series.
\fd2 integrate(a,b) returns the integral of the Poisson series \a1\ with respect to \a2\.
The variable of integration must appear only in the trigonometric arguments (i.e
.
\a2\ is on the list |poisvars|) or only in the coefficients, not in both. Note that
the usual \thisfn\ command is used, and that this specialized efficient
integration takes place only if the first argument is a Poisson series.
%should be fd3
\fd1 poissubst(a,b,c) returns a Poisson series which substitutes a for b in the Poisson series c.
Two cases are considered. (1) Where b is in poisvars, say x, the
n a must be an expression linear in poisvars variables (e.g.6*u+4*v). (2) Where
b is other than those variables, then a must also be free of those variables, a
nd furthermore, free of sines or cosines.
poissubst(a,b,c,d,n) is a special type of substitution. It computes the expans
ion of substituting a+d for b in the Poisson series c. The idea is that d is a
small parameter, not a Poisson variable. Poissubst expands cos(d) and sin(d) to
order n so as to provide a result in the right form. This functionality is ver
y useful in certain calculations, although rather mysterious if you have no use
for it. It is illustrated in the example below.
poismap(series,sinfn,cosfn) will map the function sinfn on the sine terms and cos
fn on the cosine terms of the Poisson series given, and return a new Poisson ser
ies with the transformed terms. sinfn and cosfn are functions of two arguments
which are a coefficient and a trigonometric part of a term in series respectivel
y. If a term in the series is a*sin(3*x+4*y), then the value of sinfn(a,3*x+4*
y) will be the coefficient of sin(3*x+4*y) in the answer. If we define f(p,q):=
ratsimp(p), then poismap(s,f,f) would return a new series equivalent to s, but
where each coefficient is rationally simplified.
This example illustrates many of the Poisson series facilities.
{\hsize=6in
\begintt
(c1) trial:a*cos(x+2*y)-a*sin(u-4*x);
(d1) a cos(2 y + x) + a sin(4 x - u)
(c2) intopois(trial^2);
rat/pois2.o being loaded.
[fasl rat/pois2.o]
Maximum poisson coefficient is +-15
for each of the variables in [u, v, w, x, y, z]
2
a cos(4 y + 2 x) 2 2
(d2)/P/ ----------------- + a sin(2 y + 5 x - u) - a sin(2 y - 3 x + u)
2
2
a cos(8 x - 2 u) 2
- ----------------- + a
2
(c3) integrate(trial,y);
a sin(2 y + x)
(d3)/P/ --------------
2
\endtt
\begintt
(c4) printpois(sin(x)^5);
5/8 sin(x)
- 5/16 sin(3 x)
1/16 sin(5 x)
(d4) done
(c5) /* poistrim is called with 6 arguments (the coefs of u ... z)
and mapped over the terms during multiplication. This
definition serves to discard terms when x's coefficient exceeds 3.*/
poistrim(uc,vc,wc,xc,yc,zc):= is(xc>3) $
(c6) intopois(sin(x)^5);
5 sin(x) sin(3 x)
(d6)/P/ -------- - --------
8 4
\endtt\begintt
(c7) /* This command substitutes u+e for v in the Poisson Series
cos(v). The indeterminate e is not permitted in the argument
of a trignometric form, so cos(u+e) is expanded as
cos(e) cos(u) - sin(e) sin(u), and then the cos(e) and sin(e)
terms are re-expressed as Taylor series, as shown below.*/
(powerdisp:true, /*display power series in right order*/
poissubst(u,v,cos(v),e,3));
2 3
e e
(d7)/P/ (1 - --) cos(u) + (- e + --) sin(u)
2 6
\endtt}% end of 6in hsize
Remember that coefficients in the arguments of the trigonometric functions fit
in a pre-arranged domain. If you change this domain by changing either poisvars
or poislim, all pre-existing Poisson series will be invalid.
If you are particularly concerned with efficiency,
it is possible to define the
Poisson series coefficient arithmetic to be something other than normal \ma\ general form.
You must define the programs needed to add, multiply, substitute, differentiate, encode and decode the coefficients. You must also supply the encoding for constant expressions which represent +1 and -1 and a program to t
est for 0 (zero). Packages which may be useful include those where coefficien
ts are in CRE form, polynomials with floating point coefficients, or polynomials with rational number coefficients.
A model for these is given in the Lisp source file |rat/pois2.l| which defines the whole Poisson series system and treats
coefficents as the default general macsyma form. The ambitious programmer might
look at the alternatives of using CRE form provided in the files "rat/ratpoi.l
" and "rat/nratpoi.l."
For further information on the techniques used in macsyma for Poisson series c
alculations
%should use some citation mechanism
see "On the Multiplication of Poisson Series," by R. Fateman,
{\it Celestial Mechanics}, v. 10, no 2, (Oct. 1974), pages 243-247.
\bigskip
\copyright 1986, Richard J. Fateman
\endchapter
\bye