1.3.56 โ€ข Published 6 months ago

extra-math v1.3.56

Weekly downloads
21
License
MIT
Repository
github
Last release
6 months ago

Mathematics is the classification and study of all possible patterns (1). ๐Ÿ“ฆ Node.js, ๐ŸŒ Web, ๐Ÿ“œ Files, ๐Ÿ“ฐ JSDoc, ๐Ÿ“˜ Wiki.

This package includes common number functions related to querying about numbers, comparing numbers, rounding numbers, performing rounded division, performing modulo operations, controlling range of numbers, performing arithmetic operations, obtaining divisors of a number (and related operations), getting the number of possible arrangements of a set of objects, performing geometry-related calculations, performing basic statistical analysis, and finding various statistical means.

Natural numbers: There are 3 different ways of performing the modulo operation: rem, mod, and modp. gcd/HCF and lcm of a list of numbers can be obtained. To calculate the number of ways of ordering items, use factorial/P(n, k), binomial/C(n, k), or multinomial/n!/kโ‚!kโ‚‚!....

Real numbers: Range of a number can be controlled with constrain, normalize, or remap. Use lerp for linear interpolation (or extrapolation); root for calculating the n-th root of a number; and log to find the logarithm of a number with a given base.

Geometry: Perform conversion from degrees to radians and vice versa. Find the magnitude of a vector or distance between two points.

Statistics: For a list of numbers, we can calculate the sum, product, arithmeticMean. median gives the value lying in the middle when the numbers are sorted, and modes gives the values which are repeated most often. The difference between the largest and the smallest values is the range. variance is a measure of variability of numbers.

This package is available in Node.js and Web formats. To use it on the web, simply use the extra_math global variable after loading with a <script> tag from the jsDelivr CDN.

Stability: Experimental.

const xmath = require('extra-math');
// import * as xmath from "extra-math";
// import * as xmath from "https://unpkg.com/extra-math/index.mjs"; (deno)

xmath.sum(1, 2, 3, 4);
// โ†’ 10

xmath.median(1, 7, 8);
// โ†’ 7

xmath.variance(1, 2, 3, 4);
// โ†’ 1.25

xmath.lcm(2, 3, 4);
// โ†’ 12

Index

PropertyDescription
floorRound down a number to specific precision.
ceilRound up a number to specific precision.
roundRound a number to specific precision.
floorDivPerform floor-divison of two numbers.
ceilDivPerform ceiling-divison of two numbers.
roundDivPerform rounded-divison of two numbers.
remFind the remainder of x/y with sign of x (truncated division).
modFind the remainder of x/y with sign of y (floored division).
modpFind the remainder of x/y with +ve sign (euclidean division).
constrainConstrain a number within a minimum and a maximum value.
normalizeNormalize a number from its current range into a value between 0 and 1.
remapRe-map a number from one range to another.
lerpLinearly interpolate a number between two numbers.
isPowCheck if a number is a power-of-n.
prevPowFind largest power-of-n less than or equal to given number.
nextPowFind smallest power-of-n greater than or equal to given number.
rootFind the nth root of a number (โฟโˆš).
logFind the logarithm of a number with a given base.
properDivisorsList all divisors of a number, except itself.
aliquotSumSum all proper divisors of a number.
minPrimeFactorFind the least prime number which divides a number.
maxPrimeFactorFind the greatest prime number which divides a number.
primeFactorsFind the prime factors of a number.
primeExponentialsFind the prime factors and respective exponents of a number.
isPrimeCheck if number is prime.
gcdFind the greatest common divisor of numbers.
lcmFind the least common multiple of numbers.
factorialFind the factorial of a number.
binomialFind the number of ways to choose k elements from a set of n elements.
multinomialFind the number of ways to put n objects in m bins (n=sum(kแตข)).
degreesConvert radians to degrees.
radiansConvert degrees to radians.
magnitudeCalculate the magnitude (length) of a vector.
distanceCalculate the distance between two points.
sumFind the sum of numbers (ฮฃ).
productFind the product of numbers (โˆ).
medianFind the value separating the higher and lower halves of numbers.
modesFind the values that appear most often.
rangeFind the smallest and largest values.
varianceFind the mean of squared deviation of numbers from its mean.
arithmeticMeanFind the average of numbers.
geometricMeanFind the geometric mean of numbers.
harmonicMeanFind the harmonic mean of numbers.
quadriaticMeanFind the quadriatic mean of numbers.
cubicMeanFind the cubic mean of numbers.

References

npm.io ORG DOI Coverage Status Test Coverage Maintainability

1.3.56

6 months ago

1.3.53

1 year ago

1.3.54

1 year ago

1.3.55

1 year ago

1.3.52

1 year ago

1.3.50

1 year ago

1.3.51

1 year ago

1.3.42

1 year ago

1.3.43

1 year ago

1.3.40

1 year ago

1.3.41

1 year ago

1.3.46

1 year ago

1.3.47

1 year ago

1.3.44

1 year ago

1.3.45

1 year ago

1.3.48

1 year ago

1.3.49

1 year ago

1.3.39

2 years ago

1.3.38

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.2.12

2 years ago

1.2.13

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.2.16

2 years ago

1.2.14

2 years ago

1.2.15

2 years ago

1.3.31

2 years ago

1.3.32

2 years ago

1.3.30

2 years ago

1.3.35

2 years ago

1.3.36

2 years ago

1.3.33

2 years ago

1.3.34

2 years ago

1.3.37

2 years ago

1.2.9

2 years ago

1.3.10

2 years ago

1.3.13

2 years ago

1.3.14

2 years ago

1.3.11

2 years ago

1.3.12

2 years ago

1.3.17

2 years ago

1.3.18

2 years ago

1.3.15

2 years ago

1.3.16

2 years ago

1.3.19

2 years ago

1.3.20

2 years ago

1.3.21

2 years ago

1.3.24

2 years ago

1.3.25

2 years ago

1.3.22

2 years ago

1.3.23

2 years ago

1.3.28

2 years ago

1.3.29

2 years ago

1.3.26

2 years ago

1.3.27

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.1.18

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.17

3 years ago

1.1.2

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.20

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.28

4 years ago

0.0.27

4 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago