A special function is a function that typically cannot be computed using a finite number of elementary functions such as sum, product, composition of finitely many polynomials, rational functions, trigonometric and exponential functions, and their inverse functions. The derivatives of such functions are similar. Because of their importance in many applications like the Gaussian function in statistics, hence we must have a very accurate computation of such functions. We cannot use finite difference here, as we simply cannot afford the inaccuracy. There are special techniques to compute the special functions, such as continued fraction. The special functions and their first order functions are discussed below.

` ````
```val G: Gaussian G = new Gaussian(1, 0, 1); // standard Gaussian
val dG: DGaussian dG = new DGaussian(G);
double x=-0.5;
System.out.println(String.format(dG/dx(%f) = %f", x' dG.evaluate(x)));
x = 0;
System.out.println(String.format(dG/dx(%f) = %f", x' dG.evaluate(x)));
x = 0.5;
System.out.println(String.format(dG/dx(%f) = %f", x' dG.evaluate(x)));

The output is:

` ````
```dG/dx(-0.500000) = 0.176033
dG/dx(0.000000) = -0.000000
dG/dx(0.500000) = -0.176033

` ````
```val E: Erf E = new Erf();
val dE: DErf dE = new DErf();
double z = 0.5;
System.out.println(String.format("erf(%f) = %f", z, E.evaluate(z)));
System.out.println(String.format("dErf/dz(%f) = %f", z, dE.evaluate(z)));

The output is:

` ````
```erf(0.500000) = 0.520500
dErf/dz(0.500000) = 0.878783

` ````
```val B: Beta B = new Beta();
val dB: DBeta dB = new DBeta();
double x = 1.5;
double y = 2.5;
System.out.println(String.format("Beta(%f) = %f", x, B.evaluate(x, y)));
System.out.println(String.format("dBeta/dz(%f) = %f", x, dB.evaluate(x, y)));

The output is:

` ````
```Beta(1.500000) = 0.196350
dBeta/dz(1.500000) = -0.239473

## Regularized Incomplete Beta derivative Function

The Incomplete Beta Function is a generalization of the Beta Function and is defined as

When , the incomplete beta function coincides wit the beta function.

The regularized incomplete beta function or just the regularized beta function in short is defined in terms of the incomplete beta function and the complete beta function. Mathematically

The regularized beta function is the cumulative distributive function of the beta distribution.

` ````
```val I: betaRegularized I = new BetaRegularized(p, q);
val dI: DBetaRegularized dI = new DBetaRegularized(p, q);
double p = 0.5;
double q = 2.5;
double x = 1;
System.out.println(String.format("BetaRegularized(%f) = %f", x, I.evaluate(x)));
System.out.println(String.format("dBetaRegularized/dz(%f) = %f", x, dI.evaluate(x)));

The output is:

` ````
```val G: Gamma G = new GammaLanczosQuick();
val dG: DGAmma dG = new DGamma();
double z = 0.5;
System.out.println(String.format("Gamma(%f) = %f", x, G.evaluate(z)));
System.out.println(String.format("dGamma/dz(%f) = %f", x, dG.evaluate(z)));

The output is:

` ````
```val p: Polynomial p = new Polynomial(1, 2, 1); // x^2 + 2x + 1
val dp: DPolynomial dp = new Dpolynomial(p); // 2x + 2
double x = 1;
System.out.println(String.format("dp/dx(%f) = %f", x, dp.evaluate(x)));

The output is:

` ````
```dp/dx(1.000000) = 4.000000