NAG Library Routine Document
S22AAF returns a sequence of values for either the unnormalized or normalized Legendre functions of the first kind or for real of a given order and degree .
||MODE, M, NL, IFAIL
S22AAF evaluates a sequence of values for either the unnormalized or normalized Legendre (
) or associated Legendre (
) functions of the first kind
is real with
, of order
is the (unassociated) Legendre polynomial of degree
(the Rodrigues formula
). Note that some authors (e.g., Abramowitz and Stegun (1972)
) include an additional factor of
(the Condon–Shortley Phase
) in the definitions of
. They use the notation
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
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
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
- 1: MODE – INTEGERInput
: 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.
- 2: X – REAL (KIND=nag_wp)Input
On entry: the argument of the function.
- 3: M – INTEGERInput
On entry: the order of the function.
- 4: NL – INTEGERInput
On entry: the degree of the last function required in the sequence.
- if , ;
- if , .
- 5: P() – REAL (KIND=nag_wp) arrayOutput
: the required sequence of function values as follows:
- if , contains
, for ;
- if , contains
, for .
- 6: IFAIL – INTEGERInput/Output
must be set to
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
|or|| or ,|
|or|| when ,|
|or|| when .|
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.
This example reads the values of the arguments , and from a file, calculates the sequence of unnormalized associated Legendre function values , 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)