NAG Library Routine Document
s22aaf
(legendre_p)
1
Purpose
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 .
2
Specification
Fortran Interface
Integer, Intent (In) | :: |
mode,
m,
nl | Integer, Intent (Inout) | :: |
ifail | Real (Kind=nag_wp), Intent (In) | :: |
x | Real (Kind=nag_wp), Intent (Out) | :: |
p(0:nl) |
|
C Header Interface
#include nagmk26.h
void |
s22aaf_ (
const Integer *mode,
const double *x,
const Integer *m,
const Integer *nl,
double p[],
Integer *ifail) |
|
3
Description
s22aaf evaluates a sequence of values for either the unnormalized or normalized Legendre (
) or associated Legendre (
) functions of the first kind
or
, where
is real with
, of order
and degree
defined by
respectively;
is the (unassociated) Legendre polynomial of degree
given by
(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
and
. 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
and
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
and
(e.g.,
and
).
4
References
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
5
Arguments
- 1: – 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:
or .
- 2: – Real (Kind=nag_wp)Input
-
On entry: the argument of the function.
Constraint:
.
- 3: – IntegerInput
-
On entry: the order of the function.
Constraint:
.
- 4: – IntegerInput
-
On entry: the degree of the last function required in the sequence.
Constraints:
- ;
- if , ;
- if , .
- 5: – Real (Kind=nag_wp) arrayOutput
-
On exit: the required sequence of function values as follows:
- if , contains
, for ;
- if , contains
, for .
- 6: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
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
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, | , |
or | or , |
or | , |
or | when , |
or | , |
or | when . |
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
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
Parallelism and Performance
s22aaf is not threaded in any implementation.
None.
10
Example
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.
10.1
Program Text
Program Text (s22aafe.f90)
10.2
Program Data
Program Data (s22aafe.d)
10.3
Program Results
Program Results (s22aafe.r)