Documentation for routine sqrt
Documentation for routine sqrt, assembled from the following types:
sub sqrt(Numeric(Cool) )method sqrt()
Coerces the invocant to Numeric (or in the sub form, the argument) and returns the square root, that is, a non-negative number that, when multiplied with itself, produces the original number.
say 4.sqrt; # OUTPUT: «2␤»say sqrt(2); # OUTPUT: «1.4142135623731␤»
multi sub sqrt(Numeric --> Numeric)multi method sqrt(Numeric --> Numeric)
Returns a square root of the number. For real numbers the positive square root is returned.
On negative real numbers,
NaN rather than a complex number, in order to not confuse people who are not familiar with complex arithmetic. If you want to calculate complex square roots, coerce to
Complex first, or use the