I have the following script in Python. I am calculating the Fourier Transform of an array. When I want to plot the results (Fourier transform) I am using the absolute value of that calculation. However, I do not know how the absolute value of complex numbers is being produced. Does anyone know how it calculates? I need this to reproduce in Java.
import numpy as np
import matplotlib.pyplot as plt
from numpy import fft
inp = [1,2,3,4]
res = fft.fft(inp)
print(res[1]) # returns (-2+2j) complex number
print(np.abs(res[1])) # returns 2.8284271247461903