mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
57 lines
1.6 KiB
Markdown
57 lines
1.6 KiB
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
|
|
<h1 id="function-cube">Function cube <a href="#function-cube" title="Permalink">#</a></h1>
|
|
|
|
Compute the cube of a value, `x * x * x`.
|
|
To avoid confusion with `pow(M,3)`, this function does not apply to matrices.
|
|
If you wish to cube every entry of a matrix, see the examples.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.cube(x)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`x` | number | BigNumber | bigint | Fraction | Complex | Unit | Number for which to calculate the cube
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
number | BigNumber | bigint | Fraction | Complex | Unit | Cube of x
|
|
|
|
|
|
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
|
|
|
|
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.cube(2) // returns number 8
|
|
math.pow(2, 3) // returns number 8
|
|
math.cube(4) // returns number 64
|
|
4 * 4 * 4 // returns number 64
|
|
|
|
math.map([1, 2, 3, 4], math.cube) // returns Array [1, 8, 27, 64]
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[multiply](multiply.html),
|
|
[square](square.html),
|
|
[pow](pow.html),
|
|
[cbrt](cbrt.html)
|