v0.15.5
Loading...
Searching...
No Matches
lambert_w_asy.hpp
Go to the documentation of this file.
1
2// Copyright Balazs Cziraki 2016.
3// Use, modification and distribution are subject to the
4// Boost Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7#ifndef BOOST_MATH_LAMBERT_W_ASY_HPP_INCLUDED
8#define BOOST_MATH_LAMBERT_W_ASY_HPP_INCLUDED
9
10//#include <boost/math/special_functions/factorials.hpp>
11#include "lambert_w_tools.hpp"
12
13namespace boost
14{
15namespace math
16{
17namespace lambw
18{
19 //Constant that controls series evaluation length
20 const std::size_t _asy_series_L = 4; //Does not actually have an effect yet
21
22 //Calculates Stirling numbers of the first kind.
23 //To be used for the asymptotic approximation.
24 /*
25 template<class IntegralType>
26 BOOST_CONSTEXPR IntegralType _stirling(IntegralType n, IntegralType k)
27 {
28 if( n == 0 || k == 0)
29 {
30 if( n == 0 && k == 0)
31 {
32 return 1;
33 }
34 else
35 {
36 return 0;
37 }
38 }
39 else
40 {
41 return (n-1)*_stirling((n-1),k)+_stirling((n-1),k-1);
42 }
43 }
44 */
45
46 //Calculates the asymptotic approximation
47 //Depending on L1 and L2 it either calculates W_k(z) for large abs(z) or W_{+-1}(z) for small abs(z).
48 //W_{+-1}(z), as in the W_1 and W_{-1} have a direct branch cut between them on the real axis at [-exp(-1):0).
49 //This expansion works for complex numbers close to that branch cut. From here on W_{+-1}(z) refers to expansion working in similar fashion.
50 template<class ArgumentType, class CoeffType>
51 ArgumentType _asy_body(const ArgumentType &L1, const ArgumentType &L2)
52 {
53 ArgumentType ans = L1-L2;
54 /*
55 for(std::size_t l = 0; l < _asy_series_L; ++l)
56 {
57 for(std::size_t m = 1; m <= l+1; ++m)
58 {
59 ans+=std::pow(-1.,l%2)*_stirling(l+m,l+1)/boost::math::factorial(m)*std::pow(L1,-(CoeffType)l-(CoeffType)m)*std::pow(L2,(CoeffType)m);
60 }
61 }
62 */
63 ans += L2/L1 + L2*(((CoeffType)(-2.))+L2)/(CoeffType)2./L1/L1 + L2*((CoeffType)6.-(CoeffType)9.*L2+(CoeffType)2.*L2*L2)/(CoeffType)6./L1/L1/L1
64 + L2*((CoeffType)(-12.)+(CoeffType)36.*L2-(CoeffType)22.*L2*L2+(CoeffType)3.*L2*L2*L2)/(CoeffType)12./L1/L1/L1/L1;
65
66
67 return ans;
68 }
69
70 //Calculates the asymptotic approximation for W_k(z) at large abs(z)
71 template<class ArgumentType, class CoeffType, class IndexType>
72 ArgumentType _asy(const ArgumentType &z, IndexType k = 0)
73 {
74 using std::log;
75
76 ArgumentType L1 = _log_k(z,k);
77 ArgumentType L2 = log(L1);
78
79 return _asy_body<ArgumentType,CoeffType>(L1,L2);
80 }
81
82 //Calculates the asymptotic approximation for W_{+-1}(z) at small abs(z)
83 template<class ArgumentType, class CoeffType>
84 ArgumentType _N1(const ArgumentType &z)
85 {
86 using std::log;
87
88 ArgumentType L1 = log(-z);
89 ArgumentType L2 = log(-L1);
90
91 return _asy_body<ArgumentType,CoeffType>(L1,L2);
92 }
93} //namespace lambw
94} //namespace math
95} //namespace boost
96
97#endif // BOOST_MATH_LAMBERT_W_ASY_HPP_INCLUDED
@ L2
field with C-1 continuity
Definition definitions.h:88
FTensor::Index< 'k', 3 > k
ArgumentType _asy(const ArgumentType &z, IndexType k=0)
ArgumentType _log_k(const ArgumentType &z, const IndexType &k)
const std::size_t _asy_series_L
ArgumentType _N1(const ArgumentType &z)
ArgumentType _asy_body(const ArgumentType &L1, const ArgumentType &L2)