1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Overview</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="../double_exponential.html" title="Double-exponential quadrature"> 9<link rel="prev" href="../double_exponential.html" title="Double-exponential quadrature"> 10<link rel="next" href="de_tanh_sinh.html" title="tanh_sinh"> 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="../double_exponential.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../double_exponential.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="de_tanh_sinh.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.double_exponential.de_overview"></a><a class="link" href="de_overview.html" title="Overview">Overview</a> 28</h3></div></div></div> 29<h5> 30<a name="math_toolkit.double_exponential.de_overview.h0"></a> 31 <span class="phrase"><a name="math_toolkit.double_exponential.de_overview.synopsis"></a></span><a class="link" href="de_overview.html#math_toolkit.double_exponential.de_overview.synopsis">Synopsis</a> 32 </h5> 33<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">quadrature</span><span class="special">/</span><span class="identifier">tanh_sinh</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 34 <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">quadrature</span><span class="special">/</span><span class="identifier">exp_sinh</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 35 <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">quadrature</span><span class="special">/</span><span class="identifier">sinh_sinh</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 36 37 <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> 38 39 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">></span> 40 <span class="keyword">class</span> <span class="identifier">tanh_sinh</span> 41 <span class="special">{</span> 42 <span class="keyword">public</span><span class="special">:</span> 43 <span class="identifier">tanh_sinh</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">max_refinements</span> <span class="special">=</span> <span class="number">15</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Real</span><span class="special">&</span> <span class="identifier">min_complement</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">::</span><span class="identifier">min_value</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>()</span> <span class="special">*</span> <span class="number">4</span><span class="special">)</span> 44 45 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> 46 <span class="keyword">auto</span> <span class="identifier">integrate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">F</span> <span class="identifier">f</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">b</span><span class="special">,</span> 47 <span class="identifier">Real</span> <span class="identifier">tolerance</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">::</span><span class="identifier">root_epsilon</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>(),</span> 48 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">error</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 49 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">L1</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 50 <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">*</span> <span class="identifier">levels</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)-></span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">F</span><span class="special">>()(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>()))</span> <span class="keyword">const</span><span class="special">;</span> 51 52 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> 53 <span class="keyword">auto</span> <span class="identifier">integrate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">F</span> <span class="identifier">f</span><span class="special">,</span> <span class="identifier">Real</span> 54 <span class="identifier">tolerance</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">::</span><span class="identifier">root_epsilon</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>(),</span> 55 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">error</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 56 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">L1</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 57 <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">*</span> <span class="identifier">levels</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)-></span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">F</span><span class="special">>()(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>()))</span> <span class="keyword">const</span><span class="special">;</span> 58 59 <span class="special">};</span> 60 61 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">></span> 62 <span class="keyword">class</span> <span class="identifier">exp_sinh</span> 63 <span class="special">{</span> 64 <span class="keyword">public</span><span class="special">:</span> 65 <span class="identifier">exp_sinh</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">max_refinements</span> <span class="special">=</span> <span class="number">9</span><span class="special">);</span> 66 67 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> 68 <span class="keyword">auto</span> <span class="identifier">integrate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">F</span> <span class="identifier">f</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">b</span><span class="special">,</span> 69 <span class="identifier">Real</span> <span class="identifier">tol</span> <span class="special">=</span> <span class="identifier">sqrt</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="identifier">Real</span><span class="special">>::</span><span class="identifier">epsilon</span><span class="special">()),</span> 70 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">error</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 71 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">L1</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 72 <span class="identifier">size_t</span><span class="special">*</span> <span class="identifier">levels</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)-></span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">F</span><span class="special">>()(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>()))</span> <span class="keyword">const</span><span class="special">;</span> 73 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> 74 <span class="keyword">auto</span> <span class="identifier">integrate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">F</span> <span class="identifier">f</span><span class="special">,</span> 75 <span class="identifier">Real</span> <span class="identifier">tol</span> <span class="special">=</span> <span class="identifier">sqrt</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="identifier">Real</span><span class="special">>::</span><span class="identifier">epsilon</span><span class="special">()),</span> 76 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">error</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 77 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">L1</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 78 <span class="identifier">size_t</span><span class="special">*</span> <span class="identifier">levels</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)-></span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">F</span><span class="special">>()(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>()))</span> <span class="keyword">const</span><span class="special">;</span> 79 <span class="special">};</span> 80 81 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Real</span><span class="special">></span> 82 <span class="keyword">class</span> <span class="identifier">sinh_sinh</span> 83 <span class="special">{</span> 84 <span class="keyword">public</span><span class="special">:</span> 85 <span class="identifier">sinh_sinh</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">max_refinements</span> <span class="special">=</span> <span class="number">9</span><span class="special">);</span> 86 87 <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">></span> 88 <span class="keyword">auto</span> <span class="identifier">integrate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">F</span> <span class="identifier">f</span><span class="special">,</span> 89 <span class="identifier">Real</span> <span class="identifier">tol</span> <span class="special">=</span> <span class="identifier">sqrt</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="identifier">Real</span><span class="special">>::</span><span class="identifier">epsilon</span><span class="special">()),</span> 90 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">error</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 91 <span class="identifier">Real</span><span class="special">*</span> <span class="identifier">L1</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">,</span> 92 <span class="identifier">size_t</span><span class="special">*</span> <span class="identifier">levels</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)-></span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">F</span><span class="special">>()(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">Real</span><span class="special">>()))</span> <span class="keyword">const</span><span class="special">;</span> 93 <span class="special">};</span> 94 95<span class="special">}}</span> 96</pre> 97<p> 98 These three integration routines provide robust general purpose quadrature, 99 each having a "native" range over which quadrature is performed. 100 For example, the <code class="computeroutput"><span class="identifier">sinh_sinh</span></code> 101 quadrature integrates over the entire real line, the <code class="computeroutput"><span class="identifier">tanh_sinh</span></code> 102 over (-1, 1), and the <code class="computeroutput"><span class="identifier">exp_sinh</span></code> 103 over (0, ∞). The latter integrators also have auxiliary ranges which are handled 104 via a change of variables on the function being integrated, so that the 105 <code class="computeroutput"><span class="identifier">tanh_sinh</span></code> can handle integration 106 over <span class="emphasis"><em>(a, b)</em></span>, and <code class="computeroutput"><span class="identifier">exp_sinh</span></code> 107 over /(a, ∞) and(-∞, b)/. 108 </p> 109<p> 110 Like the other quadrature routines in Boost, these routines support both 111 real and complex-valued integrands. 112 </p> 113<p> 114 The <code class="computeroutput"><span class="identifier">integrate</span></code> methods which 115 do not specify a range always integrate over the native range of the method, 116 and generally are the most efficient and produce the smallest code, on the 117 other hand the methods which do specify the bounds of integration are the 118 most general, and use argument transformations which are generally very robust. 119 The following table summarizes the ranges supported by each method: 120 </p> 121<div class="informaltable"><table class="table"> 122<colgroup> 123<col> 124<col> 125<col> 126<col> 127</colgroup> 128<thead><tr> 129<th> 130 <p> 131 Integrator 132 </p> 133 </th> 134<th> 135 <p> 136 Native range 137 </p> 138 </th> 139<th> 140 <p> 141 Other supported ranges 142 </p> 143 </th> 144<th> 145 <p> 146 Comments 147 </p> 148 </th> 149</tr></thead> 150<tbody> 151<tr> 152<td> 153 <p> 154 tanh_sinh 155 </p> 156 </td> 157<td> 158 <p> 159 (-1,1) 160 </p> 161 </td> 162<td> 163 <p> 164 (a,b)<br> (a,∞)<br> (-∞,b)<br> (-∞,∞) 165 </p> 166 </td> 167<td> 168 <p> 169 Special care is taken for endpoints at or near zero to ensure that 170 abscissa values are calculated without the loss of precision that 171 would normally occur. Likewise when transforming to an infinite 172 endpoint, the additional information which tanh_sinh has internally 173 on abscissa values is used to ensure no loss of precision during 174 the transformation. 175 </p> 176 </td> 177</tr> 178<tr> 179<td> 180 <p> 181 exp_sinh 182 </p> 183 </td> 184<td> 185 <p> 186 (0,∞) 187 </p> 188 </td> 189<td> 190 <p> 191 (a,∞)<br> (-∞,0)<br> (-∞,b) 192 </p> 193 </td> 194<td> 195 </td> 196</tr> 197<tr> 198<td> 199 <p> 200 sinh_sinh 201 </p> 202 </td> 203<td> 204 <p> 205 (-∞,∞) 206 </p> 207 </td> 208<td> 209 </td> 210<td> 211 </td> 212</tr> 213</tbody> 214</table></div> 215</div> 216<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 217<td align="left"></td> 218<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar 219 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, 220 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan 221 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, 222 Daryle Walker and Xiaogang Zhang<p> 223 Distributed under the Boost Software License, Version 1.0. (See accompanying 224 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>) 225 </p> 226</div></td> 227</tr></table> 228<hr> 229<div class="spirit-nav"> 230<a accesskey="p" href="../double_exponential.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../double_exponential.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="de_tanh_sinh.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 231</div> 232</body> 233</html> 234