886 B

Function cube

Compute the cube of a value. The cube of x is x * x * x. For matrices, the function is evaluated element wise.

Syntax

math.cube(x)

Parameters

Parameter Type Description
x Number | BigNumber | Boolean | Complex | Array | Matrix Number for which to calculate the cube

Returns

Type Description
Number | BigNumber | Complex | Array | Matrix Cube of x

Examples

var math = mathjs();

math.cube(2);                           // returns Number 8
math.pow(2, 3);                         // returns Number 8
math.multiply(math.multiply(2, 2), 2);  // returns Number 8

math.cube([1, 2, 3, 4]);                // returns Array [1, 8, 27, 64]

See also

multiply, square, pow