# IFFT Scaling

Does anyone know if there is a 1/N or 1/sqrt(N) scaling in the IFFT function of FFTW.jl? I am taking the IFFT of an array of complex numbers sampled from a continuous frequency domain function. The resulting time domain array seems too low in magnitude, but I don’t have actual numbers to compare it to. Have not been able to make heads or tails of source code. Below is my code. Thanks!

``````using Plots
using SpecialFunctions
using FFTW

#physics constants and input data
μ0 = 4*π*1e-7
σw = 3.5e7
rw = 5.6/1000
ω = collect(1:1000.0:1.0e8) #define frequency range (1 to 10^8 in increment of 1000 rad/s)

#initialize arrays
γi = zeros(ComplexF64,size(ω))
Zi = copy(γi)

#Evaluate frequency domain function
γi .= sqrt.(1im.*ω*μ0*σw)
Zi .= (1/(2*π*σw*rw)) .* γi .* besseli.(0,γi*rw)./(besseli.(1,γi*rw))

fig1 = plot(ω,abs.(Zi),xaxis=:log, yaxis=:log,legend=false,lw=4)
plot!(gridcolor=:black,gridwidth=2,gridstyle=:dot,gopacity = 0.8)
plot!(minorgrid=true,minorgridcolor=:black,minorgridlinewidth=1,minorgridstyle=:dot,minorgridalpha = 0.75)
plot!(xlim = (1e0,1e8),ylim = (1e-4,1e-1),size=(800,400))

#Inverse FFT
Zitime1 = ifft(Zi)

fig2 = plot(abs.(Zitime1),xlims=(1,1e8),xaxis=:log, yaxis=:log,legend=false,lw=4)
plot!(gridcolor=:black,gridwidth=2,gridstyle=:dot,gopacity = 0.8)
plot!(xlabel=("n"),ylabel=("|Z|"),fg=:black,bg=:white,size=(800,400))

display(fig1)
display(fig2)
``````

1/N. The forward transform (`fft`) is unscaled, and the inverse transform (`ifft`) therefore has a 1/N scaling.

2 Likes

Is it necessary to create and prepend the mirror complex conjugate of the frequency domain array if all I have is the data set for positive frequency?

Not if you use the `irfft` function.

(Note also that you can use the `bfft` or `brfft` functions if you want an unscaled transform.)

1 Like

Thanks. It is my understanding that FFT or IFFT functions generally require uniform sampling. I have a situation with logarithmic sampling of the frequency domain data set (for example 100 points per decade). Is there an ifft function that can handle that kind of input? I saw some NUFFT packages, but nothing that would handle non-integer, non-uniform spacing.

4 Likes