sqrt
Square root
sqrt(A)
A
should be an array, which can be real of complex.- It gives the square root of each element of
A
.
Example 1: Square roots of complex numbers.
% Random complex array a=complex(rand(3,4),rand(3,4)) sqrt(a)
a = 1e-1 × 0.247 + 0.020i 4.099 + 5.631i 8.520 + 6.267i 3.072 + 5.485i 3.185 + 9.263i 9.534 + 0.181i 7.543 + 3.953i 3.548 + 8.546i 7.510 + 6.964i 8.011 + 7.200i 9.378 + 8.896i 6.924 + 2.994i ans = 0.157 + 0.006i 0.744 + 0.379i 0.977 + 0.321i 0.684 + 0.401i 0.806 + 0.575i 0.976 + 0.009i 0.896 + 0.221i 0.800 + 0.534i 0.942 + 0.370i 0.969 + 0.372i 1.056 + 0.421i 0.851 + 0.176i
Example 2: Square roots of negative numbers are complex.
% Random array of negative numbers a=-rand(3,4) sqrt(a)
a = 1e-1 × -2.647 -7.629 -9.176 -3.180 -4.225 -6.426 -0.687 -8.491 -1.149 -4.777 -5.991 -9.311 ans = 1e-1 × 0.000 + 5.145i 0.000 + 8.734i 0.000 + 9.579i 0.000 + 5.639i 0.000 + 6.500i 0.000 + 8.017i 0.000 + 2.621i 0.000 + 9.215i 0.000 + 3.390i 0.000 + 6.911i 0.000 + 7.740i 0.000 + 9.649i