User`s guide

realsqrt
7-23
7realsqrt
Purpose Square root for nonnegative real inputs.
Syntax Y = realsqrt(X)
Description realsqrt(X) returns the square root of the elements of X. The domain of
realsqrt is the s et ofall nonnegativereal numbers.If X is negativeorcomplex,
realsqrt issues an error message.
realsqrt is similar to sqrt; however, sqrt’s domain is much broader than
realsqrt’s. The domain of sqrt includes all real and all complex numbers.
Despite this larger domain, if
Y is real, then you should use realsqrt rather
than
sqrt for two reasons.
First,subsequent accessof
Y may execute moreefficientlyif Y iscalculatedwith
realsqrt rather than with sqrt.Usingrealsqrt forces t he MATLAB
Compiler to impute a real type to
X and Y.Usingsqrt typically forces the
MATLAB Compiler to impute a complex type to
Y.
Second, the compiled version of
realsqrt may run somewhat faster than the
compiled version of
sqrt. (However, the interpreted version of realsqrt may
run somewhat s lower than the interpreted version of
sqrt.)
See Also exp, log, log2, logm, log10, reallog, realpow