mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
57 lines
1.5 KiB
Markdown
57 lines
1.5 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-sqrt">Function sqrt <a href="#function-sqrt" title="Permalink">#</a></h1>
|
|
|
|
Calculate the square root of a value.
|
|
|
|
For matrices, if you want the matrix square root of a square matrix,
|
|
use the `sqrtm` function. If you wish to apply `sqrt` elementwise to
|
|
a matrix M, use `math.map(M, math.sqrt)`.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.sqrt(x)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`x` | number | BigNumber | Complex | Unit | Value for which to calculate the square root.
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
number | BigNumber | Complex | Unit | Returns the square root 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.sqrt(25) // returns 5
|
|
math.square(5) // returns 25
|
|
math.sqrt(-4) // returns Complex 2i
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[square](square.html),
|
|
[multiply](multiply.html),
|
|
[cube](cube.html),
|
|
[cbrt](cbrt.html),
|
|
[sqrtm](sqrtm.html)
|