72e469da0a
[CI SKIP]
142 lines
13 KiB
HTML
142 lines
13 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
<title>Tangent Numbers</title>
|
|
<link rel="stylesheet" href="../../math.css" type="text/css">
|
|
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
|
<link rel="home" href="../../index.html" title="Math Toolkit 2.11.0">
|
|
<link rel="up" href="../number_series.html" title="Number Series">
|
|
<link rel="prev" href="bernoulli_numbers.html" title="Bernoulli Numbers">
|
|
<link rel="next" href="primes.html" title="Prime Numbers">
|
|
</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="bernoulli_numbers.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../number_series.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="primes.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.number_series.tangent_numbers"></a><a class="link" href="tangent_numbers.html" title="Tangent Numbers">Tangent Numbers</a>
|
|
</h3></div></div></div>
|
|
<p>
|
|
<a href="http://en.wikipedia.org/wiki/Tangent_numbers" target="_top">Tangent numbers</a>,
|
|
also called a zag function. See also <a href="http://mathworld.wolfram.com/TangentNumber.html" target="_top">Tangent
|
|
number</a>.
|
|
</p>
|
|
<p>
|
|
The first few values are 1, 2, 16, 272, 7936, 353792, 22368256, 1903757312
|
|
... (sequence <a href="http://oeis.org/A000182" target="_top">A000182 in OEIS</a>).
|
|
They are called tangent numbers because they appear as numerators in the
|
|
Maclaurin series of <code class="computeroutput"><span class="identifier">tan</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>.
|
|
</p>
|
|
<p>
|
|
<span class="bold"><strong>Important:</strong></span> there are two competing definitions
|
|
of Tangent numbers in common use (depending on whether you take the even
|
|
or odd numbered values as non-zero), we use:
|
|
</p>
|
|
<div class="blockquote"><blockquote class="blockquote"><p>
|
|
<span class="inlinemediaobject"><img src="../../../equations/tangent_number_def.svg"></span>
|
|
|
|
</p></blockquote></div>
|
|
<p>
|
|
Which gives:
|
|
</p>
|
|
<div class="blockquote"><blockquote class="blockquote"><p>
|
|
<span class="inlinemediaobject"><img src="../../../equations/tangent_number_def2.svg"></span>
|
|
|
|
</p></blockquote></div>
|
|
<p>
|
|
Tangent numbers are used in the computation of Bernoulli numbers, but are
|
|
also made available here.
|
|
</p>
|
|
<h5>
|
|
<a name="math_toolkit.number_series.tangent_numbers.h0"></a>
|
|
<span class="phrase"><a name="math_toolkit.number_series.tangent_numbers.synopsis"></a></span><a class="link" href="tangent_numbers.html#math_toolkit.number_series.tangent_numbers.synopsis">Synopsis</a>
|
|
</h5>
|
|
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</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">detail</span><span class="special">/</span><span class="identifier">bernoulli</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
|
</pre>
|
|
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
|
<span class="identifier">T</span> <span class="identifier">tangent_t2n</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">i</span><span class="special">);</span> <span class="comment">// Single tangent number (default policy).</span>
|
|
|
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">></span>
|
|
<span class="identifier">T</span> <span class="identifier">tangent_t2n</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">i</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Policy</span> <span class="special">&</span><span class="identifier">pol</span><span class="special">);</span> <span class="comment">// Single tangent number (user policy).</span>
|
|
|
|
<span class="comment">// Multiple tangent numbers (default policy).</span>
|
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">OutputIterator</span><span class="special">></span>
|
|
<span class="identifier">OutputIterator</span> <span class="identifier">tangent_t2n</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">start_index</span><span class="special">,</span>
|
|
<span class="keyword">const</span> <span class="keyword">unsigned</span> <span class="identifier">number_of_tangent_t2n</span><span class="special">,</span>
|
|
<span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">);</span>
|
|
|
|
<span class="comment">// Multiple tangent numbers (user policy).</span>
|
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">OutputIterator</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">></span>
|
|
<span class="identifier">OutputIterator</span> <span class="identifier">tangent_t2n</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">start_index</span><span class="special">,</span>
|
|
<span class="keyword">const</span> <span class="keyword">unsigned</span> <span class="identifier">number_of_tangent_t2n</span><span class="special">,</span>
|
|
<span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">,</span>
|
|
<span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&</span> <span class="identifier">pol</span><span class="special">);</span>
|
|
</pre>
|
|
<h5>
|
|
<a name="math_toolkit.number_series.tangent_numbers.h1"></a>
|
|
<span class="phrase"><a name="math_toolkit.number_series.tangent_numbers.examples"></a></span><a class="link" href="tangent_numbers.html#math_toolkit.number_series.tangent_numbers.examples">Examples</a>
|
|
</h5>
|
|
<p>
|
|
We can compute and save a few Tangent numbers.
|
|
</p>
|
|
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">float</span><span class="special">></span> <span class="identifier">tn</span><span class="special">;</span> <span class="comment">// Space for some `float` precision Tangent numbers.</span>
|
|
|
|
<span class="comment">// Start with Bernoulli number 0.</span>
|
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tangent_t2n</span><span class="special"><</span><span class="keyword">float</span><span class="special">>(</span><span class="number">1</span><span class="special">,</span> <span class="number">6</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">back_inserter</span><span class="special">(</span><span class="identifier">tn</span><span class="special">));</span> <span class="comment">// Fill vector with even Tangent numbers.</span>
|
|
|
|
<span class="keyword">for</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">tn</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="identifier">i</span><span class="special">++)</span>
|
|
<span class="special">{</span> <span class="comment">// Show vector of even Tangent numbers, showing all significant decimal digits.</span>
|
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">setprecision</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="keyword">float</span><span class="special">>::</span><span class="identifier">digits10</span><span class="special">)</span>
|
|
<span class="special"><<</span> <span class="string">" "</span>
|
|
<span class="special"><<</span> <span class="identifier">tn</span><span class="special">[</span><span class="identifier">i</span><span class="special">];</span>
|
|
<span class="special">}</span>
|
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
|
|
</pre>
|
|
<p>
|
|
The output is:
|
|
</p>
|
|
<pre class="programlisting"><span class="number">1</span> <span class="number">2</span> <span class="number">16</span> <span class="number">272</span> <span class="number">7936</span> <span class="number">353792</span>
|
|
</pre>
|
|
<p>
|
|
The source of this example is at <a href="../../../../example/bernoulli_example.cpp" target="_top">bernoulli_example.cpp</a>
|
|
</p>
|
|
<h5>
|
|
<a name="math_toolkit.number_series.tangent_numbers.h2"></a>
|
|
<span class="phrase"><a name="math_toolkit.number_series.tangent_numbers.implementation"></a></span><a class="link" href="tangent_numbers.html#math_toolkit.number_series.tangent_numbers.implementation">Implementation</a>
|
|
</h5>
|
|
<p>
|
|
Tangent numbers are calculated as intermediates in the calculation of the
|
|
<a class="link" href="bernoulli_numbers.html" title="Bernoulli Numbers">Bernoulli numbers</a>:
|
|
refer to the <a class="link" href="bernoulli_numbers.html" title="Bernoulli Numbers">Bernoulli
|
|
numbers</a> documentation for details.
|
|
</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 © 2006-2019 Nikhar
|
|
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
|
|
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
|
|
Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, 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="bernoulli_numbers.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../number_series.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="primes.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
|
</div>
|
|
</body>
|
|
</html>
|