- About this Journal ·
- Abstracting and Indexing ·
- Aims and Scope ·
- Annual Issues ·
- Article Processing Charges ·
- Articles in Press ·
- Author Guidelines ·
- Bibliographic Information ·
- Citations to this Journal ·
- Contact Information ·
- Editorial Board ·
- Editorial Workflow ·
- Free eTOC Alerts ·
- Publication Ethics ·
- Reviewers Acknowledgment ·
- Submit a Manuscript ·
- Subscription Information ·
- Table of Contents
Journal of Applied Mathematics
Volume 2014 (2014), Article ID 742538, 13 pages
Accurate Evaluation of Polynomials in Legendre Basis
1Department of Mathematics and Systems Science, College of Science, National University of Defense Technology, Changsha 410073, China
2The State Key Laboratory for High Performance Computation, College of Computer Science, National University of Defense Technology, Changsha 410073, China
Received 22 April 2014; Accepted 2 July 2014; Published 23 July 2014
Academic Editor: Roberto Barrio
Copyright © 2014 Peibing Du et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
This paper presents a compensated algorithm for accurate evaluation of a polynomial in Legendre basis. Since the coefficients of the evaluated polynomial are fractions, we propose to store these coefficients in two floating point numbers, such as double-double format, to reduce the effect of the coefficients’ perturbation. The proposed algorithm is obtained by applying error-free transformation to improve the Clenshaw algorithm. It can yield a full working precision accuracy for the ill-conditioned polynomial evaluation. Forward error analysis and numerical experiments illustrate the accuracy and efficiency of the algorithm.
Legendre polynomial is often used in numerical analysis [1–3], such as approximation theory and quadrature and differential equations. Legendre polynomial satisfies 3-term recurrence relation; that is, for Legendre polynomial , The polynomial represented in Legendre basis is , where and is Legendre polynomial.
The Clenshaw algorithm [4, 5] is usually used to evaluate a linear combination of Chebyshev polynomials, but it can apply to any class of functions that can be defined by a three-term recurrence relation. Therefore the Clenshaw algorithm can evaluate a polynomial in Legendre basis. The error analysis of the Clenshaw algorithm was considered in the literatures [6–10]. The relative accuracy bound of the computed values by the Clenshaw algorithm verifies
For ill-conditioned problems, several researches applied error-free transformations  to propose accurate compensated algorithms [12–15] to evaluate the polynomials in monomial, Bernstein, and Chebyshev bases with Horner, de Casteljau, and Clenshaw algorithms, respectively. Some recent applications of high-precision arithmetic were given in .
Motivated by them, we apply error-free transformations to analyze the effect of round-off errors and then compensate them to the original result of the Clenshaw algorithm. Since the coefficients of the Legendre polynomial are fractions, the coefficient perturbations in the evaluation may exist when the coefficients are truncated to floating point numbers. We store the coefficients which are not floating point numbers in double-double format, with the double working precision, to get the perturbation. We also compensate the approximate perturbed errors to the original result of the Clenshaw algorithm. Based on the above, we construct a compensated Clenshaw algorithm for the evaluation of a linear combination of Legendre polynomials, which can yield a full working precision accuracy and its relative accuracy bound satisfies
The paper is organized as follows. Section 2 shows some basic notations in error analysis, floating point arithmetic, error-free transformations, compensated algorithm, Clenshaw algorithm, and condition number. Section 3 presents the compensated algorithm and its error bound. Section 4 gives several numerical experiments to illustrate the efficiency and accuracy of the compensated algorithm for polynomial in Legendre basis.
2. Mathematical and Arithmetical Preliminaries
2.1. Basic Notations and Definitions
Throughout this paper, we assume to work with a floating point arithmetic adhering to IEEE-754 floating point standard in rounding to nearest and no overflow nor underflow occurs. Let represent the floating point computation; then the computation obeys the model where and ( is the round-off unit). We also assume that the computed result of in floating point arithmetic is denoted by and the set of all floating point numbers is denoted by . The following definition will be used in error analysis (see more details in ).
Definition 1. One defines where with , , and .
There are three classic properties which will also be used in error analysis:(i);(ii);(iii).
2.2. Accurate Sum and Product
Let , and no overflow nor underflow occurs. The transformation is regarded as an error-free transformation () that causes to exist such that , .
Theorem 2 (see ). For and , and verify
Theorem 3. For and , verifies
2.3. The Clenshaw Algorithm and Condition Number
Barrio et al.  proposed a general polynomial condition number for any polynomial basis defined by a linear recurrence and used this new condition number to give the error bounds for the Clenshaw algorithm. Based on this general condition number, we propose the absolute Legendre polynomial, which is similar to the absolute polynomial mentioned in [7, 21].
Definition 4. Let be Legendre polynomial. We define the absolute Legendre polynomial which is associated with and satisfies where , .
The absolute Legendre polynomial satisfies the following property.
Lemma 5. Let be the absolute Legendre polynomial. Then we have
Definition 6. Let , where is Legendre polynomial. Let be the absolute Legendre polynomial. Then the absolute condition number is and the relative condition number is
3. Compensated Algorithm for Evaluating Polynomials
In this section, we exhibit the exact round-off errors generated by the Clenshaw algorithm with . We also analyze the perturbations generated by truncating the fractions in Algorithm 5. We propose a compensated Clenshaw algorithm to evaluate finite Legendre series and present its error bound in the following.
Firstly, in order to analyze the perturbations, we split each coefficient into three parts as follows: where , and . Let and . Then we describe the recurrence relation at th step of Algorithm 5 for theoretical computation as For numerical computation associated with (19), it is
Remark 7. Let . We split a coefficient like (18); then the representation of splitting is unique and , .
Let and in Algorithm 5. Since every elementary floating point operation in Algorithm 5 causes round-off errors in numerical computation, we apply and the algorithms to take notes of all round-off errors and obtain The sum of the perturbation and the round-off errors of the recurrence relation at th step is where , is defined in Theorem 3. Then we obtain the following theorem.
To devise a compensated algorithm of Algorithm 5 and give its error bound, we need the following lemmas.
Lemma 9. Let be a Legendre series of degree , a floating point value, and the numerical result of Algorithm 5. Then
Lemma 10. Let be a Legendre series of degree and a floating point value. We assume that , where is real numbers; then
Among the perturbed and round-off errors in Algorithm 5, we deem that some errors do not influence the numerical result in working precision. Now we can give the perturbed error bounds and the round-off error bounds, respectively. At first we analyze the perturbed error in (24). Let . According to and Remark 7, we obtain Then let and from Lemma 10, taking into account that , we have
is , so this coefficient perturbation may influence the accuracy; we need to consider it in our compensated algorithm.
Similarly, we let ; then
is , so this coefficient perturbation does not influence the accuracy.
Remark 11. When , the th step of Algorithm 5 is , so that we only need to consider the perturbation of coefficient .
Let and using it into Lemma 10, from , we have
is , so this round-off error may influence the accuracy, we also need to consider it in our compensated algorithm.
is , so this round-off error does not influence the accuracy.
Observing the error bounds we described above, the perturbation generated by the third part of coefficients in (18) does not influence the accuracy. Thanks to the algorithm in Appendix B (see Algorithm 13), we only need to split the coefficients into two floating point numbers.
Here we give the error bound of Algorithm 6.
Theorem 12. Let be a Legendre series of degree and a floating point value. The forward error bound of the compensated Clenshaw algorithm is
Proof. From Algorithm 6, we obtain
According to Theorem 8, we have ; then Next we analyze the bound of .
Let ; then
Thus we obtain
According to Lemma 9, we get
From (50), (51) and , we derive
According to and Remark 7, we obtain From (53) we use into Lemma 10; taking into account that and , according to (52), we get
Next we let ; then thus
According to Lemma 9, we obtain
From (56), (57), and , we derive
From (43), we let and using it into Lemma 10, taking into account that and , we have
Combining (54) and (59), we get
Corollary 13. Let be a Legendre series of degree and a floating point value. The relative error bound of the compensated Clenshaw algorithm is
4. Numerical Results
All our experiments are performed using IEEE-754 double precision as working precision. Here, we consider the polynomials in Legendre basis with real coefficients and floating point entry . All the programs about accuracy measurements have been written in MATLAB R2012b and that about timing measurements have been written in C code on a 2.53-GHz Intel Core i5 laptop.
4.1. Evaluation of the Polynomial in Legendre Basis
In order to construct an ill-conditioned polynomial, we consider the evaluation of the polynomial in Legendre basis converted by the polynomials in the neighborhood of its multiple roots 0.75 and 1. We use the , algorithms and the Symbolic Toolbox to evaluate the polynomial in Legendre basis. In order to observe the perturbation of polynomial coefficients clearly, we propose the algorithm in Appendix A (see Algorithm 7) to obtain the coefficients of the Legendre series. To decrease the perturbation of the coefficients we also propose the algorithm in Appendix B (see Algorithm 16) to store the coefficients in double-double format. That is, the coefficients of the polynomial evaluated, which are obtained by the algorithm and algorithm, are in double format and double-double format, respectively. In this experiment we evaluate the polynomials for 400 equally spaced points in the intervals , , and .
From Figures 1-2 we observe that the polynomial evaluated by algorithm (on the top figure) is oscillating, and the compensated algorithm is more smooth drawing. The polynomials we evaluated by Symbolic Toolbox (on the bottom of Figures 1-2) are different because the perturbations of coefficients obtained by the algorithm are smaller than those by the algorithm. We can see that the accuracy of the polynomials evaluated by the compensated algorithm is the same with evaluated by Symbolic Toolbox in Figure 1. The polynomials in Legendre basis evaluated by the compensated algorithm are much more smooth drawing and just a little oscillation in the intervals in Figure 2. In fact, if we use the Symbolic Toolbox to get the polynomial coefficients, the oscillation will be smaller than it is in Figure 2. However, this method is expensive. We just need to use the algorithm to get the coefficients; the result obtained by the algorithm is almost the same as that by using the Symbolic Toolbox in working precision.
4.2. Accuracy of the Compensated Algorithm
The closer to the root, the larger the condition number. Thus, in this experiment, the evaluation is for 120 points near the root 0.75, that is, , for 1 : 40 and for 1 : 80. We compare the compensated algorithm with multiple precision library. Since the working precision is double precision, we choose the double-double arithmetic  (see Appendix B) which is the most efficient way to yield a full precision accuracy of evaluating the polynomial in Legendre basis to compare with the compensated algorithm. We evaluate the polynomials by the , , and algorithms in Appendix B (see Algorithm 15) and the Symbolic Toolbox, respectively, so that the relative forward errors can be obtained by and the relative error bounds are described from Corollaries 13 and A.2 in Appendix A. Then we propose the relative forward errors of evaluation of the polynomial in Legendre basis in Figure 3. As we can see, the relative errors of the compensated algorithm and double-double arithmetic are both smaller than () when the condition number is less than . And the accuracy of both algorithms is decreasing linearly for the condition number larger than . However, the algorithm cannot yield the working precision; the accuracy of which decreases linearly since the condition number is less than . When the condition number is lager than , the Clenshaw algorithm cannot obtain even one significant bit.
4.3. Time Performances
We can easily know that the , , and algorithms in Appendix B (Algorithm 8) require 6, 17, and 3 flops, respectively. Then we obtain the computational cost of the , , and algorithms:(i): 5n-2 flops;(ii): 79n-29 flops;(iii): 110n-44 flops.
Considering the previous comparison of the accuracy, we observe that is as accurate as in double precision, but it only needs about 71.8% of flops counting on average. We also implement and by using Microsoft Visual C++ 2008 on Windows 7. Similar to the statement in , we assume that the computing time of these algorithms does not depend on the coefficients of polynomial in Legendre basis nor the argument . So we generate the tested polynomials with random coefficients and arguments in the interval , whose degrees vary from 20 to 10000 by the step 50. The average measured computing time ratio of to in C code is . The reason why the measured computing time ratio is better than the theoretical flop count one can be referred to the analysis in terms of instruction level parallelism (ILP) described in [24, 25].
This paper introduces a compensated Clenshaw algorithm for accurate evaluation of the finite Legendre series. The algorithm is not precise enough for an ill-conditioned problem, especially evaluating a polynomial in the neighborhood of a multiple root. However, this new algorithm can yield a full precision accuracy in working precision, as the same as the original Clenshaw algorithm using double-double arithmetic and rounding into the working precision. Meanwhile this compensated Clenshaw algorithm is more efficient which means that it is much more useful to accurately evaluate the polynomials in Legendre basis for ill-conditioned situations.
A. The Coefficients Conversion Algorithm from Polynomial in Power Basis to Polynomial in Legendre Basis
In order to design ill-conditioned problem of the polynomial evaluation, we evaluate a polynomial in the neighborhood of a multiple root. Thus we need an algorithm for converting a polynomial in power basis to the polynomial in Legendre basis. Motivated by , the conversion algorithm can be deduced as follows.
Let and be the polynomials in power basis and Legendre basis, respectively; according to we have
Thus we get Algorithm 7.
Theorem A.1. Let and be the polynomials in power basis and Legendre basis, respectively. The forward error bound of Algorithm 7 is
Corollary A.2. Let and be the polynomials in power basis and Legendre basis, respectively. Then the relative error bound of Clenshaw algorithm by using the algorithm is
B. Double-Double Library
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
This work is partially supported by the Science Project of National University of Defense Technology (JC120201) and the National Natural Science Foundation of Hunan Province in China (13JJ2001).
- J. C. Mason and D. C. Handscomb, Chebyshev Polynomials, Chapman & Hall/CRC, Boca Raton, Fla, USA, 2003.
- D. Gottlieb and S. A. Orszag, Numerical Analysis of Spectral Methods: Theory and Applications, vol. 26 of CBMS-NSF Regional Conference Series in Applied Mathematics, Society for Industrial and Applied Mathematics, Philadelphia, Pa, USA, 1977.
- L. N. Trefethen, Approximation Theory and Approximation Practice, SIAM, Philadelphia, Pennsylvania, 2013.
- C. W. Clenshaw, “A note on the summation of Chebyshev series,” Mathematical Tables and Other Aids to Computation, vol. 9, pp. 118–120, 1955.
- R. Barrio, “A unified rounding error bound for polynomial evaluation,” Advances in Computational Mathematics, vol. 19, no. 4, pp. 385–399, 2003.
- J. Oliver, “Rounding error propagation in polynomial evaluation schemes,” Journal of Computational and Applied Mathematics, vol. 5, no. 2, pp. 85–97, 1979.
- R. Barrio, “A matrix analysis of the stability of the Clenshaw algorithm,” Extracta Mathematicae, vol. 13, no. 1, pp. 21–26, 1998.
- R. Barrio, “Rounding error bounds for the Clenshaw and Forsythe algorithms for the evaluation of orthogonal polynomial series,” Journal of Computational and Applied Mathematics, vol. 138, no. 2, pp. 185–204, 2002.
- M. Skrzipek, “Polynomial evaluation and associated polynomials,” Numerische Mathematik, vol. 79, no. 4, pp. 601–613, 1998.
- A. Smoktunowicz, “Backward stability of Clenshaw's algorithm,” BIT: Numerical Mathematics, vol. 42, no. 3, pp. 600–610, 2002.
- T. Ogita, S. M. Rump, and S. Oishi, “Accurate sum and dot product,” SIAM Journal on Scientific Computing, vol. 26, no. 6, pp. 1955–1988, 2005.
- S. Graillat, P. Langlois, and N. Louvet, “Compensated Horner scheme,” Research Report RR2005-04, LP2A, University of Perpignan, Perpignan, France, 2005.
- H. Jiang, S. Graillat, C. Hu et al., “Accurate evaluation of the -th derivative of a polynomial and its application,” Journal of Computational and Applied Mathematics, vol. 243, pp. 28–47, 2013.
- H. Jiang, S. Li, L. Cheng, and F. Su, “Accurate evaluation of a polynomial and its derivative in Bernstein form,” Computers & Mathematics with Applications, vol. 60, no. 3, pp. 744–755, 2010.
- H. Jiang, R. Barrio, H. Li, X. Liao, L. Cheng, and F. Su, “Accurate evaluation of a polynomial in Chebyshev form,” Applied Mathematics and Computation, vol. 217, no. 23, pp. 9702–9716, 2011.
- D. H. Bailey, R. Barrio, and J. M. Borwein, “High-precision computation: mathematical physics and dynamics,” Applied Mathematics and Computation, vol. 218, no. 20, pp. 10106–10121, 2012.
- N. J. Higham, Accuracy and Stability of Numerical Algorithm, Society for Industrial and Applied Mathematics, Philadelphia, Pa, USA, 2nd edition, 2002.
- D. E. Knuth, The Art of Computer Programming: Seminumerical Algorithms, Addison-Wesley, Reading, Mass, USA, 3rd edition, 1998.
- T. J. Dekker, “A floating-point technique for extending the available precision,” Numerische Mathematik, vol. 18, pp. 224–242, 1971.
- S. Graillat, “Accurate floating-point product and exponentiation,” IEEE Transactions on Computers, vol. 58, no. 7, pp. 994–1000, 2009.
- R. Barrio, H. Jiang, and S. Serrano, “A general condition number for polynomials,” SIAM Journal on Numerical Analysis, vol. 51, no. 2, pp. 1280–1294, 2013.
- X. Li, J. W. Demmel, D. H. Bailey et al., “Design, implementation and testing of extended and mixed precision BLAS,” ACM Transactions on Mathematical Software, vol. 28, no. 2, pp. 152–205, 2002.
- S. Graillat, P. Langlois, and N. Louvet, “Algorithms for accurate, validated and fast polynomial evaluation,” Japan Journal of Industrial and Applied Mathematics, vol. 26, no. 2-3, pp. 191–214, 2009.
- N. Louvet, Compensated algorithms in floating point arithmetic: accuracy, validation, performances [Ph.D. thesis], Universite' de Perpignan Via Domitia, 2007.
- P. Langlois and N. Louvet, “More instruction level parallelism explains the actual efficiency of compensated algorithms,” Tech. Rep. hal-00165020, DALI Research Team, University of Perpignan, Perpignan, France, 2007.
- “Table of Contents for MATH77/mathc90,” chapter 11.3 from, http://mathalacarte.com/c/math77_head.html.
- Y. Hida, X. S. Li, and D. H. Bailey, “Algorithms for quad-double precision floating point arithmetic,” in Proceedings of the 15th IEEE Symposium on Computer Arithmetic, pp. 155–162, Vail, Colo, USA, June 2001.