nag_real_jacobian_elliptic (s21cac) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_real_jacobian_elliptic (s21cac)

## 1  Purpose

nag_real_jacobian_elliptic (s21cac) evaluates the Jacobian elliptic functions sn, cn and dn.

## 2  Specification

 #include #include
 void nag_real_jacobian_elliptic (double u, double m, double *sn, double *cn, double *dn, NagError *fail)

## 3  Description

nag_real_jacobian_elliptic (s21cac) evaluates the Jacobian elliptic functions of argument $u$ and argument $m$,
 $snu∣m = sin⁡ϕ, cnu∣m = cos⁡ϕ, dnu∣m = 1-msin2⁡ϕ,$
where $\varphi$, called the amplitude of $u$, is defined by the integral
 $u=∫0ϕdθ 1-msin2⁡θ .$
The elliptic functions are sometimes written simply as $\mathrm{sn}u$, $\mathrm{cn}u$ and $\mathrm{dn}u$, avoiding explicit reference to the argument $m$.
Another nine elliptic functions may be computed via the formulae
 $cd⁡u = cn⁡u/dn⁡u sd⁡u = sn⁡u/dn⁡u nd⁡u = 1/dn⁡u dc⁡u = dn⁡u/cn⁡u nc⁡u = 1/cn⁡u sc⁡u = sn⁡u/cn⁡u ns⁡u = 1/sn⁡u ds⁡u = dn⁡u/sn⁡u cs⁡u = cn⁡u/sn⁡u$
(see Abramowitz and Stegun (1972)).
nag_real_jacobian_elliptic (s21cac) is based on a procedure given by Bulirsch (1960), and uses the process of the arithmetic-geometric mean (16.9 in Abramowitz and Stegun (1972)). Constraints are placed on the values of $u$ and $m$ 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

## 5  Arguments

1:     udoubleInput
2:     mdoubleInput
On entry: the argument $u$ and the argument $m$ of the functions, respectively.
Constraints:
• $\mathrm{abs}\left({\mathbf{u}}\right)\le \sqrt{\lambda }$, where $\lambda =1/{\mathbf{nag_real_safe_small_number}}$;
• if $\mathrm{abs}\left({\mathbf{u}}\right)<1/\sqrt{\lambda }$, $\mathrm{abs}\left({\mathbf{m}}\right)\le \sqrt{\lambda }$.
3:     sndouble *Output
4:     cndouble *Output
5:     dndouble *Output
On exit: the values of the functions $\mathrm{sn}u$, $\mathrm{cn}u$ and $\mathrm{dn}u$, respectively.
6:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_BAD_PARAM
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL_2
On entry, $\left|{\mathbf{m}}\right|$ is too large when used in conjunction with the supplied argument u: $\left|{\mathbf{m}}\right|=⟨\mathit{\text{value}}⟩$ it must be less than $⟨\mathit{\text{value}}⟩$.
On entry, $\left|{\mathbf{u}}\right|$ is too large: $\left|{\mathbf{u}}\right|=⟨\mathit{\text{value}}⟩$ it must be less than $⟨\mathit{\text{value}}⟩$.

## 7  Accuracy

In principle the function 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.

Not applicable.

None.

## 10  Example

This example reads values of the argument $u$ and argument $m$ from a file, evaluates the function and prints the results.

### 10.1  Program Text

Program Text (s21cace.c)

### 10.2  Program Data

Program Data (s21cace.d)

### 10.3  Program Results

Program Results (s21cace.r)

nag_real_jacobian_elliptic (s21cac) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG Library Manual