# What does it mean to take the absolute of an complex number? And why is it always positive?

16 views (last 30 days)
lil brain on 25 Apr 2022
Answered: Steven Lord on 26 Apr 2022
Hi,
I have a number which is part imaginary or complex.
-0.993061325012476 + 1.03511742045580e-16i
When I use the function abs(x) on this number like so:
abs(-0.993061325012476 + 1.03511742045580e-16i)
ans =
0.99306
Then I receive a positive number.
Can someone kindly explain to me how this works and if the abs(x) function makes it positive or if the abs(x) function simply never returns negative numbers. If so why?
Or is it maybe the case that I need to be better versed in complex numbers in general?
Thanks!

Steven Lord on 26 Apr 2022
I think one potential source of confusion is that the abs of this particular complex number looks an awful lot like its real part.
n = -0.993061325012476 + 1.03511742045580e-16i;
R = abs(n)
R = 0.9931
That's not due to abs simply taking the real part of the complex number, it's due to the fact that the imaginary part of this number is extremely small. If you were to plot this number you'd see that it's very close to being on the real line.
setupFigure();
% This plots using the real part of n as the x coordinate
% and the imaginary part of n as the y coordinate. I made the marker
% larger so it stands out
plot(n, 'bo', 'MarkerSize', 10) If we plotted another point, one whose real and imaginary parts were both not small, you'd see the abs of that number was the distance between it and the origin. For the point n2 the red dotted line is the line whose length is measured by taking abs(n2).
setupFigure();
n2 = 1+1i;
plot(n, 'bo', 'MarkerSize', 10)
plot(n2, 'ks', 'MarkerSize', 10)
plot([0 n2], 'r:', 'LineWidth', 2) fprintf("The red dotted line is %g units long.\n", abs(n2)) % sqrt(2)
The red dotted line is 1.41421 units long.
function setupFigure()
% Set up the plot to look nice
figure
axes('XAxisLocation', 'origin', 'YAxisLocation', 'origin')
axis([-1, 1, -1, 1])
xlabel('real(n)')
ylabel('imag(n)')
xticks(-1:0.25:1)
yticks(-1:0.25:1)
grid on
hold on
end

Torsten on 25 Apr 2022
abs(z) where z=x+i*y is the distance of the point (x/y) from the point (0/0), thus always >=0 and =0 only if z = 0.
##### 2 CommentsShow 1 older commentHide 1 older comment
Torsten on 26 Apr 2022
Why should anything change ?
z=x+i*y is a static point in the x-y plane. If you interprete C as R^2, then this point z is P=(x/y). And abs(z) returns the distance of P from (0/0), thus sqrt(x^2+y^2).

Walter Roberson on 26 Apr 2022
syms a b real
c = a + b*1i
c = d = abs(c)
d = With the real and imaginary components each being real, their squares are going to be non-negative numbers, and the sum of non-negative numbers is non-negative, and the square root of a non-negative number is non-negative
Walter Roberson on 26 Apr 2022
For complex numbers, it appears that hypot() is used internally. hypot() is a modified sum of squares algorithm that detects when the squaring would underflow or overflow and uses alternate calculations in those cases.