📄 sum.texi
字号:
@cindex acceleration of series@cindex summation, acceleration@cindex series, acceleration@cindex u-transform for series@cindex Levin u-transform@cindex convergence, accelerating a seriesThe functions described in this chapter accelerate the convergence of aseries using the Levin @math{u}-transform. This method takes a small number ofterms from the start of a series and uses a systematic approximation tocompute an extrapolated value and an estimate of its error. The@math{u}-transform works for both convergent and divergent series, includingasymptotic series.These functions are declared in the header file @file{gsl_sum.h}.@menu* Acceleration functions:: * Acceleration functions without error estimation:: * Example of accelerating a series:: * Series Acceleration References:: @end menu@node Acceleration functions@section Acceleration functionsThe following functions compute the full Levin @math{u}-transform of a serieswith its error estimate. The error estimate is computed by propagatingrounding errors from each term through to the final extrapolation. These functions are intended for summing analytic series where each termis known to high accuracy, and the rounding errors are assumed tooriginate from finite precision. They are taken to be relative errors oforder @code{GSL_DBL_EPSILON} for each term.The calculation of the error in the extrapolated value is an@math{O(N^2)} process, which is expensive in time and memory. A fasterbut less reliable method which estimates the error from the convergenceof the extrapolated value is described in the next section For themethod described here a full table of intermediate values andderivatives through to @math{O(N)} must be computed and stored, but thisdoes give a reliable error estimate. .@deftypefun {gsl_sum_levin_u_workspace *} gsl_sum_levin_u_alloc (size_t @var{n})This function allocates a workspace for a Levin @math{u}-transform of @var{n}terms. The size of the workspace is @math{O(2n^2 + 3n)}.@end deftypefun@deftypefun int gsl_sum_levin_u_free (gsl_sum_levin_u_workspace * @var{w})This function frees the memory associated with the workspace @var{w}.@end deftypefun@deftypefun int gsl_sum_levin_u_accel (const double * @var{array}, size_t @var{array_size}, gsl_sum_levin_u_workspace * @var{w}, double * @var{sum_accel}, double * @var{abserr})This function takes the terms of a series in @var{array} of size@var{array_size} and computes the extrapolated limit of the series usinga Levin @math{u}-transform. Additional working space must be provided in@var{w}. The extrapolated sum is stored in @var{sum_accel}, with anestimate of the absolute error stored in @var{abserr}. The actualterm-by-term sum is returned in @code{w->sum_plain}. The algorithmcalculates the truncation error (the difference between two successiveextrapolations) and round-off error (propagated from the individualterms) to choose an optimal number of terms for the extrapolation.@end deftypefun@node Acceleration functions without error estimation@section Acceleration functions without error estimationThe functions described in this section compute the Levin @math{u}-transform ofseries and attempt to estimate the error from the "truncation error" inthe extrapolation, the difference between the final two approximations.Using this method avoids the need to compute an intermediate table ofderivatives because the error is estimated from the behavior of theextrapolated value itself. Consequently this algorithm is an @math{O(N)}process and only requires @math{O(N)} terms of storage. If the seriesconverges sufficiently fast then this procedure can be acceptable. Itis appropriate to use this method when there is a need to compute manyextrapolations of series with similar converge properties at high-speed.For example, when numerically integrating a function defined by aparameterized series where the parameter varies only slightly. Areliable error estimate should be computed first using the fullalgorithm described above in order to verify the consistency of theresults.@deftypefun {gsl_sum_levin_utrunc_workspace *} gsl_sum_levin_utrunc_alloc (size_t @var{n})This function allocates a workspace for a Levin @math{u}-transform of @var{n}terms, without error estimation. The size of the workspace is@math{O(3n)}.@end deftypefun@deftypefun int gsl_sum_levin_utrunc_free (gsl_sum_levin_utrunc_workspace * @var{w})This function frees the memory associated with the workspace @var{w}.@end deftypefun@deftypefun int gsl_sum_levin_utrunc_accel (const double * @var{array}, size_t @var{array_size}, gsl_sum_levin_utrunc_workspace * @var{w}, double * @var{sum_accel}, double * @var{abserr_trunc})This function takes the terms of a series in @var{array} of size@var{array_size} and computes the extrapolated limit of the series usinga Levin @math{u}-transform. Additional working space must be provided in@var{w}. The extrapolated sum is stored in @var{sum_accel}. The actualterm-by-term sum is returned in @code{w->sum_plain}. The algorithmterminates when the difference between two successive extrapolationsreaches a minimum or is sufficiently small. The difference between thesetwo values is used as estimate of the error and is stored in@var{abserr_trunc}. To improve the reliability of the algorithm theextrapolated values are replaced by moving averages when calculating thetruncation error, smoothing out any fluctuations.@end deftypefun@node Example of accelerating a series@section Example of accelerating a seriesThe following code calculates an estimate of @math{\zeta(2) = \pi^2 / 6}using the series,@tex\beforedisplay$$\zeta(2) = 1 + 1/2^2 + 1/3^2 + 1/4^2 + \dots$$\afterdisplay@end tex@ifinfo@example\zeta(2) = 1 + 1/2^2 + 1/3^2 + 1/4^2 + ...@end example@end ifinfo@noindentAfter @var{N} terms the error in the sum is @math{O(1/N)}, making directsummation of the series converge slowly.@example#include <stdio.h>#include <gsl/gsl_math.h>#include <gsl/gsl_sum.h>#define N 20intmain (void)@{ double t[N]; double sum_accel, err; double sum = 0; int n; gsl_sum_levin_u_workspace * w = gsl_sum_levin_u_alloc (N); const double zeta_2 = M_PI * M_PI / 6.0; /* terms for zeta(2) = \sum_@{n=0@}^@{\infty@} 1/n^2 */ for (n = 0; n < N; n++) @{ double np1 = n + 1.0; t[n] = 1.0 / (np1 * np1); sum += t[n]; @} gsl_sum_levin_u_accel (t, N, w, &sum_accel, &err); printf("term-by-term sum = % .16f using %d terms\n", sum, N); printf("term-by-term sum = % .16f using %d terms\n", w->sum_plain, w->terms_used); printf("exact value = % .16f\n", zeta_2); printf("accelerated sum = % .16f using %d terms\n", sum_accel, w->terms_used); printf("estimated error = % .16f\n", err); printf("actual error = % .16f\n", sum_accel - zeta_2); gsl_sum_levin_u_free (w); return 0;@}@end example@noindentThe output below shows that the Levin @math{u}-transform is able to obtain an estimate of the sum to 1 part in @c{$10^{10}$}@math{10^10} using the first eleven terms of the series. Theerror estimate returned by the function is also accurate, givingthe correct number of significant digits. @examplebash$ ./a.out term-by-term sum = 1.5961632439130233 using 20 termsterm-by-term sum = 1.5759958390005426 using 13 termsexact value = 1.6449340668482264accelerated sum = 1.6449340668166479 using 13 termsestimated error = 0.0000000000508580actual error = -0.0000000000315785@end example@noindentNote that a direct summation of this series would require @c{$10^{10}$}@math{10^10} terms to achieve the same precision as the accelerated sum does in 13 terms.@node Series Acceleration References@section References and Further Reading@noindentThe algorithms used by these functions are described in the following papers,@itemize @asis@itemT. Fessler, W.F. Ford, D.A. Smith,@sc{hurry}: An acceleration algorithm for scalar sequences and series@cite{ACM Transactions on Mathematical Software}, 9(3):346--354, 1983.and Algorithm 602 9(3):355--357, 1983.@end itemize@noindentThe theory of the @math{u}-transform was presented by Levin,@itemize @asis@itemD. Levin,Development of Non-Linear Transformations for Improving Convergence ofSequences, @cite{Intern. J. Computer Math.} B3:371--388, 1973@end itemize@noindentA review paper on the Levin Transform is available online,@itemize @asis@itemHerbert H. H. Homeier, Scalar Levin-Type Sequence Transformations,@url{http://xxx.lanl.gov/abs/math/0005209}@end itemize
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -