NAG FL Interface
c06baf (accelerate)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

c06baf accelerates the convergence of a given convergent sequence to its limit.

2 Specification

Fortran Interface
Subroutine c06baf ( seqn, ncall, result, abserr, work, lwork, ifail)
Integer, Intent (In) :: lwork
Integer, Intent (Inout) :: ncall, ifail
Real (Kind=nag_wp), Intent (In) :: seqn
Real (Kind=nag_wp), Intent (Inout) :: work(lwork)
Real (Kind=nag_wp), Intent (Out) :: result, abserr
C Header Interface
#include <nag.h>
void  c06baf_ (const double *seqn, Integer *ncall, double *result, double *abserr, double work[], const Integer *lwork, Integer *ifail)
The routine may be called by the names c06baf or nagf_sum_accelerate.

3 Description

c06baf performs Shanks' transformation on a given sequence of real values by means of the Epsilon algorithm of Wynn (1956). A (possibly unreliable) estimate of the absolute error is also given.
The routine must be called repetitively, once for each new term in the sequence.

4 References

Shanks D (1955) Nonlinear transformations of divergent and slowly convergent sequences J. Math. Phys. 34 1–42
Wynn P (1956) On a device for computing the em(Sn) transformation Math. Tables Aids Comput. 10 91–96

5 Arguments

1: seqn Real (Kind=nag_wp) Input
On entry: the next term of the sequence to be considered.
2: ncall Integer Input/Output
On entry: on the first call ncall must be set to 0. Thereafter ncall must not be changed between calls.
On exit: the number of terms in the sequence that have been considered.
3: result Real (Kind=nag_wp) Output
On exit: the estimate of the limit of the sequence. For the first two calls, result=seqn.
4: abserr Real (Kind=nag_wp) Output
On exit: an estimate of the absolute error in result. For the first three calls, abserr is set to a large machine-dependent constant.
5: work(lwork) Real (Kind=nag_wp) array Communication Array
Used as workspace, but must not be changed between calls.
6: lwork Integer Input
On entry: the dimension of the array work as declared in the (sub)program from which c06baf is called.
Suggested value: (maximum number of terms in the sequence)+6. See Section 9.2.
Constraint: lwork7.
7: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, ncall=value.
Constraint: ncall0.
ifail=2
On entry, lwork=value.
Constraint: lwork7.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

The accuracy of the absolute error estimate abserr varies considerably with the type of sequence to which the routine is applied. In general it is better when applied to oscillating sequences than to monotonic sequences where it may be a severe underestimate.

8 Parallelism and Performance

c06baf is not threaded in any implementation.

9 Further Comments

9.1 Timing

The time taken is approximately proportional to the final value of ncall.

9.2 Choice of lwork

For long sequences, a ‘window’ of the last n values can be used instead of all the terms of the sequence. Tests on a variety of problems indicate that a suitable value is n=50 ; this implies a value for lwork of 56. You are advised to experiment with other values for your own specific problems.

9.3 Convergence

c06baf will induce convergence in some divergent sequences. See Shanks (1955) for more details.

10 Example

This example attempts to sum the infinite series
n=1 (-1) n+1 n2 = π212  
by considering the sequence of partial sums
n= 1 1 , n= 1 2 , n= 1 3 , , n= 1 10  

10.1 Program Text

Program Text (c06bafe.f90)

10.2 Program Data

None.

10.3 Program Results

Program Results (c06bafe.r)
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0.75 0.8 0.85 0.9 0.95 1 1 2 3 4 5 6 7 8 9 10 1e−08 1e−07 1e−06 1e−05 0.0001 0.001 0.01 0.1 1 Result abs(Error) Number of Terms in Sequence Example Program Estimate Sum of Infinite Series by Sequence of Partial Sums result actual error estimated error gnuplot_plot_1 gnuplot_plot_2 gnuplot_plot_3