PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_specfun_legendre_p (s22aa)
Purpose
nag_specfun_legendre_p (s22aa) 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 .
Syntax
Description
nag_specfun_legendre_p (s22aa) 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.
nag_specfun_legendre_p (s22aa) 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
Arguments) to zero whenever the required function is not defined for certain values of
and
(e.g.,
and
).
References
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
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:
– double scalar
-
The argument of the function.
Constraint:
.
- 3:
– int64int32nag_int scalar
-
The order of the function.
Constraint:
.
- 4:
– int64int32nag_int scalar
-
The degree of the last function required in the sequence.
Constraints:
- ;
- if , ;
- if , .
Optional Input Parameters
None.
Output Parameters
- 1:
– double array
-
The required sequence of function values as follows:
- if , contains
, for ;
- if , contains
, for .
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | or , |
or | , |
or | when , |
or | , |
or | when . |
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
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.
Further Comments
None.
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.
Open in the MATLAB editor:
s22aa_example
function s22aa_example
fprintf('s22aa example results\n\n');
mode = int64(1);
x = 0.5;
m = int64(2);
n = int64(3);
[p, ifail] = s22aa(mode, x, m, n);
fprintf('First %2d unnormalized associated Legendre function values ',n);
fprintf('P^%d_n(%7.4f)\n\n',m,x);
fprintf('%3s%8s\n','n','P_n');
fprintf('%3d%10.4f\n', [double([0:n]); p']);
s22aa example results
First 3 unnormalized associated Legendre function values P^2_n( 0.5000)
n P_n
0 0.0000
1 0.0000
2 2.2500
3 5.6250
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015