# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# beta

Beta function

## Syntax

```beta(x,y) ```

## Description

`beta(x,y)` returns the beta function of `x` and `y`.

## Input Arguments

 `x` Symbolic number, variable, expression, function, or a vector or matrix of symbolic numbers, variables, expressions, or functions. If `x` is a vector or matrix, `beta` returns the beta function for each element of `x`.
 `y` Symbolic number, variable, expression, function, or a vector or matrix of symbolic numbers, variables, expressions, or functions. If `y` is a vector or matrix, `beta` returns the beta function for each element of `y`.

## Examples

Compute the beta function for these numbers. Because these numbers are not symbolic objects, you get floating-point results:

`[beta(1, 5), beta(3, sqrt(2)), beta(pi, exp(1)), beta(0, 1)]`
```ans = 0.2000 0.1716 0.0379 Inf```

Compute the beta function for the numbers converted to symbolic objects:

`[beta(sym(1), 5), beta(3, sym(2)), beta(sym(4), sym(4))]`
```ans = [ 1/5, 1/12, 1/140]```

If one or both parameters are complex numbers, convert these numbers to symbolic objects:

`[beta(sym(i), 3/2), beta(sym(i), i), beta(sym(i + 2), 1 - i)]`
```ans = [ (pi^(1/2)*gamma(1i))/(2*gamma(3/2 + 1i)), gamma(1i)^2/gamma(2i),... (pi*(1/2 + 1i/2))/sinh(pi)]```

Compute the beta function for negative parameters. If one or both arguments are negative numbers, convert these numbers to symbolic objects:

`[beta(sym(-3), 2), beta(sym(-1/3), 2), beta(sym(-3), 4), beta(sym(-3), -2)]`
```ans = [ 1/6, -9/2, Inf, Inf]```

Call `beta` for the matrix `A` and the value `1`. The result is a matrix of the beta functions `beta(A(i,j),1)`:

```A = sym([1 2; 3 4]); beta(A,1)```
```ans = [ 1, 1/2] [ 1/3, 1/4]```

Differentiate the beta function, then substitute the variable t with the value 2/3 and approximate the result using `vpa`:

```syms t u = diff(beta(t^2 + 1, t)) vpa(subs(u, t, 2/3), 10)```
```u = beta(t, t^2 + 1)*(psi(t) + 2*t*psi(t^2 + 1) -... psi(t^2 + t + 1)*(2*t + 1)) ans = -2.836889094```

Expand these beta functions:

```syms x y expand(beta(x, y)) expand(beta(x + 1, y - 1))```
```ans = (gamma(x)*gamma(y))/gamma(x + y) ans = -(x*gamma(x)*gamma(y))/(gamma(x + y) - y*gamma(x + y))```

collapse all

### Beta Function

This integral defines the beta function:

`$Β\left(x,y\right)=\underset{0}{\overset{1}{\int }}{t}^{x-1}{\left(1-t\right)}^{y-1}dt=\frac{\Gamma \left(x\right)\Gamma \left(y\right)}{\Gamma \left(x+y\right)}$`

## Tips

• The beta function is uniquely defined for positive numbers and complex numbers with positive real parts. It is approximated for other numbers.

• Calling `beta` for numbers that are not symbolic objects invokes the MATLAB® `beta` function. This function accepts real arguments only. If you want to compute the beta function for complex numbers, use `sym` to convert the numbers to symbolic objects, and then call `beta` for those symbolic objects.

• If one or both parameters are negative numbers, convert these numbers to symbolic objects using `sym`, and then call `beta` for those symbolic objects.

• If the beta function has a singularity, `beta` returns the positive infinity `Inf`.

• `beta(sym(0),0)`, `beta(0,sym(0))`, and `beta(sym(0),sym(0))` return `NaN`.

• `beta(x,y) = beta(y,x)` and ```beta(x,A) = beta(A,x)```.

• At least one input argument must be a scalar or both arguments must be vectors or matrices of the same size. If one input argument is a scalar and the other one is a vector or a matrix, `beta(x,y)` expands the scalar into a vector or matrix of the same size as the other argument with all elements equal to that scalar.

## References

Zelen, M. and N. C. Severo. “Probability Functions.” Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. (M. Abramowitz and I. A. Stegun, eds.). New York: Dover, 1972.