Function sqrt #

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).

Syntax #

math.sqrt(x)

Parameters #

Parameter Type Description
x number | BigNumber | Complex | Unit Value for which to calculate the square root.

Returns #

Type Description
number | BigNumber | Complex | Unit Returns the square root of x

Throws #

Type | Description —- | ———–

Examples #

math.sqrt(25)                // returns 5
math.square(5)               // returns 25
math.sqrt(-4)                // returns Complex 2i

See also #

square, multiply, cube, cbrt, sqrtm

Fork me on GitHub