MATLAB Compiler | ![]() ![]() |
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 set of all nonnegative real numbers. If X
is negative or complex, 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 access of Y
may execute more efficiently if Y
is calculated with realsqrt
rather than with sqrt
. Using realsqrt
forces the MATLAB Compiler to impute a real type to X
and Y
. Using sqrt
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 slower than the interpreted version of sqrt
.)
See Also
exp
, log
, log2
, logm
, log10
, reallog
, realpow
![]() | realpow | Command Line Tools | ![]() |