Example: The Special Functions

Various special functions are exercised. Their use in this example typifies the manner in which other special functions in the Sfun class would be used.
using System;
using Imsl.Math;

public class SfunEx1
{
	public static void  Main(String[] args)
	{
		double result;
		
		// Log base 10 of x
		double x = 100.0;
		result = Sfun.Log10(x);
		Console.Out.WriteLine("The log base 10 of 100. is " + result);
		
		// Factorial of 10
		int n = 10;
		result = Sfun.Fact(n);
		Console.Out.WriteLine("10 factorial is " + result);
		
		// Gamma of 5.0
		double x1 = 5.0;
		result = Sfun.Gamma(x1);
		Console.Out.WriteLine
			("The Gamma function at 5.0 is " + result);
		
		// LogGamma of 1.85
		double x2 = 1.85;
		result = Sfun.LogGamma(x2);
		Console.Out.WriteLine
			("The logarithm of the absolute value of the " +
			"Gamma function \n    at 1.85 is " + result);
		
		// Beta of (2.2, 3.7)
		double a = 2.2;
		double b = 3.7;
		result = Sfun.Beta(a, b);
		Console.Out.WriteLine("Beta(2.2, 3.7) is " + result);
		
		// LogBeta of (2.2, 3.7)
		double a1 = 2.2;
		double b1 = 3.7;
		result = Sfun.LogBeta(a1, b1);
		Console.Out.WriteLine("logBeta(2.2, 3.7) is " + result + "\n");
	}
}

Output

The log base 10 of 100. is 2
10 factorial is 3628800
The Gamma function at 5.0 is 24
The logarithm of the absolute value of the Gamma function 
    at 1.85 is -0.0559238130196572
Beta(2.2, 3.7) is 0.0453759834847081
logBeta(2.2, 3.7) is -3.09277231203789


Link to C# source.