ooura_fourier_integrals.qbk 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. [/
  2. Copyright (c) 2019 Nick Thompson
  3. Copyright (c) 2019 Paul A. Bristow
  4. Use, modification and distribution are subject to the
  5. Boost Software License, Version 1.0. (See accompanying file
  6. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ]
  8. [section:fourier_integrals Fourier Integrals]
  9. [import ../../example/ooura_fourier_integrals_example.cpp]
  10. [import ../../example/ooura_fourier_integrals_cosine_example.cpp]
  11. [import ../../example/ooura_fourier_integrals_multiprecision_example.cpp]
  12. [heading Synopsis]
  13. ``
  14. #include <boost/math/quadrature/ooura_fourier_integrals.hpp>
  15. namespace boost { namespace math { namespace quadrature {
  16. template<class Real>
  17. class ooura_fourier_sin {
  18. public:
  19. ooura_fourier_sin(const Real relative_error_tolerance = tools::root_epsilon<Real>(), size_t levels = sizeof(Real));
  20. template<class F>
  21. std::pair<Real, Real> integrate(F const & f, Real omega);
  22. };
  23. template<class Real>
  24. class ooura_fourier_cos {
  25. public:
  26. ooura_fourier_cos(const Real relative_error_tolerance = tools::root_epsilon<Real>(), size_t levels = sizeof(Real))
  27. template<class F>
  28. std::pair<Real, Real> integrate(F const & f, Real omega);
  29. };
  30. }}} // namespaces
  31. ``
  32. Ooura's method for Fourier integrals computes
  33. [expression [int][sub 0][super [infin]] f(t)sin([omega] t) dt]
  34. and
  35. [expression [int][sub 0][super [infin]] f(t)cos([omega] t) dt]
  36. by a double exponentially decaying transformation.
  37. These integrals arise when computing continuous Fourier transform of odd and even functions, respectively.
  38. Oscillatory integrals are known to cause trouble for standard quadrature methods, so these routines are provided to cope with the most common oscillatory use case.
  39. The basic usage is shown below:
  40. [ooura_fourier_integrals_example_1]
  41. and compare with the expected value [pi]/2 of the integral.
  42. [ooura_fourier_integrals_example_2]
  43. The output is
  44. [ooura_fourier_integrals_example_output_1]
  45. [note This integrator is more insistent about examining the error estimate, than (say) tanh-sinh, which just returns the value of the integral.]
  46. With the macro BOOST_MATH_INSTRUMENT_OOURA defined, we can follow the progress:
  47. [ooura_fourier_integrals_example_diagnostic_output_1]
  48. Working code of this example is at [@../../example/ooura_fourier_integrals_example.cpp ooura_fourier_integrals_example.cpp]
  49. A classical cosine transform is presented below:
  50. [ooura_fourier_integrals_cosine_example_1]
  51. The value of this integral should be [pi]/(2e) and can be shown :
  52. [ooura_fourier_integrals_cosine_example_2]
  53. or with the macro BOOST_MATH_INSTRUMENT_OOURA defined, we can follow the progress:
  54. [ooura_fourier_integrals_example_cosine_diagnostic_output_1]
  55. Working code of this example is at [@../../example/ooura_fourier_integrals_cosine_example.cpp ooura_fourier_integrals_consine_example.cpp]
  56. [h5:performance Performance]
  57. The integrator precomputes nodes and weights, and hence can be reused for many different frequencies with good efficiency.
  58. The integrator is pimpl'd and hence can be shared between threads without a `memcpy` of the nodes and weights.
  59. Ooura and Mori's paper identifies criteria for rapid convergence based on the position of the poles of the integrand in the complex plane.
  60. If these poles are too close to the real axis the convergence is slow.
  61. It is not trivial to predict the convergence rate a priori, so if you are interested in figuring out if the convergence is rapid, compile with `-DBOOST_MATH_INSTRUMENT_OOURA`
  62. and some amount of printing will give you a good idea of how well this method is performing.
  63. [h5:multi_precision Higher precision]
  64. It is simple to extend to higher precision using __multiprecision.
  65. [ooura_fourier_integrals_multiprecision_example_1]
  66. [ooura_fourier_integrals_multiprecision_example_2]
  67. with output:
  68. [ooura_fourier_integrals_example_multiprecision_output_1]
  69. And with diagnostics on:
  70. [ooura_fourier_integrals_example_multiprecision_diagnostic_output_1]
  71. Working code of this example is at [@../../example/ooura_fourier_integrals_multiprecision_example.cpp ooura_fourier_integrals_multiprecision_example.cpp]
  72. For more examples of other functions and tests, see the full test suite at
  73. [@../../test/ooura_fourier_integral_test.cpp ooura_fourier_integral_test.cpp].
  74. Ngyen and Nuyens make use of __multiprecision in their extension to multiple dimensions, showing relative errors reducing to [cong] 10[super -2000]!
  75. [h5:rationale Rationale]
  76. This implementation is base on Ooura's 1999 paper rather than the later 2005 paper.
  77. It does not preclude a second future implementation based on the later work.
  78. Some of the features of the Ooura's 2005 paper that were less appealing were:
  79. * The advance of that paper is that one can compute ['both] the Fourier sine transform and Fourier cosine transform in a single shot.
  80. But there are examples, like sinc integral, where the Fourier sine would converge, but the Fourier cosine would diverge.
  81. * It would force users to live in the complex plane, when many potential applications only need real.
  82. [h4:references References]
  83. * Ooura, Takuya, and Masatake Mori, ['A robust double exponential formula for Fourier-type integrals.] Journal of computational and applied mathematics, 112.1-2 (1999): 229-241.
  84. * Ooura, Takuya, ['A Double Exponential Formula for the Fourier Transforms.] Publ. RIMS, Kyoto Univ., 41 (2005), 971-977. [@https://pdfs.semanticscholar.org/16ec/a5d76fd6b3d7acaaff0b2a6e8a70caa70190.pdf ]
  85. * Khatibi, Arezoo and Khatibi, Omid,[' Criteria for the Application of Double Exponential Transformation.] (2017) [@https://arxiv.org/pdf/1704.05752.pdf 1704.05752.pdf].
  86. * Nguyen, Dong T.P. and Nuyens, Dirk, ['Multivariate integration over Reals with exponential rate of convergence.] (2016) [@https://core.ac.uk/download/pdf/80799199.pdf].
  87. [endsect] [/section:fourier_integrals Fourier Integrals]