C06BAF (PDF version)
C06 Chapter Contents
C06 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

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

2  Specification


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 emSn transformation Math. Tables Aids Comput. 10 91–96

5  Parameters

1:     SEQN – double precisionInput
On entry: the next term of the sequence to be considered.
2:     NCALL – INTEGERInput/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 – double precisionOutput
On exit: the estimate of the limit of the sequence. For the first two calls, RESULT=SEQN .
4:     ABSERR – double precisionOutput
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) – double precision arrayCommunication Array
Used as workspace, but must not be changed between calls.
6:     LWORK – INTEGERInput
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 8.2.
Constraint: LWORK7 .
7:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
On exit: IFAIL=0 unless the routine detects an error (see Section 6).
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.

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:
On entry,NCALL<0.
On entry,LWORK<7.

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  Further Comments

8.1  Timing

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

8.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.

8.3  Convergence

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

9  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

9.1  Program Text

Program Text (c06bafe.f)

9.2  Program Data


9.3  Program Results

Program Results (c06bafe.r)

Example Program Plot for c06baf-plot

C06BAF (PDF version)
C06 Chapter Contents
C06 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009