blob: 9caa6c77f8e724bedbff5a36d0806e8b39aee0ff [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Jacobi Elliptic SN, CN and DN</title>
<link rel="stylesheet" href="../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../../index.html" title="Math Toolkit 2.2.0">
<link rel="up" href="../jacobi.html" title="Jacobi Elliptic Functions">
<link rel="prev" href="jac_over.html" title="Overvew of the Jacobi Elliptic Functions">
<link rel="next" href="jacobi_cd.html" title="Jacobi Elliptic Function cd">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="jac_over.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../jacobi.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="jacobi_cd.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="math_toolkit.jacobi.jacobi_elliptic"></a><a class="link" href="jacobi_elliptic.html" title="Jacobi Elliptic SN, CN and DN">Jacobi Elliptic
SN, CN and DN</a>
</h3></div></div></div>
<h5>
<a name="math_toolkit.jacobi.jacobi_elliptic.h0"></a>
<span class="phrase"><a name="math_toolkit.jacobi.jacobi_elliptic.synopsis"></a></span><a class="link" href="jacobi_elliptic.html#math_toolkit.jacobi.jacobi_elliptic.synopsis">Synopsis</a>
</h5>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">jacobi_elliptic</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span> <span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">V</span><span class="special">&gt;</span>
<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">jacobi_elliptic</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">k</span><span class="special">,</span> <span class="identifier">U</span> <span class="identifier">u</span><span class="special">,</span> <span class="identifier">V</span><span class="special">*</span> <span class="identifier">pcn</span><span class="special">,</span> <span class="identifier">V</span><span class="special">*</span> <span class="identifier">pdn</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">V</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">&gt;</span>
<a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">jacobi_elliptic</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">k</span><span class="special">,</span> <span class="identifier">U</span> <span class="identifier">u</span><span class="special">,</span> <span class="identifier">V</span><span class="special">*</span> <span class="identifier">pcn</span><span class="special">,</span> <span class="identifier">V</span><span class="special">*</span> <span class="identifier">pdn</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&amp;);</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<h5>
<a name="math_toolkit.jacobi.jacobi_elliptic.h1"></a>
<span class="phrase"><a name="math_toolkit.jacobi.jacobi_elliptic.description"></a></span><a class="link" href="jacobi_elliptic.html#math_toolkit.jacobi.jacobi_elliptic.description">Description</a>
</h5>
<p>
The function <a class="link" href="jacobi_elliptic.html" title="Jacobi Elliptic SN, CN and DN">jacobi_elliptic</a>
calculates the three copolar Jacobi elliptic functions <span class="emphasis"><em>sn(u, k)</em></span>,
<span class="emphasis"><em>cn(u, k)</em></span> and <span class="emphasis"><em>dn(u, k)</em></span>. The returned
value is <span class="emphasis"><em>sn(u, k)</em></span>, and if provided, <span class="emphasis"><em>*pcn</em></span>
is set to <span class="emphasis"><em>cn(u, k)</em></span>, and <span class="emphasis"><em>*pdn</em></span> is
set to <span class="emphasis"><em>dn(u, k)</em></span>.
</p>
<p>
The functions are defined as follows, given:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/jacobi1.svg"></span>
</p>
<p>
The the angle &#966; is called the <span class="emphasis"><em>amplitude</em></span> and:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/jacobi2.svg"></span>
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top">
<p>
<span class="emphasis"><em>&#966;</em></span> is called the amplitude.
</p>
<p>
<span class="emphasis"><em>k</em></span> is called the modulus.
</p>
</td></tr>
</table></div>
<div class="caution"><table border="0" summary="Caution">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../doc/src/images/caution.png"></td>
<th align="left">Caution</th>
</tr>
<tr><td align="left" valign="top">
<p>
Rather like other elliptic functions, the Jacobi functions are expressed
in a variety of different ways. In particular, the parameter <span class="emphasis"><em>k</em></span>
(the modulus) may also be expressed using a modular angle &#945;, or a parameter
<span class="emphasis"><em>m</em></span>. These are related by:
</p>
<p>
k = sin&#945;
</p>
<p>
m = k<sup>2</sup> = sin<sup>2</sup>&#945;
</p>
<p>
So that the function <span class="emphasis"><em>sn</em></span> (for example) may be expressed
as either:
</p>
<p>
sn(u, k)
</p>
<p>
sn(u \ &#945;)
</p>
<p>
sn(u| m)
</p>
<p>
To further complicate matters, some texts refer to the <span class="emphasis"><em>complement
of the parameter m</em></span>, or 1 - m, where:
</p>
<p>
1 - m = 1 - k<sup>2</sup> = cos<sup>2</sup>&#945;
</p>
<p>
This implementation uses <span class="emphasis"><em>k</em></span> throughout, and makes this
the first argument to the functions: this is for alignment with the elliptic
integrals which match the requirements of the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf" target="_top">Technical
Report on C++ Library Extensions</a>. However, you should be extra
careful when using these functions!
</p>
</td></tr>
</table></div>
<p>
The final <a class="link" href="../../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
be used to control the behaviour of the function: how it handles errors,
what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">policy
documentation for more details</a>.
</p>
<p>
The following graphs illustrate how these functions change as <span class="emphasis"><em>k</em></span>
changes: for small <span class="emphasis"><em>k</em></span> these are sine waves, while as
<span class="emphasis"><em>k</em></span> tends to 1 they become hyperbolic functions:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../graphs/jacobi_sn.svg" align="middle"></span>
</p>
<p>
<span class="inlinemediaobject"><img src="../../../graphs/jacobi_cn.svg" align="middle"></span>
</p>
<p>
<span class="inlinemediaobject"><img src="../../../graphs/jacobi_dn.svg" align="middle"></span>
</p>
<h5>
<a name="math_toolkit.jacobi.jacobi_elliptic.h2"></a>
<span class="phrase"><a name="math_toolkit.jacobi.jacobi_elliptic.accuracy"></a></span><a class="link" href="jacobi_elliptic.html#math_toolkit.jacobi.jacobi_elliptic.accuracy">Accuracy</a>
</h5>
<p>
These functions are computed using only basic arithmetic operations and trigomometric
functions, so there isn't much variation in accuracy over differing platforms.
Typically errors are trivially small for small angles, and as is typical
for cyclic functions, grow as the angle increases. Note that only results
for the widest floating point type on the system are given as narrower types
have <a class="link" href="../relative_error.html#math_toolkit.relative_error.zero_error">effectively zero
error</a>. All values are relative errors in units of epsilon.
</p>
<div class="table">
<a name="math_toolkit.jacobi.jacobi_elliptic.errors_rates_in_the_jacobi_ellip"></a><p class="title"><b>Table&#160;6.29.&#160;Errors Rates in the Jacobi Elliptic Functions</b></p>
<div class="table-contents"><table class="table" summary="Errors Rates in the Jacobi Elliptic Functions">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Significand Size
</p>
</th>
<th>
<p>
Platform and Compiler
</p>
</th>
<th>
<p>
u &lt; 1
</p>
</th>
<th>
<p>
Large u
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
53
</p>
</td>
<td>
<p>
Win32 / Visual C++ 8.0
</p>
</td>
<td>
<p>
Peak=2 Mean=0.5
</p>
</td>
<td>
<p>
Peak=44000 Mean=2500
</p>
</td>
</tr>
<tr>
<td>
<p>
64
</p>
</td>
<td>
<p>
Ubuntu Linux / G++ 4.7
</p>
</td>
<td>
<p>
Peak=2.0 Mean=0.5
</p>
</td>
<td>
<p>
Peak=25000 Mean=1500
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><h5>
<a name="math_toolkit.jacobi.jacobi_elliptic.h3"></a>
<span class="phrase"><a name="math_toolkit.jacobi.jacobi_elliptic.testing"></a></span><a class="link" href="jacobi_elliptic.html#math_toolkit.jacobi.jacobi_elliptic.testing">Testing</a>
</h5>
<p>
The tests use a mixture of spot test values calculated using the online calculator
at <a href="http://functions.wolfram.com/" target="_top">functions.wolfram.com</a>,
and random test data generated using MPFR at 1000-bit precision and this
implementation.
</p>
<h5>
<a name="math_toolkit.jacobi.jacobi_elliptic.h4"></a>
<span class="phrase"><a name="math_toolkit.jacobi.jacobi_elliptic.implementation"></a></span><a class="link" href="jacobi_elliptic.html#math_toolkit.jacobi.jacobi_elliptic.implementation">Implementation</a>
</h5>
<p>
For <span class="emphasis"><em>k &gt; 1</em></span> we apply the relations:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/jacobi3.svg"></span>
</p>
<p>
Then filter off the special cases:
</p>
<p>
<span class="emphasis"><em>sn(0, k) = 0</em></span> and <span class="emphasis"><em>cn(0, k) = dn(0, k) = 1</em></span>.
</p>
<p>
<span class="emphasis"><em>sn(u, 0) = sin(u), cn(u, 0) = cos(u) and dn(u, 0) = 1</em></span>.
</p>
<p>
<span class="emphasis"><em>sn(u, 1) = tanh(u), cn(u, 1) = dn(u, 1) = 1 / cosh(u)</em></span>.
</p>
<p>
And for <span class="emphasis"><em>k<sup>4</sup> &lt; &#949;</em></span> we have:
</p>
<p>
<span class="inlinemediaobject"><img src="../../../equations/jacobi4.svg"></span>
</p>
<p>
Otherwise the values are calculated using the method of <a href="http://dlmf.nist.gov/22.20#SS2" target="_top">arithmetic
geometric means</a>.
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014 Nikhar Agrawal,
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
Holin, Bruno Lalande, John Maddock, Johan R&#229;de, Gautam Sewani, Benjamin Sobotta,
Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="jac_over.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../jacobi.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="jacobi_cd.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>