S22AAF (PDF version)
S Chapter Contents
S 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

S22AAF returns a sequence of values for either the unnormalized or normalized Legendre functions of the first kind Pnmx or Pnm¯x for real x of a given order m and degree n=0,1,,N.

2  Specification

REAL (KIND=nag_wp)  X, P(0:NL)

3  Description

S22AAF evaluates a sequence of values for either the unnormalized or normalized Legendre (m=0) or associated Legendre (m0) functions of the first kind Pnmx or Pnm¯x, where x is real with -1x1, of order m and degree n=0,1,,N defined by
Pnmx = 1-x2m/2 dmdxm Pnx   if ​m0, Pnmx = n+m! n-m! Pn-mx   if ​m<0  and Pnm¯x = 2n+1 2 n-m! n+m! Pnmx
respectively; Pnx is the (unassociated) Legendre polynomial of degree n given by
PnxPn0x=12nn! dndxn x2-1n
(the Rodrigues formula). Note that some authors (e.g., Abramowitz and Stegun (1972)) include an additional factor of -1m (the Condon–Shortley Phase) in the definitions of Pnmx and Pnm¯x. They use the notation Pmnx-1mPnmx in order to distinguish between the two cases.
S22AAF is based on a standard recurrence relation described in Section 8.5.3 of Abramowitz and Stegun (1972). Constraints are placed on the values of m and n in order to avoid the possibility of machine overflow. It also sets the appropriate elements of the array P (see Section 5) to zero whenever the required function is not defined for certain values of m and n (e.g., m=-5 and n=3).

4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

5  Parameters

1:     MODE – INTEGERInput
On entry: indicates whether the sequence of function values is to be returned unnormalized or normalized.
The sequence of function values is returned unnormalized.
The sequence of function values is returned normalized.
Constraint: MODE=1 or 2.
2:     X – REAL (KIND=nag_wp)Input
On entry: the argument x of the function.
Constraint: absX1.0.
3:     M – INTEGERInput
On entry: the order m of the function.
Constraint: absM 27 .
4:     NL – INTEGERInput
On entry: the degree N of the last function required in the sequence.
  • NL0;
  • if M=0, NL100;
  • if M0, NL 55 - absM .
5:     P(0:NL) – REAL (KIND=nag_wp) arrayOutput
On exit: the required sequence of function values as follows:
  • if MODE=1, Pn contains Pnm x , for n=0,1,,N;
  • if MODE=2, Pn contains Pnm ¯ x , for n=0,1,,N.
6:     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.
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.
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:
On entry,absX>1.0,
orMODE1 or 2,
orNL>100 when M=0,
orNL+absM>55 when M0.

7  Accuracy

The computed function values should be accurate to within a small multiple of the machine precision except when underflow (or overflow) occurs, in which case the true function values are within a small multiple of the underflow (or overflow) threshold of the machine.

8  Further Comments


9  Example

This example reads the values of the arguments x, m and N from a file, calculates the sequence of unnormalized associated Legendre function values Pnmx,Pn+1mx,,Pn+Nmx, and prints the results.

9.1  Program Text

Program Text (s22aafe.f90)

9.2  Program Data

Program Data (s22aafe.d)

9.3  Program Results

Program Results (s22aafe.r)

S22AAF (PDF version)
S Chapter Contents
S Chapter Introduction
NAG Library Manual

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