
Finding the angle and modulus of a complex number in Octave
In this lesson, I will explain how to calculate the angle (argument) and modulus of a complex number on Octave.
What are the modulus and angle of a complex number? Every complex number z=a+bi can be represented on the complex plane at the coordinates (a,b).
So, each point on the plane is a different complex number and can be uniquely reached from the origin through a vector. The length r=|z| of the vector is called the modulus of the complex number z. The angle φ of the vector measured counterclockwise from the positive real axis (Re) is called the argument of the complex number.
For example, consider the complex number z=3+4i
On the complex plane, the number z is located at the point with coordinates (3,4).
This point is reachable from the origin by only one vector of length r and angle φ.
To calculate the modulus r=|z| of the complex number, which is the length of the vector, use the abs() function in Octave.
>> abs(z)
ans= 5
Therefore, the modulus of the complex number z=3+4i is equal to 5.
In other words, the vector that connects the origin with the point (3,4) has a length of five.
To calculate the angle (argument) of the complex number, use the angle() function instead.
>> angle(z)
ans = 0.92730
Octave returns the angle in radians.
In this case, the argument of the complex number z=3+4i is 0.92730 radians, which is approximately 53 degrees.
If this lesson on Octave by Nigiara is helpful, continue to follow us.