Math functions
Perform mathematical calculations.
abs()
Returns the absolute value of a number
.
abs(number)
Arguments
number
(Number)- The number to convert.
Returns
- (Number)
- The absolute value of the
number
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
acos()
Returns the arccosine (in radians) of a number.
acos(x)
Arguments
x
(Number)- A number representing a cosine, where x is between -1 and 1.
Returns
- (Number)
- The arccosine (angle in radians) of the given number if it's between -1 and 1; otherwise,
NaN
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
acosh()
Returns the hyperbolic arc-cosine of a number.
acosh(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The hyperbolic arc-cosine of the given number. If the number is less than 1,
NaN
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
add()
Adds two numbers.
add(augend, addend)
Arguments
Returns
- (Number)
- The resulted sum of two numbers.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
asin()
Returns the arcsine (in radians) of a number.
asin(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The arcsine (in radians) of the given number if it's between -1 and 1; otherwise,
NaN
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
asinh()
Returns the hyperbolic arcsine of a number.
asinh(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The hyperbolic arcsine of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
atan()
Returns the arctangent (in radians) of a number.
atan(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The arctangent (in radians) of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
atan2()
Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y).
atan2(y, x)
Arguments
Returns
- (Number)
- The angle in radians between the positive x-axis and the ray from (0,0) to the point (
x
,y
).
Examples
Input | Expression | Result |
---|---|---|
|
|
|
atanh()
Returns the hyperbolic arctangent of a number.
atanh(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The hyperbolic arctangent of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
avg()
Computes the average of the values in the array
.
Aliases: mean()
.
avg(array)
Arguments
Returns
- (Number)
- The average.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
avg_by()
This method is like avg() except that it accepts iteratee
which is invoked for each element in array
to generate the value to be averaged.
Aliases: mean_by()
avg_by(array, [iteratee])
Arguments
array
(Array | Null)- The array to iterate over.
iteratee
(Expression | Array | Object | String)- (Optional) The iteratee invoked per element of the
array
. Default value is&@
Returns
- (Number)
- The average.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
cbrt()
Returns the cubic root of a number.
cbrt(number)
Arguments
number
(Number)- A number.
Returns
- (Number)
- The cube root of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
ceil()
Computes number
rounded up to precision
.
ceil(number, [precision])
Arguments
number
(Number)- The number to round up.
precision
(Number)- (Optional) The precision to round up to. Default value is
0
.
Returns
- (Number)
- The rounded up number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
|
|
|
See also
cos()
Returns the cosine of the specified angle, which must be specified in radians.
cos(x)
Arguments
x
(Number)- The angle in radians for which to return the cosine.
Returns
- (Number)
- The cosine of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
cosh()
Returns the hyperbolic cosine of a number.
cosh(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The hyperbolic cosine of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
exp()
Returns e^x
, where x is the argument, and e
is the base of natural logarithms.
exp(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The value of
e
to the powerx
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
expm1()
Returns e^x - 1
, where x
is the argument, and e
is the base of natural logarithms.
expm1(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- A number representing
e^x - 1
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
div()
Same as divide().
divide()
Divide two numbers.
Aliases: div()
divide(dividend, divisor)
Arguments
Returns
- (Number)
- The quotient.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
|
|
|
See also
floor()
Computes number
rounded down to precision
.
floor(number, [precision])
Arguments
number
(Number)- The number to round down.
precision
(Number)- (Optional) The precision to round down to. Default value is
0
.
Returns
- (Number)
- The rounded down number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
|
|
|
See also
hypot()
Returns the square root of the sum of squares of array elements.
hypot(array)
Arguments
Returns
- (Number)
- The square root of the sum of squares of the given array elements.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
ln()
Returns the natural logarithm (base e
) of a number.
ln(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The natural logarithm of the given number.
NaN
if the number is negative. -Infinity if the number is 0.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
log()
Returns the base base
logarithm of x
.
log(x, [base])
Arguments
Returns
- (Number)
- The base
base
logarithm of the given number.NaN
if the number is negative. -Infinity if the number is 0.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
log10()
Returns the base 10 logarithm of a number.
log10(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The base 10 logarithm of the given number. If the number is negative,
NaN
is returned.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
log2()
Returns the base 2 logarithm of a number.
log2(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The base 2 logarithm of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
inverse()
Returns the number
with the opposite sign.
inverse(number)
Arguments
number
(Number)- The number to inverse.
Returns
- (Number)
- The inversed number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
math_e()
Returns Euler's number, the base of natural logarithms, e, which is approximately 2.718
.
math_e()
Returns
- (Number)
- The e number
Examples
Input | Expression | Result |
---|---|---|
|
|
|
math_ln10()
Returns the natural logarithm of 10, approximately 2.302
.
math_ln10()
Returns
- (Number)
- The natural logarithm of 10 number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
math_ln2()
Returns the natural logarithm of 2, approximately 0.693
.
math_ln2()
Returns
- (Number)
- The natural logarithm of 2 number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
math_log10e()
Returns the base 10 logarithm of e, approximately 0.434
.
math_log10e()
Returns
- (Number)
- The base 10 logarithm of e number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
math_log2e()
Returns the base 2 logarithm of e, approximately 1.442
.
math_log2e()
Returns
- (Number)
- The base 2 logarithm of e number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
math_pi()
Returns the ratio of the circumference of a circle to its diameter, the Pi number, approximately 3.14159
.
math_pi()
Returns
- (Number)
- The Pi number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
math_sqrt1_2()
Returns the square root of 1/2 which is approximately 0.707
.
math_sqrt1_2()
Returns
- (Number)
- The square root of 1/2 number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
math_sqrt2()
Returns the square root of 2, approximately 1.414
.
math_sqrt2()
Returns
- (Number)
- The square root of 2 number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
max()
Computes the maximum value of array
. If array
is empty or falsey, undefined is returned.
max(array)
Arguments
array
(Array)- The array to iterate over.
Returns
- (Any)
- The maximum value.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
max_by()
This method is like max() except that it accepts iteratee
which is invoked for each element in array
to generate the criterion by which the value is ranked. The iteratee
is invoked with one argument: @
(current element).
max_by(array, [iteratee])
Arguments
array
(Array | Null)- The array to iterate over.
iteratee
(Expression | Array | Object | String)- (Optional) The expression invoked per iteration. The
iteratee
expression is invoked with one argument:@
(current element). Default value is&@
.
Returns
- (Any)
- The maximum value.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
mean()
Alias for avg().
mean_by()
Alias for avg_by().
min()
Computes the minimum value of array
. If array
is empty or falsey, undefined is returned.
min(array)
Arguments
array
(Array)- The array to iterate over.
Returns
- (Any)
- The minimum value.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
mod()
Same as modulo().
modulo()
Returns the remainder left over when a dividend
is divided by a divisor
. It always takes the sign of the dividend
.
Aliases: mod()
mod(dividend, divisor)
Arguments
Returns
- (Number)
- The remainder of dividing two numbers. If one of the operands is
NaN
, or ifdivisor
is 0, returnsNaN
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
pow()
Returns the value of base
to the power of exponent
.
pow(base, exponent)
Arguments
Returns
- (Number)
- A number representing the value of
base
to the power ofexponent
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
min_by()
This method is like min() except that it accepts iteratee
which is invoked for each element in array
to generate the criterion by which the value is ranked. The iteratee
is invoked with one argument: @
(current element).
min_by(array, [iteratee])
Arguments
array
(Array | Null)- The array to iterate over.
iteratee
(Expression | Array | Object | String)- (Optional) The expression invoked per iteration. The
iteratee
expression is invoked with one argument:@
(current element). Default value is&@
.
Returns
- (Any)
- The minimum value.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
mul()
Same as multiply().
multiply()
Multiply two numbers.
Aliases: mul()
multiply(multiplier, multiplicand)
Arguments
multiplier
(Number)- The first number in a multiplication.
multiplicand
(Number)- The second number in a multiplication.
Returns
- (Number)
- The product.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
round()
Computes number
rounded to precision
.
round(number, [precision])
Arguments
number
(Number)- The number to round.
precision
(Number)- (Optional) The precision to round to. Default value is
0
.
Returns
- (Number)
- The rounded number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
|
|
|
See also
sign()
Returns the sign of the number
.
sign(number)
Arguments
number
(Number)- The number to inspect.
Returns
- (Number)
1
if number is positive, else-1
.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
sin()
Returns the sine of a number.
sin(x)
Arguments
x
(Number)- The angle in radians for which to return the sine.
Returns
- (Number)
- The sine of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
sinh()
Returns the hyperbolic sine of a number.
sinh(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The hyperbolic sine of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
sqrt()
Returns the square root of a number.
sqrt(number)
Arguments
number
(Number)- A number.
Returns
- (Number)
- The square root of the given number. If the number is negative,
NaN
is returned.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
sub()
Same as subtract().
subtract()
Subtract two numbers.
Aliases: sub()
subtract(minuend, subtrahend)
Arguments
minuend
(Number)- The first number in a subtraction.
subtrahend
(Number)- The second number in a subtraction.
Returns
- (Number)
- The difference.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
sum()
Computes the sum of the values in array
.
sum(array)
Arguments
array
(Array)- The array to iterate over.
Returns
- (Number)
- The sum.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
sum_by()
This method is like sum() except that it accepts iteratee
which is invoked for each element in array to generate the criterion by which the value is ranked. The iteratee
is invoked with one argument: @
(current element).
sum_by(array, [iteratee])
Arguments
array
(Array | Null)- The array to iterate over.
iteratee
(Expression | Array | Object | String)- (Optional) The expression invoked per iteration. The
iteratee
expression is invoked with one argument:@
(current element). Default value is&@
.
Returns
- (Number)
- The sum.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
|
|
|
See also
tan()
Returns the tangent of a number.
tan(x)
Arguments
x
(Number)- A number representing an angle in radians.
Returns
- (Number)
- The tangent of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
tanh()
Returns the hyperbolic tangent of a number.
tanh(x)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The hyperbolic tangent of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|
See also
trunc()
Returns the integer part of a number by removing any fractional digits.
trunc(number)
Arguments
x
(Number)- A number.
Returns
- (Number)
- The integer part of the given number.
Examples
Input | Expression | Result |
---|---|---|
|
|
|