View source code
Display the source code in std/mathspecial.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinglocal clone.
Function std.mathspecial.beta
Beta function, B(x,y)
real beta(
real x,
real y
) pure nothrow @nogc @safe;
Mathematically, if x > 0 and y > 0 then B(x,y) = ∫01tx-1(l-t)y-1dt. Through analytic continuation, it is extended to ℂ 2 where it can be expressed in terms of Γ(z).
B(x,y) = Γ(x)Γ(y) / Γ(x+y).
This implementation restricts x and y to the set of real numbers.
Parameters
| Name | Description |
|---|---|
| x | the first argument of B |
| y | the second argument of B |
Returns
It returns B(x,y) if it can be computed, otherwise NAN.
| x | y | beta(x, y) |
|---|---|---|
| NAN | y | NAN |
| -∞ | y | NAN |
| integer < 0 | y | NAN |
| noninteger and x+y even ≤ 0 | noninteger | -0 |
| noninteger and x+y odd ≤ 0 | noninteger | +0 |
| +0 | positive finite | +∞ |
| +0 | +∞ | NAN |
| > 0 | +∞ | +0 |
| -0 | +0 | NAN |
| -0 | > 0 | -∞ |
| noninteger < 0, ⌈x⌉ odd | +∞ | -∞ |
| noninteger < 0, ⌈x⌉ even | +∞ | +∞ |
| noninteger < 0 | ±0 | ±∞ |
Since B(x,y) = B(y,x), if the table states that beta(x, y) is a special value, then beta(y, x) is one as well.
Example
writeln(beta(1, 2)); // 0.5
Authors
Stephen L. Moshier (original C code). Conversion to D by Don Clugston
License
Copyright © 1999-2026 by the D Language Foundation | Page generated by ddox.