February 2012
Intermediate to advanced
1184 pages
37h 17m
English
sqrt EXPR
sqrtThis function returns the square root of
EXPR. For other roots such as cube roots, you
can use the ** operator to raise
something to a fractional power. Don’t try either of these approaches
with negative numbers, as that poses a slightly more complex problem
(and raises an exception). But there’s a standard module to take care of
even that:
use Math::Complex; print sqrt(–2); # prints 1.4142135623731i