UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.

48 lines (29 loc) 1.04 kB
# Function nthRoot 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. ## Syntax ```js math.nthRoot(a, root) ``` ### Parameters Parameter | Type | Description --------- | ---- | ----------- `a` | Number &#124; BigNumber &#124; Boolean &#124; Array &#124; Matrix &#124; null | Value for which to calculate the nth root `root` | Number &#124; BigNumber &#124; Boolean &#124; null | The root. Default value: 2. ### Returns Type | Description ---- | ----------- Number &#124; Complex &#124; Array &#124; Matrix | Returns the nth root of `a` ## Examples ```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 ``` ## See also [sqrt](sqrt.md), [pow](pow.md) <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->