Skip to content

Compute a Special Function

David Wright edited this page Apr 16, 2018 · 4 revisions

The Meta.Numerics.Functions namespace contains classes and methods for computing the values of special functions. Here is some example code that computes some special function values:

using Meta.Numerics;
using Meta.Numerics.Functions;

// Compute the value x at which erf(x) is just 10^{-15} from 1.
double x = AdvancedMath.InverseErfc(1.0E-15);

// The Gamma function at 1/2 is sqrt(pi)
double y = AdvancedMath.Gamma(0.5);

// Compute a Coulomb Wave Function in the quantum tunneling region
SolutionPair s = AdvancedMath.Coulomb(2, 4.5, 3.0);

// Compute the Reimann Zeta function at a complex value
Complex z = AdvancedComplexMath.RiemannZeta(new Complex(0.75, 6.0));

// Compute the 100th central binomial coefficient
double c = AdvancedIntegerMath.BinomialCoefficient(100, 50);

Most special functions are defined in the Meta.Numerics.Functions namespace as static methods on static classes, analogous to .NET's built-in System.Math class. Functions of real numbers are mostly in the AdvancedMath class. Functions of complex numbers are mostly in the AdvancedIntegerMath class. Functions of complex numbers are mostly in the AdvancedComplexMath class.

What is a special function?

"Special functions" are functions that appear in the solutions of many advanced math and science problems, but aren't common enough to have reached the typical high school curriculum, or the .NET Framework's System.Math class. They are typically the value of some integral, or the solution to some differential equation, or the sum of some infinite series. Most special functions have their own Wikipedia pages, where you can learn more about them.

What special functions are there?

Many special functions are cataloged at the Digital Library of Mathematical Functions and at the Wolfram Functions web-site. Meta.Numerics can compute the values of more than 75 special functions.

How accurate are the returned values?

Most returned values are accurate to nearly-full precision. In practice, that means that you can usually trust up to about 14 decimal digits of the result. There are few regions of a few functions where the precision is lower; these are called out in the API documentation of those functions.

What is a SolutionPair?

Some of the special functions (e.g. Bessel functions, Coulomb functions, Airy functions) are solutions to second order linear differential equations. The theory of differential equations guarantees that there are two independent solutions to such an equation, and many applications require knowing the values for both of these solutions and their derivatives at a given point. For such functions, Meta.Numerics efficiently computes all four of these values simultaneously and wraps them up in a SolutionPair object.

Why are integer-valued functions returned as floating point numbers?

The Meta.Numerics methods for computing many integer-valued functions (e.g. Factorial, BinomialCoefficient, BellNumber) return doubles. This is because the values of these function increase rapidly beyond the range of the built-in integer types. If Factorial returned a long, for example, we could only compute values up to 20!; by returning a double, we can give you values up to 170!

Home

Clone this wiki locally