lanczos.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>The Lanczos Approximation</title>
  5. <link rel="stylesheet" href="../math.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  7. <link rel="home" href="../index.html" title="Math Toolkit 2.11.0">
  8. <link rel="up" href="../backgrounders.html" title="Chapter&#160;22.&#160;Backgrounders">
  9. <link rel="prev" href="relative_error.html" title="Relative Error">
  10. <link rel="next" href="remez.html" title="The Remez Method">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr>
  14. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
  15. <td align="center"><a href="../../../../../index.html">Home</a></td>
  16. <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
  17. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  18. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  19. <td align="center"><a href="../../../../../more/index.htm">More</a></td>
  20. </tr></table>
  21. <hr>
  22. <div class="spirit-nav">
  23. <a accesskey="p" href="relative_error.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../backgrounders.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="remez.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h2 class="title" style="clear: both">
  27. <a name="math_toolkit.lanczos"></a><a class="link" href="lanczos.html" title="The Lanczos Approximation">The Lanczos Approximation</a>
  28. </h2></div></div></div>
  29. <h5>
  30. <a name="math_toolkit.lanczos.h0"></a>
  31. <span class="phrase"><a name="math_toolkit.lanczos.motivation"></a></span><a class="link" href="lanczos.html#math_toolkit.lanczos.motivation">Motivation</a>
  32. </h5>
  33. <p>
  34. <span class="emphasis"><em>Why base gamma and gamma-like functions on the Lanczos approximation?</em></span>
  35. </p>
  36. <p>
  37. First of all I should make clear that for the gamma function over real numbers
  38. (as opposed to complex ones) the Lanczos approximation (See <a href="http://en.wikipedia.org/wiki/Lanczos_approximation" target="_top">Wikipedia
  39. or </a> <a href="http://mathworld.wolfram.com/LanczosApproximation.html" target="_top">Mathworld</a>)
  40. appears to offer no clear advantage over more traditional methods such as
  41. <a href="http://en.wikipedia.org/wiki/Stirling_approximation" target="_top">Stirling's
  42. approximation</a>. <a class="link" href="lanczos.html#pugh">Pugh</a> carried out an extensive
  43. comparison of the various methods available and discovered that they were all
  44. very similar in terms of complexity and relative error. However, the Lanczos
  45. approximation does have a couple of properties that make it worthy of further
  46. consideration:
  47. </p>
  48. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
  49. <li class="listitem">
  50. The approximation has an easy to compute truncation error that holds for
  51. all <span class="emphasis"><em>z &gt; 0</em></span>. In practice that means we can use the
  52. same approximation for all <span class="emphasis"><em>z &gt; 0</em></span>, and be certain
  53. that no matter how large or small <span class="emphasis"><em>z</em></span> is, the truncation
  54. error will <span class="emphasis"><em>at worst</em></span> be bounded by some finite value.
  55. </li>
  56. <li class="listitem">
  57. The approximation has a form that is particularly amenable to analytic
  58. manipulation, in particular ratios of gamma or gamma-like functions are
  59. particularly easy to compute without resorting to logarithms.
  60. </li>
  61. </ul></div>
  62. <p>
  63. It is the combination of these two properties that make the approximation attractive:
  64. Stirling's approximation is highly accurate for large z, and has some of the
  65. same analytic properties as the Lanczos approximation, but can't easily be
  66. used across the whole range of z.
  67. </p>
  68. <p>
  69. As the simplest example, consider the ratio of two gamma functions: one could
  70. compute the result via lgamma:
  71. </p>
  72. <pre class="programlisting"><span class="identifier">exp</span><span class="special">(</span><span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span> <span class="special">-</span> <span class="identifier">lgamma</span><span class="special">(</span><span class="identifier">b</span><span class="special">));</span>
  73. </pre>
  74. <p>
  75. However, even if lgamma is uniformly accurate to 0.5ulp, the worst case relative
  76. error in the above can easily be shown to be:
  77. </p>
  78. <pre class="programlisting"><span class="identifier">Erel</span> <span class="special">&gt;</span> <span class="identifier">a</span> <span class="special">*</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">a</span><span class="special">)/</span><span class="number">2</span> <span class="special">+</span> <span class="identifier">b</span> <span class="special">*</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">b</span><span class="special">)/</span><span class="number">2</span>
  79. </pre>
  80. <p>
  81. For small <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span> that's not a problem,
  82. but to put the relationship another way: <span class="emphasis"><em>each time a and b increase
  83. in magnitude by a factor of 10, at least one decimal digit of precision will
  84. be lost.</em></span>
  85. </p>
  86. <p>
  87. In contrast, by analytically combining like power terms in a ratio of Lanczos
  88. approximation's, these errors can be virtually eliminated for small <span class="emphasis"><em>a</em></span>
  89. and <span class="emphasis"><em>b</em></span>, and kept under control for very large (or very
  90. small for that matter) <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>. Of
  91. course, computing large powers is itself a notoriously hard problem, but even
  92. so, analytic combinations of Lanczos approximations can make the difference
  93. between obtaining a valid result, or simply garbage. Refer to the implementation
  94. notes for the <a class="link" href="sf_beta/beta_function.html" title="Beta">beta</a>
  95. function for an example of this method in practice. The incomplete <a class="link" href="sf_gamma/igamma.html" title="Incomplete Gamma Functions">gamma_p
  96. gamma</a> and <a class="link" href="sf_beta/ibeta_function.html" title="Incomplete Beta Functions">beta</a>
  97. functions use similar analytic combinations of power terms, to combine gamma
  98. and beta functions divided by large powers into single (simpler) expressions.
  99. </p>
  100. <h5>
  101. <a name="math_toolkit.lanczos.h1"></a>
  102. <span class="phrase"><a name="math_toolkit.lanczos.the_approximation"></a></span><a class="link" href="lanczos.html#math_toolkit.lanczos.the_approximation">The
  103. Approximation</a>
  104. </h5>
  105. <p>
  106. The Lanczos Approximation to the Gamma Function is given by:
  107. </p>
  108. <div class="blockquote"><blockquote class="blockquote"><p>
  109. <span class="inlinemediaobject"><img src="../../equations/lanczos0.svg"></span>
  110. </p></blockquote></div>
  111. <p>
  112. Where S<sub>g</sub>(z) is an infinite sum, that is convergent for all z &gt; 0, and <span class="emphasis"><em>g</em></span>
  113. is an arbitrary parameter that controls the "shape" of the terms
  114. in the sum which is given by:
  115. </p>
  116. <div class="blockquote"><blockquote class="blockquote"><p>
  117. <span class="inlinemediaobject"><img src="../../equations/lanczos0a.svg"></span>
  118. </p></blockquote></div>
  119. <p>
  120. With individual coefficients defined in closed form by:
  121. </p>
  122. <div class="blockquote"><blockquote class="blockquote"><p>
  123. <span class="inlinemediaobject"><img src="../../equations/lanczos0b.svg"></span>
  124. </p></blockquote></div>
  125. <p>
  126. However, evaluation of the sum in that form can lead to numerical instability
  127. in the computation of the ratios of rising and falling factorials (effectively
  128. we're multiplying by a series of numbers very close to 1, so roundoff errors
  129. can accumulate quite rapidly).
  130. </p>
  131. <p>
  132. The Lanczos approximation is therefore often written in partial fraction form
  133. with the leading constants absorbed by the coefficients in the sum:
  134. </p>
  135. <div class="blockquote"><blockquote class="blockquote"><p>
  136. <span class="inlinemediaobject"><img src="../../equations/lanczos1.svg"></span>
  137. </p></blockquote></div>
  138. <p>
  139. where:
  140. </p>
  141. <div class="blockquote"><blockquote class="blockquote"><p>
  142. <span class="inlinemediaobject"><img src="../../equations/lanczos2.svg"></span>
  143. </p></blockquote></div>
  144. <p>
  145. Again parameter <span class="emphasis"><em>g</em></span> is an arbitrarily chosen constant, and
  146. <span class="emphasis"><em>N</em></span> is an arbitrarily chosen number of terms to evaluate
  147. in the "Lanczos sum" part.
  148. </p>
  149. <div class="note"><table border="0" summary="Note">
  150. <tr>
  151. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
  152. <th align="left">Note</th>
  153. </tr>
  154. <tr><td align="left" valign="top"><p>
  155. Some authors choose to define the sum from k=1 to N, and hence end up with
  156. N+1 coefficients. This happens to confuse both the following discussion and
  157. the code (since C++ deals with half open array ranges, rather than the closed
  158. range of the sum). This convention is consistent with <a class="link" href="lanczos.html#godfrey">Godfrey</a>,
  159. but not <a class="link" href="lanczos.html#pugh">Pugh</a>, so take care when referring to
  160. the literature in this field.
  161. </p></td></tr>
  162. </table></div>
  163. <h5>
  164. <a name="math_toolkit.lanczos.h2"></a>
  165. <span class="phrase"><a name="math_toolkit.lanczos.computing_the_coefficients"></a></span><a class="link" href="lanczos.html#math_toolkit.lanczos.computing_the_coefficients">Computing
  166. the Coefficients</a>
  167. </h5>
  168. <p>
  169. The coefficients C0..CN-1 need to be computed from <span class="emphasis"><em>N</em></span> and
  170. <span class="emphasis"><em>g</em></span> at high precision, and then stored as part of the program.
  171. Calculation of the coefficients is performed via the method of <a class="link" href="lanczos.html#godfrey">Godfrey</a>;
  172. let the constants be contained in a column vector P, then:
  173. </p>
  174. <p>
  175. P = D B C F
  176. </p>
  177. <p>
  178. where B is an NxN matrix:
  179. </p>
  180. <div class="blockquote"><blockquote class="blockquote"><p>
  181. <span class="inlinemediaobject"><img src="../../equations/lanczos4.svg"></span>
  182. </p></blockquote></div>
  183. <p>
  184. D is an NxN matrix:
  185. </p>
  186. <div class="blockquote"><blockquote class="blockquote"><p>
  187. <span class="inlinemediaobject"><img src="../../equations/lanczos3.svg"></span>
  188. </p></blockquote></div>
  189. <p>
  190. C is an NxN matrix:
  191. </p>
  192. <div class="blockquote"><blockquote class="blockquote"><p>
  193. <span class="inlinemediaobject"><img src="../../equations/lanczos5.svg"></span>
  194. </p></blockquote></div>
  195. <p>
  196. and F is an N element column vector:
  197. </p>
  198. <div class="blockquote"><blockquote class="blockquote"><p>
  199. <span class="inlinemediaobject"><img src="../../equations/lanczos6.svg"></span>
  200. </p></blockquote></div>
  201. <p>
  202. Note than the matrices B, D and C contain all integer terms and depend only
  203. on <span class="emphasis"><em>N</em></span>, this product should be computed first, and then
  204. multiplied by <span class="emphasis"><em>F</em></span> as the last step.
  205. </p>
  206. <h5>
  207. <a name="math_toolkit.lanczos.h3"></a>
  208. <span class="phrase"><a name="math_toolkit.lanczos.choosing_the_right_parameters"></a></span><a class="link" href="lanczos.html#math_toolkit.lanczos.choosing_the_right_parameters">Choosing
  209. the Right Parameters</a>
  210. </h5>
  211. <p>
  212. The trick is to choose <span class="emphasis"><em>N</em></span> and <span class="emphasis"><em>g</em></span> to
  213. give the desired level of accuracy: choosing a small value for <span class="emphasis"><em>g</em></span>
  214. leads to a strictly convergent series, but one which converges only slowly.
  215. Choosing a larger value of <span class="emphasis"><em>g</em></span> causes the terms in the series
  216. to be large and/or divergent for about the first <span class="emphasis"><em>g-1</em></span> terms,
  217. and to then suddenly converge with a "crunch".
  218. </p>
  219. <p>
  220. <a class="link" href="lanczos.html#pugh">Pugh</a> has determined the optimal value of <span class="emphasis"><em>g</em></span>
  221. for <span class="emphasis"><em>N</em></span> in the range <span class="emphasis"><em>1 &lt;= N &lt;= 60</em></span>:
  222. unfortunately in practice choosing these values leads to cancellation errors
  223. in the Lanczos sum as the largest term in the (alternating) series is approximately
  224. 1000 times larger than the result. These optimal values appear not to be useful
  225. in practice unless the evaluation can be done with a number of guard digits
  226. <span class="emphasis"><em>and</em></span> the coefficients are stored at higher precision than
  227. that desired in the result. These values are best reserved for say, computing
  228. to float precision with double precision arithmetic.
  229. </p>
  230. <div class="table">
  231. <a name="math_toolkit.lanczos.optimal_choices_for_n_and_g_when"></a><p class="title"><b>Table&#160;22.1.&#160;Optimal choices for N and g when computing with guard digits (source:
  232. Pugh)</b></p>
  233. <div class="table-contents"><table class="table" summary="Optimal choices for N and g when computing with guard digits (source:
  234. Pugh)">
  235. <colgroup>
  236. <col>
  237. <col>
  238. <col>
  239. <col>
  240. </colgroup>
  241. <thead><tr>
  242. <th>
  243. <p>
  244. Significand Size
  245. </p>
  246. </th>
  247. <th>
  248. <p>
  249. N
  250. </p>
  251. </th>
  252. <th>
  253. <p>
  254. g
  255. </p>
  256. </th>
  257. <th>
  258. <p>
  259. Max Error
  260. </p>
  261. </th>
  262. </tr></thead>
  263. <tbody>
  264. <tr>
  265. <td>
  266. <p>
  267. 24
  268. </p>
  269. </td>
  270. <td>
  271. <p>
  272. 6
  273. </p>
  274. </td>
  275. <td>
  276. <p>
  277. 5.581
  278. </p>
  279. </td>
  280. <td>
  281. <p>
  282. 9.51e-12
  283. </p>
  284. </td>
  285. </tr>
  286. <tr>
  287. <td>
  288. <p>
  289. 53
  290. </p>
  291. </td>
  292. <td>
  293. <p>
  294. 13
  295. </p>
  296. </td>
  297. <td>
  298. <p>
  299. 13.144565
  300. </p>
  301. </td>
  302. <td>
  303. <p>
  304. 9.2213e-23
  305. </p>
  306. </td>
  307. </tr>
  308. </tbody>
  309. </table></div>
  310. </div>
  311. <br class="table-break"><p>
  312. The alternative described by <a class="link" href="lanczos.html#godfrey">Godfrey</a> is to perform
  313. an exhaustive search of the <span class="emphasis"><em>N</em></span> and <span class="emphasis"><em>g</em></span>
  314. parameter space to determine the optimal combination for a given <span class="emphasis"><em>p</em></span>
  315. digit floating-point type. Repeating this work found a good approximation for
  316. double precision arithmetic (close to the one <a class="link" href="lanczos.html#godfrey">Godfrey</a>
  317. found), but failed to find really good approximations for 80 or 128-bit long
  318. doubles. Further it was observed that the approximations obtained tended to
  319. optimised for the small values of z (1 &lt; z &lt; 200) used to test the implementation
  320. against the factorials. Computing ratios of gamma functions with large arguments
  321. were observed to suffer from error resulting from the truncation of the Lancozos
  322. series.
  323. </p>
  324. <p>
  325. <a class="link" href="lanczos.html#pugh">Pugh</a> identified all the locations where the theoretical
  326. error of the approximation were at a minimum, but unfortunately has published
  327. only the largest of these minima. However, he makes the observation that the
  328. minima coincide closely with the location where the first neglected term (a<sub>N</sub>)
  329. in the Lanczos series S<sub>g</sub>(z) changes sign. These locations are quite easy to
  330. locate, albeit with considerable computer time. These "sweet spots"
  331. need only be computed once, tabulated, and then searched when required for
  332. an approximation that delivers the required precision for some fixed precision
  333. type.
  334. </p>
  335. <p>
  336. Unfortunately, following this path failed to find a really good approximation
  337. for 128-bit long doubles, and those found for 64 and 80-bit reals required
  338. an excessive number of terms. There are two competing issues here: high precision
  339. requires a large value of <span class="emphasis"><em>g</em></span>, but avoiding cancellation
  340. errors in the evaluation requires a small <span class="emphasis"><em>g</em></span>.
  341. </p>
  342. <p>
  343. At this point note that the Lanczos sum can be converted into rational form
  344. (a ratio of two polynomials, obtained from the partial-fraction form using
  345. polynomial arithmetic), and doing so changes the coefficients so that <span class="emphasis"><em>they
  346. are all positive</em></span>. That means that the sum in rational form can be
  347. evaluated without cancellation error, albeit with double the number of coefficients
  348. for a given N. Repeating the search of the "sweet spots", this time
  349. evaluating the Lanczos sum in rational form, and testing only those "sweet
  350. spots" whose theoretical error is less than the machine epsilon for the
  351. type being tested, yielded good approximations for all the types tested. The
  352. optimal values found were quite close to the best cases reported by <a class="link" href="lanczos.html#pugh">Pugh</a>
  353. (just slightly larger <span class="emphasis"><em>N</em></span> and slightly smaller <span class="emphasis"><em>g</em></span>
  354. for a given precision than <a class="link" href="lanczos.html#pugh">Pugh</a> reports), and even
  355. though converting to rational form doubles the number of stored coefficients,
  356. it should be noted that half of them are integers (and therefore require less
  357. storage space) and the approximations require a smaller <span class="emphasis"><em>N</em></span>
  358. than would otherwise be required, so fewer floating point operations may be
  359. required overall.
  360. </p>
  361. <p>
  362. The following table shows the optimal values for <span class="emphasis"><em>N</em></span> and
  363. <span class="emphasis"><em>g</em></span> when computing at fixed precision. These should be taken
  364. as work in progress: there are no values for 106-bit significand machines (Darwin
  365. long doubles &amp; NTL quad_float), and further optimisation of the values
  366. of <span class="emphasis"><em>g</em></span> may be possible. Errors given in the table are estimates
  367. of the error due to truncation of the Lanczos infinite series to <span class="emphasis"><em>N</em></span>
  368. terms. They are calculated from the sum of the first five neglected terms -
  369. and are known to be rather pessimistic estimates - although it is noticeable
  370. that the best combinations of <span class="emphasis"><em>N</em></span> and <span class="emphasis"><em>g</em></span>
  371. occurred when the estimated truncation error almost exactly matches the machine
  372. epsilon for the type in question.
  373. </p>
  374. <div class="table">
  375. <a name="math_toolkit.lanczos.optimum_value_for_n_and_g_when_c"></a><p class="title"><b>Table&#160;22.2.&#160;Optimum value for N and g when computing at fixed precision</b></p>
  376. <div class="table-contents"><table class="table" summary="Optimum value for N and g when computing at fixed precision">
  377. <colgroup>
  378. <col>
  379. <col>
  380. <col>
  381. <col>
  382. <col>
  383. </colgroup>
  384. <thead><tr>
  385. <th>
  386. <p>
  387. Significand Size
  388. </p>
  389. </th>
  390. <th>
  391. <p>
  392. Platform/Compiler Used
  393. </p>
  394. </th>
  395. <th>
  396. <p>
  397. N
  398. </p>
  399. </th>
  400. <th>
  401. <p>
  402. g
  403. </p>
  404. </th>
  405. <th>
  406. <p>
  407. Max Truncation Error
  408. </p>
  409. </th>
  410. </tr></thead>
  411. <tbody>
  412. <tr>
  413. <td>
  414. <p>
  415. 24
  416. </p>
  417. </td>
  418. <td>
  419. <p>
  420. Win32, VC++ 7.1
  421. </p>
  422. </td>
  423. <td>
  424. <p>
  425. 6
  426. </p>
  427. </td>
  428. <td>
  429. <p>
  430. 1.428456135094165802001953125
  431. </p>
  432. </td>
  433. <td>
  434. <p>
  435. 9.41e-007
  436. </p>
  437. </td>
  438. </tr>
  439. <tr>
  440. <td>
  441. <p>
  442. 53
  443. </p>
  444. </td>
  445. <td>
  446. <p>
  447. Win32, VC++ 7.1
  448. </p>
  449. </td>
  450. <td>
  451. <p>
  452. 13
  453. </p>
  454. </td>
  455. <td>
  456. <p>
  457. 6.024680040776729583740234375
  458. </p>
  459. </td>
  460. <td>
  461. <p>
  462. 3.23e-016
  463. </p>
  464. </td>
  465. </tr>
  466. <tr>
  467. <td>
  468. <p>
  469. 64
  470. </p>
  471. </td>
  472. <td>
  473. <p>
  474. Suse Linux 9 IA64, gcc-3.3.3
  475. </p>
  476. </td>
  477. <td>
  478. <p>
  479. 17
  480. </p>
  481. </td>
  482. <td>
  483. <p>
  484. 12.2252227365970611572265625
  485. </p>
  486. </td>
  487. <td>
  488. <p>
  489. 2.34e-024
  490. </p>
  491. </td>
  492. </tr>
  493. <tr>
  494. <td>
  495. <p>
  496. 116
  497. </p>
  498. </td>
  499. <td>
  500. <p>
  501. HP Tru64 Unix 5.1B / Alpha, Compaq C++ V7.1-006
  502. </p>
  503. </td>
  504. <td>
  505. <p>
  506. 24
  507. </p>
  508. </td>
  509. <td>
  510. <p>
  511. 20.3209821879863739013671875
  512. </p>
  513. </td>
  514. <td>
  515. <p>
  516. 4.75e-035
  517. </p>
  518. </td>
  519. </tr>
  520. </tbody>
  521. </table></div>
  522. </div>
  523. <br class="table-break"><p>
  524. Finally note that the Lanczos approximation can be written as follows by removing
  525. a factor of exp(g) from the denominator, and then dividing all the coefficients
  526. by exp(g):
  527. </p>
  528. <div class="blockquote"><blockquote class="blockquote"><p>
  529. <span class="inlinemediaobject"><img src="../../equations/lanczos7.svg"></span>
  530. </p></blockquote></div>
  531. <p>
  532. This form is more convenient for calculating lgamma, but for the gamma function
  533. the division by <span class="emphasis"><em>e</em></span> turns a possibly exact quality into
  534. an inexact value: this reduces accuracy in the common case that the input is
  535. exact, and so isn't used for the gamma function.
  536. </p>
  537. <h5>
  538. <a name="math_toolkit.lanczos.h4"></a>
  539. <span class="phrase"><a name="math_toolkit.lanczos.references"></a></span><a class="link" href="lanczos.html#math_toolkit.lanczos.references">References</a>
  540. </h5>
  541. <div class="orderedlist"><ol class="orderedlist" type="1">
  542. <li class="listitem">
  543. <a name="godfrey"></a>Paul Godfrey, <a href="http://my.fit.edu/~gabdo/gamma.txt" target="_top">"A
  544. note on the computation of the convergent Lanczos complex Gamma approximation"</a>.
  545. </li>
  546. <li class="listitem">
  547. <a name="pugh"></a>Glendon Ralph Pugh, <a href="http://bh0.physics.ubc.ca/People/matt/Doc/ThesesOthers/Phd/pugh.pdf" target="_top">"An
  548. Analysis of the Lanczos Gamma Approximation"</a>, PhD Thesis November
  549. 2004.
  550. </li>
  551. <li class="listitem">
  552. Viktor T. Toth, <a href="http://www.rskey.org/gamma.htm" target="_top">"Calculators
  553. and the Gamma Function"</a>.
  554. </li>
  555. <li class="listitem">
  556. Mathworld, <a href="http://mathworld.wolfram.com/LanczosApproximation.html" target="_top">The
  557. Lanczos Approximation</a>.
  558. </li>
  559. </ol></div>
  560. </div>
  561. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  562. <td align="left"></td>
  563. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
  564. Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
  565. Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
  566. R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
  567. Daryle Walker and Xiaogang Zhang<p>
  568. Distributed under the Boost Software License, Version 1.0. (See accompanying
  569. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  570. </p>
  571. </div></td>
  572. </tr></table>
  573. <hr>
  574. <div class="spirit-nav">
  575. <a accesskey="p" href="relative_error.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../backgrounders.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="remez.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  576. </div>
  577. </body>
  578. </html>