How to resolve the algorithm Gamma function step by step in the Phixmonti programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Gamma function step by step in the Phixmonti programming language
Table of Contents
Problem Statement
Implement one algorithm (or more) to compute the Gamma (
Γ
{\displaystyle \Gamma }
) function (in the real field only). If your language has the function as built-in or you know a library which has it, compare your implementation's results with the results of the built-in/library function. The Gamma function can be defined as: This suggests a straightforward (but inefficient) way of computing the
Γ
{\displaystyle \Gamma }
through numerical integration.
Better suggested methods:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Gamma function step by step in the Phixmonti programming language
Source code in the phixmonti programming language
0.577215664901 var gamma
-0.65587807152056 var coeff
-0.042002635033944 var quad
0.16653861138228 var qui
-0.042197734555571 var theSet
def recigamma var z /# n -- n #/
z 6 power theSet *
z 5 power qui *
z 4 power quad *
z 3 power coeff *
z 2 power gamma *
z + + + + +
enddef
/# without var
def recigamma
dup 6 power theSet * swap
dup 5 power qui * swap
dup 4 power quad * swap
dup 3 power coeff * swap
dup 2 power gamma * swap
+ + + + +
enddef
#/
def gammafunc /# n -- n #/
dup 1 == if
else
dup abs 0.5 <= if
recigamma 1 swap /
else
dup 1 - gammafunc swap 1 - *
endif
endif
enddef
0.1 2.1 .1 3 tolist
for
dup print " = " print gammafunc print nl
endfor
You may also check:How to resolve the algorithm Levenshtein distance/Alignment step by step in the Raku programming language
You may also check:How to resolve the algorithm Death Star step by step in the Phix programming language
You may also check:How to resolve the algorithm Stair-climbing puzzle step by step in the Tcl programming language
You may also check:How to resolve the algorithm Verify distribution uniformity/Naive step by step in the Factor programming language
You may also check:How to resolve the algorithm Brownian tree step by step in the zkl programming language