Back to Mathjs

Constant reference

docs/reference/constants.md

15.2.01.8 KB
Original Source

Constant reference

Math.js contains the following constants.

ConstantDescriptionValue
e, EEuler's number, the base of the natural logarithm.2.718281828459045
iImaginary 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)
InfinityInfinity, a number which is larger than the maximum number that can be handled by a floating point number.Infinity
LN2Returns the natural logarithm of 2.0.6931471805599453
LN10Returns the natural logarithm of 10.2.302585092994046
LOG2EReturns the base-2 logarithm of E.1.4426950408889634
LOG10EReturns the base-10 logarithm of E.0.4342944819032518
NaNNot a number.NaN
nullValue null.null
phiPhi 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)) / 21.618033988749895
pi, PIThe number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter.3.141592653589793
SQRT1_2Returns the square root of 1/2.0.7071067811865476
SQRT2Returns the square root of 2.1.4142135623730951
tauTau is the ratio constant of a circle's circumference to radius, equal to 2 * pi.6.283185307179586
undefinedAn undefined value. Preferably, use null to indicate undefined values.undefined
versionReturns the version number of math.js.For example 0.24.1

Example usage:

js
math.sin(math.pi / 4)          // 0.70711
math.multiply(math.i, math.i)  // -1