<<

A M.ACSYikA Package for the Generation and ivlanipulation of Chebyshev Series (Extended Abstract)

Theodore H. Einwohner Lawrence Livermore Lnhoratory University of California

Richard J. Fateman Computer Science Division University of California, Berkeley

1. Summary are performed. Conversion to power series and Techniques for a MACSYMA package for expanding an between the roots of a Chebyshev are supported. arbitrary univariate expression as a truncated series in The Clenshaw method for symbolic Chebyshev expansion of Chebyshev and manipulating such expansions is the solution of a linear whose coefficients described. A data structure is introduced to represent a are low degree polynomials is implemented in the package. truncated expansion in a set of . The data structure contains the independent variable, the name of the orthogonal polynomial set, the number of terms retained, and a 2. Data Structure list of the expansion coefficients. Although we restrict attention Orthogonal polynomials are generalizations of here to the set of as the orthogonal set, perpendicular vectors. The perpendicularity of vectors a, b extension to other orthogonal polynomials will be done later. A with components a(i), b(i), namely xa(i)b(i) = 0, is data structure for truncated power series is provided as an generalized to polynomial functions a(x), b(x) of continuous alternative. variates x by a generalized perpendicularity, The principal function of the package converts a given fw(x)a(x)b(x) dx = 0. Here w(x) is a weight function. expression into the aforementioned data structure. Special Orthogonal polynomials arise in the solution of some problems cases are the conversion of sums, products, the ratio, or the in mathematical physics [ 11, and a symbolic package for their composition of truncated Chebyshev expansions. error-free manipulation is beneficial to workers in that field. Another special case is converting an expression free of The truncated expansion in a set of univariate truncated Chebyshev expansions. The package generates exact orthogonal polynomials named orthpoly is represented by the expansion coefficients whenever possible. In addition to data structure: well-known Chebyshev expansions, such as for polynomials, orthser( indep-var, coefficient-list, orthpoly, we provide new methods for getting exact Chebyshev desc(highest-index - of - exact-coefficient, expansions for reciprocals of polynomials of degree one or highest-index-of nonzero-coeff )) two, meromorphic functions, arbitrary powers of a first-degree where indep-var is the argument of the orthogonal polynomial polynomial, the error-function, and generalized hypergeometric and coefficient-list is a MACSYMA list of expansion functions . coefficients. When exact Chebyshev espansions for a function are We call such a data structure an ort hser and provide functions unknown, or too costly to compute, approximate expansions for converting any expression into an orthscr, in particular an orthser whose indep-var is atomic. The resulting orthser can be inexact, not only due to truncating at a finite number of terms but also due to the coefficients themselves being inexact. Even simple conversions, such as for the product of two orthsers, can contaminate coefficients. All items in Permission to copy without fee all or part of this matertial is granted provided that the copies are not made or distributed for direct coefficient-list with index less than or equal to the first commercial advantage, the ACM copyright notice and the title of the argument of desc are exact. publication and its date appear. and notice is given that the copying is by permission of the Association for Computing Machinery. To copy other- wise, or to republish, requires a fee and/or specific permission.

0 1989 ACM O-89791-325-6/89/0007/0180 $1.50 180 In this paper the orthogonal polynomial set is restricted to the Chebyshev . An alternative calculation of to the set of Chebj;shev po?),nomials: Chebyshev series composition avoids conversion to the power T,(x) = cos(n cos -l(x)) (Z-l) basis by reducing composition to multiplication and addition of [2], which are representative of general orthogonal polynomials orthsers. Let M but have a simpler calculus. Chebyshev expansions are also sM= c amTm(x) (3-2) useful in nroviding close to the best supnorm approximations m=O of functions by polynomials [3][11]. where In later work we will consider other orthogonal M polynomials and convert from one set of orthogonal X= C PmTm(X) (3-3) m=O polynomials to another, corresponding to a change of basis in We seek SM as a single Chebyshev series in x. The three-term the vector space of polynomials. This is done through the intermediary of the basis of powers of the independent variable. recurrence for Chebyshev polynomials with adjacent indices can be written in matrix-vector form (51: 3. Conversion to a Truncated Series in Orthogonal Polynomials Expressions which are converted to an orthser (with atomic in&p-var ) are one of these types: l] linear combination, product, or ratio of orthsers, where 21 expression containing no orthsers A(X) = 31 linear combination, product, or ratio of types 1 and 2 43 orthser whose indep-var is an orthser Then SM-.- can be written : 51 univariate expression whose argument is an orthser, Vxl f(orthserL,,)) (3-Q 61 orthser whose indep var is a univariate function whose To(x) where S(1) is the matrix polynomial: argument is one of the previous types. M Of these, type 6 can be reduced to type 4 or 5 by S(l) = c akAk-' converting the indep-var or argument to an orthser. Similarly k=l type 3 can be reduced to 1 or 2. Expressions of type 5 can be and first takes the first component of a vector. The Horner form reduced to type 4 by converting f(a*x) to orthser(x,,,) using of S(1) yields a recurrence which produces S(1) solely in the rules of 2 and substituting the orthser argument of f for x/a. terms of sums and products of two orthsers. The multiplier a is chosen to keep x of absolute value less than 1, to improve the rate of convergence of the Chebyshev series. y[M,O] = a A linear combination of orthsers with the same indep-var reduces to an orthser with the appropriate linear v[MJl= (aMI + A(X)). d”vi-lfX) combination of the coejjficient-lists . A product of two i=l,. . .,M-I Chebyshev orthsers is reduced to a single orthser by using the SM = a.0+ first(vi”,“-*~X)j rule:

This method generalizes to all other orthogonal polynomials, T,(x) T,(x) = ~m+n(x)+T/m-n/(x)) (3-l) which also have three-term recurrences for polynomials with adjacent indices. [4] and the distributive law. Because this rule is so simple, it is cheaper to calculate the product within the Chebyshev 4. Conversion of Expressions Containing No polynomial basis and avoid back and forth interconversion with Orthsers the power basis. We seek the Chebyshev expansion coefficients, Am, of Type 4 is a composition of Chebyshev series. It can be g(x): converted to a single orthser by conversion to the power basis, doing the composition in the power basis, and converting back g(x) = C Am T,(x) (4-l) m=O

181 and truncate the list of Am at some value m to produce the To apply this lemma to the Chebyshev expansion coefficient-list of the orthser. When g depends on parameters, coefficients of F(x), one would, in principle, find the inverse we seek a symbolic expression for A,, exact if possible. transform f(x) and expand fin Maclaurin series. Instead of inverting the Chebyshev transform using a Poisson formula [lo], we guess a form for f and take the Chebyshev 4.1 Exact Chebyshev Expansion Coefficients transform, hoping that the resulting F is simple and interesting. Although in principle one could get an exact A, from What simplify F are the identities: the mutual of Chebyshev polynomials 1 x+ + x- = 2 x (4.1.2-3) Am= 2 g(x)Tm(ix) dx (4.1-l) x+ * x- = 1 (4.2.2-4) n(1+80m) I -1 vi2 we relegate this alternative to a user option, since we expect that For example, if f(x)=l/(l-Qx), then up to scaling constants in general a symbolic definite integral package wiIl fail to give F(x)=l/(l-qx), where Iqlcl and an answer, even after much effort. Instead we derive some special methods for exact Chebyshev expansion coefficients, Q(q)= ’ (4.1.2-5) which are invoked by pattern matching of g. Should these fail, 1+1/1-42 approximate methods for A, are used. so that F(x) has the Chebyshev expansion[l2]: 00

4.1.1 Application of the Bessel Function Generator -&=&< Q” T,,(x) (4.1.2-6) 2 ” The generating function for modified Bessel functions can be put into the form of a Chebyshev expansion [6]: Choosing f(x) = tanh-l(x) yields F(x)=( 1/23sanh-l(x) so’that exp(ax)=2i’ I,(a)Tdx) (4.1.1-1) m n=O tanh-‘(x) = FE’ 1 T”(x) (4.1.2LQ where Ixl<=l and the prime on the summation means that its ,&) 2n+l first term is halved. From this expansion, Chebyshev Similarly choosing f(x) = tan-l(a x) yields the expansion expansions can be obtained, not only for the exponential, but -1 (,).al+l also for sin(ax), cos(ax), sinh(ax),cosh(ax). A slightly more tal?(q x) = 2x T,,(x) (4.1.2-Q “3 2n+l complicated application of (4.1.1-l) is and choosing f(x)=ln( 1-ax) yields

ln(l -qx) = -ln( 1-Q2) + 25 $ Tn(x) (4.1.2-9) n=l In all the above examples, f and F had similar structure. The ratio of two polynomials exhibits the same behavior. If f is a 4.1.2 The Chebyshev Transform Lemma and Its polynomial of degree n-l divided by a polynomial of degree n, Applications then so is F, except for an additive constant. This can be used For an independent variable x, let to derive the Chebyshev expansion of the ratio of a linear to a quadratic in x. It turns out that one can solve relations between x+=x+@7 (4.1.2-la) the parameters with no greater effort than solving a quadratic x=x-m (4.1.2-lb) equation in a parameter. A more complicated application of the Chebyshev We define the Chebyshev transform of f(x) to be transform lemma gives the Chebyshev expansion coefficients F(x) = $f(x+)+f@-)) (4.1.2-2) of d(l-qx) as the Maclaurin expansion coefficients of:

It is easy to show that the Chebyshev transform of xn is Tn(x) 1/ l+Wqx)-w (4.1.2-10) [7], from which follows the Lemma The expansion coefficients of the Maclnurin expansion of f(x) are identically the Chebyshev expansion coefficients of its Chebyshev transform F(x).

182 4.1.3 Chebyshev Expansion of Rational and the terms of Ml, M2, M3 can be expanded in Chebyshev series Meromorphic Functions using (4.1.2-6). (Note that, although laji should exceed 1, s, If the denominator of a rational function can be arbitrarily small, i.e. poles can lie on the imaginary axis M(x):=N(x)/D(x) can be factored into linear and quadratic arbitrarily close to the origin.) The resulting coefficient of a factors with real coefficients, then a partial fraction expansion T,(x) becomes an infinite sum of the mth powers of various reduces the rational function to a sum of terms, each of which Q, one Q for each pole. can be treated by a method in the previous section. Repeated factors of D(x) can be treated by approptiare differentiation with Chebyshev expansions for tan(ax) and sec(ax), where respect to a parameter. Should any of the roots of D should lie poles are evenly spaced, were obtained using this method. For in the interval t-1, 11, one should avoid Chebyshev expansion m>3 convergence of the infinite sum in the coefficient of T, of the term in the partial fraction expansion containing that root. was sufficiently rapid to be truncated at ten terms for a relative If the coefficients of powers of x in D are all numeric, error of 10e8. For smaller m, the entire series was summed then numeric factorization of D is possible using the MACSYMA function allroots. using truncated Maclaurin expansions in a, whose coefficients Meromorphic functions are generalizations of rational involve Bernoulli or Euler numbers. functions, in which N and D are not polynomials but power series. Chebyshev expansions for N/D can be derived when 4.1.4 Miscellaneous Exact Expansions the roots of D, possibly infinite in number, are known. We Expansion (4.1.1-l) yields the expansion: consider the special case of N/D bounded at infinity and all (1 -qxp =2f’ T](x) G&t,q) (4.1.4-l) roots of D, i.e. all poles of the meromorphic function M(x), I=0 being simple. Then M, as a function of the complex variable z, where has a well-known partial fraction expansion [8]: 00 G,(aqj’f$-&F, ~1,crtm, m+l,s) (4.1.4-2) M(z)=M(O)+C ( j=l B is the beta function, and 2Fl is the . where aj is the jth pole of M and bj is the residue of M at aj. FOT q=l, where the series form of the hypergeometric function Specializing further to M(Z) real for real z and poIes either real, diverges, a special method gives the expansion coefficients of aj, or pure imaginary, i s,: (I-x)* in terms of a recurrence. Calculating the hypergeometric series motivates a M(x) = Mo+Ml(x)+xMz(x)+M3(x) (4.1.3-2) Chebyshev economization, and we can get the exact Chebyshev expansion coefficients of the hypergeometric series where in terms of other hypergeometric functions. In general, the kth - b. exact Chebyshev expansion coefficient for the generalized M,(x)= c &, (4.1.3-3) hypergeometric function ,Ft (a; b; qx) is proportional to j=l J

a+~,,+kti)+l(‘).b+k(‘) b+k+)+l(Q,k+l;(2”‘q)2) M2(x) = c cf, (4.1.3-4) 2 2 ‘-7 2 “& x2+$+ where a is a vector of s components, b is a vector of t components, and k is a vector of s components all equal to M3(x) = c ‘tn (4.1.3-5) “=o x*+s*n k.

-b. - 4.2 Approximate Chcbgshev Expansion Coefficients hlo=M(Obx G-c 2 (4.1.3-6) When the exact Chebyshev expansion coefficients j=l n=o cannot be obtained by the above methods, the following where Q, and 7n are 2 times the real part and -2 times the methods are available for approximate expansion coefficients. l] Expanding the expression as a Maclourin series in x to a imaginary part of the residue of M at i sn, respectively. Each of large number of terms and converting the resulting polynomial

183 !o ,: :mncated Chebyshev series. Command under contract N00039-84-C-0089, through the 21 ;d:iercolai;ng at the roots of a Chebyshev polynomial [3]. Electronics Research Laboratory, University of California at Shouid the expression y(x) to be expanded satisfy a Berkeley; the IBM Corporation; a match ing grand from the linear differential equation with coefficients of the derivatives State of California MICRO program. appearing as a polynomials in x of low order and with appropriate initial conditions, the expansion can be obtained by [I] See, for example, H. Margenau and Murphy “The a symbolic implementation of the Clenshaw method 191. The Mathematics of Physics and Chemistry” Van Nostrand highest derivative of y appearing in the differential equation is [2] This expression can be shown to be a polynomial in x by expanded as a truncated Chebyshev series with unknown showing from the definition that Tg(x)=l, Tl(x)=x, and (the coefficients. Successively lower derivatives are obtained, also recurrence) Tn+I(x)=2xTn(x)-Tn-I(x). From the recurrence it as truncated Chebyshev expansions, using the relation [33: follows that T,+l is a polynomial in x if T, and T,-I are. [3] E. Cheney “Introduction to ” Second Ed. Chelsea New York 1982 ~126 [4] L. Fox and I. Parker “Chebyshev Polynomials in Numerical Analysis” Oxford London 1968 The polynomial coefficients of the derivatives are also IS] Massachusetts Institute of Technology, Artificial expanded as truncated Chebyshev series, appropriate series are Intelligence Laboratory AI Memo 239, a.k.a.Hakmem multiplied and substituted in the differential equation. [6] M. Abramowitz and I. Stegun “Handbook of Mathematical Coefficients of corresponding Chebyshev polynomials are equated. The resulting equations and equations in the unknown Functions” National Bureau of Standards AMS 55 Washington coefficients resulting from the initial conditions are solved for 1964. p376,(9.6.34) the unknown coefficients. [7] The identity x+n + x-n = 2 T,(x) appears in M. Snyder “Chebyshev Methods in Numerical Approximation” 5. Conclusions Prentice-Hall Englewood Cliffs, New Jersey 1966 ~13, Procedures in a package for generating exact (1.1-14) as an alternative definition of T, but not as part of a Chebyshev expansion coefficients for many functions have Chebyshev transform. been described. In addition to well-known Chebyshev [8] E. Whittaker and G. Watson “A Course in Modern expansions, such as for polynomials, we provided new Analysis” Third Ed. Cambridge 1920 ~134 methods for getting exact Chebyshev expansions for [9] C. Clenshaw “Chebyshev Series for Mathematical reciprocals of polynomials of degree one or two, meromorphic Functions” Her Majesty’s Stationery Office London 1962, See functions, arbitrary powers of a first-degree polynomial, the also K. Geddes 1977 MACSYMA users’ conference. error-function, and generalized hypergeometic functions. [lo] We didn’t know that there was an exact form for the When exact Chebyshev expansions for a function are inverse of the Chebyshevtransform until W. Kahan taught us unknown, or too costly to compute, approximate expansions that the inverse can be obtained by a Poisson integral. In fact: were performed.

6. Acknowledgement Special thanks to Prof. W. Kahan for his comments. where the integration contour is a unit circle, and F(x) is real. Some of the work was performed under the auspices of He learned it from J.C.P. Miller at Cambridge in the mid the U. S. Department of Energy by the Lawrence Livermore 1950’s. The appropriate Poisson integral formula is given in National Laboratory under Contract W-7405Eng-48 [G, Carrier, M. Krook, and C. Pearson “Theory of Functions This work was supported in part by the following of a Complex Variable”, McGraw-Hill, 1966, p.47 ] We grants: National Science Foundation under grant number know of no case where using the Poisson integral formula CCR-8812843; Army Research Office, grant gives an answer that could not be obtained by guessing at the DAAG29-85-K-0070, through the Center for Pure and Applied inverse. For the case of (4.1.2-6), guessing the inverse Mathematics, University of California at Berkeley; the Defense Chebyshev transform is much simpler than calculating the Advanced Research Projects Agency (DOD) ARPA order Poisson integral by residues. The residue method requires #4871, monitored by Space 8: Naval Warfare Systems calculating the location of poles, determining whether they are

184 inside the contour, and calculating the residue of those that lie inside. Moreover, the residue method must invoke analytic continuation in the case of complex q. [l l] The advantage of Chebyshev approximations can be glimpsed by comparing numerical approximations for e. The exact value is 2.718...; truncating the Maclaurin series for ex at 0(x4) yields 2.708; the corresponding (2,2)Pade approximant is 2.714; truncating the Chebyshev series at O(Tq(x)) yields 2.718. [12] In the seminal paper on Chebyshev series: C.Lanczos, J.Math. & Phys. l7,123(1938), eq. (4.1.2-6) is derived in a different way. A three-term recurrence with constant coefficients is solved, using as a boundary condition the vanishing of all coefficients in the Chebyshev series witrh index beyond a fixed n. The index n is then allowed to go to infinity. Characteristically, truncating Chebyshev series at a finite index n gives more complicated answers than do the exact Chebyshev series.

185