sqrt(Re(z)**2 + Im(z)**2)

for z = a + ib this becomes:

sqrt(a*a + b*b)

It's just the euclidean norm. You have to sum the square of real part and imaginary part (without the i) and do the sqrt of it.

https://www.varsitytutors.com/hotmath/hotmath_help/topics/absolute-value-complex-number

Answer from Lukr on Stack Overflow
🌐
Medium
medium.com › @whyamit404 › working-with-complex-numbers-in-numpy-c3eae8876a88
Working with Complex Numbers in NumPy | by whyamit404 | Medium
February 8, 2025 - This is essentially the “length” or “distance” of the complex number from the origin (0,0) in the complex plane. The magnitude of a + bj is given by: ... What happens here?
🌐
GeeksforGeeks
geeksforgeeks.org › python › finding-magnitude-of-a-complex-number-in-python
Finding Magnitude of a Complex Number in Python - GeeksforGeeks
July 23, 2025 - #Manually calculating magnitude ... magnitude: {result}") ... In this example, the abs() function in Python can be used to find the magnitude of a complex number....
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.5.dev0 Manual
>>> x = np.linspace(-2*np.pi, 2*np.pi, 100) >>> xx = x + 1j * x[:, np.newaxis] # a + ib over complex plane >>> out = np.exp(xx) >>> plt.subplot(121) >>> plt.imshow(np.abs(out), ... extent=[-2*np.pi, 2*np.pi, -2*np.pi, 2*np.pi], cmap='gray') >>> plt.title('Magnitude of exp(x)')
🌐
OneLinerHub
onelinerhub.com › python-numpy › how-to-get-complex-number-magnitude
Python Numpy: How to get complex number magnitude - OneLinerHub
import numpy as np z = 3 + 4j magnitude = np.abs(z)ctrl + c · youtubegithub · import numpy as np z = 3+4j print(np.abs(z)) 5.0 · How to get real part from complex number · How to get imaginary part from complex number · How to get angle in degrees from complex number ·
🌐
Python Pool
pythonpool.com › home › blog › different ways to calculate magnitude using numpy in python
Different Ways to Calculate Magnitude Using Numpy in Python
July 24, 2021 - The conclusion is that three functions evaluate the same result only. We can use the abs() function to calculate the magnitude of a complex number. How Numpy Extrapolation is Changing the Game in Data Analysis
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › absolute
Python Numpy absolute() - Calculate Absolute Value | Vultr Docs
November 6, 2024 - Execute the absolute function to determine the magnitudes. ... complex_data = np.array([3+4j, -2-1j, 0+1j]) abs_complex_values = np.absolute(complex_data) print(abs_complex_values) Explain Code · The output provides the magnitudes of the complex ...
🌐
CopyProgramming
copyprogramming.com › howto › calculate-the-absolute-value-of-complex-numbers-in-numpy
Python: Finding the Magnitude of Complex Numbers using Numpy
May 14, 2023 - Implementing complex numbers in Numpy can be done easily with np.exp(1+ 2.3j). However, one might wonder what 2.3j represents as it's not a variable name. ... Python has an integrated data type for complex numbers. Performing complex number operations is possible within the interpreter, even ...
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.angle.html
numpy.angle — NumPy v2.4 Manual
The counterclockwise angle from ... on the complex plane in the range (-pi, pi], with dtype as numpy.float64. ... This function passes the imaginary and real parts of the argument to arctan2 to compute the result; consequently, it follows the convention of arctan2 when the magnitude of the argument ...
Find elsewhere
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.absolute.html
numpy.absolute — NumPy v2.4 Manual
At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized. ... For other keyword-only arguments, see the ufunc docs. ... An ndarray containing the absolute value of each element in x. For complex input, a + ib, the absolute value is \(\sqrt{ a^2 + b^2 }\).
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Calculate the absolute value element-wise (np.abs, np.fabs) | note.nkmk.me
January 14, 2024 - For details about the data type (dtype) in NumPy, see the following article. ... In Python, complex numbers (complex) can be represented using j as the imaginary unit. ... np.abs() also supports complex numbers (complex), converting them to their absolute values (modulus or magnitude).
🌐
Learning About Electronics
learningaboutelectronics.com › Articles › Complex-numbers-in-Python.php
Complex Numbers in Python
Using the abs() function, we get the output, 5.0, which is the magnitude of the complex number. And this is the majority of the functions that you will have to deal with regarding complex numbers in Python.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.fabs.html
numpy.fabs — NumPy v2.4 Manual
This function returns the absolute values (positive magnitude) of the data in x. Complex values are not handled, use absolute to find the absolute values of complex data.
🌐
Aleksandar Haber
aleksandarhaber.com › complex-numbers-in-python-define-perform-basic-operations-and-convert
Complex Numbers in Python – Define, Perform Basic Operations, and Convert Polar Form to Rectangular and Vice-Versa – Fusion of Engineering, Control, Coding, Machine Learning, and Science
October 30, 2023 - In the script presented above, we can use the NumPy function “arctan2(b,a)” to verify that the phase is computed properly. The following Python script will transform the rectangular form of the complex number into the polar form of the complex number , where is the magnitude and is the argument.
🌐
SciPy
docs.scipy.org › doc › numpy-1.12.0 › reference › generated › numpy.absolute.html
numpy.absolute — NumPy v1.12 Manual
numpy.absolute(x[, out]) = <ufunc 'absolute'>¶ · Calculate the absolute value element-wise. Examples · >>> x = np.array([-1.2, 1.2]) >>> np.absolute(x) array([ 1.2, 1.2]) >>> np.absolute(1.2 + 1j) 1.5620499351813308 · Plot the function over [-10, 10]: >>> import matplotlib.pyplot as plt · >>> x = np.linspace(start=-10, stop=10, num=101) >>> plt.plot(x, np.absolute(x)) >>> plt.show() (Source code, png, pdf) Plot the function over the complex plane: >>> xx = x + 1j * x[:, np.newaxis] >>> plt.imshow(np.abs(xx), extent=[-10, 10, -10, 10]) >>> plt.show() (png, pdf) numpy.square ·
Top answer
1 of 1
2

Basically, two steps would be involved :

  • Offset all numbers by the minimum along real and imaginary axes.

  • Divide each by the max. magnitude. To get the magnitude of a complex number, simply use np.abs().

Thus, the implementation would be -

def normalize_complex_arr(a):
    a_oo = a - a.real.min() - 1j*a.imag.min() # origin offsetted
    return a_oo/np.abs(a_oo).max()

Sample runs for verification

Let'start with an array that has a minimum one of [0+0j] and two more elements - [x1+y1*J] & [y1+x1*J]. Thus, their magnitudes after normalizing should be 1 each.

In [358]: a = np.array([0+0j, 1+17j, 17+1j])

In [359]: normalize_complex_arr(a)
Out[359]: 
array([ 0.00000000+0.j        ,  0.05872202+0.99827437j,
        0.99827437+0.05872202j])

In [360]: np.abs(normalize_complex_arr(a))
Out[360]: array([ 0.,  1.,  1.])

Next up, let's add an offset to the minimum element. This shouldn't change their magnitudes after normalization -

In [361]: a = np.array([0+0j, 1+17j, 17+1j]) + np.array([2+3j])

In [362]: a
Out[362]: array([  2. +3.j,   3.+20.j,  19. +4.j])

In [363]: normalize_complex_arr(a)
Out[363]: 
array([ 0.00000000+0.j        ,  0.05872202+0.99827437j,
        0.99827437+0.05872202j])

In [364]: np.abs(normalize_complex_arr(a))
Out[364]: array([ 0.,  1.,  1.])

Finally, let's add another element that is at twice the distance from offsetted origin to make sure this new one has a magnitude of 1 and others are reduce to 0.5 -

In [365]: a = np.array([0+0j, 1+17j, 17+1j, 34+2j]) + np.array([2+3j])

In [366]: a
Out[366]: array([  2. +3.j,   3.+20.j,  19. +4.j,  36. +5.j])

In [367]: normalize_complex_arr(a)
Out[367]: 
array([ 0.00000000+0.j        ,  0.02936101+0.49913719j,
        0.49913719+0.02936101j,  0.99827437+0.05872202j])

In [368]: np.abs(normalize_complex_arr(a))
Out[368]: array([ 0. ,  0.5,  0.5,  1. ])
🌐
Python Guides
pythonguides.com › python-numpy-absolute-value
NumPy's Np.abs() Function In Python
May 16, 2025 - import numpy as np # Create an array of complex numbers complex_arr = np.array([1+2j, -3-4j, 0+5j]) # Calculate absolute values (magnitudes) magnitudes = np.abs(complex_arr) print(magnitudes) # Output: [2.23607 5. 5. ] For complex numbers, the absolute value is calculated as √(a² + b²), ...
🌐
TutorialsPoint
tutorialspoint.com › calculate-the-absolute-value-of-complex-numbers-in-numpy
Calculate the absolute value of complex numbers in Numpy
February 8, 2022 - ", arr.dtype) # Get the dimensions of the Array print(" Our Array Dimension... ",arr.ndim) # Get the shape of the Array print(" Our Array Shape... ",arr.shape) # To return the absolute value of complex values, use the numpy.absolute() method in Python Numpy print(" Result...