{"id":16692502,"url":"https://github.com/ckormanyos/gamma_f77","last_synced_at":"2026-01-02T03:40:16.355Z","repository":{"id":191350793,"uuid":"684466444","full_name":"ckormanyos/gamma_f77","owner":"ckormanyos","description":"real-valued gamma function in quad-precision using classic Fortran77","archived":false,"fork":false,"pushed_at":"2024-08-17T12:16:33.000Z","size":51,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-20T18:11:29.012Z","etag":null,"topics":["fortran","fortran77","gamma-function","numerical-methods","quadruple-precision","special-function","special-functions"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ckormanyos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-29T07:23:44.000Z","updated_at":"2024-08-19T19:06:07.000Z","dependencies_parsed_at":"2024-08-04T11:04:01.241Z","dependency_job_id":null,"html_url":"https://github.com/ckormanyos/gamma_f77","commit_stats":null,"previous_names":["ckormanyos/gamma_f77"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Fgamma_f77","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Fgamma_f77/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Fgamma_f77/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Fgamma_f77/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ckormanyos","download_url":"https://codeload.github.com/ckormanyos/gamma_f77/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243495484,"owners_count":20299921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fortran","fortran77","gamma-function","numerical-methods","quadruple-precision","special-function","special-functions"],"created_at":"2024-10-12T16:27:21.147Z","updated_at":"2026-01-02T03:40:16.331Z","avatar_url":"https://github.com/ckormanyos.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"gamma_f77\n==================\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/ckormanyos/gamma_f77/actions\"\u003e\n        \u003cimg src=\"https://github.com/ckormanyos/gamma_f77/actions/workflows/gamma_f77.yml/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/ckormanyos/gamma_f77\" \u003e \n        \u003cimg src=\"https://codecov.io/gh/ckormanyos/gamma_f77/graph/badge.svg?token=rn9o8UoMRm\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/ckormanyos/gamma_f77/blob/master/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-BSL%201.0-blue.svg\" alt=\"Boost Software License 1.0\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://godbolt.org/z/xPWhqab9z\" alt=\"godbolt\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/try%20it%20on-godbolt-green\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n`ckormanyos/gamma_f77` implements the real-valued Gamma function\nin quadruple-precision using the classic `Fortran77` language.\n\n## Mathematical Background\n\nThe gamma function $\\Gamma\\left(z\\right)$ is the complex-valued extension\nof the well-known integer factorial function.\n\nFor $\\mathbb{Re}\\left(z\\right) \u003e 0$, $\\Gamma\\left(z\\right)$ is defined by\n\n$$\\Gamma\\left(z\\right)=\\int_{0}^{\\infty}t^{z-1} e^{t} dt\\text{,}$$\n\n$\\Gamma\\left(z\\right)$ has a value of complex-infinity at the origin and also\nhas poles at integer values along the negative real axis.\n\nReflection is given by\n\n$$ \\Gamma(-z)= \\frac{\\pi}{z\\Gamma\\left(z\\right)\\sin\\left(\\pi z\\right)}\\text{.}$$\n\nReccurence is given by\n\n$$ \\Gamma\\left(z+1\\right)= z\\Gamma\\left(z\\right)\\text{.}$$\n\n## Calculation Method\n\nLet's look at some background information regarding\ncomputations of the real-valued gamma function.\n\nThe real-valued gamma function, $\\Gamma\\left(x\\right)$\ncan be readily calculated using a series expansion\nfor its reciprocal near the origin.\nLarge arguments valued greater than one use recurrence.\nFor negative argument, the function value for the corresponding\npositive-valued argument is first calculated and the value\nfor negative argument is obtaind via reflection.\n\nConsider the series expansion of the reciprocal of the gamma function\nnear the origin\n\n$$ \\frac{1}{\\Gamma\\left(z\\right)}\\approx \\sum_{k=1}^{n} a^{k} z^{k}\\text{.}$$\n\nIn the subroutine `GAMMA` in Sect. 3.1.5 on pages 49-50 of [1],\nthe coefficients $a_{k}$ are given to $26$ terms. These are used\nin a series calculation of $\\Gamma\\left(x\\right)$ for real-valued $x$\nusing `Fortran77`'s double-precision data type `REAL*8`.\nFurther information on this coefficient expansion can be found\nin Sect. 6.1.34 of [2], in Sect. 5.7.1 of [3]\nand in additional references therein.\n\nSee also\n[Wolfram Alpha(R)](https://www.wolframalpha.com/input?i=Series%5B1%2FGamma%5Bz%5D%2C+%7Bz%2C+0%2C+3%7D%5D)\nfor brief mathematical insight into the fascinating\nseries expansion of the reciprocal of the gamma function near the origin.\n\n## Expanded Quadruple-Precision Implementation\n\nIn this repository, the series calculation mentioned above has been\nextended to quadruple-precision.\n\nThe coefficients $a_{k}$ have been expanded (via computer algebra)\nto $48$ terms having $51$ decimal digits of precision. With this coefficient list,\nit is possible to reach the quadruple-precision of `Fortran77`'s data type `REAL*16`.\nThese higher-precision coefficients can be found in the table `G` in the\n[source code](https://github.com/ckormanyos/gamma_f77/blob/main/gamma.f).\n\nThe implementation uses the `gfortran` dialect that is available in `g++`.\n\n## Test-Run and CI\n\n### Continuous Integration\n\nContinuous integration (CI) runs with gfortran using GHA ubuntu-latest\nand macos-latest runners. CI exercises both building `gamma` as well as running\nseveral straightforward `gamma` test cases.\n\nA (growing) test suite is present in both the build workflows\nas well as in [`cover.sh`](./.gcov/make/cover.sh).\nThese tests are used in CI to verify the expected functionality and also\nto obtain [code coverage results](https://app.codecov.io/gh/ckormanyos/gamma_f77).\n\n### Testing\n\nThe test-run computes $9$ gamma values $\\Gamma\\left(x\\right)$\nfor positive, real-valued arguments at\n\n$$x = 1.11, 2.21, 3.31, {\\ldots} 9.91\\text{.}$$\n\nNegative reflection is tested at\n\n$$x=-4.56\\text{.}$$\n\nIntegral-valued argument is checked for\n\n$$x=31\\text{,}$$\n\nwhich is used to compute $\\Gamma\\left(31\\right)$, the result of which\nis expected to be equal to the integral factorial\n\n$$30 ! = 265,252,859,812,191,058,636,308,480,000,000 \\text{.}$$\n\nCI runs on Ubuntu and MacOS using `g++`.\nCorrect numerical results are verified on the OS-level\nup to the $33$ decimal digit precision using the built-in\nprogram `grep`.\n\nThe program can also be compiled and executed at this\n[short link](https://godbolt.org/z/xPWhqab9z)\nto [godbolt](https://godbolt.org).\n\n## Long Standards-Conforming Time-Span\n\nThe program compiles with language standards `legacy` (i.e., `Fortran77`)\nas well as all the way up to modern `f2023`.\n\nThis is a remarkably long standards-conforming time-span.\nIt exceeds 40 years - with hopefully more to come!\n\nProving this longevity in this repository was achieved in part\nthrough contributions from [@Beliavsky](https://github.com/Beliavsky).\nThese were initially proposed in [gamma_f77/issues/13](https://github.com/ckormanyos/gamma_f77/issues/13).\nThank you for these contributions.\n\n## References\n\n[1] Shanjie Zhang and Jianming Jin, _Computation_ _of_ _Special_ _Functions_,\nWiley, 1996, ISBN: 0-471-11963-6, LC: QA351.C45\n\n[2] M. Abramowitz and I.A. Stegun, _Handbook_ _of_ _Mathematical_ _Functions_,\n9th Printing, Dover Publications, 1970.\n\n[3] F.W.J. Olver, D.W. Lozier, R.F. Boisvert and C.W. Clark,\n_NIST_ _Handbook_ _of_ _Mathematical_ _Functions_,\nCambridge University Press, 2010.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckormanyos%2Fgamma_f77","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fckormanyos%2Fgamma_f77","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckormanyos%2Fgamma_f77/lists"}