### Author Topic: Gamma!  (Read 3671 times)

0 Members and 1 Guest are viewing this topic.

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
•            • • Posts: 4664
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do. ##### Gamma!
« on: May 17, 2013, 11:08:55 am »
I wanted to show you one result from my work over the past two days, since it lead to some neat derivations. Essentially, it is an approximation that converges to the gamma function. I know, it isn't that awesome, but I had fun Attached are some computation thingies, too, if you wanted to look at it.

#### ruler501

• Meep
• LV11 Super Veteran (Next: 3000)
•           • • Posts: 2475
• Rating: +66/-9
• Crazy Programmer ##### Re: Gamma!
« Reply #1 on: May 17, 2013, 08:26:20 pm »
I see how you prove it is a function that matches that f(x+1)=f(x)*(x+1) but how do you prove it is the gamma function? I thought you could have an infinite number of functions with this feature and the gamma was special in some way that made it a better approximation for most purposes.
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

#### Adriweb

• Editor
• LV10 31337 u53r (Next: 2000)
•          • • Posts: 1708
• Rating: +229/-17 ##### Re: Gamma!
« Reply #2 on: May 17, 2013, 08:46:06 pm »
Interesting read I've worked with those functions for school for like 2 years now I couldn't resist looking things up on Wolfram Alpha with what you said.

It turns out that : ( )

I wanted to graph the difference between the 2 things :
It's commonly known that gamma(x+1) == x!, so graphing what you say is (to see the difference) : A bit weird (against your idea at least) since it doesn't look like it's converging as x gets bigger ?....

But then I saw that W|A actually give what you'd be looking for : the difference between the 2 expressions : But that's not really usable then ^^
(Well, Mathematice 9 doesn't get further, or at least not directly : )
« Last Edit: May 17, 2013, 08:46:47 pm by adriweb »
My calculator programs
TI-Nspire Lua programming : Tutorials  |  API Documentation

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
•            • • Posts: 4664
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do. ##### Re: Gamma!
« Reply #3 on: May 17, 2013, 09:03:15 pm »
That is spectacular, thank you, Adriweb o.o
@ruler501: I believe that the defining characteristic of the Gamma function (the one that makes it unique) is that its concavity is always up. There are infinitely many functions that satisfy the other traits, but once you have a function that satisfies those and is concave up, it must be the Gamma function.

Evidently, I need to see where I have the difference of two ratios wrong Again, thanks!

#### ruler501

• Meep
• LV11 Super Veteran (Next: 3000)
•           • • Posts: 2475
• Rating: +66/-9
• Crazy Programmer ##### Re: Gamma!
« Reply #4 on: May 17, 2013, 11:48:47 pm »
I would think that all factorial functions would be concave up as they are all increasing at ever faster rates

According to wikipedia the thing that makes it unique is that it is superconvex(the composition of it and the log function is concave up)
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
•            • • Posts: 4664
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do. ##### Re: Gamma!
« Reply #5 on: May 22, 2016, 12:49:16 pm »
This time I bring a much better approximation to the Gamma function!
$\Gamma(x+1) \approx f(x)=C\sqrt{x}x^{x}e^{-x+\frac{1}{12x}-\frac{1}{360x^{3}}+\frac{1}{1260x^{5}}}, C\approx2.5066282745692$

The approximation gets better as x gets bigger, too! For example, $\Gamma(1.5)=\frac{\sqrt{\pi}}{2}\approx.8862269255$.
However, $f(.5)\approx.9008942683$ which is terrible accuracy Instead we do $\frac{f(9.5)}{9.5*8.5*7.5*...*1.5}\approx.8862269255$ !

How did I derive this?

First I observed that $ln(n!)=\sum_{k=1}^{n}{ln(k)}=\sum_{k=2}^{n}{ln(k)}$, and then I applied the Euler-Maclaurin formula to get:
$\sum_{k=2}^{n}{log(k)}=\int_{1}^{n}{log(x)dx}+\frac{log(n)-log(1)}{2}+\sum_{k=1}^{\infty}{\frac{B_{2k}(2k-2)!}{(2k)!}\left(n^{1-2k}-1\right)}$
$\sum_{k=2}^{n}{log(k)}=xlog(x)-x+1+\frac{log(n)}{2}+C+\sum_{k=1}^{\infty}{\frac{B_{2k}}{2k(2k-1)}n^{1-2k}}$
From there I tested a few values to approximate C, then I truncated the sum to three terms!

Also, the function $f(1)=1, f(x)=x^{x}f(x-1)$ can be approximated by:
$Cx^{x(x+1)/2}e^{ln(x)/12-x^{2}/4+\frac{1}{720x^{2}}-\frac{1}{5040x^{4}}+\frac{1}{10080x^{6}}}, C\approx1.282427129442$