s21caf is based on a procedure given by Bulirsch (1960), and uses the process of the arithmetic-geometric mean ( in Abramowitz and Stegun (1972)). Constraints are placed on the values of and in order to avoid the possibility of machine overflow.
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Bulirsch R (1960) Numerical calculation of elliptic integrals and elliptic functions Numer. Math.7 76–90
1: – Real (Kind=nag_wp)Input
2: – Real (Kind=nag_wp)Input
On entry: the argument and the argument of the functions, respectively.
, where ;
if , .
3: – Real (Kind=nag_wp)Output
4: – Real (Kind=nag_wp)Output
5: – Real (Kind=nag_wp)Output
On exit: the values of the functions , and , respectively.
6: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or 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).
6Error 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, is too large: it must be less than .
On entry, is too large when used in conjunction with the supplied argument u: it must be less than .
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
In principle the routine is capable of achieving full relative precision in the computed values. However, the accuracy obtainable in practice depends on the accuracy of the standard elementary functions such as SIN and COS.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
s21caf is not threaded in any implementation.
This example reads values of the argument and argument from a file, evaluates the function and prints the results.