1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
|
[/
Copyright (c) 2012 John Maddock
Use, modification and distribution are subject to the
Boost Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
]
[section:airy Airy Functions]
[section:ai Airy Ai Function]
[heading Synopsis]
``
#include <boost/math/special_functions/airy.hpp>
``
namespace boost { namespace math {
template <class T>
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_ai(T x);
template <class T, class Policy>
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_ai(T x, const Policy&);
}} // namespaces
[heading Description]
The function __airy_ai calculates the Airy function Ai which is the first solution
to the differential equation:
[equation airy]
See Weisstein, Eric W. "Airy Functions." From MathWorld--A Wolfram Web Resource.
[@http://mathworld.wolfram.com/AiryFunctions.html]
and [@https://en.wikipedia.org/wiki/Airy_zeta_function Airy Zeta function].
[optional_policy]
The following graph illustrates how this function changes as /x/ changes: for negative /x/
the function is cyclic, while for positive /x/ the value tends to zero:
[graph airy_ai]
[heading Accuracy]
This function is implemented entirely in terms of the Bessel functions
__cyl_bessel_j and __cyl_bessel_k - refer to those functions for detailed accuracy information.
In general though, the relative error is low (less than 100 [epsilon]) for /x > 0/ while
only the absolute error is low for /x < 0/ as the following error plot illustrates:
[graph ai__double]
[heading Testing]
Since this function is implemented in terms of other special functions, there are only a few
basic sanity checks, using test values from [@http://functions.wolfram.com/ Wolfram Airy Functions].
[heading Implementation]
This function is implemented in terms of the Bessel functions using the relations:
[equation airy_ai]
[endsect] [/section:ai Airy Ai Function]
[section:bi Airy Bi Function]
[heading Synopsis]
``
#include <boost/math/special_functions/airy.hpp>
``
namespace boost { namespace math {
template <class T>
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_bi(T x);
template <class T, class Policy>
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_bi(T x, const Policy&);
}} // namespaces
[heading Description]
The function __airy_bi calculates the Airy function Bi which is the second solution to the differential equation:
[equation airy]
[optional_policy]
The following graph illustrates how this function changes as /x/ changes: for negative /x/
the function is cyclic, while for positive /x/ the value tends to infinity:
[graph airy_bi]
[heading Accuracy]
This function is implemented entirely in terms of the Bessel functions
__cyl_bessel_i and __cyl_bessel_j - refer to those functions for detailed accuracy information.
In general though, the relative error is low (less than 100 [epsilon]) for /x > 0/ while
only the absolute error is low for /x < 0/ as the following error plot illustrate:
[graph bi__double]
[heading Testing]
Since this function is implemented in terms of other special functions, there are only a few
basic sanity checks, using test values from [@http://functions.wolfram.com functions.wolfram.com].
[heading Implementation]
This function is implemented in terms of the Bessel functions using the relations:
[equation airy_bi]
[endsect] [/section:bi Airy Bi Function]
[section:aip Airy Ai' Function]
[heading Synopsis]
``
#include <boost/math/special_functions/airy.hpp>
``
namespace boost { namespace math {
template <class T>
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_ai_prime(T x);
template <class T, class Policy>
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_ai_prime(T x, const Policy&);
}} // namespaces
[heading Description]
The function __airy_ai_prime calculates the Airy function Ai' which is the derivative of the first solution to the differential equation:
[equation airy]
[optional_policy]
The following graph illustrates how this function changes as /x/ changes: for negative /x/
the function is cyclic, while for positive /x/ the value tends to zero:
[graph airy_aip]
[heading Accuracy]
This function is implemented entirely in terms of the Bessel functions
__cyl_bessel_j and __cyl_bessel_k - refer to those functions for detailed accuracy information.
In general though, the relative error is low (less than 100 [epsilon]) for /x > 0/ while
only the absolute error is low for /x < 0/ as the following error plot illustrates:
[graph ai_prime__double]
[heading Testing]
Since this function is implemented in terms of other special functions, there are only a few
basic sanity checks, using test values from [@http://functions.wolfram.com functions.wolfram.com].
[heading Implementation]
This function is implemented in terms of the Bessel functions using the relations:
[equation airy_aip]
[endsect] [/section:aip Airy Ai' Function]
[section:bip Airy Bi' Function]
[heading Synopsis]
``
#include <boost/math/special_functions/airy.hpp>
``
namespace boost { namespace math {
template <class T>
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_bi_prime(T x);
template <class T, class Policy>
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_bi_prime(T x, const Policy&);
}} // namespaces
[heading Description]
The function __airy_bi_prime calculates the Airy function Bi' which is the derivative of the second solution to the differential equation:
[equation airy]
[optional_policy]
The following graph illustrates how this function changes as /x/ changes: for negative /x/
the function is cyclic, while for positive /x/ the value tends to infinity:
[graph airy_bi]
[heading Accuracy]
This function is implemented entirely in terms of the Bessel functions
__cyl_bessel_i and __cyl_bessel_j - refer to those functions for detailed accuracy information.
In general though, the relative error is low (less than 100 [epsilon]) for /x > 0/ while
only the absolute error is low for /x < 0/ as the following error plot illustrates:
[graph bi_prime__double]
[heading Testing]
Since this function is implemented in terms of other special functions, there are only a few
basic sanity checks, using test values from [@http://functions.wolfram.com functions.wolfram.com].
[heading Implementation]
This function is implemented in terms of the Bessel functions using the relations:
[equation airy_bip]
[endsect] [/section:bip Airy Bi' Function]
[section:airy_root Finding Zeros of Airy Functions]
[h4 Synopsis]
`#include <boost/math/special_functions/airy.hpp>`
Functions for obtaining both a single zero or root of the Airy functions,
and placing multiple zeros into a container like `std::vector`
by providing an output iterator.
The signature of the single value functions are:
template <class T>
BOOST_MATH_GPU_ENABLED T airy_ai_zero(
int m); // 1-based index of zero.
template <class T>
BOOST_MATH_GPU_ENABLED T airy_bi_zero(
int m); // 1-based index of zero.
and for multiple zeros:
template <class T, class OutputIterator>
BOOST_MATH_GPU_ENABLED OutputIterator airy_ai_zero(
int start_index, // 1-based index of first zero.
unsigned number_of_zeros, // How many zeros to generate.
OutputIterator out_it); // Destination for zeros.
template <class T, class OutputIterator>
BOOST_MATH_GPU_ENABLED OutputIterator airy_bi_zero(
int start_index, // 1-based index of zero.
unsigned number_of_zeros, // How many zeros to generate
OutputIterator out_it); // Destination for zeros.
There are also versions which allow control of the __policy_section for error handling and precision.
template <class T>
BOOST_MATH_GPU_ENABLED T airy_ai_zero(
int m, // 1-based index of zero.
const Policy&); // Policy to use.
template <class T>
BOOST_MATH_GPU_ENABLED T airy_bi_zero(
int m, // 1-based index of zero.
const Policy&); // Policy to use.
template <class T, class OutputIterator>
BOOST_MATH_GPU_ENABLED OutputIterator airy_ai_zero(
int start_index, // 1-based index of first zero.
unsigned number_of_zeros, // How many zeros to generate.
OutputIterator out_it, // Destination for zeros.
const Policy& pol); // Policy to use.
template <class T, class OutputIterator>
BOOST_MATH_GPU_ENABLED OutputIterator airy_bi_zero(
int start_index, // 1-based index of zero.
unsigned number_of_zeros, // How many zeros to generate.
OutputIterator out_it, // Destination for zeros.
const Policy& pol); // Policy to use.
[h4 Description]
The Airy Ai and Bi functions have an infinite
number of zeros on the negative real axis. The real zeros on the negative real
axis can be found by solving for the roots of
[:['Ai(x[sub m]) = 0]]
[:['Bi(y[sub m]) = 0]]
Here, ['x[sub m]] represents the ['m[super th]]
root of the Airy Ai function,
and ['y[sub m]] represents the ['m[super th]]
root of the Airy Bi function.
The zeros or roots (values of `x` where the function crosses the horizontal `y = 0` axis)
of the Airy Ai and Bi functions are computed by two functions,
`airy_ai_zero` and `airy_bi_zero`.
In each case the index or rank of the zero
returned is 1-based, which is to say:
airy_ai_zero(1);
returns the first zero of Ai.
Passing an `start_index <= 0` results in a __domain_error being raised.
The first few zeros returned by these functions have approximate values as follows:
[table
[[m][Ai][Bi]]
[[1][-2.33811...][-1.17371...]]
[[2][-4.08795...][-3.27109...]]
[[3][-5.52056...][-4.83074...]]
[[4][-6.78671...][-6.16985...]]
[[5][-7.94413...][-7.37676...]]
[[6][-9.02265...][-8.49195...]]
]
[graph airy_zeros]
[h4 Examples of finding Airy Zeros]
[import ../../example/airy_zeros_example.cpp]
[airy_zeros_example_1]
[airy_zeros_example_2]
Produces the program output:
[pre
boost::math::airy_ai_zero<double>(1) = -2.33811
boost::math::airy_ai_zero<double>(2) = -4.08795
boost::math::airy_bi_zero<double>(3) = -4.83074
airy_ai_zeros:
-2.33811
-4.08795
-5.52056
-6.78671
-7.94413
boost::math::airy_bi_zero<float_type>(1) = -2.3381074104597670384891972524467354406385401456711
boost::math::airy_bi_zero<float_type>(2) = -4.0879494441309706166369887014573910602247646991085
boost::math::airy_bi_zero<float_type>(7) = -9.5381943793462388866329885451560196208390720763825
airy_ai_zeros:
-2.3381074104597670384891972524467354406385401456711
-4.0879494441309706166369887014573910602247646991085
-5.5205598280955510591298555129312935737972142806175
]
The full code (and output) for this example is at
[@../../example/airy_zeros_example.cpp airy_zeros_example.cpp],
[h3 Implementation]
Given the following function (A&S 10.4.105):
[equation airy_zero_1]
Then an initial estimate for the n[super th] zero a[sub n] of Ai is given by (A&S 10.4.94):
[equation airy_zero_2]
and an initial estimate for the n[super th] zero b[sub n] of Bi is given by (A&S 10.4.98):
[equation airy_zero_3]
Thereafter the roots are refined using Newton iteration.
[h3 Testing]
The precision of evaluation of zeros was tested at 50 decimal digits using `cpp_dec_float_50`
and found identical with spot values computed by __WolframAlpha.
[endsect] [/section:airy_root Finding Zeros of Airy Functions]
[endsect] [/section:airy Airy Functions]
|