mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
52 lines
1.4 KiB
Markdown
52 lines
1.4 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-nthroot">Function nthRoot <a href="#function-nthroot" title="Permalink">#</a></h1>
|
|
|
|
Calculate the nth root of a value.
|
|
The principal nth root of a positive real number A, is the positive real
|
|
solution of the equation
|
|
|
|
x^root = A
|
|
|
|
For matrices, the function is evaluated element wise.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.nthRoot(a)
|
|
math.nthRoot(a, root)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`a` | number | BigNumber | Array | Matrix | Complex | Value for which to calculate the nth root
|
|
`root` | number | BigNumber | The root. Default value: 2.
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
number | Complex | Array | Matrix | Returns the nth root of `a`
|
|
|
|
|
|
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.nthRoot(9, 2) // returns 3, as 3^2 == 9
|
|
math.sqrt(9) // returns 3, as 3^2 == 9
|
|
math.nthRoot(64, 3) // returns 4, as 4^3 == 64
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[sqrt](sqrt.html),
|
|
[pow](pow.html)
|