PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox Chapter Introduction
C06 — summation of series
Scope of the Chapter
This chapter is concerned with the following tasks.
(a) |
Calculating the discrete Fourier transform of a sequence of real or complex data values. |
(b) |
Calculating the discrete convolution or the discrete correlation of two sequences of real or complex data values using discrete Fourier transforms. |
(c) |
Calculating the inverse Laplace transform of a user-supplied function. |
(d) |
Direct summation of orthogonal series. |
(e) |
Acceleration of convergence of a seuqnce of real values. |
Background to the Problems
Discrete Fourier Transforms
Complex transforms
Most of the functions in this chapter calculate the finite
discrete Fourier transform (DFT) of a sequence of
complex numbers
, for
. The direct transform is defined by
for
. Note that equation
(1) makes sense for all integral
and with this extension
is periodic with period
, i.e.,
, and in particular
. Note also that the scale-factor of
may be omitted in the definition of the DFT, and replaced by
in the definition of the inverse.
If we write
and
, then the definition of
may be written in terms of sines and cosines as
The original data values
may conversely be recovered from the transform
by an
inverse discrete Fourier transform:
for
. If we take the complex conjugate of
(2), we find that the sequence
is the DFT of the sequence
. Hence the inverse DFT of the sequence
may be obtained by taking the complex conjugates of the
; performing a DFT, and taking the complex conjugates of the result. (Note that the terms
forward transform and
backward transform are also used to mean the direct and inverse transforms respectively.)
The definition
(1) of a one-dimensional transform can easily be extended to multidimensional transforms. For example, in two dimensions we have
Note: definitions of the discrete Fourier transform vary. Sometimes
(2) is used as the definition of the DFT, and
(1) as the definition of the inverse.
Real transforms
If the original sequence is purely real valued, i.e.,
, then
and
is the complex conjugate of
. Thus the DFT of a real sequence is a particular type of complex sequence, called a
Hermitian sequence, or
half-complex or
conjugate symmetric, with the properties
and, if
is even,
.
Thus a Hermitian sequence of complex data values can be represented by only , rather than , independent real values. This can obviously lead to economies in storage, with two schemes being used in this chapter. In
the first (deprecated) scheme, which will be referred to as the real storage format for Hermitian sequences, the real parts for are stored in normal order in the first locations of an array x of length ; the corresponding nonzero imaginary parts are stored in reverse order in the remaining locations of x. To clarify,
if x is declared with bounds in your calling function,
the following two tables illustrate the storage of the real and imaginary parts of for the two cases: even and odd.
If is even then the sequence has two purely real elements and is stored as follows:
Index of x |
0 |
1 |
2 |
|
|
|
|
|
Sequence |
|
|
|
|
|
|
|
|
Stored values |
|
|
|
|
|
|
|
|
If is odd then the sequence has one purely real element and, letting , is stored as follows:
Index of x |
0 |
1 |
2 |
|
|
|
|
|
|
Sequence |
|
|
|
|
|
|
|
|
|
Stored values |
|
|
|
|
|
|
|
|
|
The second (recommended) storage scheme, referred to in this chapter as the complex storage format for Hermitian sequences, stores the real and imaginary parts , for , in consecutive locations of an array x of length .
If x is declared with bounds in your calling function, the
following two tables illustrate the storage of the real and imaginary parts of for the two cases: even and odd.
If is even then the sequence has two purely real elements and is stored as follows:
Index of x |
0 |
1 |
2 |
3 |
|
|
|
|
|
Stored values |
|
|
|
|
|
|
|
|
|
If is odd then the sequence has one purely real element and, letting , is stored as follows:
Index of x |
0 |
1 |
2 |
3 |
|
|
|
|
|
Stored values |
|
|
|
|
|
|
|
|
|
Also, given a Hermitian sequence, the inverse (or backward) discrete transform produces a real sequence. That is,
where
if
is odd.
For real data that is two-dimensional or higher, the symmetry in the transform persists for the leading dimension only. So, using the notation of equation
(3) for the complex two-dimensional discrete transform, we have that
is the complex conjugate of
. It is more convenient for transformed data of two or more dimensions to be stored as a complex sequence of length
where
is the number of dimensions. The inverse discrete Fourier transform operating on such a complex sequence (Hermitian in the leading dimension) returns a real array of full dimension (
).
Real symmetric transforms
In many applications the sequence
will not only be real, but may also possess additional symmetries which we may exploit to reduce further the computing time and storage requirements. For example, if the sequence
is
odd,
, then the discrete Fourier transform of
contains only sine terms. Rather than compute the transform of an odd sequence, we define the
sine transform of a real sequence by
which could have been computed using the Fourier transform of a real odd sequence of length
. In this case the
are arbitrary, and the symmetry only becomes apparent when the sequence is extended. Similarly we define the
cosine transform of a real sequence by
which could have been computed using the Fourier transform of a real
even sequence of length
.
In addition to these ‘half-wave’ symmetries described above, sequences arise in practice with ‘quarter-wave’ symmetries. We define the
quarter-wave sine transform by
which could have been computed using the Fourier transform of a real sequence of length
of the form
Similarly we may define the
quarter-wave cosine transform by
which could have been computed using the Fourier transform of a real sequence of length
of the form
Fourier integral transforms
The usual application of the discrete Fourier transform is that of obtaining an approximation of the
Fourier integral transform
when
is negligible outside some region
. Dividing the region into
equal intervals we have
and so
for
, where
and
.
Hence the discrete Fourier transform gives an approximation to the Fourier integral transform in the region to .
If the function is defined over some more general interval , then the integral transform can still be approximated by the discrete transform provided a shift is applied to move the point to the origin.
Convolutions and correlations
One of the most important applications of the discrete Fourier transform is to the computation of the discrete
convolution or
correlation of two vectors
and
defined (as in
Brigham (1974)) by
- convolution:
- correlation:
(Here
and
are assumed to be periodic with period
.)
Under certain circumstances (see
Brigham (1974)) these can be used as approximations to the convolution or correlation integrals defined by
and
For more general advice on the use of Fourier transforms, see
Hamming (1962); more detailed information on the fast Fourier transform algorithm can be found in
Gentleman and Sande (1966) and
Brigham (1974).
Applications to solving partial differential equations (PDEs)
A further application of the fast Fourier transform, and in particular of the Fourier transforms of symmetric sequences, is in the solution of elliptic PDEs. If an equation is discretized using finite differences, then it is possible to reduce the problem of solving the resulting large system of linear equations to that of solving a number of tridiagonal systems of linear equations. This is accomplished by uncoupling the equations using Fourier transforms, where the nature of the boundary conditions determines the choice of transforms – see
Application to Elliptic Partial Differential Equations. Full details of the Fourier method for the solution of PDEs may be found in
Swarztrauber (1977) and
Swarztrauber (1984).
Inverse Laplace Transforms
Let
be a real function of
, with
for
, and be piecewise continuous and of exponential order
, i.e.,
for large
, where
is the minimal such exponent.
The Laplace transform of
is given by
where
is defined for
.
The inverse transform is defined by the Bromwich integral
The integration is performed along the line
in the complex plane, where
. This is equivalent to saying that the line
lies to the right of all singularities of
. For this reason, the value of
is crucial to the correct evaluation of the inverse. It is not essential to know
exactly, but an upper bound must be known.
The problem of determining an inverse Laplace transform may be classified according to whether (a) is known for real values only, or (b) is known in functional form and can therefore be calculated for complex values of . Problem (a) is very ill-defined and no functions are provided. Two methods are provided for problem (b).
Direct Summation of Orthogonal Series
For any series of functions
which satisfy a recurrence
the sum
is given by
where
This may be used to compute the sum of the series. For further reading, see
Hamming (1962).
Acceleration of Convergence
This device has applications in a large number of fields, such as summation of series, calculation of integrals with oscillatory integrands (including, for example, Hankel transforms), and root-finding. The mathematical description is as follows. Given a sequence of values
, for
, then, except in certain singular cases, arguments,
,
,
may be determined such that
If the sequence
converges, then
may be taken as an estimate of the limit. The method will also find a pseudo-limit of certain divergent sequences – see
Shanks (1955) for details.
To use the method to sum a series, the terms
of the sequence should be the partial sums of the series, e.g.,
, where
is the
th term of the series. The algorithm can also be used to some advantage to evaluate integrals with oscillatory integrands; one approach is to write the integral (in this case over a semi-infinite interval) as
and to consider the sequence of values
where the integrals are evaluated using standard quadrature methods. In choosing the values of the
, it is worth bearing in mind that
nag_sum_accelerate (c06ba) converges much more rapidly for sequences whose values oscillate about a limit. The
should thus be chosen to be (close to) the zeros of
, so that successive contributions to the integral are of opposite sign. As an example, consider the case where
and
: convergence will be much improved if
rather than
.
Recommendations on Choice and Use of Available Functions
The fast Fourier transform algorithm ceases to be ‘fast’ if applied to values of which cannot be expressed as a product of small prime factors. All the FFT functions in this chapter are particularly efficient if the only prime factors of are , or .
One-dimensional Fourier Transforms
The choice of function is determined first of all by whether the data values constitute a real, Hermitian or general complex sequence. It is wasteful of time and storage to use an inappropriate function.
Real and Hermitian data
nag_sum_fft_realherm_1d (c06pa) transforms a single sequence of real data onto (and in-place) a representation of the transformed Hermitian sequence using the
complex storage scheme described in
Real transforms.
nag_sum_fft_realherm_1d (c06pa) also performs the inverse transform using the representation of Hermitian data and transforming back to a real data sequence.
Alternatively, the two-dimensional function
nag_sum_fft_real_2d (c06pv) can be used (on setting the second dimension to 1) to transform a sequence of real data onto an Hermitian sequence whose first half is stored in a separate Complex array. The second half need not be stored since these are the complex conjugate of the first half in reverse order.
nag_sum_fft_hermitian_2d (c06pw) performs the inverse operation, transforming the the Hermitian sequence (half-)stored in a Complex array onto a separate real array.
Complex data
nag_sum_fft_complex_1d (c06pc) transforms a single complex sequence in-place; it also performs the inverse transform.
nag_sum_fft_complex_1d_multi_col (c06ps) transforms multiple complex sequences, each stored sequentially; it also performs the inverse transform on multiple complex sequences. This function is designed to perform several transforms in a single call, all with the same value of
.
If extensive use is to be made of these functions and you are concerned about efficiency, you are advised to conduct your own timing tests.
Half- and Quarter-wave Transforms
Four functions are provided for computing fast Fourier transforms (FFTs) of real symmetric sequences.
nag_sum_fft_sine (c06re) computes multiple Fourier sine transforms,
nag_sum_fft_cosine (c06rf) computes multiple Fourier cosine transforms,
nag_sum_fft_qtrsine (c06rg) computes multiple quarter-wave Fourier sine transforms, and
nag_sum_fft_qtrcosine (c06rh) computes multiple quarter-wave Fourier cosine transforms.
Application to Elliptic Partial Differential Equations
As described in
Applications to solving partial differential equations (PDEs), Fourier transforms may be used in the solution of elliptic PDEs.
nag_sum_fft_sine (c06re) may be used to solve equations where the solution is specified along the boundary.
nag_sum_fft_cosine (c06rf) may be used to solve equations where the derivative of the solution is specified along the boundary.
nag_sum_fft_qtrsine (c06rg) may be used to solve equations where the solution is specified on the lower boundary, and the derivative of the solution is specified on the upper boundary.
nag_sum_fft_qtrcosine (c06rh) may be used to solve equations where the derivative of the solution is specified on the lower boundary, and the solution is specified on the upper boundary.
For equations with periodic boundary conditions the full-range Fourier transforms computed by
nag_sum_fft_realherm_1d (c06pa) are appropriate.
Multidimensional Fourier Transforms
The following functions compute multidimensional discrete Fourier transforms of real, Hermitian and complex data stored in complex arrays:
The Hermitian data, either transformed from or being transformed to real data, is compacted (due to symmetry) along its first dimension when stored in Complex arrays; thus approximately half the full Hermitian data is stored.
nag_sum_fft_complex_2d (c06pu) and
nag_sum_fft_complex_3d (c06px) should be used in preference to
nag_sum_fft_complex_multid (c06pj) for two- and three-dimensional transforms, as they are easier to use and are likely to be more efficient.
The transform of multidimensional real data is stored as a complex sequence that is Hermitian in its leading dimension. The inverse transform takes such a complex sequence and computes the real transformed sequence. Consequently, separate functions are provided for performing forward and inverse transforms.
nag_sum_fft_real_2d (c06pv) performs the forward two-dimensionsal transform while
nag_sum_fft_hermitian_2d (c06pw) performs the inverse of this transform.
nag_sum_fft_real_3d (c06py) performs the forward three-dimensional transform while
nag_sum_fft_hermitian_3d (c06pz) performs the inverse of this transform.
The complex sequences computed by
nag_sum_fft_real_2d (c06pv) and
nag_sum_fft_real_3d (c06py) contain roughly half of the Fourier coefficients; the remainder can be reconstructed by conjugation of those computed. For example, the Fourier coefficients of the two-dimensional transform
are the complex conjugate of
for
, and
.
Convolution and Correlation
nag_sum_convcorr_real (c06fk) computes either the discrete convolution or the discrete correlation of two real vectors.
nag_sum_convcorr_complex (c06pk) computes either the discrete convolution or the discrete correlation of two complex vectors.
Inverse Laplace Transforms
Two methods are provided: Weeks' method (
nag_sum_invlaplace_weeks (c06lb)) and Crump's method (
nag_sum_invlaplace_crump (c06la)). Both require the function
to be evaluated for complex values of
. If in doubt which method to use, try Weeks' method (
nag_sum_invlaplace_weeks (c06lb)) first; when it is suitable, it is usually much faster.
Typically the inversion of a Laplace transform becomes harder as
increases so that all numerical methods tend to have a limit on the range of
for which the inverse
can be computed.
nag_sum_invlaplace_crump (c06la) is useful for small and moderate values of
.
It is often convenient or necessary to scale a problem so that
is close to
. For this purpose it is useful to remember that the inverse of
is
. The method used by
nag_sum_invlaplace_crump (c06la) is not so satisfactory when
is close to zero, in which case a term may be added to
, e.g.,
has the inverse
.
Singularities in the inverse function
generally cause numerical methods to perform less well. The positions of singularities can often be identified by examination of
. If
contains a term of the form
then a finite discontinuity may be expected in the inverse at
.
nag_sum_invlaplace_crump (c06la), for example, is capable of estimating a discontinuous inverse but, as the approximation used is continuous, Gibbs' phenomena (overshoots around the discontinuity) result. If possible, such singularities of
should be removed before computing the inverse.
Direct Summation of Orthogonal Series
The only function available is
nag_sum_chebyshev (c06dc), which sums a finite Chebyshev series
depending on the choice of a argument.
Acceleration of Convergence
The only function available is
nag_sum_accelerate (c06ba).
Decision Trees
Tree 1: Fourier Transform of Discrete Complex Data
Tree 2: Fourier Transform of Real Data or Data in Complex Hermitian Form Resulting from the Transform of Real Data
Functionality Index
Convolution or Correlation, | | |
Discrete Fourier Transform, | | |
multiple half- and quarter-wave transforms, | | |
Fourier cosine transforms, | | |
quarter-wave cosine transforms, | | |
quarter-wave sine transforms, | | |
Inverse Laplace Transform, | | |
References
Brigham E O (1974) The Fast Fourier Transform Prentice–Hall
Davies S B and Martin B (1979) Numerical inversion of the Laplace transform: A survey and comparison of methods J. Comput. Phys. 33 1–32
Fox L and Parker I B (1968) Chebyshev Polynomials in Numerical Analysis Oxford University Press
Gentleman W S and Sande G (1966) Fast Fourier transforms for fun and profit Proc. Joint Computer Conference, AFIPS 29 563–578
Hamming R W (1962) Numerical Methods for Scientists and Engineers McGraw–Hill
Shanks D (1955) Nonlinear transformations of divergent and slowly convergent sequences J. Math. Phys. 34 1–42
Swarztrauber P N (1977) The methods of cyclic reduction, Fourier analysis and the FACR algorithm for the discrete solution of Poisson's equation on a rectangle SIAM Rev. 19(3) 490–501
Swarztrauber P N (1984) Fast Poisson solvers Studies in Numerical Analysis (ed G H Golub) Mathematical Association of America
Swarztrauber P N (1986) Symmetric FFT's Math. Comput. 47(175) 323–346
Wynn P (1956) On a device for computing the transformation Math. Tables Aids Comput. 10 91–96
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015