(20S) Gamma Function Approximation (Stirling) - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (20S) Gamma Function Approximation (Stirling) (/thread-18984.html) |
(20S) Gamma Function Approximation (Stirling) - Eddie W. Shore - 10-19-2022 05:43 AM The gamma function uses the approximation sequence: Let t = x + 9 Then calculate: Let G = Γ(t) ≈ exp( ln √(2 × π ÷ t) + t × ln t - t + (12 × t)^-1 - (360 × t^3)^-1 + (1260 × t^5)^-1 ) Note: (360 × t^3)^-1 = (12 × t)^-1 × (30 × t^2)^-1 (1260 × t^5)^-1 = (360 × t^3)^-1 × (3.5 × t^2)^-1 While x > t: G = G ÷ x x = x + 1 End Loop Display G as the final answer The approximation polynomial is used for higher values because for the approximation is more accurate for higher values. HP 20S: Gamma Approximation (63 steps) Key Code: { Key } Code: 61, 41, b : { LBL B } Examples Γ(0.5) returns 1.77245385109 Γ(4.4) returns 10.1361018514 Calculate the gamma function, press [ XEQ ] B. This program is based on the approximation code of the HP 25. Source: Davidson, Jim, and John Vlissides. "HP-25 Program-Gamma Function" ENTER: 65 NOTES Vol. 3 No. 10 December 1976 RE: (20S) Gamma Function Approximation (Stirling) - Gil - 10-19-2022 10:25 AM Very nice indeed. Thanks. |