UNPKG

1.85 kBMarkdownView Raw
1# Constant reference
2
3Math.js contains the following constants.
4
5Constant | Description | Value
6--------------- | ----------- | -----
7`e`, `E` | Euler's number, the base of the natural logarithm. | 2.718281828459045
8`i` | Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part. | `sqrt(-1)`
9`Infinity` | Infinity, a number which is larger than the maximum number that can be handled by a floating point number. | `Infinity`
10`LN2` | Returns the natural logarithm of 2. | `0.6931471805599453`
11`LN10` | Returns the natural logarithm of 10. | `2.302585092994046`
12`LOG2E` | Returns the base-2 logarithm of E. | `1.4426950408889634`
13`LOG10E` | Returns the base-10 logarithm of E. | `0.4342944819032518`
14`NaN` | Not a number. | `NaN`
15`null` | Value null. | `null`
16`phi` | Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` | `1.618033988749895`
17`pi`, `PI` | The number pi is a mathematical constant that is the ratio of a circle\'s circumference to its diameter. | `3.141592653589793`
18`SQRT1_2` | Returns the square root of 1/2. | `0.7071067811865476`
19`SQRT2` | Returns the square root of 2. | `1.4142135623730951`
20`tau` | Tau is the ratio constant of a circle\'s circumference to radius, equal to `2 * pi`. | `6.283185307179586`
21`undefined` | An undefined value. Preferably, use `null` to indicate undefined values. | `undefined`
22`version` | Returns the version number of math.js. | For example `0.24.1`
23
24Example usage:
25
26```js
27math.sin(math.pi / 4) // 0.70711
28math.multiply(math.i, math.i) // -1
29```