holtsmark.hpp 148 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519
  1. // Copyright Takuma Yoshimura 2024.
  2. // Copyright Matt Borland 2024.
  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. #ifndef BOOST_STATS_HOLTSMARK_HPP
  7. #define BOOST_STATS_HOLTSMARK_HPP
  8. #ifdef _MSC_VER
  9. #pragma warning(push)
  10. #pragma warning(disable : 4127) // conditional expression is constant
  11. #endif
  12. #include <boost/math/tools/config.hpp>
  13. #include <boost/math/tools/numeric_limits.hpp>
  14. #include <boost/math/tools/tuple.hpp>
  15. #include <boost/math/tools/type_traits.hpp>
  16. #include <boost/math/constants/constants.hpp>
  17. #include <boost/math/distributions/complement.hpp>
  18. #include <boost/math/distributions/detail/common_error_handling.hpp>
  19. #include <boost/math/distributions/detail/derived_accessors.hpp>
  20. #include <boost/math/tools/rational.hpp>
  21. #include <boost/math/special_functions/cbrt.hpp>
  22. #include <boost/math/policies/policy.hpp>
  23. #include <boost/math/policies/error_handling.hpp>
  24. #include <boost/math/tools/promotion.hpp>
  25. #ifndef BOOST_MATH_HAS_NVRTC
  26. #include <boost/math/distributions/fwd.hpp>
  27. #include <boost/math/tools/big_constant.hpp>
  28. #include <utility>
  29. #include <cmath>
  30. #endif
  31. namespace boost { namespace math {
  32. template <class RealType, class Policy>
  33. class holtsmark_distribution;
  34. namespace detail {
  35. template <class RealType>
  36. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_pdf_plus_imp_prec(const RealType& x, const boost::math::integral_constant<int, 53>&)
  37. {
  38. BOOST_MATH_STD_USING
  39. RealType result;
  40. if (x < 1) {
  41. // Rational Approximation
  42. // Maximum Relative Error: 4.7894e-17
  43. BOOST_MATH_STATIC const RealType P[8] = {
  44. static_cast<RealType>(2.87352751452164445024e-1),
  45. static_cast<RealType>(1.18577398160636011811e-3),
  46. static_cast<RealType>(-2.16526599226820153260e-2),
  47. static_cast<RealType>(2.06462093371223113592e-3),
  48. static_cast<RealType>(2.43382128013710116747e-3),
  49. static_cast<RealType>(-2.15930711444603559520e-4),
  50. static_cast<RealType>(-1.04197836740809694657e-4),
  51. static_cast<RealType>(1.74679078247026597959e-5),
  52. };
  53. BOOST_MATH_STATIC const RealType Q[8] = {
  54. static_cast<RealType>(1.),
  55. static_cast<RealType>(4.12654472808214997252e-3),
  56. static_cast<RealType>(2.93891863033354755743e-1),
  57. static_cast<RealType>(8.70867222155141724171e-3),
  58. static_cast<RealType>(3.15027515421842640745e-2),
  59. static_cast<RealType>(2.11141832312672190669e-3),
  60. static_cast<RealType>(1.23545521355569424975e-3),
  61. static_cast<RealType>(1.58181113865348637475e-4),
  62. };
  63. result = tools::evaluate_polynomial(P, x) / tools::evaluate_polynomial(Q, x);
  64. }
  65. else if (x < 2) {
  66. RealType t = x - 1;
  67. // Rational Approximation
  68. // Maximum Relative Error: 3.0925e-17
  69. BOOST_MATH_STATIC const RealType P[8] = {
  70. static_cast<RealType>(2.02038159607840130389e-1),
  71. static_cast<RealType>(-1.20368541260123112191e-2),
  72. static_cast<RealType>(-3.19235497414059987151e-3),
  73. static_cast<RealType>(8.88546222140257289852e-3),
  74. static_cast<RealType>(-5.37287599824602316660e-4),
  75. static_cast<RealType>(-2.39059149972922243276e-4),
  76. static_cast<RealType>(9.19551014849109417931e-5),
  77. static_cast<RealType>(-8.45210544648986348854e-6),
  78. };
  79. BOOST_MATH_STATIC const RealType Q[8] = {
  80. static_cast<RealType>(1.),
  81. static_cast<RealType>(6.11634701234079515138e-1),
  82. static_cast<RealType>(4.39922162828115412952e-1),
  83. static_cast<RealType>(1.73609068791154078128e-1),
  84. static_cast<RealType>(6.15831808473403962054e-2),
  85. static_cast<RealType>(1.64364949550314788638e-2),
  86. static_cast<RealType>(2.94399615562137394932e-3),
  87. static_cast<RealType>(4.99662797033514776061e-4),
  88. };
  89. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  90. }
  91. else if (x < 4) {
  92. RealType t = x - 2;
  93. // Rational Approximation
  94. // Maximum Relative Error: 1.4499e-17
  95. BOOST_MATH_STATIC const RealType P[10] = {
  96. static_cast<RealType>(8.45396231261375200568e-2),
  97. static_cast<RealType>(-9.15509628797205847643e-3),
  98. static_cast<RealType>(1.82052933284907579374e-2),
  99. static_cast<RealType>(-2.44157914076021125182e-4),
  100. static_cast<RealType>(8.40871885414177705035e-4),
  101. static_cast<RealType>(7.26592615882060553326e-5),
  102. static_cast<RealType>(-1.87768359214600016641e-6),
  103. static_cast<RealType>(1.65716961206268668529e-6),
  104. static_cast<RealType>(-1.73979640146948858436e-7),
  105. static_cast<RealType>(7.24351142163396584236e-9),
  106. };
  107. BOOST_MATH_STATIC const RealType Q[9] = {
  108. static_cast<RealType>(1.),
  109. static_cast<RealType>(8.88099527896838765666e-1),
  110. static_cast<RealType>(6.53896948546877341992e-1),
  111. static_cast<RealType>(2.96296982585381844864e-1),
  112. static_cast<RealType>(1.14107585229341489833e-1),
  113. static_cast<RealType>(3.08914671331207488189e-2),
  114. static_cast<RealType>(7.03139384769200902107e-3),
  115. static_cast<RealType>(1.01201814277918577790e-3),
  116. static_cast<RealType>(1.12200113270398674535e-4),
  117. };
  118. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  119. }
  120. else if (x < 8) {
  121. RealType t = x - 4;
  122. // Rational Approximation
  123. // Maximum Relative Error: 6.5259e-17
  124. BOOST_MATH_STATIC const RealType P[11] = {
  125. static_cast<RealType>(1.36729417918039395222e-2),
  126. static_cast<RealType>(1.19749117683408419115e-2),
  127. static_cast<RealType>(6.26780921592414207398e-3),
  128. static_cast<RealType>(1.84846137440857608948e-3),
  129. static_cast<RealType>(3.39307829797262466829e-4),
  130. static_cast<RealType>(2.73606960463362090866e-5),
  131. static_cast<RealType>(-1.14419838471713498717e-7),
  132. static_cast<RealType>(1.64552336875610576993e-8),
  133. static_cast<RealType>(-7.95501797873739398143e-10),
  134. static_cast<RealType>(2.55422885338760255125e-11),
  135. static_cast<RealType>(-4.12196487201928768038e-13),
  136. };
  137. BOOST_MATH_STATIC const RealType Q[9] = {
  138. static_cast<RealType>(1.),
  139. static_cast<RealType>(1.61334003864149486454e0),
  140. static_cast<RealType>(1.28348868912975898501e0),
  141. static_cast<RealType>(6.36594545291321210154e-1),
  142. static_cast<RealType>(2.11478937436277242988e-1),
  143. static_cast<RealType>(4.71550897200311391579e-2),
  144. static_cast<RealType>(6.64679677197059316835e-3),
  145. static_cast<RealType>(4.93706832858615742810e-4),
  146. static_cast<RealType>(9.26919465059204396228e-6),
  147. };
  148. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  149. }
  150. else if (x < 16) {
  151. RealType t = x - 8;
  152. // Rational Approximation
  153. // Maximum Relative Error: 3.5084e-17
  154. BOOST_MATH_STATIC const RealType P[8] = {
  155. static_cast<RealType>(1.90649774685568282390e-3),
  156. static_cast<RealType>(7.43708409389806210196e-4),
  157. static_cast<RealType>(9.53777347766128955847e-5),
  158. static_cast<RealType>(3.79800193823252979170e-6),
  159. static_cast<RealType>(2.84836656088572745575e-8),
  160. static_cast<RealType>(-1.22715411241721187620e-10),
  161. static_cast<RealType>(8.56789906419220801109e-13),
  162. static_cast<RealType>(-4.17784858891714869163e-15),
  163. };
  164. BOOST_MATH_STATIC const RealType Q[7] = {
  165. static_cast<RealType>(1.),
  166. static_cast<RealType>(7.29383849235788831455e-1),
  167. static_cast<RealType>(2.16287201867831015266e-1),
  168. static_cast<RealType>(3.28789040872705709070e-2),
  169. static_cast<RealType>(2.64660789801664804789e-3),
  170. static_cast<RealType>(1.03662724048874906931e-4),
  171. static_cast<RealType>(1.47658125632566407978e-6),
  172. };
  173. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  174. }
  175. else if (x < 32) {
  176. RealType t = x - 16;
  177. // Rational Approximation
  178. // Maximum Relative Error: 1.4660e-19
  179. BOOST_MATH_STATIC const RealType P[9] = {
  180. static_cast<RealType>(3.07231582988207590928e-4),
  181. static_cast<RealType>(5.16108848485823513911e-5),
  182. static_cast<RealType>(3.05776014220862257678e-6),
  183. static_cast<RealType>(7.64787444325088143218e-8),
  184. static_cast<RealType>(7.40426355029090813961e-10),
  185. static_cast<RealType>(1.57451122102115077046e-12),
  186. static_cast<RealType>(-2.14505675750572782093e-15),
  187. static_cast<RealType>(5.11204601013038698192e-18),
  188. static_cast<RealType>(-9.00826023095223871551e-21),
  189. };
  190. BOOST_MATH_STATIC const RealType Q[8] = {
  191. static_cast<RealType>(1.),
  192. static_cast<RealType>(3.28966789835486457746e-1),
  193. static_cast<RealType>(4.46981634258601621625e-2),
  194. static_cast<RealType>(3.22521297380474263906e-3),
  195. static_cast<RealType>(1.31985203433890010111e-4),
  196. static_cast<RealType>(3.01507121087942156530e-6),
  197. static_cast<RealType>(3.47777238523841835495e-8),
  198. static_cast<RealType>(1.50780503777979189972e-10),
  199. };
  200. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  201. }
  202. else if (x < 64) {
  203. RealType t = x - 32;
  204. // Rational Approximation
  205. // Maximum Relative Error: 4.2292e-18
  206. BOOST_MATH_STATIC const RealType P[8] = {
  207. static_cast<RealType>(5.25741312407933720817e-5),
  208. static_cast<RealType>(2.34425802342454046697e-6),
  209. static_cast<RealType>(3.30042747965497652847e-8),
  210. static_cast<RealType>(1.58564820095683252738e-10),
  211. static_cast<RealType>(1.54070758384735212486e-13),
  212. static_cast<RealType>(-8.89232435250437247197e-17),
  213. static_cast<RealType>(8.14099948000080417199e-20),
  214. static_cast<RealType>(-4.61828164399178360925e-23),
  215. };
  216. BOOST_MATH_STATIC const RealType Q[7] = {
  217. static_cast<RealType>(1.),
  218. static_cast<RealType>(1.23544974283127158019e-1),
  219. static_cast<RealType>(6.01210465184576626802e-3),
  220. static_cast<RealType>(1.45390926665383063500e-4),
  221. static_cast<RealType>(1.80594709695117864840e-6),
  222. static_cast<RealType>(1.06088985542982155880e-8),
  223. static_cast<RealType>(2.20287881724613104903e-11),
  224. };
  225. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  226. }
  227. else {
  228. RealType t = 1 / sqrt(x * x * x);
  229. // Rational Approximation
  230. // Maximum Relative Error: 2.3004e-17
  231. BOOST_MATH_STATIC const RealType P[4] = {
  232. static_cast<RealType>(2.99206710301074508455e-1),
  233. static_cast<RealType>(-8.62469397757826072306e-1),
  234. static_cast<RealType>(1.74661995423629075890e-1),
  235. static_cast<RealType>(8.75909164947413479137e-1),
  236. };
  237. BOOST_MATH_STATIC const RealType Q[3] = {
  238. static_cast<RealType>(1.),
  239. static_cast<RealType>(-6.07405848111002255020e0),
  240. static_cast<RealType>(1.34068401972703571636e1),
  241. };
  242. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t) * t / x;
  243. }
  244. return result;
  245. }
  246. template <class RealType>
  247. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_pdf_plus_imp_prec(const RealType& x, const boost::math::integral_constant<int, 113>&)
  248. {
  249. BOOST_MATH_STD_USING
  250. RealType result;
  251. if (x < 1) {
  252. // Rational Approximation
  253. // Maximum Relative Error: 4.5215e-35
  254. // LCOV_EXCL_START
  255. BOOST_MATH_STATIC const RealType P[14] = {
  256. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.87352751452164445024482162286994868262e-1),
  257. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.07622509000285763173795736744991173600e-2),
  258. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.75004930885780661923539070646503039258e-2),
  259. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.72358602484766333657370198137154157310e-4),
  260. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.80082654994455046054228833198744292689e-3),
  261. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.53887200727615005180492399966262970151e-4),
  262. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.07684195532179300820096260852073763880e-4),
  263. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.39151986881253768780523679256708455051e-6),
  264. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.31700721746247708002568205696938014069e-6),
  265. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.52538425285394123789751606057231671946e-7),
  266. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.13997198703138372752313576244312091598e-8),
  267. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.74788965317036115104204201740144738267e-9),
  268. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.18994723428163008965406453309272880204e-10),
  269. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.49208308902369087634036371223527932419e-11),
  270. };
  271. BOOST_MATH_STATIC const RealType Q[15] = {
  272. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  273. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.07053963271862256947338846403373278592e-1),
  274. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.30146528469038357598785392812229655811e-1),
  275. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.22168809220570888957518451361426420755e-2),
  276. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.30911708477464424748895247790513118077e-2),
  277. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.32037605861909345291211474811347056388e-3),
  278. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.37380742268959889784160508321242249326e-3),
  279. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.17777859396994816599172003124202701362e-4),
  280. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.69357597449425742856874347560067711953e-4),
  281. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.22061268498705703002731594804187464212e-5),
  282. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.03685918248668999775572498175163352453e-5),
  283. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.42037705933347925911510259098903765388e-6),
  284. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.13651251802353350402740200231061151003e-7),
  285. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.15390928968620849348804301589542546367e-8),
  286. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.96186359077726620124148756657971390386e-9),
  287. };
  288. // LCOV_EXCL_STOP
  289. result = tools::evaluate_polynomial(P, x) / tools::evaluate_polynomial(Q, x);
  290. }
  291. else if (x < 2) {
  292. RealType t = x - 1;
  293. // Rational Approximation
  294. // Maximum Relative Error: 1.3996e-35
  295. // LCOV_EXCL_START
  296. BOOST_MATH_STATIC const RealType P[14] = {
  297. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.02038159607840130388931544845552929992e-1),
  298. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.85240836242909590376775233472494840074e-2),
  299. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.92928437142375928121954427888812334305e-2),
  300. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.56075992368354834619445578502239925632e-3),
  301. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.85410663490566091471288623735720924369e-3),
  302. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.09160661432404033681463938555133581443e-4),
  303. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.60290555290385646856693819798655258098e-4),
  304. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.24420942563054709904053017769325945705e-5),
  305. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.06370233020823161157791461691510091864e-6),
  306. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.51562554221298564845071290898761434388e-7),
  307. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.77361020844998296791409508640756247324e-8),
  308. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.10768937536097342883548728871352580308e-9),
  309. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.97810512763454658214572490850146305033e-10),
  310. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.77430867682132459087084564268263825239e-11),
  311. };
  312. BOOST_MATH_STATIC const RealType Q[15] = {
  313. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  314. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.30030169049261634787262795838348954434e-1),
  315. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.45935676273909940847479638179887855033e-1),
  316. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.14724239378269259016679286177700667008e-1),
  317. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.21580123796578745240828564510740594111e-1),
  318. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.70287348745451818082884807214512422940e-2),
  319. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.46859813604124308580987785473592196488e-2),
  320. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.49627445316021031361394030382456867983e-3),
  321. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.05157712406194406440213776605199788051e-3),
  322. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.91541875103990251411297099611180353187e-4),
  323. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.47960462287955806798879139599079388744e-5),
  324. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.80126815763067695392857052825785263211e-6),
  325. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.04569118116204820761181992270024358122e-6),
  326. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.63024381269503801668229632579505279520e-8),
  327. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.00967434338725770754103109040982001783e-8),
  328. };
  329. // LCOV_EXCL_STOP
  330. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  331. }
  332. else if (x < 4) {
  333. RealType t = x - 2;
  334. // Rational Approximation
  335. // Maximum Relative Error: 1.6834e-35
  336. // LCOV_EXCL_START
  337. BOOST_MATH_STATIC const RealType P[17] = {
  338. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.45396231261375200568114750897618690566e-2),
  339. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.83107635287140466760500899510899613385e-3),
  340. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.71690205829238281191309321676655995475e-2),
  341. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.95995611963950467634398178757261552497e-3),
  342. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.52444689050426648467863527289016233648e-3),
  343. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.40423239472181137610649503303203209123e-4),
  344. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.72181273738390251101985797318639680476e-4),
  345. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.11423032981781501087311583401963332916e-5),
  346. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.37255768388351332508195641748235373885e-5),
  347. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.25140171472943043666747084376053803301e-6),
  348. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.98925617316135247540832898350427842870e-7),
  349. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.27532592227329144332335468302536835334e-8),
  350. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.25846339430429852334026937219420930290e-9),
  351. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.17852693845678292024334670662803641322e-10),
  352. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.60008761860786244203651832067697976835e-11),
  353. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.85474213475378978699789357283744252832e-13),
  354. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.05561259222780127064607109581719435800e-15),
  355. };
  356. BOOST_MATH_STATIC const RealType Q[17] = {
  357. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  358. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.08902510590064634965634560548380735284e0),
  359. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.60127698266075086782895988567899172787e-1),
  360. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.73299227011247478433171171063045855612e-1),
  361. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.94019328695445269130845646745771017029e-1),
  362. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.21478511930928822349285105322914093227e-1),
  363. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.42888485420705779382804725954524839381e-2),
  364. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.36839484685440714657854206969200824442e-2),
  365. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.77082068469251728028552451884848161629e-3),
  366. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.92625563541021144576900067220082880950e-4),
  367. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.88302521658522279293312672887766072876e-4),
  368. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.37703703342287521257351386589629343948e-5),
  369. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.32454189932655869016489443530062686013e-6),
  370. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.81822848072558151338694737514507945151e-7),
  371. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.40176559099032106726456059226930240477e-8),
  372. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.55722115663529425797132143276461872035e-9),
  373. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.18236697046568703899375072798708359035e-10),
  374. };
  375. // LCOV_EXCL_STOP
  376. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  377. }
  378. else if (x < 8) {
  379. RealType t = x - 4;
  380. // Rational Approximation
  381. // Maximum Relative Error: 5.6207e-35
  382. // LCOV_EXCL_START
  383. BOOST_MATH_STATIC const RealType P[20] = {
  384. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.36729417918039395222067998266923903488e-2),
  385. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.05780369334958736210688756060527042344e-2),
  386. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.88449456199223796440901487003885388570e-2),
  387. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.20213624124017393492512893302682417041e-2),
  388. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.95009975955570002297453163471062373746e-3),
  389. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.35668345583965001606910217518443864382e-3),
  390. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.69006847702829685253055277085000792826e-4),
  391. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.08366922884479491780654020783735539561e-4),
  392. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.71834368599657597252633517017213868956e-5),
  393. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.88269472722301903965736220481240654265e-6),
  394. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.37797139843759131750966129487745639531e-6),
  395. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.72390971590654495025982276782257590019e-7),
  396. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.68354503497961090303189233611418754374e-8),
  397. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.20749461042713568368181066233478264894e-9),
  398. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.71167265100639100355339812752823628805e-11),
  399. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.37497033071709741762372104386727560387e-12),
  400. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.08992504249040731356693038222581843266e-15),
  401. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.03311745412603363076896897060158476094e-17),
  402. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.89266184062176002518506060373755160893e-19),
  403. BOOST_MATH_BIG_CONSTANT(RealType, 113, -8.22157263424086267338486564980223658130e-22),
  404. };
  405. BOOST_MATH_STATIC const RealType Q[19] = {
  406. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  407. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.24254809760594824834854946949546737102e0),
  408. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.66740386908805016172202899592418717176e0),
  409. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.17175023341071972435947261868288366592e0),
  410. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.33939409711833786730168591434519989589e0),
  411. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.58859674176126567295417811572162232222e-1),
  412. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.66346764121676348703738437519493817401e-1),
  413. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.00687534341032230207422557716131339293e-2),
  414. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.57352381181825892637055619366793541271e-2),
  415. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.23955067096868711061473058513398543786e-3),
  416. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.28279376429637301814743591831507047825e-3),
  417. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.22380760186302431267562571014519501842e-4),
  418. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.21421839279245792393425090284615681867e-5),
  419. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.80151544531415207189620615654737831345e-6),
  420. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.57177992740786529976179511261318869505e-7),
  421. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.54223623314672019530719165336863142227e-8),
  422. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.26447311109866547647645308621478963788e-9),
  423. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.76514314007336173875469200193103772775e-11),
  424. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.63785420481380041892410849615596985103e-13),
  425. };
  426. // LCOV_EXCL_STOP
  427. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  428. }
  429. else if (x < 16) {
  430. RealType t = x - 8;
  431. // Rational Approximation
  432. // Maximum Relative Error: 6.8882e-35
  433. // LCOV_EXCL_START
  434. BOOST_MATH_STATIC const RealType P[17] = {
  435. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.90649774685568282389553481307707005425e-3),
  436. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.70151946710788532273869130544473159961e-3),
  437. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.76188245008605985768921328976193346788e-3),
  438. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.94997481586873355765607596415761713534e-4),
  439. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.83556339450065349619118429405554762845e-4),
  440. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.39766178753196196595432796889473826698e-5),
  441. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.48835240264191055418415753552383932859e-6),
  442. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.23205178959384483669515397903609703992e-7),
  443. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.80665018951397281836428650435128239368e-8),
  444. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.27113208299726105096854812628329439191e-9),
  445. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.75272882929773945317046764560516449105e-11),
  446. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.73174017370926101455204470047842394787e-13),
  447. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.55548825213165929101134655786361059720e-15),
  448. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.79786015549170518239230891794588988732e-17),
  449. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.73060731998834750292816218696923192789e-20),
  450. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.62842837946576938669447109511449827857e-23),
  451. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.33878078951302606409419167741041897986e-26),
  452. };
  453. BOOST_MATH_STATIC const RealType Q[17] = {
  454. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  455. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.75629880937514507004822969528240262723e0),
  456. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.43883005193126748135739157335919076027e0),
  457. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.26826935326347315479579835343751624245e-1),
  458. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.52263130214924169696993839078084050641e-1),
  459. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.34708681216662922818631865761136370252e-2),
  460. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.19079618273418070513605131981401070622e-2),
  461. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.68812668867590621701228940772852924670e-3),
  462. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.81323523265546812020317698573638573275e-4),
  463. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.46655191174052062382710487986225631851e-5),
  464. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.79864553144116347379916608661549264281e-7),
  465. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.81866770335021233700248077520029108331e-8),
  466. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.15408288688082935176022095799735538723e-9),
  467. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.29421875915133979067465908221270435168e-11),
  468. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.74564282803894180881025348633912184161e-13),
  469. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.69782249847887916810010605635064672269e-15),
  470. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.85875986197737611300062229945990879767e-18),
  471. };
  472. // LCOV_EXCL_STOP
  473. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  474. }
  475. else if (x < 32) {
  476. RealType t = x - 16;
  477. // Rational Approximation
  478. // Maximum Relative Error: 2.7988e-35
  479. // LCOV_EXCL_START
  480. BOOST_MATH_STATIC const RealType P[15] = {
  481. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.07231582988207590928480356376941073734e-4),
  482. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.35574911514921623999866392865480652576e-4),
  483. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.60219401814297026945664630716309317015e-5),
  484. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.84927222345566515103807882976184811760e-6),
  485. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.96327408363203008584583124982694689234e-7),
  486. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.86684048703029160378252571846517319101e-9),
  487. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.65469175974819997602752600929172261626e-10),
  488. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.21842057555380199566706533446991680612e-12),
  489. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.53555106309423641769303386628162522042e-14),
  490. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.92686543698369260585325449306538016446e-16),
  491. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.01838615452860702770059987567879856504e-18),
  492. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.65492535746962514730615062374864701860e-21),
  493. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.53395563720606494853374354984531107080e-24),
  494. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.99957357701259203151690416786669242677e-28),
  495. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.46357124817620384236108395837490629563e-31),
  496. };
  497. BOOST_MATH_STATIC const RealType Q[15] = {
  498. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  499. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.02259092175256156108200465685980768901e-1),
  500. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.63438230616954606028022008517920766366e-1),
  501. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.63880061357592661176130881772975919418e-2),
  502. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.81911305852397235014131637306820512975e-3),
  503. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.09690724408294608306577482852270088377e-4),
  504. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.11275552068434583356476295833517496456e-5),
  505. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.24681861037105338446379750828324925566e-7),
  506. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.16034379416965004687140768474445096709e-8),
  507. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.23234481703249409689976894391287818596e-10),
  508. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.93297387560911081670605071704642179017e-12),
  509. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.50338428974314371000017727660753886621e-14),
  510. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.27897854868353937080739431205940604582e-16),
  511. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.37798740524930029176790562876868493344e-19),
  512. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.29920082153439260734550295626576101192e-22),
  513. };
  514. // LCOV_EXCL_STOP
  515. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  516. }
  517. else if (x < 64) {
  518. RealType t = x - 32;
  519. // Rational Approximation
  520. // Maximum Relative Error: 6.9688e-36
  521. // LCOV_EXCL_START
  522. BOOST_MATH_STATIC const RealType P[15] = {
  523. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.25741312407933720816582583160953651639e-5),
  524. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.04434146174674791036848306058526901384e-6),
  525. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.68959516304795838166182070164492846877e-7),
  526. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.78859935261158263390023581309925613858e-8),
  527. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.21854067989018450973827853792407054510e-10),
  528. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.20573856697340412957421887367218135538e-11),
  529. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.30843538021351383101589538141878424462e-13),
  530. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.05991458689384045976214216819611949900e-16),
  531. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.82253708752556965233757129893944884411e-18),
  532. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.97645331663303764054986066027964294209e-21),
  533. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.69353366461654917577775981574517182648e-24),
  534. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.59050144462227302681332505386238071973e-27),
  535. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.85165507189649330971049854127575847359e-31),
  536. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.70711310565669331853925519429988855964e-34),
  537. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.72047006026700174884151916064158941262e-38),
  538. };
  539. BOOST_MATH_STATIC const RealType Q[14] = {
  540. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  541. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.50985661940624198574968436548711898948e-1),
  542. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.81705882167596649186405364717835589894e-2),
  543. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.86537779048672498307196786015602357729e-3),
  544. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.09555188550938733096253930959407749063e-5),
  545. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.41930442687159455334801545898059105733e-6),
  546. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.09084284266255183930305946875294557622e-8),
  547. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.58122754063904909636061457739518406730e-10),
  548. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.91800215912676651584368499126132687326e-12),
  549. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.66413330532845384974993669138524203429e-14),
  550. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.65919563020196445006309683624384862816e-16),
  551. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.61596083414169579692212575079167989319e-19),
  552. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.16321386033703806802403099255708972015e-21),
  553. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.90892719803158002834365234646982537288e-25),
  554. };
  555. // LCOV_EXCL_STOP
  556. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  557. }
  558. else {
  559. RealType t = 1 / sqrt(x * x * x);
  560. // Rational Approximation
  561. // Maximum Relative Error: 3.0545e-39
  562. // LCOV_EXCL_START
  563. BOOST_MATH_STATIC const RealType P[8] = {
  564. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.99206710301074508454959544950786401357e-1),
  565. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.75243304700875633383991614142545185173e0),
  566. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.69652690455351600373808930804785330828e1),
  567. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.36233941060408773406522171349397343951e2),
  568. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.28958973553713980463808202034854958375e2),
  569. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.55704950313835982743029388151551925282e2),
  570. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.28767698270323629107775935552991333781e2),
  571. BOOST_MATH_BIG_CONSTANT(RealType, 113, -8.80591252844738626580182351673066365090e1),
  572. };
  573. BOOST_MATH_STATIC const RealType Q[7] = {
  574. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  575. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.57593243741246726197476469913307836496e1),
  576. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.99458751269722094414105565700775283458e2),
  577. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.91043982880665229427553316951582511317e3),
  578. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.99054490423334526438490907473548839751e3),
  579. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.36948968143124830402744607365089118030e4),
  580. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.13781639547150826385071482161074041168e4),
  581. };
  582. // LCOV_EXCL_STOP
  583. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t) * t / x;
  584. }
  585. return result;
  586. }
  587. template <class RealType>
  588. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_pdf_imp_prec(const RealType& x, const boost::math::integral_constant<int, 53> &tag) {
  589. BOOST_MATH_STD_USING // for ADL of std functions
  590. return holtsmark_pdf_plus_imp_prec<RealType>(abs(x), tag);
  591. }
  592. template <class RealType>
  593. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_pdf_imp_prec(const RealType& x, const boost::math::integral_constant<int, 113>& tag) {
  594. BOOST_MATH_STD_USING // for ADL of std functions
  595. return holtsmark_pdf_plus_imp_prec<RealType>(abs(x), tag);
  596. }
  597. template <class RealType, class Policy>
  598. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_pdf_imp(const holtsmark_distribution<RealType, Policy>& dist, const RealType& x) {
  599. //
  600. // This calculates the pdf of the Holtsmark distribution and/or its complement.
  601. //
  602. BOOST_MATH_STD_USING // for ADL of std functions
  603. constexpr auto function = "boost::math::pdf(holtsmark<%1%>&, %1%)";
  604. RealType result = 0;
  605. RealType location = dist.location();
  606. RealType scale = dist.scale();
  607. if (false == detail::check_location(function, location, &result, Policy()))
  608. {
  609. return result;
  610. }
  611. if (false == detail::check_scale(function, scale, &result, Policy()))
  612. {
  613. return result;
  614. }
  615. if (false == detail::check_x(function, x, &result, Policy()))
  616. {
  617. return result;
  618. }
  619. typedef typename tools::promote_args<RealType>::type result_type;
  620. typedef typename policies::precision<result_type, Policy>::type precision_type;
  621. typedef boost::math::integral_constant<int,
  622. precision_type::value <= 0 ? 0 :
  623. precision_type::value <= 53 ? 53 :
  624. precision_type::value <= 113 ? 113 : 0
  625. > tag_type;
  626. static_assert(tag_type::value, "The Holtsmark distribution is only implemented for types with known precision, and 113 bits or fewer in the mantissa (ie 128 bit quad-floats");
  627. RealType u = (x - location) / scale;
  628. result = holtsmark_pdf_imp_prec(u, tag_type()) / scale;
  629. return result;
  630. }
  631. template <class RealType>
  632. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_cdf_plus_imp_prec(const RealType& x, const boost::math::integral_constant<int, 53>&)
  633. {
  634. BOOST_MATH_STD_USING
  635. RealType result;
  636. if (x < 0.5) {
  637. // Rational Approximation
  638. // Maximum Relative Error: 1.3147e-17
  639. BOOST_MATH_STATIC const RealType P[6] = {
  640. static_cast<RealType>(5.0e-1),
  641. static_cast<RealType>(-1.34752580674786639030e-1),
  642. static_cast<RealType>(1.86318418252163378528e-2),
  643. static_cast<RealType>(1.04499798132512381447e-2),
  644. static_cast<RealType>(-1.60831910014592923855e-3),
  645. static_cast<RealType>(1.38823662364438342844e-4),
  646. };
  647. BOOST_MATH_STATIC const RealType Q[7] = {
  648. static_cast<RealType>(1.),
  649. static_cast<RealType>(3.05200341554753776087e-1),
  650. static_cast<RealType>(2.12663999430421346175e-1),
  651. static_cast<RealType>(7.23836000984872591553e-2),
  652. static_cast<RealType>(1.67941072412796299986e-2),
  653. static_cast<RealType>(4.71213644318790580839e-3),
  654. static_cast<RealType>(5.86825130959777535991e-4),
  655. };
  656. result = tools::evaluate_polynomial(P, x) / tools::evaluate_polynomial(Q, x);
  657. }
  658. else if (x < 1) {
  659. RealType t = x - 0.5f;
  660. // Rational Approximation
  661. // Maximum Relative Error: 1.6265e-18
  662. BOOST_MATH_STATIC const RealType P[7] = {
  663. static_cast<RealType>(3.60595773518728397351e-1),
  664. static_cast<RealType>(5.75238626843218819756e-1),
  665. static_cast<RealType>(-3.31245319943021227117e-1),
  666. static_cast<RealType>(1.48132966310216368831e-1),
  667. static_cast<RealType>(-2.32875122617713403365e-2),
  668. static_cast<RealType>(2.08038303148835575624e-3),
  669. static_cast<RealType>(6.01511310581302829460e-6),
  670. };
  671. BOOST_MATH_STATIC const RealType Q[7] = {
  672. static_cast<RealType>(1.),
  673. static_cast<RealType>(2.32264360456739861886e0),
  674. static_cast<RealType>(6.39715443864749851087e-1),
  675. static_cast<RealType>(5.03940458163958921325e-1),
  676. static_cast<RealType>(8.84780893031413729292e-2),
  677. static_cast<RealType>(3.01497774031208621961e-2),
  678. static_cast<RealType>(3.45886005612108195390e-3),
  679. };
  680. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  681. }
  682. else if (x < 2) {
  683. RealType t = x - 1;
  684. // Rational Approximation
  685. // Maximum Relative Error: 7.4398e-20
  686. BOOST_MATH_STATIC const RealType P[8] = {
  687. static_cast<RealType>(2.43657975600729535515e-1),
  688. static_cast<RealType>(-6.02286263626532324632e-2),
  689. static_cast<RealType>(4.68361231392743283350e-2),
  690. static_cast<RealType>(-1.13497179885838883972e-3),
  691. static_cast<RealType>(1.20141595689136205012e-3),
  692. static_cast<RealType>(3.02402304689333413256e-4),
  693. static_cast<RealType>(-1.22652173865646814676e-6),
  694. static_cast<RealType>(2.29521832683440044997e-6),
  695. };
  696. BOOST_MATH_STATIC const RealType Q[9] = {
  697. static_cast<RealType>(1.),
  698. static_cast<RealType>(5.82002427359748247121e-1),
  699. static_cast<RealType>(3.96529686558825119743e-1),
  700. static_cast<RealType>(1.49690294526117385174e-1),
  701. static_cast<RealType>(5.15049953937764895435e-2),
  702. static_cast<RealType>(1.30218216530450637564e-2),
  703. static_cast<RealType>(2.53640337919037463659e-3),
  704. static_cast<RealType>(3.79575042317720710311e-4),
  705. static_cast<RealType>(2.94034997185982139717e-5),
  706. };
  707. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  708. }
  709. else if (x < 4) {
  710. RealType t = x - 2;
  711. // Rational Approximation
  712. // Maximum Relative Error: 5.6148e-17
  713. BOOST_MATH_STATIC const RealType P[9] = {
  714. static_cast<RealType>(1.05039829654829164883e-1),
  715. static_cast<RealType>(1.66621813028423002562e-2),
  716. static_cast<RealType>(2.93820049104275137099e-2),
  717. static_cast<RealType>(3.36850260303189378587e-3),
  718. static_cast<RealType>(2.27925819398326978014e-3),
  719. static_cast<RealType>(1.66394162680543987783e-4),
  720. static_cast<RealType>(4.51400415642703075050e-5),
  721. static_cast<RealType>(2.12164734714059446913e-7),
  722. static_cast<RealType>(1.69306881760242775488e-8),
  723. };
  724. BOOST_MATH_STATIC const RealType Q[9] = {
  725. static_cast<RealType>(1.),
  726. static_cast<RealType>(9.63461239051296108254e-1),
  727. static_cast<RealType>(6.54183344973801096611e-1),
  728. static_cast<RealType>(2.92007762594247903696e-1),
  729. static_cast<RealType>(1.00918751132022401499e-1),
  730. static_cast<RealType>(2.55899135910670703945e-2),
  731. static_cast<RealType>(4.85740416919283630358e-3),
  732. static_cast<RealType>(6.11435190489589619906e-4),
  733. static_cast<RealType>(4.10953248859973756440e-5),
  734. };
  735. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  736. }
  737. else if (x < 8) {
  738. RealType t = x - 4;
  739. // Rational Approximation
  740. // Maximum Relative Error: 6.5866e-17
  741. BOOST_MATH_STATIC const RealType P[8] = {
  742. static_cast<RealType>(3.05754562114095142887e-2),
  743. static_cast<RealType>(3.25462617990002726083e-2),
  744. static_cast<RealType>(1.78205524297204753048e-2),
  745. static_cast<RealType>(5.61565369088816402420e-3),
  746. static_cast<RealType>(1.05695297340067353106e-3),
  747. static_cast<RealType>(9.93588579804511250576e-5),
  748. static_cast<RealType>(2.94302107205379334662e-6),
  749. static_cast<RealType>(1.09016076876928010898e-8),
  750. };
  751. BOOST_MATH_STATIC const RealType Q[9] = {
  752. static_cast<RealType>(1.),
  753. static_cast<RealType>(1.51164395622515150122e0),
  754. static_cast<RealType>(1.09391911233213526071e0),
  755. static_cast<RealType>(4.77950346062744800732e-1),
  756. static_cast<RealType>(1.34082684956852773925e-1),
  757. static_cast<RealType>(2.37572579895639589816e-2),
  758. static_cast<RealType>(2.41806218388337284640e-3),
  759. static_cast<RealType>(1.10378140456646280084e-4),
  760. static_cast<RealType>(1.31559373832822136249e-6),
  761. };
  762. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  763. }
  764. else if (x < 16) {
  765. RealType t = x - 8;
  766. // Rational Approximation
  767. // Maximum Relative Error: 5.6575e-17
  768. BOOST_MATH_STATIC const RealType P[8] = {
  769. static_cast<RealType>(9.47408470248235718880e-3),
  770. static_cast<RealType>(4.70888722333356024081e-3),
  771. static_cast<RealType>(8.66397831692913140221e-4),
  772. static_cast<RealType>(7.11721056656424862090e-5),
  773. static_cast<RealType>(2.56320582355149253994e-6),
  774. static_cast<RealType>(3.37749186035552101702e-8),
  775. static_cast<RealType>(8.32182844837952178153e-11),
  776. static_cast<RealType>(-8.80541360484428526226e-14),
  777. };
  778. BOOST_MATH_STATIC const RealType Q[8] = {
  779. static_cast<RealType>(1.),
  780. static_cast<RealType>(6.98261117346347123707e-1),
  781. static_cast<RealType>(1.97823959738695249267e-1),
  782. static_cast<RealType>(2.89311735096848395080e-2),
  783. static_cast<RealType>(2.30087055379997473849e-3),
  784. static_cast<RealType>(9.60592522700377510007e-5),
  785. static_cast<RealType>(1.84474415187428058231e-6),
  786. static_cast<RealType>(1.14339998084523151203e-8),
  787. };
  788. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  789. }
  790. else if (x < 32) {
  791. RealType t = x - 16;
  792. // Rational Approximation
  793. // Maximum Relative Error: 1.4164e-17
  794. BOOST_MATH_STATIC const RealType P[8] = {
  795. static_cast<RealType>(3.19610991747326729867e-3),
  796. static_cast<RealType>(5.11880074251341162590e-4),
  797. static_cast<RealType>(2.80704092977662888563e-5),
  798. static_cast<RealType>(6.31310155466346114729e-7),
  799. static_cast<RealType>(5.29618446795457166842e-9),
  800. static_cast<RealType>(9.20292337847562746519e-12),
  801. static_cast<RealType>(-9.16761719448360345363e-15),
  802. static_cast<RealType>(1.20433396121606479712e-17),
  803. };
  804. BOOST_MATH_STATIC const RealType Q[7] = {
  805. static_cast<RealType>(1.),
  806. static_cast<RealType>(2.56283944667056551858e-1),
  807. static_cast<RealType>(2.56811818304462676948e-2),
  808. static_cast<RealType>(1.26678062261253559927e-3),
  809. static_cast<RealType>(3.17001344827541091252e-5),
  810. static_cast<RealType>(3.68737201224811007437e-7),
  811. static_cast<RealType>(1.47625352605312785910e-9),
  812. };
  813. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  814. }
  815. else if (x < 64) {
  816. RealType t = x - 32;
  817. // Rational Approximation
  818. // Maximum Relative Error: 9.2537e-18
  819. BOOST_MATH_STATIC const RealType P[8] = {
  820. static_cast<RealType>(1.11172037056341397612e-3),
  821. static_cast<RealType>(7.84545643188695076893e-5),
  822. static_cast<RealType>(1.94862940242223222641e-6),
  823. static_cast<RealType>(2.02704958737259525509e-8),
  824. static_cast<RealType>(7.99772378955335076832e-11),
  825. static_cast<RealType>(6.62544230949971310060e-14),
  826. static_cast<RealType>(-3.18234118727325492149e-17),
  827. static_cast<RealType>(2.03424457039308806437e-20),
  828. };
  829. BOOST_MATH_STATIC const RealType Q[7] = {
  830. static_cast<RealType>(1.),
  831. static_cast<RealType>(1.17861198759233241198e-1),
  832. static_cast<RealType>(5.45962263583663240699e-3),
  833. static_cast<RealType>(1.25274651876378267111e-4),
  834. static_cast<RealType>(1.46857544539612002745e-6),
  835. static_cast<RealType>(8.06441204620771968579e-9),
  836. static_cast<RealType>(1.53682779460286464073e-11),
  837. };
  838. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  839. }
  840. else {
  841. RealType x_cube = x * x * x;
  842. RealType t = static_cast<RealType>((boost::math::isnormal)(x_cube) ? 1 / sqrt(x_cube) : 1 / pow(sqrt(x), 3));
  843. // Rational Approximation
  844. // Maximum Relative Error: 4.2897e-18
  845. BOOST_MATH_STATIC const RealType P[4] = {
  846. static_cast<RealType>(1.99471140200716338970e-1),
  847. static_cast<RealType>(-6.90933799347184400422e-1),
  848. static_cast<RealType>(4.30385245884336871950e-1),
  849. static_cast<RealType>(3.52790131116013716885e-1),
  850. };
  851. BOOST_MATH_STATIC const RealType Q[3] = {
  852. static_cast<RealType>(1.),
  853. static_cast<RealType>(-5.05959751628952574534e0),
  854. static_cast<RealType>(8.04408113719341786819e0),
  855. };
  856. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t) * t;
  857. }
  858. return result;
  859. }
  860. template <class RealType>
  861. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_cdf_plus_imp_prec(const RealType& x, const boost::math::integral_constant<int, 113>&)
  862. {
  863. BOOST_MATH_STD_USING
  864. RealType result;
  865. if (x < 0.5) {
  866. // Rational Approximation
  867. // Maximum Relative Error: 8.6635e-36
  868. // LCOV_EXCL_START
  869. BOOST_MATH_STATIC const RealType P[12] = {
  870. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.0e-1),
  871. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.48548242430636907136192799540229598637e-1),
  872. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.31541453581608245475805834922621529866e-1),
  873. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.16579064508490250336159593502955219069e-2),
  874. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.61598809551362112011328341554044706550e-2),
  875. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.15119245273512554325709429759983470969e-3),
  876. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.02145196753734867721148927112307708045e-3),
  877. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.90817224464950088663183617156145065001e-4),
  878. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.69596202760983052482358128481956242532e-5),
  879. BOOST_MATH_BIG_CONSTANT(RealType, 113, -5.50461337222845025623869078372182437091e-6),
  880. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.62777995800923647521692709390412901586e-7),
  881. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.63937253747323898965514197114021890186e-8),
  882. };
  883. BOOST_MATH_STATIC const RealType Q[12] = {
  884. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  885. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.76090180430550757765787254935343576341e-2),
  886. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.07685236907561593034104428156351640194e-1),
  887. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.27770556484351179553611274487979706736e-2),
  888. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.99201460869149634331004096815257398515e-2),
  889. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.70139000408086498153685620963430185837e-3),
  890. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.74682544708653069148470666809094453722e-3),
  891. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.57607114117485446922700160080966856243e-4),
  892. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.01069214414741946409122492979083487977e-4),
  893. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.19996282759031441186748256811206136921e-6),
  894. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.60933466092746543579699079418115420013e-6),
  895. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.92780739162611243933581782562159603862e-8),
  896. };
  897. // LCOV_EXCL_STOP
  898. result = tools::evaluate_polynomial(P, x) / tools::evaluate_polynomial(Q, x);
  899. }
  900. else if (x < 1) {
  901. RealType t = x - 0.5;
  902. // Rational Approximation
  903. // Maximum Relative Error: 7.1235e-35
  904. // LCOV_EXCL_START
  905. BOOST_MATH_STATIC const RealType P[12] = {
  906. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.60595773518728397925852903878144761766e-1),
  907. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.46999595154527091473427440379143006753e-1),
  908. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.36962313432466566724352608642383560211e-2),
  909. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.08387290167105915393692028475888846796e-2),
  910. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.34156151832478939276011262838869269011e-2),
  911. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.15970594471853166393830585755485842021e-3),
  912. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.47022841547527682761332752928069503835e-3),
  913. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.01955019188793323293925482112543902560e-4),
  914. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.03069493388735516695142799880566783261e-4),
  915. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.61367662035593735709965982000611000987e-5),
  916. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.62800430658278408539398798888955969345e-6),
  917. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.22300086876618079439960709120163780513e-8),
  918. };
  919. BOOST_MATH_STATIC const RealType Q[12] = {
  920. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  921. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.19740977756009966244249035150363085180e-1),
  922. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.39394884078938560974435920719979860046e-1),
  923. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.97107758486905601309707335353809421910e-2),
  924. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.36594079604957733960211938310153276332e-2),
  925. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.85712904264673773213248691029253356702e-4),
  926. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.87605080555629969548037543637523346061e-3),
  927. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.26356599628579249350545909071984757938e-4),
  928. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.79582114368994462181480978781382155103e-4),
  929. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.00970375323007336435151032145023199020e-5),
  930. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.06528824060244313614177859412028348352e-6),
  931. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.13914667697998291289987140319652513139e-7),
  932. };
  933. // LCOV_EXCL_STOP
  934. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  935. }
  936. else if (x < 2) {
  937. RealType t = x - 1;
  938. // Rational Approximation
  939. // Maximum Relative Error: 6.7659e-38
  940. // LCOV_EXCL_START
  941. BOOST_MATH_STATIC const RealType P[14] = {
  942. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.43657975600729535499895880792984203140e-1),
  943. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.37090874182351552816526775008685285108e-2),
  944. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.70793783828569126853147999925198280654e-2),
  945. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.27295555253412802819195403503721983066e-3),
  946. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.95916890788873842705597506423512639342e-3),
  947. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.93625795791721417553345795882983866640e-4),
  948. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.73237387099610415336810752053706403935e-4),
  949. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.08118655139419640900853055479087235138e-5),
  950. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.74920069862339840183963818219485580710e-5),
  951. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.59015304773612605296533206093582658838e-6),
  952. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.57256820413579442950151375512313072105e-7),
  953. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.36240848333000575199740403759568680951e-8),
  954. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.53890585580518120552628221662318725825e-9),
  955. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.59245311730292556271235324976832000740e-10),
  956. };
  957. BOOST_MATH_STATIC const RealType Q[16] = {
  958. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  959. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.49800491033591771256676595185869442663e-1),
  960. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.35827615015880595229881139361463765537e-1),
  961. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.41657125931991211322147702760511651998e-1),
  962. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.11782602975553967179829921562737846592e-1),
  963. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.79410805176258968660086532862367842847e-2),
  964. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.22872839892405613311532856773434270554e-2),
  965. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.23742349724658114137235071924317934569e-3),
  966. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.80350762663884259375711329227548815674e-4),
  967. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.59501693037547119094683008622867020131e-4),
  968. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.86068186167498269806443077840917848151e-5),
  969. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.36940342373887783231154918541990667741e-6),
  970. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.48911186460768204167014270878839691938e-7),
  971. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.55051094964993052272146587430780404904e-8),
  972. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.96312716130620326771080033656930839768e-9),
  973. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.45496951385730104726429368791951742738e-10),
  974. };
  975. // LCOV_EXCL_STOP
  976. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  977. }
  978. else if (x < 4) {
  979. RealType t = x - 2;
  980. // Rational Approximation
  981. // Maximum Relative Error: 9.9091e-35
  982. // LCOV_EXCL_START
  983. BOOST_MATH_STATIC const RealType P[17] = {
  984. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.05039829654829170780787685299556996311e-1),
  985. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.28948022754388615368533934448107849329e-2),
  986. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.34139151583225691775740839359914493385e-2),
  987. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.13366377215523066657592295006960955345e-2),
  988. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.08045462837998791188853367062130086996e-2),
  989. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.37648565386728404881404199616182064711e-3),
  990. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.14881702523183566448187346081007871684e-3),
  991. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.73169022445183613027772635992366708052e-4),
  992. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.86434609673325793686202636939208406356e-5),
  993. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.20865083025640755296377488921536984172e-5),
  994. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.24550087063009488023243811976147518386e-6),
  995. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.78763689691843975658550702147832072016e-7),
  996. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.53901449493513509116902285044951137217e-8),
  997. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.64133451376958243174967226929215155126e-9),
  998. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.78021916681275593923355425070000331160e-10),
  999. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.40116391931116431686557163556034777896e-12),
  1000. BOOST_MATH_BIG_CONSTANT(RealType, 113, -9.43891156389092896219387988411277617045e-15),
  1001. };
  1002. BOOST_MATH_STATIC const RealType Q[17] = {
  1003. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1004. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.30840297297890638941129884491157396207e0),
  1005. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.16059271948787750556465175239345182035e0),
  1006. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.32333703228724830516425197803770832978e-1),
  1007. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.74722711058640395885914966387546141874e-1),
  1008. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.57544653090705553268164186689966671940e-1),
  1009. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.65943099435809995745673109708218670077e-2),
  1010. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.74158626875895095042054345316232575354e-2),
  1011. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.65978318533667031874695821156329945501e-3),
  1012. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.07907034178758316909655424935083792468e-3),
  1013. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.16769901831316460137104511711073411646e-4),
  1014. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.72764558714782436683712413015421717627e-5),
  1015. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.42494185105694341746192094740530489313e-6),
  1016. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.47668761140694808076322373887857100882e-7),
  1017. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.06395948884595166425357861427667353718e-8),
  1018. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.04398743651684916010743222115099630062e-9),
  1019. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.47852251142917253705233519146081069006e-10),
  1020. };
  1021. // LCOV_EXCL_STOP
  1022. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  1023. }
  1024. else if (x < 8) {
  1025. RealType t = x - 4;
  1026. // Rational Approximation
  1027. // Maximum Relative Error: 3.2255e-36
  1028. // LCOV_EXCL_START
  1029. BOOST_MATH_STATIC const RealType P[20] = {
  1030. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.05754562114095147060025732340404111260e-2),
  1031. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.29082907781747007723015304584383528212e-2),
  1032. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.15736486393536930535038719804968063752e-2),
  1033. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.47619683293773846642359668429058772885e-2),
  1034. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.78777185267549567154655052281449528836e-2),
  1035. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.32280474402180284471490985942690221861e-3),
  1036. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.45430564625797085273267452885960070105e-3),
  1037. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.81643129239005795245093568930666448817e-4),
  1038. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.57851748656417804512189330871167578685e-4),
  1039. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.04264676511381380381909064283066657450e-5),
  1040. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.84536783037391183433322642273799250079e-6),
  1041. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.27169201994160924743393109705813711010e-7),
  1042. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.42623512076200527099335832138825884729e-8),
  1043. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.98298083389459839517970895839114237996e-9),
  1044. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.71357920034737751299594537655948527288e-10),
  1045. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.98563999354325930973228648080876368296e-12),
  1046. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.36248172644168880316722905969876969074e-13),
  1047. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.61071663749398045880261823483568866904e-16),
  1048. BOOST_MATH_BIG_CONSTANT(RealType, 113, -8.95933262363502031836408613043245164787e-19),
  1049. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.23007623135952181561484264810647517912e-21),
  1050. };
  1051. BOOST_MATH_STATIC const RealType Q[19] = {
  1052. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1053. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.17760389606658547971193065026711073898e0),
  1054. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.49565543987559264712057768584303008339e0),
  1055. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.94822569926563661124528478579051628722e0),
  1056. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.14676844425183314970062115422221981422e0),
  1057. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.35960757354198367535169328826167556715e-1),
  1058. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.04865288305482048252211468989095938024e-1),
  1059. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.51599632816346741950206107526304703067e-2),
  1060. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.74065824586512487126287762563576185455e-2),
  1061. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.91819078437689679732215988465616022328e-3),
  1062. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.41675362609023565846569121735444698127e-4),
  1063. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.17176431752708802291177040031150143262e-4),
  1064. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.52367587943529121285938327286926798550e-5),
  1065. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.59405168077254169099025950029539316125e-6),
  1066. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.29448420654438993509041228047289503943e-7),
  1067. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.70091773726833073512661846603385666642e-9),
  1068. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.03909417984236210307694235586859612592e-10),
  1069. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.59098698207309055890188845050700901852e-12),
  1070. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.28146456709550379493162440280752828165e-14),
  1071. };
  1072. // LCOV_EXCL_STOP
  1073. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  1074. }
  1075. else if (x < 16) {
  1076. RealType t = x - 8;
  1077. // Rational Approximation
  1078. // Maximum Relative Error: 2.0174e-36
  1079. // LCOV_EXCL_START
  1080. BOOST_MATH_STATIC const RealType P[17] = {
  1081. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.47408470248235665279366712356669210597e-3),
  1082. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.32149712567170349164953101675315481096e-2),
  1083. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.39806230477579028722350422669222849223e-3),
  1084. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.19665271447867857827798702851111114658e-3),
  1085. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.06773237553503696884546088197977608676e-4),
  1086. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.41294370314265386485116359052296796357e-4),
  1087. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.74848600628353761723457890991084017928e-5),
  1088. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.52963427970210468265870547940464851481e-6),
  1089. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.33389244528769791436454176079341120973e-8),
  1090. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.86702000100897346192018772319301428852e-9),
  1091. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.04192907586200235211623448416582655030e-10),
  1092. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.70804269459077260463819507381406529187e-12),
  1093. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.52665761996923502719902050367236108720e-14),
  1094. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.01866635015788942430563628065687465455e-17),
  1095. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.46658865059509532456423012727042498365e-20),
  1096. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.05806999626031246519161395419216393127e-23),
  1097. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.37645700309533972676063947195650607935e-26),
  1098. };
  1099. BOOST_MATH_STATIC const RealType Q[16] = {
  1100. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1101. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.59608758824065179587008165265773042260e0),
  1102. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.17347162462484266250945490058846704988e0),
  1103. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.24511137251392519285309985668265122633e-1),
  1104. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.58497164094526279145784765183039854604e-1),
  1105. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.40787701096334660711443654292041286786e-2),
  1106. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.34615029717812271556414485397095293077e-3),
  1107. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.17712219229282308306346195001801048971e-4),
  1108. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.24578142893420308057222282020407949529e-5),
  1109. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.23429691331344898578916434987129070432e-6),
  1110. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.41486460551571344910835151948209788541e-7),
  1111. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.23569151219279213399210115101532416912e-9),
  1112. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.21438860148387356361258237451828377118e-11),
  1113. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.46770060692933726695086996017149976796e-13),
  1114. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.58079984178724940266882149462170567147e-15),
  1115. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.19997796316046571607659704855966005180e-17),
  1116. };
  1117. // LCOV_EXCL_STOP
  1118. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  1119. }
  1120. else if (x < 32) {
  1121. RealType t = x - 16;
  1122. // Rational Approximation
  1123. // Maximum Relative Error: 4.5109e-36
  1124. // LCOV_EXCL_START
  1125. BOOST_MATH_STATIC const RealType P[16] = {
  1126. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.19610991747326725339429696634365932643e-3),
  1127. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.74646611039453235739153286141429338461e-3),
  1128. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.13331430865337412098234177873337036811e-4),
  1129. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.58947311195482646360642638791970923726e-5),
  1130. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.79226752074485124923797575635082779509e-6),
  1131. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.73081326043094090549807549513512116319e-7),
  1132. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.05408849431691450650464797109033182773e-8),
  1133. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.75716486666270246158606737499459843698e-10),
  1134. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.81075133718930099703621109350447306080e-12),
  1135. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.41318403854345256855350755520072932140e-14),
  1136. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.70220987388883118699419526374266655536e-16),
  1137. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.38711669183547686107032286389030018396e-18),
  1138. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.31300491679098874872172866011372530771e-21),
  1139. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.99223939265527640018203019269955457925e-25),
  1140. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.18316957049006338447926554380706108087e-28),
  1141. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.47298013808154174645356607027685011183e-32),
  1142. };
  1143. BOOST_MATH_STATIC const RealType Q[15] = {
  1144. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1145. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.42561659771176310412113991024326129105e-1),
  1146. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.83353398513931409985504410958429204317e-1),
  1147. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.07254121026393428163401481487563215753e-2),
  1148. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.36667170168890854756291846167398225330e-3),
  1149. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.54019749685699795075624204463938596069e-4),
  1150. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.35321766966107368759516431698755077175e-5),
  1151. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.13350720091296144188972188966204719103e-7),
  1152. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.38107118390482863395863404555696613407e-8),
  1153. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.59267757423034664579822257229473088511e-10),
  1154. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.29549090773392058626428205171445962834e-12),
  1155. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.69922128600755513676564327500993739088e-14),
  1156. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.31337037977667816904491472174578334375e-16),
  1157. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.28088047429043940293455906253037445768e-19),
  1158. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.01213369826105495256520034997664473667e-22),
  1159. };
  1160. // LCOV_EXCL_STOP
  1161. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  1162. }
  1163. else if (x < 64) {
  1164. RealType t = x - 32;
  1165. // Rational Approximation
  1166. // Maximum Relative Error: 1.2707e-35
  1167. // LCOV_EXCL_START
  1168. BOOST_MATH_STATIC const RealType P[15] = {
  1169. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.11172037056341396583040940446061501972e-3),
  1170. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.09383362521204903801686281772843962372e-4),
  1171. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.71440982391172647693486692131238237524e-5),
  1172. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.01685075759372692173396811575536866699e-7),
  1173. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.36574894913423830789864836789988898151e-8),
  1174. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.59644999935503505576091023207315968623e-10),
  1175. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.95573282292603122067959656607163690356e-12),
  1176. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.10361486103428098366627536344769789255e-14),
  1177. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.80946231978997457068033851007899208222e-16),
  1178. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.39341134002270945594553624959145830111e-19),
  1179. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.72307967968246649714945553177468010263e-21),
  1180. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.41093409238620968003297675770440189200e-24),
  1181. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.70464969040825495565297719377221881609e-28),
  1182. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.25341184125872354328990441812668510029e-32),
  1183. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.54663422572657744572284839697818435372e-36),
  1184. };
  1185. BOOST_MATH_STATIC const RealType Q[14] = {
  1186. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1187. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.35632539169215377884393376342532721825e-1),
  1188. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.46975491055790597767445011183622230556e-2),
  1189. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.51806800870130779095309105834725930741e-3),
  1190. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.07403939022350326847926101278370197017e-5),
  1191. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.66046114012817696416892197044749060854e-6),
  1192. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.16723371111678357128668916130767948114e-8),
  1193. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.22972796529973974439855811125888770710e-10),
  1194. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.91073180314665062004869985842402705599e-12),
  1195. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.43753004383633382914827301174981384446e-14),
  1196. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.77313206526206002175298314351042907499e-17),
  1197. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.32850553089285690900825039331456226080e-19),
  1198. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.85369976595753971532524294793778805089e-22),
  1199. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.28948021485210224442871255909409155592e-25),
  1200. };
  1201. // LCOV_EXCL_STOP
  1202. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t);
  1203. }
  1204. else {
  1205. RealType x_cube = x * x * x;
  1206. RealType t = (boost::math::isnormal)(x_cube) ? 1 / sqrt(x_cube) : 1 / pow(sqrt(x), 3);
  1207. // Rational Approximation
  1208. // Maximum Relative Error: 5.4677e-35
  1209. // LCOV_EXCL_START
  1210. BOOST_MATH_STATIC const RealType P[7] = {
  1211. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.99471140200716338969973029967190934238e-1),
  1212. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.48481268366645066801385595379873318648e0),
  1213. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.64087860141734943856373451877569284231e1),
  1214. BOOST_MATH_BIG_CONSTANT(RealType, 113, -9.45555576045996041260191574503331698473e1),
  1215. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.43290677381328916734673040799990923091e2),
  1216. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.63011127597770211743774689830589568544e1),
  1217. BOOST_MATH_BIG_CONSTANT(RealType, 113, -5.61127812511057623691896118746981066174e0),
  1218. };
  1219. BOOST_MATH_STATIC const RealType Q[6] = {
  1220. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1221. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.90660291309478542795359451748753358123e1),
  1222. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.60631500002415936739518466837931659008e2),
  1223. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.88655117367497147850617559832966816275e2),
  1224. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.48350179543067311398059386524702440002e3),
  1225. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.18873206560757944356169500452181141647e3),
  1226. };
  1227. // LCOV_EXCL_STOP
  1228. result = tools::evaluate_polynomial(P, t) / tools::evaluate_polynomial(Q, t) * t;
  1229. }
  1230. return result;
  1231. }
  1232. template <class RealType>
  1233. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_cdf_imp_prec(const RealType& x, bool complement, const boost::math::integral_constant<int, 53>& tag) {
  1234. if (x >= 0) {
  1235. return complement ? holtsmark_cdf_plus_imp_prec(x, tag) : 1 - holtsmark_cdf_plus_imp_prec(x, tag);
  1236. }
  1237. else if (x <= 0) {
  1238. return complement ? 1 - holtsmark_cdf_plus_imp_prec(-x, tag) : holtsmark_cdf_plus_imp_prec(-x, tag);
  1239. }
  1240. else {
  1241. return boost::math::numeric_limits<RealType>::quiet_NaN();
  1242. }
  1243. }
  1244. template <class RealType>
  1245. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_cdf_imp_prec(const RealType& x, bool complement, const boost::math::integral_constant<int, 113>& tag) {
  1246. if (x >= 0) {
  1247. return complement ? holtsmark_cdf_plus_imp_prec(x, tag) : 1 - holtsmark_cdf_plus_imp_prec(x, tag);
  1248. }
  1249. else if (x <= 0) {
  1250. return complement ? 1 - holtsmark_cdf_plus_imp_prec(-x, tag) : holtsmark_cdf_plus_imp_prec(-x, tag);
  1251. }
  1252. else {
  1253. return boost::math::numeric_limits<RealType>::quiet_NaN();
  1254. }
  1255. }
  1256. template <class RealType, class Policy>
  1257. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_cdf_imp(const holtsmark_distribution<RealType, Policy>& dist, const RealType& x, bool complement) {
  1258. //
  1259. // This calculates the cdf of the Holtsmark distribution and/or its complement.
  1260. //
  1261. BOOST_MATH_STD_USING // for ADL of std functions
  1262. constexpr auto function = "boost::math::cdf(holtsmark<%1%>&, %1%)";
  1263. RealType result = 0;
  1264. RealType location = dist.location();
  1265. RealType scale = dist.scale();
  1266. if (false == detail::check_location(function, location, &result, Policy()))
  1267. {
  1268. return result;
  1269. }
  1270. if (false == detail::check_scale(function, scale, &result, Policy()))
  1271. {
  1272. return result;
  1273. }
  1274. if (false == detail::check_x(function, x, &result, Policy()))
  1275. {
  1276. return result;
  1277. }
  1278. typedef typename tools::promote_args<RealType>::type result_type;
  1279. typedef typename policies::precision<result_type, Policy>::type precision_type;
  1280. typedef boost::math::integral_constant<int,
  1281. precision_type::value <= 0 ? 0 :
  1282. precision_type::value <= 53 ? 53 :
  1283. precision_type::value <= 113 ? 113 : 0
  1284. > tag_type;
  1285. static_assert(tag_type::value, "The Holtsmark distribution is only implemented for types with known precision, and 113 bits or fewer in the mantissa (ie 128 bit quad-floats");
  1286. RealType u = (x - location) / scale;
  1287. result = holtsmark_cdf_imp_prec(u, complement, tag_type());
  1288. return result;
  1289. }
  1290. template <class RealType>
  1291. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_quantile_upper_imp_prec(const RealType& p, const boost::math::integral_constant<int, 53>&)
  1292. {
  1293. BOOST_MATH_STD_USING
  1294. RealType result;
  1295. if (ilogb(p) >= -2) {
  1296. RealType t = -log2(ldexp(p, 1));
  1297. // Rational Approximation
  1298. // Maximum Relative Error: 5.8068e-17
  1299. BOOST_MATH_STATIC const RealType P[8] = {
  1300. static_cast<RealType>(7.59789769759814986929e-1),
  1301. static_cast<RealType>(1.27515008642985381862e0),
  1302. static_cast<RealType>(4.38619247097275579086e-1),
  1303. static_cast<RealType>(-1.25521537863031799276e-1),
  1304. static_cast<RealType>(-2.58555599127223857177e-2),
  1305. static_cast<RealType>(1.20249932437303932411e-2),
  1306. static_cast<RealType>(-1.36753104188136881229e-3),
  1307. static_cast<RealType>(6.57491277860092595148e-5),
  1308. };
  1309. BOOST_MATH_STATIC const RealType Q[9] = {
  1310. static_cast<RealType>(1.),
  1311. static_cast<RealType>(2.48696501912062288766e0),
  1312. static_cast<RealType>(2.06239370128871696850e0),
  1313. static_cast<RealType>(5.67577904795053902651e-1),
  1314. static_cast<RealType>(-2.89022828087034733385e-2),
  1315. static_cast<RealType>(-2.17207943286085236479e-2),
  1316. static_cast<RealType>(3.14098307020814954876e-4),
  1317. static_cast<RealType>(3.51448381406676891012e-4),
  1318. static_cast<RealType>(5.71995514606568751522e-5),
  1319. };
  1320. result = t * tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1321. }
  1322. else if (ilogb(p) >= -3) {
  1323. RealType t = -log2(ldexp(p, 2));
  1324. // Rational Approximation
  1325. // Maximum Relative Error: 1.0339e-17
  1326. BOOST_MATH_STATIC const RealType P[8] = {
  1327. static_cast<RealType>(3.84521387984759064238e-1),
  1328. static_cast<RealType>(4.15763727809667641126e-1),
  1329. static_cast<RealType>(-1.73610240124046440578e-2),
  1330. static_cast<RealType>(-3.89915764128788049837e-2),
  1331. static_cast<RealType>(1.07252911248451890192e-2),
  1332. static_cast<RealType>(7.62613727089795367882e-4),
  1333. static_cast<RealType>(-3.11382403581073580481e-4),
  1334. static_cast<RealType>(3.93093062843177374871e-5),
  1335. };
  1336. BOOST_MATH_STATIC const RealType Q[7] = {
  1337. static_cast<RealType>(1.),
  1338. static_cast<RealType>(6.76193897442484823754e-1),
  1339. static_cast<RealType>(3.70953499602257825764e-2),
  1340. static_cast<RealType>(-2.84211795745477605398e-2),
  1341. static_cast<RealType>(2.66146101014551209760e-3),
  1342. static_cast<RealType>(1.85436727973937413751e-3),
  1343. static_cast<RealType>(2.00318687649825430725e-4),
  1344. };
  1345. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1346. }
  1347. else if (ilogb(p) >= -4) {
  1348. RealType t = -log2(ldexp(p, 3));
  1349. // Rational Approximation
  1350. // Maximum Relative Error: 1.4431e-17
  1351. BOOST_MATH_STATIC const RealType P[8] = {
  1352. static_cast<RealType>(4.46943301497773314460e-1),
  1353. static_cast<RealType>(-1.07267614417424412546e-2),
  1354. static_cast<RealType>(-7.21097021064631831756e-2),
  1355. static_cast<RealType>(2.93948745441334193469e-2),
  1356. static_cast<RealType>(-7.33259305010485915480e-4),
  1357. static_cast<RealType>(-1.38660725579083612045e-3),
  1358. static_cast<RealType>(2.95410432808739478857e-4),
  1359. static_cast<RealType>(-2.88688017391292485867e-5),
  1360. };
  1361. BOOST_MATH_STATIC const RealType Q[7] = {
  1362. static_cast<RealType>(1.),
  1363. static_cast<RealType>(-2.72809429017073648893e-2),
  1364. static_cast<RealType>(-7.85526213469762960803e-2),
  1365. static_cast<RealType>(2.41360900478283465241e-2),
  1366. static_cast<RealType>(3.44597797125179611095e-3),
  1367. static_cast<RealType>(-8.65046428689780375806e-4),
  1368. static_cast<RealType>(-1.04147382037315517658e-4),
  1369. };
  1370. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1371. }
  1372. else if (ilogb(p) >= -6) {
  1373. RealType t = -log2(ldexp(p, 4));
  1374. // Rational Approximation
  1375. // Maximum Relative Error: 4.8871e-17
  1376. BOOST_MATH_STATIC const RealType P[10] = {
  1377. static_cast<RealType>(4.25344469980677332786e-1),
  1378. static_cast<RealType>(3.42055470008289997369e-2),
  1379. static_cast<RealType>(9.33607217644370441642e-2),
  1380. static_cast<RealType>(4.57057092587794346086e-2),
  1381. static_cast<RealType>(1.16149976708336017542e-2),
  1382. static_cast<RealType>(6.40479797962035786337e-3),
  1383. static_cast<RealType>(1.58526153828271386329e-3),
  1384. static_cast<RealType>(3.84032908993313260466e-4),
  1385. static_cast<RealType>(6.98960839033991110525e-5),
  1386. static_cast<RealType>(9.66690587477825432174e-6),
  1387. };
  1388. BOOST_MATH_STATIC const RealType Q[10] = {
  1389. static_cast<RealType>(1.),
  1390. static_cast<RealType>(1.60044610004497775009e-1),
  1391. static_cast<RealType>(2.41675490962065446592e-1),
  1392. static_cast<RealType>(1.13752642382290596388e-1),
  1393. static_cast<RealType>(4.05058759031434785584e-2),
  1394. static_cast<RealType>(1.59432816225295660111e-2),
  1395. static_cast<RealType>(4.79286678946992027479e-3),
  1396. static_cast<RealType>(1.16048151070154814260e-3),
  1397. static_cast<RealType>(2.01755520912887201472e-4),
  1398. static_cast<RealType>(2.82884561026909054732e-5),
  1399. };
  1400. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1401. }
  1402. else if (ilogb(p) >= -8) {
  1403. RealType t = -log2(ldexp(p, 6));
  1404. // Rational Approximation
  1405. // Maximum Relative Error: 4.8173e-17
  1406. BOOST_MATH_STATIC const RealType P[9] = {
  1407. static_cast<RealType>(3.68520435599726877886e-1),
  1408. static_cast<RealType>(8.26682725061327242371e-1),
  1409. static_cast<RealType>(6.85235826889543887309e-1),
  1410. static_cast<RealType>(3.28640408399661746210e-1),
  1411. static_cast<RealType>(9.04801242897407528807e-2),
  1412. static_cast<RealType>(1.57470088502958130451e-2),
  1413. static_cast<RealType>(1.61541023176880542598e-3),
  1414. static_cast<RealType>(9.78919203915954346945e-5),
  1415. static_cast<RealType>(9.71371309261213597491e-8),
  1416. };
  1417. BOOST_MATH_STATIC const RealType Q[8] = {
  1418. static_cast<RealType>(1.),
  1419. static_cast<RealType>(2.29132755303753682133e0),
  1420. static_cast<RealType>(1.95530118226232968288e0),
  1421. static_cast<RealType>(9.55029685883545321419e-1),
  1422. static_cast<RealType>(2.68254036588585643328e-1),
  1423. static_cast<RealType>(4.61398419640231283164e-2),
  1424. static_cast<RealType>(4.66131710581568432246e-3),
  1425. static_cast<RealType>(2.94491397241310968725e-4),
  1426. };
  1427. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1428. }
  1429. else if (ilogb(p) >= -16) {
  1430. RealType t = -log2(ldexp(p, 8));
  1431. // Rational Approximation
  1432. // Maximum Relative Error: 6.0376e-17
  1433. BOOST_MATH_STATIC const RealType P[10] = {
  1434. static_cast<RealType>(3.48432718168951419458e-1),
  1435. static_cast<RealType>(2.99680703419193973028e-1),
  1436. static_cast<RealType>(1.09531896991852433149e-1),
  1437. static_cast<RealType>(2.28766133215975559897e-2),
  1438. static_cast<RealType>(3.09836969941710802698e-3),
  1439. static_cast<RealType>(2.89346186674853481383e-4),
  1440. static_cast<RealType>(1.96344583080243707169e-5),
  1441. static_cast<RealType>(9.48415601271652569275e-7),
  1442. static_cast<RealType>(3.08821091232356755783e-8),
  1443. static_cast<RealType>(5.58003465656339818416e-10),
  1444. };
  1445. BOOST_MATH_STATIC const RealType Q[10] = {
  1446. static_cast<RealType>(1.),
  1447. static_cast<RealType>(8.73938978582311007855e-1),
  1448. static_cast<RealType>(3.21771888210250878162e-1),
  1449. static_cast<RealType>(6.70432401844821772827e-2),
  1450. static_cast<RealType>(9.05369648218831664411e-3),
  1451. static_cast<RealType>(8.50098390828726795296e-4),
  1452. static_cast<RealType>(5.73568804840571459050e-5),
  1453. static_cast<RealType>(2.78374120155590875053e-6),
  1454. static_cast<RealType>(9.03427646135263412003e-8),
  1455. static_cast<RealType>(1.63556457120944847882e-9),
  1456. };
  1457. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1458. }
  1459. else if (ilogb(p) >= -32) {
  1460. RealType t = -log2(ldexp(p, 16));
  1461. // Rational Approximation
  1462. // Maximum Relative Error: 2.2804e-17
  1463. BOOST_MATH_STATIC const RealType P[10] = {
  1464. static_cast<RealType>(3.41419813138786920868e-1),
  1465. static_cast<RealType>(1.30219412019722274099e-1),
  1466. static_cast<RealType>(2.36047671342109636195e-2),
  1467. static_cast<RealType>(2.67913051721210953893e-3),
  1468. static_cast<RealType>(2.10896260337301129968e-4),
  1469. static_cast<RealType>(1.19804595761611765179e-5),
  1470. static_cast<RealType>(4.91470756460287578143e-7),
  1471. static_cast<RealType>(1.38299844947707591018e-8),
  1472. static_cast<RealType>(2.25766283556816829070e-10),
  1473. static_cast<RealType>(-8.46510608386806647654e-18),
  1474. };
  1475. BOOST_MATH_STATIC const RealType Q[9] = {
  1476. static_cast<RealType>(1.),
  1477. static_cast<RealType>(3.81461950831351846380e-1),
  1478. static_cast<RealType>(6.91390438866520696447e-2),
  1479. static_cast<RealType>(7.84798596829449138229e-3),
  1480. static_cast<RealType>(6.17735117400536913546e-4),
  1481. static_cast<RealType>(3.50937328177439258136e-5),
  1482. static_cast<RealType>(1.43958654321452532854e-6),
  1483. static_cast<RealType>(4.05109749922716264456e-8),
  1484. static_cast<RealType>(6.61306247924109415113e-10),
  1485. };
  1486. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1487. }
  1488. else if (ilogb(p) >= -64) {
  1489. RealType t = -log2(ldexp(p, 32));
  1490. // Rational Approximation
  1491. // Maximum Relative Error: 4.8545e-17
  1492. BOOST_MATH_STATIC const RealType P[9] = {
  1493. static_cast<RealType>(3.41392032051575965049e-1),
  1494. static_cast<RealType>(1.53372256183388434238e-1),
  1495. static_cast<RealType>(3.33822240038718319714e-2),
  1496. static_cast<RealType>(4.66328786929735228532e-3),
  1497. static_cast<RealType>(4.67981207864367711082e-4),
  1498. static_cast<RealType>(3.48119463063280710691e-5),
  1499. static_cast<RealType>(2.17755850282052679342e-6),
  1500. static_cast<RealType>(7.40424342670289242177e-8),
  1501. static_cast<RealType>(4.61294046336533026640e-9),
  1502. };
  1503. BOOST_MATH_STATIC const RealType Q[9] = {
  1504. static_cast<RealType>(1.),
  1505. static_cast<RealType>(4.49255524669251621744e-1),
  1506. static_cast<RealType>(9.77826688966262423974e-2),
  1507. static_cast<RealType>(1.36596271675764346980e-2),
  1508. static_cast<RealType>(1.37080296105355418281e-3),
  1509. static_cast<RealType>(1.01970588303201339768e-4),
  1510. static_cast<RealType>(6.37846903580539445994e-6),
  1511. static_cast<RealType>(2.16883897125962281968e-7),
  1512. static_cast<RealType>(1.35121503608967367232e-8),
  1513. };
  1514. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1515. }
  1516. else {
  1517. const BOOST_MATH_STATIC_LOCAL_VARIABLE RealType c = ldexp(cbrt(constants::pi<RealType>()), 1);
  1518. RealType p_square = p * p;
  1519. if ((boost::math::isnormal)(p_square)) {
  1520. result = 1 / (cbrt(p_square) * c);
  1521. }
  1522. else if (p > 0) {
  1523. result = 1 / (cbrt(p) * cbrt(p) * c);
  1524. }
  1525. else {
  1526. result = boost::math::numeric_limits<RealType>::infinity();
  1527. }
  1528. }
  1529. return result;
  1530. }
  1531. template <class RealType>
  1532. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_quantile_upper_imp_prec(const RealType& p, const boost::math::integral_constant<int, 113>&)
  1533. {
  1534. BOOST_MATH_STD_USING
  1535. RealType result;
  1536. if (ilogb(p) >= -2) {
  1537. RealType u = -log2(ldexp(p, 1));
  1538. if (u < 0.5) {
  1539. // Rational Approximation
  1540. // Maximum Relative Error: 1.7987e-35
  1541. // LCOV_EXCL_START
  1542. BOOST_MATH_STATIC const RealType P[14] = {
  1543. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.59789769759815031687162026655576575384e-1),
  1544. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.23247138049619855169890925442523844619e0),
  1545. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.35351935489348780511227763760731136136e0),
  1546. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.17321534695821967609074567968260505604e0),
  1547. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.30930523792327030433989902919481147250e0),
  1548. BOOST_MATH_BIG_CONSTANT(RealType, 113, -9.47676800034255152477549544991291837378e-2),
  1549. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.09952071024064609787697026812259269093e-1),
  1550. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.65479872964217159571026674930672527880e-3),
  1551. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.30204907832301876030269224513949605725e-3),
  1552. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.61038349134944320766567917361933431224e-4),
  1553. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.17242905696479357297850061918336600969e-5),
  1554. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.43640101589433162893041733511239841220e-5),
  1555. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.39406616773257816628641556843884616119e-6),
  1556. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.54871597065387376666252643921309051097e-7),
  1557. };
  1558. BOOST_MATH_STATIC const RealType Q[13] = {
  1559. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1560. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.06310038178166385607814371094968073940e0),
  1561. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.06144046990424238286303107360481469219e1),
  1562. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.17860081295611631017119482265353540470e1),
  1563. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.26319639748358310901277622665331115333e0),
  1564. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.25962127567362715217159291513550804588e0),
  1565. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.65543974081934423010588955830131357921e-1),
  1566. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.80331848633772107482330422252085368575e-2),
  1567. BOOST_MATH_BIG_CONSTANT(RealType, 113, -9.97426948050874772305317056836660558275e-3),
  1568. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.10722999873793200671617106731723252507e-3),
  1569. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.68871255379198546500699434161302033826e-4),
  1570. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.70190278641952708999014435335172772138e-5),
  1571. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.11562497711461468804693130702653542297e-7),
  1572. };
  1573. // LCOV_EXCL_STOP
  1574. result = u * tools::evaluate_polynomial(P, u) / (tools::evaluate_polynomial(Q, u) * cbrt(p * p));
  1575. }
  1576. else {
  1577. RealType t = u - static_cast <RealType>(0.5);
  1578. // Rational Approximation
  1579. // Maximum Relative Error: 2.5554e-35
  1580. // LCOV_EXCL_START
  1581. BOOST_MATH_STATIC const RealType P[13] = {
  1582. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.63490994331899195346399558699533994243e-1),
  1583. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.68682839419340144322747963938810505658e-1),
  1584. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.63089084712442063245295709191126453412e-1),
  1585. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.24910510426787025593146475670961782647e-1),
  1586. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.14005632199839351091767181535761567981e-2),
  1587. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.88144015238275997284082820907124267240e-4),
  1588. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.12015895125039876623372795832970536355e-3),
  1589. BOOST_MATH_BIG_CONSTANT(RealType, 113, -8.96386756665254981286292821446749025989e-4),
  1590. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.82855208595003635135641502084317667629e-4),
  1591. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.18007513930934295792217002090233670917e-5),
  1592. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.82563310387467580262182864644541746616e-6),
  1593. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.52830681121195099547078704713089681353e-7),
  1594. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.91383571211375811878311159248551586411e-8),
  1595. };
  1596. BOOST_MATH_STATIC const RealType Q[12] = {
  1597. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1598. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.96820655322136936855997114940653763917e0),
  1599. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.30209571878469737819039455443404070107e0),
  1600. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.61235660141139249931521613001554108034e-1),
  1601. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.31683133997030095798635713869616211197e-2),
  1602. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.20681979279848555447978496580849290723e-3),
  1603. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.08958899028812330281115719259773001136e-3),
  1604. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.02478613175545210977059079339657545008e-4),
  1605. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.68653479132148912896487809682760117627e-5),
  1606. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.35166554499214836086438565154832646441e-5),
  1607. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.95409975934011596023165394669416595582e-6),
  1608. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.84312112139729518216217161835365265801e-7),
  1609. };
  1610. // LCOV_EXCL_STOP
  1611. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1612. }
  1613. }
  1614. else if (ilogb(p) >= -3) {
  1615. RealType u = -log2(ldexp(p, 2));
  1616. if (u < 0.5) {
  1617. // Rational Approximation
  1618. // Maximum Relative Error: 1.0297e-35
  1619. // LCOV_EXCL_START
  1620. BOOST_MATH_STATIC const RealType P[12] = {
  1621. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.84521387984759060262188972210005114936e-1),
  1622. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.70837834325236202821328032137877091515e-1),
  1623. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.53856963029219911450181095566096563059e-1),
  1624. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.97659091653089105048621336944687224192e-2),
  1625. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.77726241585387617566937892474685179582e-2),
  1626. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.21657224955483589784473724186837316423e-2),
  1627. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.76357400631206366078287330192525531850e-3),
  1628. BOOST_MATH_BIG_CONSTANT(RealType, 113, -8.45967265853745968166172649261385754061e-4),
  1629. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.08367654892620484522749804048317330020e-5),
  1630. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.41224530727710207304898458924763411052e-5),
  1631. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.02908228738160003274584644834000176496e-6),
  1632. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.05702214080592377840761032481067834813e-7),
  1633. };
  1634. BOOST_MATH_STATIC const RealType Q[12] = {
  1635. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1636. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.33954869248363301881659953529609341564e0),
  1637. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.73738626674455393272550888585363920917e-1),
  1638. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.90708494363306682523722238824373341707e-2),
  1639. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.49559648492983033200126224112060119905e-2),
  1640. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.07561158260652000950392950266037061167e-3),
  1641. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.30349651195547682860585068738648645100e-3),
  1642. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.21766408404123861757376277367204136764e-4),
  1643. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.22181499366766592894880124261171657846e-5),
  1644. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.74488053046587079829684775540618210211e-6),
  1645. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.90504597668186854963746384968119788469e-6),
  1646. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.45195198322028676384075318222338781298e-7),
  1647. };
  1648. // LCOV_EXCL_STOP
  1649. result = tools::evaluate_polynomial(P, u) / (tools::evaluate_polynomial(Q, u) * cbrt(p * p));
  1650. }
  1651. else {
  1652. RealType t = u - static_cast <RealType>(0.5);
  1653. // Rational Approximation
  1654. // Maximum Relative Error: 1.3688e-35
  1655. // LCOV_EXCL_START
  1656. BOOST_MATH_STATIC const RealType P[12] = {
  1657. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.34418795581931891732555950599385666106e-1),
  1658. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.13006013029934051875748102515422669897e-1),
  1659. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.27990072710518465265454549585803147529e-2),
  1660. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.82530244963278920355650323928131927272e-2),
  1661. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.05335741422175616606162502617378682462e-2),
  1662. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.71242678756797136217651369710748524650e-3),
  1663. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.65147398836785709305701073315614307906e-3),
  1664. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.23912765853731378067295654886575185240e-4),
  1665. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.77861910171412622761254991979036167882e-5),
  1666. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.11971510714149983297022108523700437739e-5),
  1667. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.23649928279010039670034778778065846828e-6),
  1668. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.99636080473697209793683863161785312159e-8),
  1669. };
  1670. BOOST_MATH_STATIC const RealType Q[12] = {
  1671. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1672. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.95056572065373808001002483348789719155e-1),
  1673. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.55702988004729812458415992666809422570e-2),
  1674. BOOST_MATH_BIG_CONSTANT(RealType, 113, -5.07586989542594910084052301521098115194e-2),
  1675. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.96831670560124470215505714403486118412e-2),
  1676. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.86445076378084412691927796983792892534e-3),
  1677. BOOST_MATH_BIG_CONSTANT(RealType, 113, -8.75566285003039738258189045863064261980e-4),
  1678. BOOST_MATH_BIG_CONSTANT(RealType, 113, -7.18557444175572723760508226182075127685e-5),
  1679. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.66667716357950609103712975111660496416e-5),
  1680. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.70999480357934082364999779023268059131e-6),
  1681. BOOST_MATH_BIG_CONSTANT(RealType, 113, -5.14604868719110256415222454908306045416e-8),
  1682. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.32724040071094913191419223901752642417e-8),
  1683. };
  1684. // LCOV_EXCL_STOP
  1685. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1686. }
  1687. }
  1688. else if (ilogb(p) >= -4) {
  1689. RealType t = -log2(ldexp(p, 3));
  1690. // Rational Approximation
  1691. // Maximum Relative Error: 6.6020e-36
  1692. // LCOV_EXCL_START
  1693. BOOST_MATH_STATIC const RealType P[15] = {
  1694. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.46943301497773318715008398224877079279e-1),
  1695. BOOST_MATH_BIG_CONSTANT(RealType, 113, -9.85403413700924949902626248891615772650e-2),
  1696. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.02791895890363892816315784780533893399e-1),
  1697. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.89147412486638444082129846251261616763e-2),
  1698. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.93382251168424191872267997181870008850e-3),
  1699. BOOST_MATH_BIG_CONSTANT(RealType, 113, -9.68332196426082871660060467570049113632e-3),
  1700. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.88720436260994811649162949644253306037e-3),
  1701. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.34099304204778307050211441936900839075e-4),
  1702. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.42970601149275611131932131801993030928e-4),
  1703. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.19329425598839605828710629592687495198e-5),
  1704. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.48826007216547106568423189194739111033e-6),
  1705. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.47132934846160946190230821709692067279e-6),
  1706. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.34123780321108493820637601375183345528e-7),
  1707. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.64549285026064221742294542922996905241e-8),
  1708. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.72723306533295983872420985773212608299e-9),
  1709. };
  1710. BOOST_MATH_STATIC const RealType Q[15] = {
  1711. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1712. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.23756826160440280076231428938184359865e-1),
  1713. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.46557011055563840763437682311082689407e-1),
  1714. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.18907861669025579159409035585375166964e-1),
  1715. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.09998981512549500250715800529896557509e-3),
  1716. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.09496663758959409482213456915225652712e-2),
  1717. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.37086325651334206453116588474211557676e-3),
  1718. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.65325780110454655811120026458133145750e-4),
  1719. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.93435549562125602056160657604473721758e-4),
  1720. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.34967558308250784125219085040752451132e-5),
  1721. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.73883529653464036447550624641291181317e-6),
  1722. BOOST_MATH_BIG_CONSTANT(RealType, 113, -5.88600727347267778330635397957540267359e-7),
  1723. BOOST_MATH_BIG_CONSTANT(RealType, 113, -6.26681383000234695948685993798733295748e-9),
  1724. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.19871610873353691152255428262732390602e-8),
  1725. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.42468017918888155246438948321084323623e-9),
  1726. };
  1727. // LCOV_EXCL_STOP
  1728. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1729. }
  1730. else if (ilogb(p) >= -5) {
  1731. RealType u = -log2(ldexp(p, 4));
  1732. if (u < 0.5) {
  1733. // Rational Approximation
  1734. // Maximum Relative Error: 5.0596e-35
  1735. // LCOV_EXCL_START
  1736. BOOST_MATH_STATIC const RealType P[12] = {
  1737. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.25344469980677353573160570139298422046e-1),
  1738. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.41915371584999983192100443156935649063e-1),
  1739. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.02829239548689190780023994008688591230e-1),
  1740. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.29283473326959885625548350158197923999e-2),
  1741. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.01078477165670046284950196047161898687e-3),
  1742. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.02714892887893367912743194877742997622e-3),
  1743. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.43133417775367444366548711083157149060e-4),
  1744. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.34782994090554432391320506638030058071e-4),
  1745. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.06742736859237185836735105245477248882e-5),
  1746. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.55982601406660341132288721616681417444e-6),
  1747. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.57770758189194396236862269776507019313e-7),
  1748. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.29311341249565125992213260043135188072e-8),
  1749. };
  1750. BOOST_MATH_STATIC const RealType Q[12] = {
  1751. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1752. BOOST_MATH_BIG_CONSTANT(RealType, 113, -2.54021943144355190773797361537886598583e-1),
  1753. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.30965787836836308380896385568728211303e-1),
  1754. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.19314242976592846926644622802257778872e-2),
  1755. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.84123785238634690769817401191138848504e-3),
  1756. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.75779029464908805680899310810660326192e-3),
  1757. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.15078294915445673781718097749944059134e-3),
  1758. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.84667183003626452412083824490324913477e-4),
  1759. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.59521438712225874821007396323337016693e-5),
  1760. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.90446539427779905568600432145715126083e-6),
  1761. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.21425779911599424040614866482614099753e-7),
  1762. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.00972806247654369646317764344373036462e-8),
  1763. };
  1764. // LCOV_EXCL_STOP
  1765. result = tools::evaluate_polynomial(P, u) / (tools::evaluate_polynomial(Q, u) * cbrt(p * p));
  1766. }
  1767. else {
  1768. RealType t = u - static_cast <RealType>(0.5);
  1769. // Rational Approximation
  1770. // Maximum Relative Error: 8.3743e-35
  1771. // LCOV_EXCL_START
  1772. BOOST_MATH_STATIC const RealType P[13] = {
  1773. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.08071367192424306005939751362206079160e-1),
  1774. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.94625900993512461462097316785202943274e-1),
  1775. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.55970241156822104458842450713854737857e-1),
  1776. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.07663066299810473476390199553510422731e-2),
  1777. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.89859986209620592557993828310690990189e-3),
  1778. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.04002735956724252558290154433164340078e-3),
  1779. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.28754717941144647796091692241880059406e-3),
  1780. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.19307116062867039608045413276099792797e-4),
  1781. BOOST_MATH_BIG_CONSTANT(RealType, 113, -5.02377178609994923303160815309590928289e-5),
  1782. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.71739619655097982325716241977619135216e-6),
  1783. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.70229045058419872036870274360537396648e-7),
  1784. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.90495731447121207951661931979310025968e-7),
  1785. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.23210708203609461650368387780135568863e-8),
  1786. };
  1787. BOOST_MATH_STATIC const RealType Q[11] = {
  1788. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1789. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.93402256203255215539822867473993726421e-1),
  1790. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.42452702043886045884356307934634512995e-1),
  1791. BOOST_MATH_BIG_CONSTANT(RealType, 113, -5.16981055684612802160174937997247813645e-2),
  1792. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.39560623514414816165791968511612762553e-2),
  1793. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.26014275897567952035148355055139912545e-3),
  1794. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.42163967753843746501638925686714935099e-3),
  1795. BOOST_MATH_BIG_CONSTANT(RealType, 113, -3.63605648300801696460942201096159808446e-5),
  1796. BOOST_MATH_BIG_CONSTANT(RealType, 113, -4.55933967787268788177266789383155699064e-5),
  1797. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.41526208021076709058374666903111908743e-5),
  1798. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.08505866202670144225100385141263360218e-6),
  1799. };
  1800. // LCOV_EXCL_STOP
  1801. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1802. }
  1803. }
  1804. else if (ilogb(p) >= -6) {
  1805. RealType t = -log2(ldexp(p, 5));
  1806. // Rational Approximation
  1807. // Maximum Relative Error: 2.4734e-35
  1808. // LCOV_EXCL_START
  1809. BOOST_MATH_STATIC const RealType P[16] = {
  1810. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.92042979500197776619414802317216082414e-1),
  1811. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.94742044285563829335663810275331541585e-2),
  1812. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.14525306632578654372860377652983462776e-1),
  1813. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.88893010132758460781753381176593178775e-2),
  1814. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.08491462791290535107958214106528611951e-1),
  1815. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.61374431854187722720094162894017991926e-2),
  1816. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.11641062509116613779440753514902522337e-2),
  1817. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.12474548036763970495563846370119556004e-3),
  1818. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.48140831258790372410036499310440980121e-3),
  1819. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.26913338169355215445128368312197650848e-4),
  1820. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.63109797282729701768942543985418804075e-4),
  1821. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.55296802973076575732233624155433324402e-5),
  1822. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.72108609713971908723724065216410393928e-6),
  1823. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.93328436272999507339897246655916666269e-7),
  1824. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.72119240610740992234979508242967886200e-8),
  1825. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.17836139198065889244530078295061548097e-10),
  1826. };
  1827. BOOST_MATH_STATIC const RealType Q[15] = {
  1828. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1829. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.78065342260594920160228973261455037923e-1),
  1830. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.08575070304822733863613657779515344137e-1),
  1831. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.81185785915044621118680763035984134530e-1),
  1832. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.87597191269586886460326897968559867853e-1),
  1833. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.07903258768761230286548634868645339678e-1),
  1834. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.88395769450457864233486684232536503140e-2),
  1835. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.05678227243099671420442217017131559055e-2),
  1836. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.24803207742284923122212652186826674987e-3),
  1837. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.06094715338829793088081672723947647238e-3),
  1838. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.96454433858093590192363331553516923090e-4),
  1839. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.94509901530299070041475386866323617753e-5),
  1840. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.49001710126540196485963921184736711193e-5),
  1841. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.58899179756014192338509671769986887613e-6),
  1842. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.06916561094749601736592488829778059190e-8),
  1843. };
  1844. // LCOV_EXCL_STOP
  1845. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1846. }
  1847. else if (ilogb(p) >= -8) {
  1848. RealType t = -log2(ldexp(p, 6));
  1849. // Rational Approximation
  1850. // Maximum Relative Error: 1.1570e-35
  1851. // LCOV_EXCL_START
  1852. BOOST_MATH_STATIC const RealType P[18] = {
  1853. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.68520435599726860132888599110871216319e-1),
  1854. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.01076105507184082206031922185510102322e-1),
  1855. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.39912455237662038937400667644545834191e0),
  1856. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.51088991221663244634723139723207272560e0),
  1857. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.26465949648856746869050310379379898086e0),
  1858. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.37079746226805258449355819952819997723e-1),
  1859. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.49372033421420312720741838903118544951e-1),
  1860. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.95729572745049276972587492142384353131e-1),
  1861. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.92794840197452838799536047152725573779e-2),
  1862. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.96897979363475104635129765703613472468e-2),
  1863. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.44138843334474914059035559588791041371e-3),
  1864. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.78076328055619970057667292651627051391e-4),
  1865. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.04182093251998194244585085400876144351e-4),
  1866. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.04392999917657413659748817212746660436e-5),
  1867. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.76006125565969084470924344826977844710e-7),
  1868. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.21045181507045010640119572995692565368e-8),
  1869. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.61400097324698003962179537436043636306e-9),
  1870. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.88084230973635340409728710734906398080e-11),
  1871. };
  1872. BOOST_MATH_STATIC const RealType Q[18] = {
  1873. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1874. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.49319798750825059930589954921919984293e0),
  1875. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.90218243410186000622818205955425584848e0),
  1876. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.25384789213915993855434876209137054104e0),
  1877. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.58563858782064482133038568901836564329e0),
  1878. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.39112608961600614189971858070197609546e0),
  1879. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.29192895265168981204927382938872469754e0),
  1880. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.66418375973954918346810939649929797237e-1),
  1881. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.01606040038159207768769492693779323748e-1),
  1882. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.75837675697421536953171865636865644576e-2),
  1883. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.30258315910281295093103384193132807400e-2),
  1884. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.28333635097670841003561009290200071343e-3),
  1885. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.04871369296490431325621140782944603554e-4),
  1886. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.05077352164673794093561693258318905067e-5),
  1887. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.28508157403208548483052311164947568580e-6),
  1888. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.22527248376737724147359908626095469985e-7),
  1889. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.75479484339716254784610505187249810386e-9),
  1890. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.39990051830081888581639577552526319577e-11),
  1891. };
  1892. // LCOV_EXCL_STOP
  1893. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1894. }
  1895. else if (ilogb(p) >= -16) {
  1896. RealType t = -log2(ldexp(p, 8));
  1897. // Rational Approximation
  1898. // Maximum Relative Error: 1.1362e-35
  1899. // LCOV_EXCL_START
  1900. BOOST_MATH_STATIC const RealType P[22] = {
  1901. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.48432718168951398420402661878962745094e-1),
  1902. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.55946442453078865766668586202885528338e-1),
  1903. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.54912640113904816247923987542554486059e-1),
  1904. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.60852745978561293262851287627328856197e-1),
  1905. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.93256608166097432329211369307994852513e-1),
  1906. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.94707001299612588571704157159595918562e-2),
  1907. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.40368387009950846525432054396214443833e-2),
  1908. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.62326983889228773089492130483459202197e-3),
  1909. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.97166112600628615762158757484340724056e-4),
  1910. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.95053681446806610424931810174198926457e-5),
  1911. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.13613767164027076487881255767029235747e-6),
  1912. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.46627172639536503825606138995804926378e-7),
  1913. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.26813757095977946534946955553296696736e-8),
  1914. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.01393212063713249666862633388902006492e-9),
  1915. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.04428602119155661411061942866480445477e-10),
  1916. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.52977051350929618206095556763031195967e-12),
  1917. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.63092013964238065197415324341392517794e-13),
  1918. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.77457116423818347179318334884304764609e-15),
  1919. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.10372468210274291890669895933038762772e-16),
  1920. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.85517152798650696598776156882211719502e-18),
  1921. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.01916800572423194619358228507804954863e-20),
  1922. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.72241483171311778625855302356391965266e-26),
  1923. };
  1924. BOOST_MATH_STATIC const RealType Q[21] = {
  1925. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1926. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.18341916009800042837726003154518652168e0),
  1927. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.19215655980509256344434487727207541208e0),
  1928. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.34380326549827252189214516628038733750e0),
  1929. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.65069135930665131327262366757787760402e-1),
  1930. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.74132905027750048531814627726862962404e-1),
  1931. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.11184893124573373947875834716323223477e-2),
  1932. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.68456853089572312034718359282699132364e-3),
  1933. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.16340806625223749486884390838046244494e-3),
  1934. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.45007766006724826837429360471785418874e-4),
  1935. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.50443251593190111677537955057976277305e-5),
  1936. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.30829464745241179175728900376502542995e-6),
  1937. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.57256894336319418553622695416919409120e-8),
  1938. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.89973763917908403951538315949652981312e-9),
  1939. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.05834675579622824896206540981508286215e-10),
  1940. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.32721343511724613011656816221169980981e-11),
  1941. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.77569292346900432492044041866264215291e-13),
  1942. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.39903737668944675386972393000746368518e-14),
  1943. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.23200083621376582032771041306045737695e-16),
  1944. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.43557805626692790539354751731913075096e-18),
  1945. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.91326410956582998375100191562832969140e-20),
  1946. };
  1947. // LCOV_EXCL_STOP
  1948. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1949. }
  1950. else if (ilogb(p) >= -32) {
  1951. RealType t = -log2(ldexp(p, 16));
  1952. // Rational Approximation
  1953. // Maximum Relative Error: 9.1729e-35
  1954. // LCOV_EXCL_START
  1955. BOOST_MATH_STATIC const RealType P[19] = {
  1956. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.41419813138786928653984591611599949126e-1),
  1957. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.94225020281693988785012368481961427155e-1),
  1958. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.28967134188573605597955859185818311256e-2),
  1959. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.16617725083935565014535265818666424029e-3),
  1960. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.13379610773944032381149443514208866162e-3),
  1961. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.06508483032198116332154635763926628153e-4),
  1962. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.89315471210589177037346413966039863126e-6),
  1963. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.72993906450633221200844495419180873066e-7),
  1964. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.32883391567312244751716481903540505335e-8),
  1965. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.50998889887280885500990101116973130081e-10),
  1966. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.23247766687180294767338042555173653249e-11),
  1967. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.12326475887709255500757383109178584638e-13),
  1968. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.11688319088825228685832870139320733695e-14),
  1969. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.95381542569360703428852622701723193645e-16),
  1970. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.70730387484749668293167350494151199659e-18),
  1971. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.84243405919322052861165273432136993833e-20),
  1972. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.40860917180131228318146854666419586211e-22),
  1973. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.85122374200561402546731933480737679849e-30),
  1974. BOOST_MATH_BIG_CONSTANT(RealType, 113, -1.79744248200459077556218062241428072826e-32),
  1975. };
  1976. BOOST_MATH_STATIC const RealType Q[17] = {
  1977. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  1978. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.68930884381361438749954611436694811868e-1),
  1979. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.54944129151720429074748655153760118465e-1),
  1980. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.68493670923968273171437877298940102712e-2),
  1981. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.32109946297461941811102221103314572340e-3),
  1982. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.11983030120265263999033828442555862122e-4),
  1983. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.31204888358097171713697195034681853057e-5),
  1984. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.38548604936907265274059071726622071821e-6),
  1985. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.82158855359673890472124017801768455208e-8),
  1986. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.78564556026252472894386810079914912632e-9),
  1987. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.46854501887011863360558947087254908412e-11),
  1988. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.67236380279070121978196383998000020645e-12),
  1989. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.20076045812548485396837897240357026254e-14),
  1990. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.15814123143437217877762088763846289858e-15),
  1991. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.67177999717442465582949551415385496304e-17),
  1992. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.71135001552136641449927514544850663366e-19),
  1993. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.98449056954034104266783180068258117013e-22),
  1994. };
  1995. // LCOV_EXCL_STOP
  1996. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  1997. }
  1998. else if (ilogb(p) >= -64) {
  1999. RealType t = -log2(ldexp(p, 32));
  2000. // Rational Approximation
  2001. // Maximum Relative Error: 1.8330e-35
  2002. // LCOV_EXCL_START
  2003. BOOST_MATH_STATIC const RealType P[19] = {
  2004. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.41392032051575981622151194498090952488e-1),
  2005. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.32651097995974052731414709779952524875e-1),
  2006. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.51927763729719814565225981452897995722e-2),
  2007. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.11148082477882981299945196621348531180e-3),
  2008. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.80457559655975695558885644380771202301e-4),
  2009. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.96223001525552834934139567532649816367e-5),
  2010. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.10625449265784963560596299595289620029e-6),
  2011. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.14785887121654524328854820350425279893e-8),
  2012. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.00832358736396150660417651391240544392e-9),
  2013. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.63128732906298604011217701767305935851e-11),
  2014. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.86148432181465165445355560568442172406e-12),
  2015. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.44088921565424320298916604159745842835e-14),
  2016. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.95220124898384051195673049864765987092e-16),
  2017. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.50531060529388128674128631193212903032e-17),
  2018. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.06119051130826148039530805693452156757e-19),
  2019. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.19849873960405145967462029876325494393e-21),
  2020. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.66833600176986734600260382043861669021e-23),
  2021. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.07829060832934383885234817363480653925e-26),
  2022. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.21485411177823993142696645934560017341e-40),
  2023. };
  2024. BOOST_MATH_STATIC const RealType Q[18] = {
  2025. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  2026. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.88559444380290379529260819350179144435e-1),
  2027. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.37942717465159991856146428659881557553e-2),
  2028. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.11409915376157429952160202733757574026e-3),
  2029. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.21511733003564236929107862750700281202e-4),
  2030. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.74773232555012468159223116269289241483e-5),
  2031. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.24042271031862389840796415749527818562e-6),
  2032. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.50790246845873571117791557191071320982e-7),
  2033. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.88274886666078071130557536971927872847e-9),
  2034. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.94242592538917360235050248151146832636e-10),
  2035. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.45262967284548223426004177385213311949e-12),
  2036. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.30081806380053435857465845326686775489e-13),
  2037. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.62226426496757450797456131921060042081e-15),
  2038. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.40933140159573381494354127717542598424e-17),
  2039. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.03760580312376891985077265621432029857e-19),
  2040. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.43980683769941233230954109646012150124e-21),
  2041. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.88686274782816858372719510890126716148e-23),
  2042. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.07336140055510452905474533727353308321e-25),
  2043. };
  2044. // LCOV_EXCL_STOP
  2045. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  2046. }
  2047. else if (ilogb(p) >= -128) {
  2048. RealType t = -log2(ldexp(p, 64));
  2049. // Rational Approximation
  2050. // Maximum Relative Error: 5.9085e-35
  2051. // LCOV_EXCL_START
  2052. BOOST_MATH_STATIC const RealType P[18] = {
  2053. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.41392031627647840832213878541731833340e-1),
  2054. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.48256908849985263191468999842405689327e-1),
  2055. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.16515822909144946601084169745484248278e-2),
  2056. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.42246334265547596187501472291026180697e-3),
  2057. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.54145961608971551335283437288203286104e-4),
  2058. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.64840354062369555376354747633807898689e-5),
  2059. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.38246669464526050793398379055335943951e-6),
  2060. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.29684566081664150074215568847731661446e-7),
  2061. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.98456331768093420851844051941851740455e-9),
  2062. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.36738267296531031235518935656891979319e-10),
  2063. BOOST_MATH_BIG_CONSTANT(RealType, 113, 8.08128287278026286279504717089979753319e-12),
  2064. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.38334581618709868951669630969696873534e-13),
  2065. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.08478537820365448038773095902465198679e-15),
  2066. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.30768169494950935152733510713679558562e-16),
  2067. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.49254243621461466892836128222648688091e-18),
  2068. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.17026357413798368802986708112771803774e-20),
  2069. BOOST_MATH_BIG_CONSTANT(RealType, 113, 5.05630817682870951728748696694117980745e-22),
  2070. BOOST_MATH_BIG_CONSTANT(RealType, 113, -5.13881361534205323565985756195674181203e-50),
  2071. };
  2072. BOOST_MATH_STATIC const RealType Q[17] = {
  2073. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.),
  2074. BOOST_MATH_BIG_CONSTANT(RealType, 113, 4.34271731953273239599863811873205236246e-1),
  2075. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.27133013035186849060586077266046297964e-2),
  2076. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.29542078693828543540010668640353491847e-2),
  2077. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.33027698228265344545932885863767276804e-3),
  2078. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.06868444562964057780556916100143215394e-4),
  2079. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.97868278672593071061800234869603536243e-6),
  2080. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.79869926850283188735312536038469293739e-7),
  2081. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.75298857713475428365153491580710497759e-8),
  2082. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.93449891515741631851202042430818496480e-10),
  2083. BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.36715626731277089013724968542144140938e-11),
  2084. BOOST_MATH_BIG_CONSTANT(RealType, 113, 6.98125789528264426869121548546848968670e-13),
  2085. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.78234546049400950521459021508632294206e-14),
  2086. BOOST_MATH_BIG_CONSTANT(RealType, 113, 3.83044000387150792643468853129175805308e-16),
  2087. BOOST_MATH_BIG_CONSTANT(RealType, 113, 7.30111486296552039388613073915170671881e-18),
  2088. BOOST_MATH_BIG_CONSTANT(RealType, 113, 9.28628462422858134962149154420358876352e-20),
  2089. BOOST_MATH_BIG_CONSTANT(RealType, 113, 1.48108558735886480279744474396456699335e-21),
  2090. };
  2091. // LCOV_EXCL_STOP
  2092. result = tools::evaluate_polynomial(P, t) / (tools::evaluate_polynomial(Q, t) * cbrt(p * p));
  2093. }
  2094. else {
  2095. const BOOST_MATH_STATIC_LOCAL_VARIABLE RealType c = ldexp(cbrt(constants::pi<RealType>()), 1);
  2096. RealType p_square = p * p;
  2097. if ((boost::math::isnormal)(p_square)) {
  2098. result = 1 / (cbrt(p_square) * c);
  2099. }
  2100. else if (p > 0) {
  2101. result = 1 / (cbrt(p) * cbrt(p) * c);
  2102. }
  2103. else {
  2104. result = boost::math::numeric_limits<RealType>::infinity();
  2105. }
  2106. }
  2107. return result;
  2108. }
  2109. template <class RealType>
  2110. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_quantile_imp_prec(const RealType& p, bool complement, const boost::math::integral_constant<int, 53>& tag)
  2111. {
  2112. if (p > 0.5) {
  2113. return !complement ? holtsmark_quantile_upper_imp_prec(1 - p, tag) : -holtsmark_quantile_upper_imp_prec(1 - p, tag);
  2114. }
  2115. return complement ? holtsmark_quantile_upper_imp_prec(p, tag) : -holtsmark_quantile_upper_imp_prec(p, tag);
  2116. }
  2117. template <class RealType>
  2118. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_quantile_imp_prec(const RealType& p, bool complement, const boost::math::integral_constant<int, 113>& tag)
  2119. {
  2120. if (p > 0.5) {
  2121. return !complement ? holtsmark_quantile_upper_imp_prec(1 - p, tag) : -holtsmark_quantile_upper_imp_prec(1 - p, tag);
  2122. }
  2123. return complement ? holtsmark_quantile_upper_imp_prec(p, tag) : -holtsmark_quantile_upper_imp_prec(p, tag);
  2124. }
  2125. template <class RealType, class Policy>
  2126. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_quantile_imp(const holtsmark_distribution<RealType, Policy>& dist, const RealType& p, bool complement)
  2127. {
  2128. // This routine implements the quantile for the Holtsmark distribution,
  2129. // the value p may be the probability, or its complement if complement=true.
  2130. constexpr auto function = "boost::math::quantile(holtsmark<%1%>&, %1%)";
  2131. BOOST_MATH_STD_USING // for ADL of std functions
  2132. RealType result = 0;
  2133. RealType scale = dist.scale();
  2134. RealType location = dist.location();
  2135. if (false == detail::check_location(function, location, &result, Policy()))
  2136. {
  2137. return result;
  2138. }
  2139. if (false == detail::check_scale(function, scale, &result, Policy()))
  2140. {
  2141. return result;
  2142. }
  2143. if (false == detail::check_probability(function, p, &result, Policy()))
  2144. {
  2145. return result;
  2146. }
  2147. typedef typename tools::promote_args<RealType>::type result_type;
  2148. typedef typename policies::precision<result_type, Policy>::type precision_type;
  2149. typedef boost::math::integral_constant<int,
  2150. precision_type::value <= 0 ? 0 :
  2151. precision_type::value <= 53 ? 53 :
  2152. precision_type::value <= 113 ? 113 : 0
  2153. > tag_type;
  2154. static_assert(tag_type::value, "The Holtsmark distribution is only implemented for types with known precision, and 113 bits or fewer in the mantissa (ie 128 bit quad-floats");
  2155. result = location + scale * holtsmark_quantile_imp_prec(p, complement, tag_type());
  2156. return result;
  2157. }
  2158. template <class RealType>
  2159. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_entropy_imp_prec(const boost::math::integral_constant<int, 53>&)
  2160. {
  2161. return static_cast<RealType>(2.06944850513462440032);
  2162. }
  2163. template <class RealType>
  2164. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_entropy_imp_prec(const boost::math::integral_constant<int, 113>&)
  2165. {
  2166. return BOOST_MATH_BIG_CONSTANT(RealType, 113, 2.0694485051346244003155800384542166381);
  2167. }
  2168. template <class RealType, class Policy>
  2169. BOOST_MATH_GPU_ENABLED inline RealType holtsmark_entropy_imp(const holtsmark_distribution<RealType, Policy>& dist)
  2170. {
  2171. // This implements the entropy for the Holtsmark distribution,
  2172. constexpr auto function = "boost::math::entropy(holtsmark<%1%>&, %1%)";
  2173. BOOST_MATH_STD_USING // for ADL of std functions
  2174. RealType result = 0;
  2175. RealType scale = dist.scale();
  2176. if (false == detail::check_scale(function, scale, &result, Policy()))
  2177. {
  2178. return result;
  2179. }
  2180. typedef typename tools::promote_args<RealType>::type result_type;
  2181. typedef typename policies::precision<result_type, Policy>::type precision_type;
  2182. typedef boost::math::integral_constant<int,
  2183. precision_type::value <= 0 ? 0 :
  2184. precision_type::value <= 53 ? 53 :
  2185. precision_type::value <= 113 ? 113 : 0
  2186. > tag_type;
  2187. static_assert(tag_type::value, "The Holtsmark distribution is only implemented for types with known precision, and 113 bits or fewer in the mantissa (ie 128 bit quad-floats");
  2188. result = holtsmark_entropy_imp_prec<RealType>(tag_type()) + log(scale);
  2189. return result;
  2190. }
  2191. } // detail
  2192. template <class RealType = double, class Policy = policies::policy<> >
  2193. class holtsmark_distribution
  2194. {
  2195. public:
  2196. typedef RealType value_type;
  2197. typedef Policy policy_type;
  2198. BOOST_MATH_GPU_ENABLED holtsmark_distribution(RealType l_location = 0, RealType l_scale = 1)
  2199. : mu(l_location), c(l_scale)
  2200. {
  2201. constexpr auto function = "boost::math::holtsmark_distribution<%1%>::holtsmark_distribution";
  2202. RealType result = 0;
  2203. detail::check_location(function, l_location, &result, Policy());
  2204. detail::check_scale(function, l_scale, &result, Policy());
  2205. } // holtsmark_distribution
  2206. BOOST_MATH_GPU_ENABLED RealType location()const
  2207. {
  2208. return mu;
  2209. }
  2210. BOOST_MATH_GPU_ENABLED RealType scale()const
  2211. {
  2212. return c;
  2213. }
  2214. private:
  2215. RealType mu; // The location parameter.
  2216. RealType c; // The scale parameter.
  2217. };
  2218. typedef holtsmark_distribution<double> holtsmark;
  2219. #ifdef __cpp_deduction_guides
  2220. template <class RealType>
  2221. holtsmark_distribution(RealType) -> holtsmark_distribution<typename boost::math::tools::promote_args<RealType>::type>;
  2222. template <class RealType>
  2223. holtsmark_distribution(RealType, RealType) -> holtsmark_distribution<typename boost::math::tools::promote_args<RealType>::type>;
  2224. #endif
  2225. template <class RealType, class Policy>
  2226. BOOST_MATH_GPU_ENABLED inline const boost::math::pair<RealType, RealType> range(const holtsmark_distribution<RealType, Policy>&)
  2227. { // Range of permissible values for random variable x.
  2228. BOOST_MATH_IF_CONSTEXPR (boost::math::numeric_limits<RealType>::has_infinity)
  2229. {
  2230. return boost::math::pair<RealType, RealType>(-boost::math::numeric_limits<RealType>::infinity(), boost::math::numeric_limits<RealType>::infinity()); // - to + infinity.
  2231. }
  2232. else
  2233. { // Can only use max_value.
  2234. using boost::math::tools::max_value;
  2235. return boost::math::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max.
  2236. }
  2237. }
  2238. template <class RealType, class Policy>
  2239. BOOST_MATH_GPU_ENABLED inline const boost::math::pair<RealType, RealType> support(const holtsmark_distribution<RealType, Policy>&)
  2240. { // Range of supported values for random variable x.
  2241. // This is range where cdf rises from 0 to 1, and outside it, the pdf is zero.
  2242. BOOST_MATH_IF_CONSTEXPR (boost::math::numeric_limits<RealType>::has_infinity)
  2243. {
  2244. return boost::math::pair<RealType, RealType>(-boost::math::numeric_limits<RealType>::infinity(), boost::math::numeric_limits<RealType>::infinity()); // - to + infinity.
  2245. }
  2246. else
  2247. { // Can only use max_value.
  2248. using boost::math::tools::max_value;
  2249. return boost::math::pair<RealType, RealType>(-tools::max_value<RealType>(), max_value<RealType>()); // - to + max.
  2250. }
  2251. }
  2252. template <class RealType, class Policy>
  2253. BOOST_MATH_GPU_ENABLED inline RealType pdf(const holtsmark_distribution<RealType, Policy>& dist, const RealType& x)
  2254. {
  2255. return detail::holtsmark_pdf_imp(dist, x);
  2256. } // pdf
  2257. template <class RealType, class Policy>
  2258. BOOST_MATH_GPU_ENABLED inline RealType cdf(const holtsmark_distribution<RealType, Policy>& dist, const RealType& x)
  2259. {
  2260. return detail::holtsmark_cdf_imp(dist, x, false);
  2261. } // cdf
  2262. template <class RealType, class Policy>
  2263. BOOST_MATH_GPU_ENABLED inline RealType quantile(const holtsmark_distribution<RealType, Policy>& dist, const RealType& p)
  2264. {
  2265. return detail::holtsmark_quantile_imp(dist, p, false);
  2266. } // quantile
  2267. template <class RealType, class Policy>
  2268. BOOST_MATH_GPU_ENABLED inline RealType cdf(const complemented2_type<holtsmark_distribution<RealType, Policy>, RealType>& c)
  2269. {
  2270. return detail::holtsmark_cdf_imp(c.dist, c.param, true);
  2271. } // cdf complement
  2272. template <class RealType, class Policy>
  2273. BOOST_MATH_GPU_ENABLED inline RealType quantile(const complemented2_type<holtsmark_distribution<RealType, Policy>, RealType>& c)
  2274. {
  2275. return detail::holtsmark_quantile_imp(c.dist, c.param, true);
  2276. } // quantile complement
  2277. template <class RealType, class Policy>
  2278. BOOST_MATH_GPU_ENABLED inline RealType mean(const holtsmark_distribution<RealType, Policy> &dist)
  2279. {
  2280. return dist.location();
  2281. }
  2282. template <class RealType, class Policy>
  2283. BOOST_MATH_GPU_ENABLED inline RealType variance(const holtsmark_distribution<RealType, Policy>& /*dist*/)
  2284. {
  2285. return boost::math::numeric_limits<RealType>::infinity();
  2286. }
  2287. template <class RealType, class Policy>
  2288. BOOST_MATH_GPU_ENABLED inline RealType mode(const holtsmark_distribution<RealType, Policy>& dist)
  2289. {
  2290. return dist.location();
  2291. }
  2292. template <class RealType, class Policy>
  2293. BOOST_MATH_GPU_ENABLED inline RealType median(const holtsmark_distribution<RealType, Policy>& dist)
  2294. {
  2295. return dist.location();
  2296. }
  2297. template <class RealType, class Policy>
  2298. BOOST_MATH_GPU_ENABLED inline RealType skewness(const holtsmark_distribution<RealType, Policy>& /*dist*/)
  2299. {
  2300. // There is no skewness:
  2301. typedef typename Policy::assert_undefined_type assert_type;
  2302. static_assert(assert_type::value == 0, "The Holtsmark Distribution has no skewness");
  2303. return policies::raise_domain_error<RealType>(
  2304. "boost::math::skewness(holtsmark<%1%>&)",
  2305. "The Holtsmark distribution does not have a skewness: "
  2306. "the only possible return value is %1%.",
  2307. boost::math::numeric_limits<RealType>::quiet_NaN(), Policy()); // infinity?
  2308. }
  2309. template <class RealType, class Policy>
  2310. BOOST_MATH_GPU_ENABLED inline RealType kurtosis(const holtsmark_distribution<RealType, Policy>& /*dist*/)
  2311. {
  2312. // There is no kurtosis:
  2313. typedef typename Policy::assert_undefined_type assert_type;
  2314. static_assert(assert_type::value == 0, "The Holtsmark Distribution has no kurtosis");
  2315. return policies::raise_domain_error<RealType>(
  2316. "boost::math::kurtosis(holtsmark<%1%>&)",
  2317. "The Holtsmark distribution does not have a kurtosis: "
  2318. "the only possible return value is %1%.",
  2319. boost::math::numeric_limits<RealType>::quiet_NaN(), Policy());
  2320. }
  2321. template <class RealType, class Policy>
  2322. BOOST_MATH_GPU_ENABLED inline RealType kurtosis_excess(const holtsmark_distribution<RealType, Policy>& /*dist*/)
  2323. {
  2324. // There is no kurtosis excess:
  2325. typedef typename Policy::assert_undefined_type assert_type;
  2326. static_assert(assert_type::value == 0, "The Holtsmark Distribution has no kurtosis excess");
  2327. return policies::raise_domain_error<RealType>(
  2328. "boost::math::kurtosis_excess(holtsmark<%1%>&)",
  2329. "The Holtsmark distribution does not have a kurtosis: "
  2330. "the only possible return value is %1%.",
  2331. boost::math::numeric_limits<RealType>::quiet_NaN(), Policy());
  2332. }
  2333. template <class RealType, class Policy>
  2334. BOOST_MATH_GPU_ENABLED inline RealType entropy(const holtsmark_distribution<RealType, Policy>& dist)
  2335. {
  2336. return detail::holtsmark_entropy_imp(dist);
  2337. }
  2338. }} // namespaces
  2339. #endif // BOOST_STATS_HOLTSMARK_HPP