• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Finding Zeros of Airy Functions</title>
5<link rel="stylesheet" href="../../math.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Math Toolkit 2.12.0">
8<link rel="up" href="../airy.html" title="Airy Functions">
9<link rel="prev" href="bip.html" title="Airy Bi' Function">
10<link rel="next" href="../ellint.html" title="Elliptic Integrals">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="bip.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../airy.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="../ellint.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="math_toolkit.airy.airy_root"></a><a class="link" href="airy_root.html" title="Finding Zeros of Airy Functions">Finding Zeros of Airy Functions</a>
28</h3></div></div></div>
29<h5>
30<a name="math_toolkit.airy.airy_root.h0"></a>
31        <span class="phrase"><a name="math_toolkit.airy.airy_root.synopsis"></a></span><a class="link" href="airy_root.html#math_toolkit.airy.airy_root.synopsis">Synopsis</a>
32      </h5>
33<p>
34        <code class="computeroutput"><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">airy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
35      </p>
36<p>
37        Functions for obtaining both a single zero or root of the Airy functions,
38        and placing multiple zeros into a container like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>
39        by providing an output iterator.
40      </p>
41<p>
42        The signature of the single value functions are:
43      </p>
44<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
45<span class="identifier">T</span> <span class="identifier">airy_ai_zero</span><span class="special">(</span>
46         <span class="keyword">int</span> <span class="identifier">m</span><span class="special">);</span>         <span class="comment">// 1-based index of zero.</span>
47
48<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
49<span class="identifier">T</span> <span class="identifier">airy_bi_zero</span><span class="special">(</span>
50         <span class="keyword">int</span> <span class="identifier">m</span><span class="special">);</span>         <span class="comment">// 1-based index of zero.</span>
51</pre>
52<p>
53        and for multiple zeros:
54      </p>
55<pre class="programlisting"><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">OutputIterator</span><span class="special">&gt;</span>
56<span class="identifier">OutputIterator</span> <span class="identifier">airy_ai_zero</span><span class="special">(</span>
57                     <span class="keyword">int</span> <span class="identifier">start_index</span><span class="special">,</span>           <span class="comment">// 1-based index of first zero.</span>
58                     <span class="keyword">unsigned</span> <span class="identifier">number_of_zeros</span><span class="special">,</span>  <span class="comment">// How many zeros to generate.</span>
59                     <span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">);</span>    <span class="comment">// Destination for zeros.</span>
60
61<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">OutputIterator</span><span class="special">&gt;</span>
62<span class="identifier">OutputIterator</span> <span class="identifier">airy_bi_zero</span><span class="special">(</span>
63                     <span class="keyword">int</span> <span class="identifier">start_index</span><span class="special">,</span>           <span class="comment">// 1-based index of zero.</span>
64                     <span class="keyword">unsigned</span> <span class="identifier">number_of_zeros</span><span class="special">,</span>  <span class="comment">// How many zeros to generate</span>
65                     <span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">);</span>    <span class="comment">// Destination for zeros.</span>
66</pre>
67<p>
68        There are also versions which allow control of the <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policies</a>
69        for error handling and precision.
70      </p>
71<pre class="programlisting"> <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
72 <span class="identifier">T</span> <span class="identifier">airy_ai_zero</span><span class="special">(</span>
73          <span class="keyword">int</span> <span class="identifier">m</span><span class="special">,</span>          <span class="comment">// 1-based index of zero.</span>
74          <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&amp;);</span> <span class="comment">// Policy to use.</span>
75
76 <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
77 <span class="identifier">T</span> <span class="identifier">airy_bi_zero</span><span class="special">(</span>
78          <span class="keyword">int</span> <span class="identifier">m</span><span class="special">,</span>          <span class="comment">// 1-based index of zero.</span>
79          <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&amp;);</span> <span class="comment">// Policy to use.</span>
80
81
82<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">OutputIterator</span><span class="special">&gt;</span>
83<span class="identifier">OutputIterator</span> <span class="identifier">airy_ai_zero</span><span class="special">(</span>
84                     <span class="keyword">int</span> <span class="identifier">start_index</span><span class="special">,</span>           <span class="comment">// 1-based index of first zero.</span>
85                     <span class="keyword">unsigned</span> <span class="identifier">number_of_zeros</span><span class="special">,</span>  <span class="comment">// How many zeros to generate.</span>
86                     <span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">,</span>     <span class="comment">// Destination for zeros.</span>
87                     <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&amp;</span> <span class="identifier">pol</span><span class="special">);</span>        <span class="comment">// Policy to use.</span>
88
89<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">OutputIterator</span><span class="special">&gt;</span>
90<span class="identifier">OutputIterator</span> <span class="identifier">airy_bi_zero</span><span class="special">(</span>
91                     <span class="keyword">int</span> <span class="identifier">start_index</span><span class="special">,</span>           <span class="comment">// 1-based index of zero.</span>
92                     <span class="keyword">unsigned</span> <span class="identifier">number_of_zeros</span><span class="special">,</span>  <span class="comment">// How many zeros to generate.</span>
93                     <span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">,</span>     <span class="comment">// Destination for zeros.</span>
94                     <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&amp;</span> <span class="identifier">pol</span><span class="special">);</span>        <span class="comment">// Policy to use.</span>
95</pre>
96<h5>
97<a name="math_toolkit.airy.airy_root.h1"></a>
98        <span class="phrase"><a name="math_toolkit.airy.airy_root.description"></a></span><a class="link" href="airy_root.html#math_toolkit.airy.airy_root.description">Description</a>
99      </h5>
100<p>
101        The Airy Ai and Bi functions have an infinite number of zeros on the negative
102        real axis. The real zeros on the negative real axis can be found by solving
103        for the roots of
104      </p>
105<div class="blockquote"><blockquote class="blockquote"><p>
106          <span class="emphasis"><em>Ai(x<sub>m</sub>) = 0</em></span>
107        </p></blockquote></div>
108<div class="blockquote"><blockquote class="blockquote"><p>
109          <span class="emphasis"><em>Bi(y<sub>m</sub>) = 0</em></span>
110        </p></blockquote></div>
111<p>
112        Here, <span class="emphasis"><em>x<sub>m</sub></em></span> represents the <span class="emphasis"><em>m<sup>th</sup></em></span> root
113        of the Airy Ai function, and <span class="emphasis"><em>y<sub>m</sub></em></span> represents the <span class="emphasis"><em>m<sup>th</sup></em></span>
114        root of the Airy Bi function.
115      </p>
116<p>
117        The zeros or roots (values of <code class="computeroutput"><span class="identifier">x</span></code>
118        where the function crosses the horizontal <code class="computeroutput"><span class="identifier">y</span>
119        <span class="special">=</span> <span class="number">0</span></code>
120        axis) of the Airy Ai and Bi functions are computed by two functions, <code class="computeroutput"><span class="identifier">airy_ai_zero</span></code> and <code class="computeroutput"><span class="identifier">airy_bi_zero</span></code>.
121      </p>
122<p>
123        In each case the index or rank of the zero returned is 1-based, which is
124        to say:
125      </p>
126<pre class="programlisting"><span class="identifier">airy_ai_zero</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
127</pre>
128<p>
129        returns the first zero of Ai.
130      </p>
131<p>
132        Passing an <code class="computeroutput"><span class="identifier">start_index</span> <span class="special">&lt;=</span>
133        <span class="number">0</span></code> results in a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
134        being raised.
135      </p>
136<p>
137        The first few zeros returned by these functions have approximate values as
138        follows:
139      </p>
140<div class="informaltable"><table class="table">
141<colgroup>
142<col>
143<col>
144<col>
145</colgroup>
146<thead><tr>
147<th>
148                <p>
149                  m
150                </p>
151              </th>
152<th>
153                <p>
154                  Ai
155                </p>
156              </th>
157<th>
158                <p>
159                  Bi
160                </p>
161              </th>
162</tr></thead>
163<tbody>
164<tr>
165<td>
166                <p>
167                  1
168                </p>
169              </td>
170<td>
171                <p>
172                  -2.33811...
173                </p>
174              </td>
175<td>
176                <p>
177                  -1.17371...
178                </p>
179              </td>
180</tr>
181<tr>
182<td>
183                <p>
184                  2
185                </p>
186              </td>
187<td>
188                <p>
189                  -4.08795...
190                </p>
191              </td>
192<td>
193                <p>
194                  -3.27109...
195                </p>
196              </td>
197</tr>
198<tr>
199<td>
200                <p>
201                  3
202                </p>
203              </td>
204<td>
205                <p>
206                  -5.52056...
207                </p>
208              </td>
209<td>
210                <p>
211                  -4.83074...
212                </p>
213              </td>
214</tr>
215<tr>
216<td>
217                <p>
218                  4
219                </p>
220              </td>
221<td>
222                <p>
223                  -6.78671...
224                </p>
225              </td>
226<td>
227                <p>
228                  -6.16985...
229                </p>
230              </td>
231</tr>
232<tr>
233<td>
234                <p>
235                  5
236                </p>
237              </td>
238<td>
239                <p>
240                  -7.94413...
241                </p>
242              </td>
243<td>
244                <p>
245                  -7.37676...
246                </p>
247              </td>
248</tr>
249<tr>
250<td>
251                <p>
252                  6
253                </p>
254              </td>
255<td>
256                <p>
257                  -9.02265...
258                </p>
259              </td>
260<td>
261                <p>
262                  -8.49195...
263                </p>
264              </td>
265</tr>
266</tbody>
267</table></div>
268<div class="blockquote"><blockquote class="blockquote"><p>
269          <span class="inlinemediaobject"><img src="../../../graphs/airy_zeros.svg" align="middle"></span>
270
271        </p></blockquote></div>
272<h5>
273<a name="math_toolkit.airy.airy_root.h2"></a>
274        <span class="phrase"><a name="math_toolkit.airy.airy_root.examples_of_finding_airy_zeros"></a></span><a class="link" href="airy_root.html#math_toolkit.airy.airy_root.examples_of_finding_airy_zeros">Examples
275        of finding Airy Zeros</a>
276      </h5>
277<p>
278        This example demonstrates calculating zeros of the Airy functions. It also
279        shows how Boost.Math and Boost.Multiprecision can be combined to provide
280        a many decimal digit precision. For 50 decimal digit precision we need to
281        include
282      </p>
283<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">multiprecision</span><span class="special">/</span><span class="identifier">cpp_dec_float</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
284</pre>
285<p>
286        and a <code class="computeroutput"><span class="keyword">typedef</span></code> for <code class="computeroutput"><span class="identifier">float_type</span></code> may be convenient (allowing
287        a quick switch to re-compute at built-in <code class="computeroutput"><span class="keyword">double</span></code>
288        or other precision)
289      </p>
290<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">cpp_dec_float_50</span> <span class="identifier">float_type</span><span class="special">;</span>
291</pre>
292<p>
293        To use the functions for finding zeros of the functions we need
294      </p>
295<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">airy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
296</pre>
297<p>
298        This example shows obtaining both a single zero of the Airy functions, and
299        then placing multiple zeros into a container like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>
300        by providing an iterator. The signature of the single-value Airy Ai function
301        is:
302      </p>
303<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
304<span class="identifier">T</span> <span class="identifier">airy_ai_zero</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">m</span><span class="special">);</span> <span class="comment">// 1-based index of the zero.</span>
305</pre>
306<p>
307        The signature of multiple zeros Airy Ai function is:
308      </p>
309<pre class="programlisting"><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">OutputIterator</span><span class="special">&gt;</span>
310<span class="identifier">OutputIterator</span> <span class="identifier">airy_ai_zero</span><span class="special">(</span>
311                         <span class="keyword">unsigned</span> <span class="identifier">start_index</span><span class="special">,</span> <span class="comment">// 1-based index of the zero.</span>
312                         <span class="keyword">unsigned</span> <span class="identifier">number_of_zeros</span><span class="special">,</span> <span class="comment">// How many zeros to generate.</span>
313                         <span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">);</span> <span class="comment">// Destination for zeros.</span>
314</pre>
315<p>
316        There are also versions which allows control of the <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policies</a>
317        for error handling and precision.
318      </p>
319<pre class="programlisting"><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">OutputIterator</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">&gt;</span>
320<span class="identifier">OutputIterator</span> <span class="identifier">airy_ai_zero</span><span class="special">(</span>
321                         <span class="keyword">unsigned</span> <span class="identifier">start_index</span><span class="special">,</span> <span class="comment">// 1-based index of the zero.</span>
322                         <span class="keyword">unsigned</span> <span class="identifier">number_of_zeros</span><span class="special">,</span> <span class="comment">// How many zeros to generate.</span>
323                         <span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">,</span> <span class="comment">// Destination for zeros.</span>
324                         <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&amp;</span> <span class="identifier">pol</span><span class="special">);</span>  <span class="comment">// Policy to use.</span>
325</pre>
326<div class="tip"><table border="0" summary="Tip">
327<tr>
328<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../doc/src/images/tip.png"></td>
329<th align="left">Tip</th>
330</tr>
331<tr><td align="left" valign="top"><p>
332          It is always wise to place code using Boost.Math inside <code class="computeroutput"><span class="keyword">try</span><span class="char">'n'</span><span class="keyword">catch</span></code> blocks;
333          this will ensure that helpful error messages are shown when exceptional
334          conditions arise.
335        </p></td></tr>
336</table></div>
337<p>
338        First, evaluate a single Airy zero.
339      </p>
340<p>
341        The precision is controlled by the template parameter <code class="computeroutput"><span class="identifier">T</span></code>,
342        so this example has <code class="computeroutput"><span class="keyword">double</span></code> precision,
343        at least 15 but up to 17 decimal digits (for the common 64-bit double).
344      </p>
345<pre class="programlisting"><span class="keyword">double</span> <span class="identifier">aiz1</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">airy_ai_zero</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;(</span><span class="number">1</span><span class="special">);</span>
346<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"boost::math::airy_ai_zero&lt;double&gt;(1) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">aiz1</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
347<span class="keyword">double</span> <span class="identifier">aiz2</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">airy_ai_zero</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;(</span><span class="number">2</span><span class="special">);</span>
348<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"boost::math::airy_ai_zero&lt;double&gt;(2) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">aiz2</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
349<span class="keyword">double</span> <span class="identifier">biz3</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">airy_bi_zero</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;(</span><span class="number">3</span><span class="special">);</span>
350<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"boost::math::airy_bi_zero&lt;double&gt;(3) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">biz3</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
351</pre>
352<p>
353        Other versions of <code class="computeroutput"><span class="identifier">airy_ai_zero</span></code>
354        and <code class="computeroutput"><span class="identifier">airy_bi_zero</span></code> allow calculation
355        of multiple zeros with one call, placing the results in a container, often
356        <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>. For example, generate and display
357        the first five <code class="computeroutput"><span class="keyword">double</span></code> roots
358        <a href="http://mathworld.wolfram.com/AiryFunctionZeros.html" target="_top">Wolfram
359        Airy Functions Zeros</a>.
360      </p>
361<pre class="programlisting"><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">n_roots</span> <span class="special">=</span> <span class="number">5U</span><span class="special">;</span>
362<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">roots</span><span class="special">;</span>
363<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">airy_ai_zero</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;(</span><span class="number">1U</span><span class="special">,</span> <span class="identifier">n_roots</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">roots</span><span class="special">));</span>
364<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"airy_ai_zeros:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
365<span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span><span class="identifier">roots</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span>
366          <span class="identifier">roots</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span>
367          <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\n"</span><span class="special">));</span>
368</pre>
369<p>
370        The first few real roots of Ai(x) are approximately -2.33811, -4.08795, -5.52056,
371        -6.7867144, -7.94413, -9.02265 ...
372      </p>
373<p>
374        Or we can use Boost.Multiprecision to generate 50 decimal digit roots.
375      </p>
376<p>
377        We set the precision of the output stream, and show trailing zeros to display
378        a fixed 50 decimal digits.
379      </p>
380<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">.</span><span class="identifier">precision</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">float_type</span><span class="special">&gt;::</span><span class="identifier">digits10</span><span class="special">);</span> <span class="comment">// float_type has 50 decimal digits.</span>
381<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">showpoint</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// Show trailing zeros too.</span>
382
383<span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">m</span> <span class="special">=</span> <span class="number">1U</span><span class="special">;</span>
384<span class="identifier">float_type</span> <span class="identifier">r</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">airy_ai_zero</span><span class="special">&lt;</span><span class="identifier">float_type</span><span class="special">&gt;(</span><span class="number">1U</span><span class="special">);</span> <span class="comment">// 1st root.</span>
385<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"boost::math::airy_bi_zero&lt;float_type&gt;("</span> <span class="special">&lt;&lt;</span> <span class="identifier">m</span> <span class="special">&lt;&lt;</span> <span class="string">")  = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">r</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
386<span class="identifier">m</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
387<span class="identifier">r</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">airy_ai_zero</span><span class="special">&lt;</span><span class="identifier">float_type</span><span class="special">&gt;(</span><span class="number">2U</span><span class="special">);</span> <span class="comment">// 2nd root.</span>
388<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"boost::math::airy_bi_zero&lt;float_type&gt;("</span> <span class="special">&lt;&lt;</span> <span class="identifier">m</span> <span class="special">&lt;&lt;</span> <span class="string">")  = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">r</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
389<span class="identifier">m</span> <span class="special">=</span> <span class="number">7U</span><span class="special">;</span>
390<span class="identifier">r</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">airy_bi_zero</span><span class="special">&lt;</span><span class="identifier">float_type</span><span class="special">&gt;(</span><span class="number">7U</span><span class="special">);</span> <span class="comment">// 7th root.</span>
391<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"boost::math::airy_bi_zero&lt;float_type&gt;("</span> <span class="special">&lt;&lt;</span> <span class="identifier">m</span> <span class="special">&lt;&lt;</span> <span class="string">")  = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">r</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
392
393<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">float_type</span><span class="special">&gt;</span> <span class="identifier">zeros</span><span class="special">;</span>
394<span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">airy_ai_zero</span><span class="special">&lt;</span><span class="identifier">float_type</span><span class="special">&gt;(</span><span class="number">1U</span><span class="special">,</span> <span class="number">3</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">zeros</span><span class="special">));</span>
395<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"airy_ai_zeros:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
396<span class="comment">// Print the roots to the output stream.</span>
397<span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span><span class="identifier">zeros</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">zeros</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span>
398          <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special">&lt;</span><span class="identifier">float_type</span><span class="special">&gt;(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\n"</span><span class="special">));</span>
399</pre>
400<p>
401        Produces the program output:
402      </p>
403<pre class="programlisting">boost::math::airy_ai_zero&lt;double&gt;(1) = -2.33811
404boost::math::airy_ai_zero&lt;double&gt;(2) = -4.08795
405boost::math::airy_bi_zero&lt;double&gt;(3) = -4.83074
406airy_ai_zeros:
407-2.33811
408-4.08795
409-5.52056
410-6.78671
411-7.94413
412
413boost::math::airy_bi_zero&lt;float_type&gt;(1)  = -2.3381074104597670384891972524467354406385401456711
414boost::math::airy_bi_zero&lt;float_type&gt;(2)  = -4.0879494441309706166369887014573910602247646991085
415boost::math::airy_bi_zero&lt;float_type&gt;(7)  = -9.5381943793462388866329885451560196208390720763825
416airy_ai_zeros:
417-2.3381074104597670384891972524467354406385401456711
418-4.0879494441309706166369887014573910602247646991085
419-5.5205598280955510591298555129312935737972142806175
420</pre>
421<p>
422        The full code (and output) for this example is at <a href="../../../../example/airy_zeros_example.cpp" target="_top">airy_zeros_example.cpp</a>,
423      </p>
424<h4>
425<a name="math_toolkit.airy.airy_root.h3"></a>
426        <span class="phrase"><a name="math_toolkit.airy.airy_root.implementation"></a></span><a class="link" href="airy_root.html#math_toolkit.airy.airy_root.implementation">Implementation</a>
427      </h4>
428<p>
429        Given the following function (A&amp;S 10.4.105):
430      </p>
431<div class="blockquote"><blockquote class="blockquote"><p>
432          <span class="inlinemediaobject"><img src="../../../equations/airy_zero_1.svg"></span>
433
434        </p></blockquote></div>
435<p>
436        Then an initial estimate for the n<sup>th</sup> zero a<sub>n</sub> of Ai is given by (A&amp;S 10.4.94):
437      </p>
438<div class="blockquote"><blockquote class="blockquote"><p>
439          <span class="inlinemediaobject"><img src="../../../equations/airy_zero_2.svg"></span>
440
441        </p></blockquote></div>
442<p>
443        and an initial estimate for the n<sup>th</sup> zero b<sub>n</sub> of Bi is given by (A&amp;S 10.4.98):
444      </p>
445<div class="blockquote"><blockquote class="blockquote"><p>
446          <span class="inlinemediaobject"><img src="../../../equations/airy_zero_3.svg"></span>
447
448        </p></blockquote></div>
449<p>
450        Thereafter the roots are refined using Newton iteration.
451      </p>
452<h4>
453<a name="math_toolkit.airy.airy_root.h4"></a>
454        <span class="phrase"><a name="math_toolkit.airy.airy_root.testing"></a></span><a class="link" href="airy_root.html#math_toolkit.airy.airy_root.testing">Testing</a>
455      </h4>
456<p>
457        The precision of evaluation of zeros was tested at 50 decimal digits using
458        <code class="computeroutput"><span class="identifier">cpp_dec_float_50</span></code> and found
459        identical with spot values computed by <a href="http://www.wolframalpha.com/" target="_top">Wolfram
460        Alpha</a>.
461      </p>
462</div>
463<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
464<td align="left"></td>
465<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar
466      Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
467      Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
468      Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
469      Daryle Walker and Xiaogang Zhang<p>
470        Distributed under the Boost Software License, Version 1.0. (See accompanying
471        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>)
472      </p>
473</div></td>
474</tr></table>
475<hr>
476<div class="spirit-nav">
477<a accesskey="p" href="bip.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../airy.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="../ellint.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
478</div>
479</body>
480</html>
481