MathLib.sqrt()

MathLib.sqrt calculates the square root of a number: \[ \text{MathLib.sqrt}(x) = \sqrt{x} \]

Examples

To calculate the square root of 16 type: var result = MathLib.sqrt(16); // result is now 4

Specification

MathLib.sqrt accepts one argument. Any additional arguments will be ignored. The type of the argument should be number. For other argument types see the unary function specification.
  1. MathLib.sqrt(NaN) = NaN
  2. MathLib.sqrt(+0) = +0
  3. MathLib.sqrt(-0) = -0
  4. MathLib.sqrt(+∞) = +∞
  5. MathLib.sqrt(x) = NaN if x < 0
  6. otherwise MathLib.sqrt(x) = square root of x.

Implementation

MathLib uses the built-in function Math.sqrt.

Tests

Categories: unary Function