v0.15.5
Loading...
Searching...
No Matches
lambert_w_mid.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_MID_HPP_INCLUDED
8#define BOOST_MATH_LAMBERT_W_MID_HPP_INCLUDED
9
10#include <cmath>
11#include <boost/array.hpp>
12#include "lambert_w_tools.hpp"
13
14namespace boost
15{
16namespace math
17{
18namespace lambw
19{
20 //Constant that controls series evaluation length
21 const std::size_t _mid_series_L = 8; //Does not actually have an effect yet
22
23 //Array to store the coefficients of the series expansion for W(exp(1+z)).
24 //It has a larger convergence radius than the Taylor and Laurent series, but smaller than the asymptotic.
25 template<class CoeffType>
26 inline const boost::array<CoeffType,_mid_series_L>& _lw_midc()
27 {
28 static const boost::array<CoeffType,_mid_series_L> ans = {
29 ((CoeffType)1./(CoeffType)2.),
30 ((CoeffType)1./(CoeffType)8.),
31 -((CoeffType)1./(CoeffType)12.),
32 ((CoeffType)1./(CoeffType)16.),
33 -((CoeffType)13./(CoeffType)20.),
34 -((CoeffType)47./(CoeffType)312.),
35 ((CoeffType)73./(CoeffType)1316.),
36 -((CoeffType)2447./(CoeffType)2336.)
37 };
38
39 return ans;
40 }
41
42 //Calculates the approximation of W(z) for mid-range values.
43 template<class ArgumentType, class CoeffType>
44 ArgumentType _mid(const ArgumentType &z)
45 {
46 using std::log;
47
48 ArgumentType x = log(z)-(CoeffType)1.;
49 return _series_sum(x,_lw_midc<CoeffType>());
50 }
51} //namespace lambw
52} //namespace math
53} //namespace boost
54
55#endif // BOOST_MATH_LAMBERT_W_MID_HPP_INCLUDED
const std::size_t _mid_series_L
ArgumentType _series_sum(const ArgumentType &z, const boost::array< CoeffType, L > &c)
ArgumentType _mid(const ArgumentType &z)
const boost::array< CoeffType, _mid_series_L > & _lw_midc()