# dart-numerics

`dart-numerics` is an ultimate mathematical package inspired by .NET analogue, aiming to provide methods and algorithms for numerical computations in science, engineering and every day use.

## Usage

A simple usage example:

``````import 'package:dart_numerics/dart_numerics.dart' as numerics;

main() {
print(numerics.acosh(numerics.pi / 2));
}
``````

## Classes

Permutation
Class to represent a permutation for a subset of the natural numbers.

## Constants

catalan → const double
The Catalan constant [...]
`0.9159655941772190150546035149323841107741493742816721342664981196217630197762547694794`
degree → const double
The number (pi)/180 - factor to convert from Degree (deg) to Radians (rad).
`0.017453292519943295769236907684886127134428718885417`
doubleWidth → const int
The number of binary digits used to represent the binary number for a double precision floating point value. i.e. there are this many digits used to represent the actual number, where in a number as: 0.134556 * 10^5 the digits are 0.134556 and the exponent is 5.
`53`
e → const double
The number e
`2.7182818284590452353602874713526624977572470937000`
epsilon → const double
The smallest positive `double` value that is greater than zero.
`4.94065645841247E-324`
eulerMascheroni → const double
The Euler-Mascheroni constant [...]
`0.5772156649015328606065120900824024310421593359399235988057672348849`
factorialMaxArgument → const int
`170`
glaisher → const double
The Glaisher constant [...]
`1.2824271291006226368753425688697917277676889273250011920637400217404063088588264611297`
goldenRatio → const double
The number (1+sqrt(5))/2, also known as the golden ratio
`1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072`
`0.015707963267948966192313216916397514420985846996876`
halfSqrt3 → const double
The number sqrt(3)/2
`0.86602540378443864676372317075293618347140262690520`
int64MaxValue → const int
The biggest possible value of an int within 64 bits.
`9223372036854775807`
int64MinValue → const int
The smallest possible value of an int within 64 bits.
`-9223372036854775808`
invE → const double
The number 1/e
`0.36787944117144232159552377016146086744581113103176`
invPi → const double
The number 1/pi
`0.31830988618379067153776752674502872406891929148091`
invSqrt2Pi → const double
The number 1/sqrt(2pi)
`0.39894228040143267793994605993438186847585863116492`
invSqrtPi → const double
The number 1/sqrt(pi)
`0.56418958354775628694807945156077258584405062932899`
khinchin → const double
The Khinchin constant [...]
`2.6854520010653064453097148354817956938203822939944629530511523455572188595371520028011`
ln2 → const double
The number loge
`0.69314718055994530941723212145817656807550013436026`
ln2PiOver2 → const double
The number loge/2
`0.91893853320467274178032973640561763986139747363780`
ln10 → const double
The number loge
`2.3025850929940456840179914546843642076011014886288`
lnPi → const double
The number loge
`1.1447298858494001741434273513530587116472948129153`
log2E → const double
The number log2
`1.4426950408889634073599246810018921374266459541530`
log10E → const double
The number log10
`0.43429448190325182765112891891660508229439700580366`
logSqrt2PiE → const double
The number log(sqrt(2pie))
`1.4189385332046727417803297364056176398613974736378`
logTwoSqrtEOverPi → const double
The number log(2 * sqrt(e / pi))
`0.6207822376352452223455184457816472122518527279025978`
neutralDecibel → const double
The number ln(10)/10 - factor to convert from Neutral Decibel (dB) to Neper (Np). Use this version when either both or neither of the Decibel and the compared values represent powers.
`0.23025850929940456840179914546843642076011014886288`
pi → const double
The number pi
`3.1415926535897932384626433832795028841971693993751`
pi2 → const double
The number pi*2
`6.2831853071795864769252867665590057683943387987502`
pi3Over2 → const double
The number pi*3/2
`4.71238898038468985769396507491925432629575409906266`
piOver2 → const double
The number pi/2
`1.5707963267948966192313216916397514420985846996876`
piOver4 → const double
The number pi/4
`0.78539816339744830961566084581987572104929234984378`
powerDecibel → const double
The number ln(10)/20 - factor to convert from Power Decibel (dB) to Neper (Np). Use this version when the Decibel represent a power gain but the compared values are not powers (e.g. amplitude, current, voltage).
`0.11512925464970228420089957273421821038005507443144`
sogSqrt2Pi → const double
The number log(sqrt(2*pi))
`0.91893853320467274178032973640561763986139747363778`
sqrt1Over2 → const double
The number sqrt(1/2) = 1/sqrt(2) = sqrt(2)/2
`0.70710678118654752440084436210484903928483593768845`
sqrt2 → const double
The number sqrt(2)
`1.4142135623730950488016887242096980785696718753769`
sqrt2Pi → const double
The number sqrt(2pi)
`2.5066282746310005024157652848110452530069867406099`
sqrt2PiE → const double
The number sqrt(2pie)
`4.1327313541224929384693918842998526494455219169913`
sqrt3 → const double
The number sqrt(3)
`1.7320508075688772935274463415058723669428052538104`
sqrtE → const double
The number sqrt(e)
`1.6487212707001281468486507878141635716537761007101`
sqrtPi → const double
The number sqrt(pi)
`1.7724538509055160272981674833411451827975494561224`
twoInvPi → const double
The number 2/pi
`0.63661977236758134307553505349005744813783858296182`
twoInvSqrtPi → const double
The number 2/sqrt(pi)
`1.1283791670955125738961589031215451716881012586580`
twoSqrtEOverPi → const double
The number 2 * sqrt(e / pi)
`1.8603827342052657173362492472666631120594218414085755`

## Properties

doubleDecimalPlaces int
The number of significant decimal places of double-precision floating numbers (64 bit).
final
doublePrecision
Standard epsilon, the maximum relative precision of IEEE 754 double-precision floating numbers (64 bit). [...]
final
machineEpsilon
Actual double precision machine epsilon, the smallest number that can be subtracted from 1, yielding a results different than 1. [...]
final
multiplyDeBruijnBitPosition List<int>
positiveDoublePrecision
Standard epsilon, the maximum relative precision of IEEE 754 double-precision floating numbers (64 bit).
final
positiveMachineEpsilon
Actual double precision machine epsilon, the smallest number that can be added to 1, yielding a results different than 1. [...]
final

## Functions

Trigonometric principal Arc Cosine in radian.
acosh(double value)
Hyperbolic Area Cosine.
Trigonometric principal Arc Cotangent in radian.
acoth(double value)
Hyperbolic Area Cotangent.
acsc(double hypotenuse)
Trigonometric principal Arc Cosecant in radian.
acsch(double value)
Hyperbolic Area Cosecant.
almostEqual(double a, ) bool
Checks whether two double numbers are almost equal.
almostEqualD(double a, double b, double maximumAbsoluteError) bool
Compares two doubles and determines if they are equal within the specified maximum error.
almostEqualI(double a, double b, int decimals) bool
Compares two doubles and determines if they are equal within the specified maximum error.
almostEqualNormD(double a, double b, double diff, double maximumAbsoluteError) bool
Compares two doubles and determines if they are equal within the specified maximum absolute error.
almostEqualNormI(double a, double b, double diff, int decimalPlaces) bool
Compares two doubles and determines if they are equal to within the specified number of decimal places or not, using the number of decimal places as an absolute measure.
almostEqualNormRelativeD(double a, double b, double diff, double maximumError) bool
Compares two doubles and determines if they are equal within the specified maximum error.
almostEqualNormRelativeI(double a, double b, double diff, int decimalPlaces) bool
Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
almostEqualNumbersBetween(double a, double b, int maxNumbersBetween) bool
Compares two doubles and determines if they are equal to within the tolerance or not. Equality comparison is based on the binary representation. [...]
almostEqualRelativeD(double a, double b, double maximumError) bool
Compares two doubles and determines if they are equal within the specified maximum error.
almostEqualRelativeI(double a, double b, int decimalPlaces) bool
Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.
asec(double hypotenuse)
Trigonometric principal Arc Secant in radian.
asech(double value)
Hyperbolic Area Secant.
asin(double opposite)
Trigonometric principal Arc Sine in radian.
asinh(double value)
Hyperbolic Area Sine.
atan(double opposite)
Trigonometric principal Arc Tangent in radian
atanh(double value)
Hyperbolic Area Tangent.
beta(double z, )
Computes the Euler Beta function.
betaIncomplete(double a, double b, )
Returns the lower incomplete (unregularized) beta function B(a,b,x) = int(t^(a-1)*(1-t)^(b-1),t=0..x) for real a > 0, b > 0, 1 >= x >= 0.
betaLn(double z, )
Computes the logarithm of the Euler Beta function.
betaRegularized(double a, double b, )
Returns the regularized lower incomplete beta function I_x(a,b) = 1/Beta(a,b) * int(t^(a-1)*(1-t)^(b-1),t=0..x) for real a > 0, b > 0, 1 >= x >= 0.
binomial(int n, int k)
Computes the binomial coefficient: `n` choose `k`.
binomialLn(int n, int k)
Computes the natural logarithm of the binomial coefficient: ln(`n` choose `k`).
ceilingToPowerOfTwo(int number) int
Find the closest perfect power of two that is larger or equal to the provided integer.
coerceZero()
Forces small numbers near zero to zero. [...]
coerceZeroD(double a, double maximumAbsoluteError)
Forces small numbers near zero to zero, according to the specified absolute accuracy. [...]
coerceZeroI(double a, int maxNumbersBetween)
Forces small numbers near zero to zero, according to the specified absolute accuracy.
compareToD(double a, double b, double maximumAbsoluteError) int
Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
compareToI(double a, double b, int decimalPlaces) int
Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
compareToNumbersBetween(double a, double b, int maxNumbersBetween) int
Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
compareToRelativeD(double a, double b, double maximumError) int
Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
compareToRelativeI(double a, double b, int decimalPlaces) int
Compares two doubles and determines which double is bigger. a < b -> -1; a ~= b (almost equal according to parameter) -> 0; a > b -> +1.
Trigonometric Cosine of an angle in `radian`, or adjacent / hypotenuse.
cosh(double angle)
Hyperbolic Cosine.
Trigonometric Cotangent of an angle in `radian`, or adjacent / opposite. Reciprocal of the tangent.
coth(double angle)
Hyperbolic Cotangent.
Trigonometric Cosecant of an angle in `radian`, or hypotenuse / opposite. Reciprocal of the sine.
csch(double angle)
Hyperbolic Cosecant.
decrement(double value, [ int count = 1 ])
Decrements a floating point number to the next smaller number representable by the data type. [...]
Converts a `degree` (360-periodic) angle to a grad (400-periodic) angle.
Converts a `degree` (360-periodic) angle to a radian (2*Pi-periodic) angle.
diGamma()
Computes the Digamma function which is mathematically defined as the derivative of the logarithm of the gamma function. [...]
diGammaInv()
Computes the inverse Digamma function: this is the inverse of the logarithm of the gamma function. This function will only return solutions that are positive. [...]
epsilonOf(double value)
Evaluates the minimum distance to the next distinguishable number near the argument value. [...]
exponentialIntegral(double x, int n)
Computes the generalized Exponential Integral function (En). [...]
factorialBig()
Computes the factorial of an integer.
factorialD(int x)
Computes the factorial function `x` -> `x`! of an integer number > 0. The function can represent all number up to 22! exactly, all numbers up to 170! using a double representation. All larger values will overflow. [...]
factorialLn(int x)
Computes the logarithmic factorial function `x` -> ln(`x`!) of an integer number > 0.
fit( x, y) Tuple2<double, double>
Least-Squares fitting the points (x,y) to a line y : x -> a+b*x, returning its best fitting parameters as (a, b) tuple, where a is the intercept and b the slope.
fitFromMany( samples) Tuple2<double, double>
Least-Squares fitting the points (x,y) to a line y : x -> a+b*x, returning its best fitting parameters as (a, b) tuple, where a is the intercept and b the slope.
fitThroughOrigin( x, y)
Least-Squares fitting the points (x,y) to a line y : x -> b*x, returning its best fitting parameter b, where the intercept is zero and b the slope.
fitThroughOriginFromMany( samples)
Least-Squares fitting the points (x,y) to a line y : x -> b*x, returning its best fitting parameter b, where the intercept is zero and b the slope.
gamma()
Computes the Gamma function. [...]
gammaLn()
Computes the logarithm of the Gamma function. [...]
gammaLowerIncomplete(double a, )
Returns the lower incomplete gamma function gamma(a,x) = int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.
gammaLowerRegularized(double a, )
Returns the lower incomplete regularized gamma function P(a,x) = 1/Gamma(a) * int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.
gammaUpperIncomplete(double a, )
Returns the upper incomplete gamma function Gamma(a,x) = int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.
gammaUpperRegularized(double a, )
Returns the upper incomplete regularized gamma function Q(a,x) = 1/Gamma(a) * int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.
Converts a `grad` (400-periodic) angle to a degree (360-periodic) angle.
Converts a `grad` (400-periodic) angle to a radian (2*Pi-periodic) angle.
greatestCommonDivisor(int a, int b) int
Returns the greatest common divisor (gcd) of two integers using Euclid's algorithm.
greatestCommonDivisorBig(BigInt a, )
Returns the greatest common divisor (gcd) of two BigInt using Euclid's algorithm.
greatestCommonDivisorOfMany(List<int> integers) int
Returns the greatest common divisor (gcd) of two integers using Euclid's algorithm.
greatestCommonDivisorOfManyBig( integers)
Returns the greatest common divisor (gcd) of many BigInt using Euclid's algorithm.
increment(double value, [ int count = 1 ])
Increments a floating point number to the next bigger number representable by the data type. [...]
isEven(int number) bool
Find out whether the provided integer is an even number.
isLargerD(double a, double b, double maximumAbsoluteError) bool
Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
isLargerI(double a, double b, int decimalPlaces) bool
Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
isLargerNumbersBetween(double a, double b, int maxNumbersBetween) bool
Compares two doubles and determines if the `a` value is larger than the `b` value to within the tolerance or not. Equality comparison is based on the binary representation.
isLargerRelativeD(double a, double b, double maximumError) bool
Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
isLargerRelativeI(double a, double b, int decimalPlaces) bool
Compares two doubles and determines if the first value is larger than the second value to within the specified number of decimal places or not.
isOdd(int number) bool
Find out whether the provided integer is an odd number.
isPerfectSquare(int number) bool
Find out whether the provided integer is a perfect square, i.e. a square of an integer. [...]
isPowerOfTwo(int number) bool
Find out whether the provided integer is a perfect power of two. [...]
isSmallerD(double a, double b, double maximumAbsoluteError) bool
Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
isSmallerI(double a, double b, int decimalPlaces) bool
Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
isSmallerNumbersBetween(double a, double b, int maxNumbersBetween) bool
Compares two doubles and determines if the `a` value is smaller than the `b` value to within the tolerance or not. Equality comparison is based on the binary representation.
isSmallerRelativeD(double a, double b, double maximumError) bool
Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
isSmallerRelativeI(double a, double b, int decimalPlaces) bool
Compares two doubles and determines if the first value is smaller than the second value to within the specified number of decimal places or not.
leastCommonMultiple(int a, int b) int
Returns the least common multiple (lcm) of two integers using Euclid's algorithm.
leastCommonMultipleBig(BigInt a, )
Returns the least common multiple (lcm) of two BigInt using Euclid's algorithm.
leastCommonMultipleOfMany(List<int> integers) int
Returns the least common multiple (lcm) of many BigInt using Euclid's algorithm.
leastCommonMultipleOfManyBig( integers)
Returns the least common multiple (lcm) of many BigInt using Euclid's algorithm.
line( x, y) Tuple2<double, double>
Least-Squares fitting the points (x,y) to a line y : x -> a+b*x, returning its best fitting parameters as `a, b` array, where a is the intercept and b the slope.
lineFunc( x, y) double Function(double)
Least-Squares fitting the points (x,y) to a line y : x -> a+b*x, returning a function y' for the best fitting line.
lineThroughOrigin( x, y)
Least-Squares fitting the points (x,y) to a line through origin y : x -> b*x, returning its best fitting parameter b, where the intercept is zero and b the slope.
lineThroughOriginFunc( x, y) double Function(double)
Least-Squares fitting the points (x,y) to a line through origin y : x -> b*x, returning a function y' for the best fitting line.
log2(int number) int
Evaluate the binary logarithm of an integer number. [...]
log10(num x)
Converts `x` to a double and returns the common logarithm of the value. [...]
logistic()
Computes the logistic function. see: http://en.wikipedia.org/wiki/Logistic
logit()
Computes the logit function, the inverse of the sigmoid logistic function. see: http://en.wikipedia.org/wiki/Logit
magnitude(double value) int
Returns the magnitude of the number.
maximumMatchingFloatingPointNumber(double value, int maxNumbersBetween)
Returns the floating point number that will match the value with the tolerance on the maximum size (i.e. the result is always bigger than the value)
minimumMatchingFloatingPointNumber(double value, int maxNumbersBetween)
Returns the floating point number that will match the value with the tolerance on the minimum size (i.e. the result is always smaller than the value)
modulusBig(BigInt dividend, BigInt divisor)
Canonical Modulus. The result has the sign of the divisor.
modulusD(double dividend, double divisor)
Canonical Modulus. The result has the sign of the divisor.
modulusI(int dividend, int divisor) int
Canonical Modulus. The result has the sign of the divisor.
multinomial(int n, List<int> ni)
Computes the multinomial coefficient: `n` choose n1, n2, n3, ...
numbersBetween(double a, ) int
Evaluates the count of numbers between two double numbers [...]
positiveEpsilonOf(double value)
Evaluates the minimum distance to the next distinguishable number near the argument value. [...]
powerOfTwo(int exponent) int
Raises 2 to the provided integer `exponent` (0 < `exponent`).
Converts a `radian` (2*Pi-periodic) angle to a degree (360-periodic) angle.
Converts a `radian` (2*Pi-periodic) angle to a grad (400-periodic) angle.
rangeOfMatchingFloatingPointNumbers(double value, int maxNumbersBetween) Tuple2<double, double>
Determines the range of floating point numbers that will match the specified value with the given tolerance.
rangeOfMatchingNumbers(double value, double relativeDifference) Tuple2<int, int>
Determines the range of ulps that will match the specified value with the given tolerance. [...]
remainder(BigInt dividend, BigInt divisor)
Remainder (% operator). The result has the sign of the dividend.
remainderD(double dividend, double divisor)
Remainder (% operator). The result has the sign of the dividend.
remainderI(int dividend, int divisor) int
Remainder (% operator). The result has the sign of the dividend.
scaleUnitMagnitude(double value)
Returns the number divided by it's magnitude, effectively returning a number between -10 and 10.
Trigonometric Secant of an angle in `radian`, or hypotenuse / adjacent. Reciprocal of the cosine.
Trigonometric Sine of an angle in `radian`, or opposite / hypotenuse.
Normalized Sinc function. sinc(`x`) = sin(pi*`x`)/(pi*`x`).
Trigonometric Tangent of an angle in `radian`, or opposite / adjacent.