| |
|
|
p.specht
| The Gammafunktion is known under many others properties The kontinuierliche Variante the Faktoriellenfunktion - z.B. is facto(5)=5*4*3*2*1. The Gammafunktion gamma(x+1) ought to with ganzzahligem reellen Input the same Result supplying How facto(x), and so a (differenzierbare) Formel for Kurvenform the Faktoriellenfunktion supplying. the works but yet not so correctly.: numerous berühmte Näherungen existieren. These stammt from 2007 and becomes in the nachstehenden Program ausgetestet and your absolute deviation determined.
Window Title " Test the Gammafunktions-Näherung to [G.Nemes 2007]"
Window Style 24:Window 0,0-800,%maxy-40:font 2
'https://en.wikipedia.org/wiki/Stirling%27s_approximation#A_convergent_version_of_Stirling's_formula
proc GammaNemes :parameters z!
case z!<1/1e4:return 0:if z!>168:print " *** OVERFLOW ERROR ***":return 0:endif
var uz!=1/z!
return Sqrt(6.2831853071795865*uz!)*(.367879441171442322*(z!+1/(12*z!-.1*uz!)))^z!
endproc
proc facto :parameters x&
case x&<1:return 0
if x&>168:print " *** OVERFLOW ERROR ***":return 0:endif
var p!=1
whileloop x&,1,-1
p!=p!*&Loop
endwhile
return p!
Endproc
'Main part
Declare gamma!
CLS:set("decimals",4)
Whileloop 180
gamma!=GammaNemes(&Loop+1)
Print:print " ",&Loop,
print stature$("%g",facto(&Loop)),
print stature$("%g",round(gamma!,4)),
print " AbsErr: ";stature$("%g",gamma!-facto(&Loop))
waitinput 8000
case %csrlin>34:cls
endwhile
print "---"
waitinput
End
|
|
|
| Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 05/30/21 ▲ |
|
|
|