MathExtended

Adds more functions to the native Math class in JavaScript.

Note: this library extends the native Math class of JavaScript, and therefore, there may be naming conflicts if other scripts add functions with the same names.

Summary

Math extended adds the following contstants:

  • Square Root of 3,
  • Square Root of 5,
  • Square Root of 6,
  • Square Root of 10,
  • Phi (a.k.a. Golden Ratio),
  • Silver Ratio.

It also adds the following functions:

  • isInt – checks if a number is an integer,
  • randomBetween – generates a random number between a and b,
  • roundTo – rounds a number to specified decimal places,
  • square – raises the number to the second power,
  • cube – raises the number to the third power,
  • factorial – calculates the factorial of n,
  • fallingFactorial – calculates the falling factorial of n with k steps,
  • binomialCoefficient – calculates the binomial coefficient (n choose k),
  • gcd – calculates the greatest common divisor of two integers,
  • lcm – calculates the least common multiple of two integers,
  • average – calculates the average of the given numbers,
  • weightedAcerage – calculates the weighted average of the given numbers,
  • geometricMean – calculates the geometric mean (geometric average) of the given numbers
  • mean – calculates the mean of the given numbers,
  • variance – calculates the variance of a set of numbers,
  • standardDeviation – calculates the standard deviation of a set of numbers.

Usage

See Getting Started.

Setup

Web

To install MathExtended on the web client, include this script tag in your document, (above other scripts).

<script src="https://joker876.github.io/MathExtended/dist/math-extended.min.js"></script>

Node

Coming soon

GitHub

View Github