hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_specfun_legendre_p (s22aa)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_specfun_legendre_p (s22aa) 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.

Syntax

[p, ifail] = s22aa(mode, x, m, nl)
[p, ifail] = nag_specfun_legendre_p(mode, x, m, nl)

Description

nag_specfun_legendre_p (s22aa) 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.
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 m and n 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 m and n (e.g., m=-5 and n=3).

References

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

Parameters

Compulsory Input Parameters

1:     mode int64int32nag_int scalar
Indicates whether the sequence of function values is to be returned unnormalized or normalized.
mode=1
The sequence of function values is returned unnormalized.
mode=2
The sequence of function values is returned normalized.
Constraint: mode=1 or 2.
2:     x – double scalar
The argument x of the function.
Constraint: absx1.0.
3:     m int64int32nag_int scalar
The order m of the function.
Constraint: absm 27 .
4:     nl int64int32nag_int scalar
The degree N of the last function required in the sequence.
Constraints:
  • nl0;
  • if m=0, nl100;
  • if m0, nl 55 - absm .

Optional Input Parameters

None.

Output Parameters

1:     p0:nl – double array
The required sequence of function values as follows:
  • if mode=1, pn+1 contains Pnm x , for n=0,1,,N;
  • if mode=2, pn+1 contains Pnm ¯ x , for n=0,1,,N.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,absx>1.0,
ormode1 or 2,
ornl<0,
ornl>100 when m=0,
orabsm>27,
ornl+absm>55 when m0.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
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 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.
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)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015