How can I implement the Gaussian Hypergeometric Function 2F1(a, b, c, z) in C#, with the ability on handling negative and large z values?
2F1 is part of the integral of a certain equation resulting in the following implementation:
internal static double HCWR(double distance, double n)
{
double geometricResult = 2F1(1, 1 / n, 1 + 1 / n, -Math.Pow(distance, -n));
return (Math.Pow(distance, -n) * geometricResult);
}
n can be any number bigger or equal to 2 and distance can be any number in the interval [0,1].
Values like for example a = 1, b = 0.5, c = 1.5 and z = -25.0, which should be 0.27468 aren’t handled well in every implementation I could find. CenterSpace refuses every |z| > 1 and MathNet.Numerics returns -infinity, while I would also prefer an implementation that can handle non-integer values for z.
Clarification: This question seeks for recommendation on implementing math. It’s about implementing a general, well known math function in C# not about libraries, not about tutorials, not about tools, not about books, and not about other off-site resources. It’s about any kind of solution to implement a well known mathematical function that can handle a certain kind of values.
3