## How do I have to normalize fft and ifft when I am using the convolution theorem?

on 17 Sep 2013

### Matt J (view profile)

I would like to calculate a convolution of a density profile rho(x) and a weight function w(x), to get the weighted density. the density is basicly a heavyside function that starts to be nonzero at z = sigma. and the weight function is of the form pi/8*(sigma^2-z^2).

To calculate the convolution I wanted to use the convolution theorem:

w * rho = ifft( fft(w) . fft(rho) )

So I initialized the two function by two vectors and calculated the convolution of the two in the way discribed above. Unfortunatly the result has the right shape, but doesn't have the same hight as my analytic result. I have been reading about the normalization of fft and ifft, but couldn't figure out how I had to normalize my fft and ifft vectors.

Thank you very much for your help.

I have the following code:

```if true
sigma = 0.24*10^(-10);
eta = 0.05;
rho0 = eta*6/(pi*sigma^3);
y = linspace(-sigma,0,100);
x = linspace(0,3*sigma,300);
rho = [zeros(1,100) rho0*ones(1,100) zeros(1,100)];
w = [pi/8*(sigma^2-x(1:100).^2) zeros(1,100) pi/8*(sigma^2-y(1:100).^2)];
frho = fft(rho);
fw = fft(w);
n = ifft(fw.*frho);
plot(x,n);
```
```end
```

## Products

No products are associated with this question.

on 17 Sep 2013
Edited by Matt J

### Matt J (view profile)

on 17 Sep 2013

The convolution you've done is a discrete sum. To make a sum approximate an integral, you must multiply it by the interval dx at which rho(x) and weight(x) were sampled.

Matthias

### Matthias (view profile)

on 19 Sep 2013

#### Join the 15-year community celebration.

Play games and win prizes!

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi