All problems
Beta Function Value
Problem
Evaluate the beta function B(a, b) = Gamma(a) * Gamma(b) / Gamma(a + b) using the gamma recursion for integer and half-integer arguments.
Define a local gamma helper with Gamma(1) = 1 and Gamma(0.5) = sqrt(pi), then combine the three values.
Hint
For integers, B(a, b) reduces to (a-1)! (b-1)! / (a+b-1)!.
Test cases
case 1
in: [1,1]
expected: 1
case 2
in: [2,3]
expected: 0.08333333333333333
case 3
in: [0.5,0.5]
expected: 3.1415926535897927
case 4
in: [3,3]
expected: 0.03333333333333333
case 5
in: [1,5]
expected: 0.2
Starter codePython
def beta_value(a, b):
# Your code here
pass5 test cases · run your code against them in the editor