The Math class
in the .NET framework Base Class Libraries implements a large number of
elementary functions. Unfortunately, this list is far from complete.
class in the Extreme.Mathematics
namespace defines many elementary functions that are missing from
Some functions exist in the .NET Framework, but there implementation
is far from optimal. We've implemented them in a more efficient way that
in some cases is up to 50x faster.
Checks if a value is Not-a-Number.
Checks if a value represents a finite real number.
Checks if a value represents positive or negative infinity.
Restricts a value to the specified interval.
Returns the Heaviside step function.
Calculating a trigonometric function for an argument close to a multiple of υ/2 is often problematic.
Fortunately, in the actual expressions, the argument is often expressed as a multiple of υ. In these cases,
it is possible to compute the exact values of the sine, cosine, and tangent. The following methods implement this
Accurately computes the cosine of a value times υ.
Accurately computes the sine of a value times υ.
Accurately computes the tangent of a value times υ.
Returns the unnormalized Sinc function.
A related problem is that the standard methods quickly become less accurate for larger arguments.
To make the calculation of a trigonometric function fast and accurate, the argument must be reduced
to a relatively small interval around zero. This is done by subtracting an integer multiple of υ
from the argument. The standard implementation uses a value of υ with only 66 bits of precision.
Some precision is lost for arguments as small as 30,000.
Worse still, for arguments greater than or equal to 2^63, the argument is returned unchanged.
Aside from the fact that this result is completely meaningless, it can cause problems in code that relies
on the fact that the sine and cosine are bounded by -1 and +1.
The trigonometric methods
perform complete argument reduction, and return accurate results even for very large arguments.
More trigonometric functions
Accurately computes the cosine of a value.
Accurately computes the sine of a value.
Accurately computes the tangent of a value.
Inverse Hyperbolic Functions
Inverse hyperbolic cosine.
Inverse hyperbolic cotangent.
Inverse hyperbolic co-secant.
Inverse hyperbolic secant.
Inverse hyperbolic sine.
Inverse hyperbolic tangent.
Exponential, Logarithmic and Miscellaneous Functions
The functions in this section calculate expressions with a higher accuracy than
using the standard expression would produce.
Exponential, logarithmic, and miscellaneous functions
The exponential function minus one, ex-1,
calculated to high precision when x
is near zero.
The hypotenuse of a right-angled triangle with specified sides.
Lambert's W function, the (real) solution W of
x = WeW.
The natural logarithm of 1+x calculated to high precision
for x close to zero.
A number raised to an integer power.
The difference between the square root of a number close to 1 and 1.
The Pow method is useful only for larger values of the exponent.
For small values, the JIT compiler automatically converts the expression to an optimized multiplication.
Elementary Functions of Decimal Values
The Decimal type is a decimal
floating-point type with up to 28 digits of precision. Transcendental functions like
sine, cosine, exponential and logarithm are not available in the
class implements all the methods that are defined for
Double for the decimal
type to full precision. Because the implementation is mostly in software,
the evaluation of these functions takes significantly longer than
the built-in functions for double-precision numbers.
Elementary functions of decimal values
Inverse tangent with two arguments.
Logarithm with specified base.
Base 10 logarithm.